I'm trying to get the Canvas to use two fonts when drawing text. This is because my main font is Comic Sans MS (It's a kids app). Since I can't find Comic Sans on iPad, I'm trying to substitute it with MarkerFelt-Thin.
I've tried to use several variations of the following statement:
ctx.font = "40pt MarkerFelt-Thin; 40pt Comic Sans MS";
Doesn't seem to be working. So at the moment I'm using user agent detection and manually assigning different fonts for each user agent.
Anyone know the right way to do this?
Cheers
The font-family property can hold several font names as a "fallback" system. If the browser does not support the first font, it tries the next font. There are two types of font family names: family-name - The name of a font-family, like "times", "courier", "arial", etc.
There are two methods fillText() and strokeText() to draw text on canvas. You can use font property (type : string) to specify a number of text setting such as style, weight, size, and font. The style can be normal, italic, or bold. Default style is normal.
Canvas's font
uses the same syntax as the CSS font
attribute. So try:
ctx.font = "40pt MarkerFelt-Thin, Comic Sans MS";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With