rommex rommex - 5 months ago 18
Javascript Question

Horizontally scaled font via drawText?

Is there an elegant way to put text in canvas via drawText, so that it is squeezed horizontally/vertically?

Answer

"Elegant?, Well...Kind of yes!"

You can scale the canvas horizontally and the text will be squeezed.

ctx.scale(.80,1);
ctx.fillText("Squeezed!",15/.80,30);
ctx.scale(-0.80,1);

enter image description here

Comments