1

I'm working with html5 canvas text and need to change the horizontal spacing between the characters.

Normally, I'd use CSS to set "letter-spacing", but the spec for canvas Text only allows for a "font" value: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#text-0

Is there a way to set "letter-spacing" or similar using canvas text?

shackleton
  • 701
  • 1
  • 12
  • 27
  • 1
    possible duplicate of [Letter spacing in canvas element](http://stackoverflow.com/questions/8952909/letter-spacing-in-canvas-element) – Todd Moses Mar 02 '12 at 02:01

1 Answers1

3

See Letter spacing in canvas element

This answer:

This is not possible; the HTML5 Canvas does not have all the text-transformation power of CSS in HTML. I would suggest that you should combine the appropriate technologies for each usage. Use HTML layered with Canvas and perhaps even SVG, each doing what it does best.

Note also that 'rolling your own'—drawing each character with a custom offset—is going to produce bad results for most fonts, given that there are letter kerning pairs and pixel-aligned font hinting.

Community
  • 1
  • 1
Todd Moses
  • 10,969
  • 10
  • 47
  • 65