The question says it all pretty much. I've been searching around and starting to worry that it's impossible.
I've got this canvas element that I'm drawing text to. I want to set the letter spacing similar to the CSS letter-spacing
attribute. By that I mean increasing the amount of pixels between letters when a string is drawn.
My code for drawing the text is like so, ctx is the canvas context variable.
ctx.font = "3em sheepsans";
ctx.textBaseline = "middle";
ctx.textAlign = "center";
ctx.fillStyle = "rgb(255, 255, 255)";
ctx.fillText("Blah blah text", 1024 / 2, 768 / 2);
I've tried adding ctx.letterSpacing = "2px";
before the drawing but with no avail. Is there a way to do this just with a simple setting, or will I have to make a function to individually draw each character with the spacing in mind?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…