Obviously, it is no difficulty to place letters on the arc itself (just align center bottom to the circle). However, as you noted, the problem is kerning.
Luckily, we have measureText()
, which can tell us the width of the letters and therefore what kerning to use.
The circumference of your circle is simply 2πr
, and total width of the text is ctx.measureText("Your text here");
. Get the ratio of these two values and you will find out how much you need to space out or squash together your words.
You probably want to apply the spacing modifier to the words as a whole, rather than the individual letters. To do this, use measureText()
on the sentence with spaces stripped to get the width of the letters (and by extension the total width of the spaces).
Now you need to plot where each word will go. Use measureText()
again to find the width of each word and plot its center point on your circle, adding a portion of the total space value between each word. Now use measureText()
on each individual letter and draw it in the right place to get perfect kerning.
All being well, you should have a perfectly spaced circle of text.