Inn the jsfiddle, the call to measureText that sets the canvas width:
tCtx.canvas.width = tCtx.measureText(this.value).width;
overwrites the font size:
tCtx.font = "25px serif"
If I remove the call to measureText, then the canvas uses the font size I expect. Unfortunately I then have to guess on how wide to make my canvas. Why is this and is there a better way to do it?
question from:https://stackoverflow.com/questions/65602038/cannot-set-canvas-width-and-change-font-at-the-same-time