Draw string with multiple sizes

Right now, in web watch app, if we do

context.fillText(str, x, y);

We can write a string with one size. Is it possible to write a string with bold, big, small, etc within the string?

The fillText() method draws filled text on the canvas. The default color of the text is black. You can use the font property to specify font and font size, and use the fillStyle property to render the text in another color/gradient.

Check out this link. It may help you.

Thanks for reply. But here’s the problem: I can only specified one size one font within the string. If let’s say you have a string with some part of the text BOLD it can’t be done.

Right now I am constructing a multiple string, use measureText to measure the position, and draw them out individually. Is this the best method?

I understand your point of view. I have also implemented the “bold string” like you did.

However I have found a discussion about this in stackoverflow. Check this out.

Thanks! This is similar to how I did. Have to use measureText.width of different string and join together. Looks like that’s the answer.