How Browser Canvas Text Rendering and System Fonts Work
Font stacks, fallback, text measurement, outline joins, and resolution-independent positioning in browser-based image text tools.
Primary Browser Tool
Add Text to Image
Place draggable text layers on a photo with font, size, color, outline, shadow, and background box controls.
Font Stacks and Fallback
A browser can draw text only with fonts it has access to. This tool requests a list of families, known as a stack, such as “Georgia, Times New Roman, Times, serif”. The browser uses the first family in the list that is installed, and the generic keyword at the end guarantees that something suitable is always found.
The practical consequence is that the same setting can produce slightly different letter shapes and widths on different devices. That affects only the editing session. Once exported, the text is pixels in the image and looks identical everywhere.
Measuring, Wrapping, and Drawing
Before drawing, the canvas API measures how wide a string will be in the chosen font and size. Tools use that measurement to align lines, size background boxes, and, where wrapping is enabled, decide where a line must break. Wrapping is greedy: words are added to a line until the next one would exceed the limit.
Drawing happens in two passes. The outline is stroked first at twice the visible width, because a stroke is centered on the letter edge and half of it falls inside the letter. The fill is then drawn on top and covers that inner half. Round line joins prevent sharp spikes at the corners of letters such as M and W when outlines are thick.
Keeping Preview and Export Identical
The preview is drawn on a reduced copy of the image for speed, while the export is drawn on the full-size original. To keep the two consistent, nothing is stored in pixels. Positions are fractions of width and height, font size is a percentage of image width, and outline and padding are percentages of font size. The same function draws both, with only the canvas dimensions changing.
| Property | Stored as | Why |
|---|---|---|
| Position | Fraction of width and height (0–1) | Same spot at any resolution |
| Font size | Percent of image width | Same visual proportion |
| Outline, box padding | Percent of font size | Scales with the text |
| Rotation | Degrees around the layer center | Independent of size |
Practical Examples
Same layer, two resolutions
A title at 8% size is 96 px tall on the 1200 px preview and 320 px tall on a 4000 px original. It occupies the same share of the picture in both.
Common Mistakes & Honest Limitations
Mistakes to Avoid
- Expecting a specific commercial typeface. Only fonts installed on the device can be used, and web fonts are deliberately not downloaded.
Technical Limitations
- Canvas text has no automatic hyphenation or justification, and complex typographic features such as ligature control are left to the browser’s defaults.