Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we use this font to draw on canvas? #16

Closed
quanghd opened this issue Apr 25, 2013 · 3 comments
Closed

Can we use this font to draw on canvas? #16

quanghd opened this issue Apr 25, 2013 · 3 comments

Comments

@quanghd
Copy link

quanghd commented Apr 25, 2013

I tried this code to draw on canvas but no result:

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.font="30px "+font.fontFamily;
ctx.fillText("Hello World", 10, 50);

@Pomax
Copy link
Owner

Pomax commented Apr 25, 2013

kind of missing the rest of the code that sets up the font object here. Also, did you do some debugging yourself to see what was in "font" on that third line? Does it have a fontFamily assigned? does the console show an error or warning? Is the fon't your trying to load actually called what you use as construction string, etc?

@quanghd
Copy link
Author

quanghd commented Apr 25, 2013

Ok, i've found the problem. The fontFamily = 'A.C.M.E. Secret Agent' and it's illegal name to set to ctx.font. It's works when I change the font family to 'SecretAgent'.

Thanks,

@quanghd quanghd closed this as completed Apr 25, 2013
@Pomax
Copy link
Owner

Pomax commented Apr 25, 2013

ah, yes for family names with special characters, you need to extra-quote the family name. That gets weird, so it's always a good idea to use a font name without spaces or special characters when using the Font object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants