Nantucket E-Books on Nostr: For those using the HTML canvas element to measure text: When setting the ctx.font ...
For those using the HTML canvas element to measure text:
When setting the ctx.font property, the value has to be in this order: style/weight, font size, font family. For example, "bold 12px serif" or "bold italic 14px sans-serif"
At least from what I've seen, if you try measuring text for '12px serif bold' and '12px serif', the browser will report the same width for both.
When setting the ctx.font property, the value has to be in this order: style/weight, font size, font family. For example, "bold 12px serif" or "bold italic 14px sans-serif"
At least from what I've seen, if you try measuring text for '12px serif bold' and '12px serif', the browser will report the same width for both.