Draw/write text on HTML5 canvas with multiple fonts using javascript

Is it possible to draw/write text on a HTML5 canvas with multiple fonts using javascript? I have only been able to set one font for all text that is for the canvas.
LVL 2
itniflAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

COBOLdinosaurCommented:
Canvas is a replaced element.  It is implemented much like an image.  in order to apply multiple fonts you would have to carry the fonts with other tags, and you cannot put tags inside a canvas.  

If you need different fonts, you do like you do when you need text in an image you use an absolute positioned element to overlay.  

Cd&
0
Robert SchuttSoftware EngineerCommented:
In css you can only assign 1 font to canvas but that's not what I would normally use.

Do you mean something like this:
ctx.font="30px Arial";
ctx.fillText("Hello World",10,50);

ctx.font="10px monospace";
ctx.fillText("Hello World",120,80);

Open in new window

tested here: http://schutt.nl/ee/Q_28244477/ 
capture
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
itniflAuthor Commented:
I use pt instead if px. When using px I got the result you were showing.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.