#336·pretext

system-ui: why it's inaccurate in each browser, and what supporting it would take

Author: chenglouCreated Sep 18, 2026Updated Sep 18, 2026

Heads-up: everything below comes from a work-in-progress branch (rebuild-20260916, an experimental rewrite that follows each browser's own line breaker). The numbers are that branch's, not main's. main's position is unchanged: system-ui is unsupported for accuracy, use a named font.

system-ui keeps coming up because native-looking apps use it a lot, so here is what we now know about why it's hard, per browser, and what supporting it would take. Short version: it isn't one bug. Each browser has its own structural reason, two of the three can't be fixed from an OffscreenCanvas, and we're postponing it.

What system-ui is on macOS

It isn't an ordinary font. SF Pro has an optical size axis (letter shapes and spacing change with the rendered size), a size-dependent tracking table, and a per-language fallback list. The page and Canvas don't agree on the inputs to any of those three: the size the font is made at, whether optical sizing applies at all, and which language picks the fallback. That is what the two bugs we already track in PLATFORM_BUGS.md look like from outside (Chromium #489579956, Mozilla #2020917), plus the Safari canvas-language behaviour (WebKit #285993).

What we measured

3,471 generated system-ui cases on macOS 27 at DPR 2 (Chrome 153, Firefox 156, Safari 27's WebKit): system-ui, -apple-system and BlinkMacSystemFont, alone, first in a list, and as a fallback; 9 to 40px including fractional sizes and the sizes around the optical switch; all weights and italic; letter and word spacing; Latin with kerning and ligatures, digits, emoji, Arabic, Thai, and CJK under en, ja, zh-Hans, zh-Hant and ko; rich inline mixes with a named font; normal and pre-wrap. Share of cases where the branch predicts the browser exactly:

line count breaks line widths
Chrome 99.5% 99.1% 94.5%
Safari 99.4% 97.9% 89.9%
Firefox, measuring on an OffscreenCanvas 88.3% 75.5% 51.0%
Firefox, measuring on a detached <canvas> element 99.9% 99.8% 93.0%

For comparison, the same branch is at 99.8 to 99.9% line counts on named fonts.

Chrome

  • The page makes the platform font at the zoomed size, floored to 1/100 px in float32 (FontDescription::EffectiveFontSize, font_description.cc). Canvas has no zoom, so it makes it at the floored CSS size. At 16.8px and DPR 2 that is 16.79px against 33.59px: a ratio of 2.0006, not 2. Optical size and HarfBuzz's ptem come from the specified size on both sides, and Skia removes trak, so nothing else differs. Scaling Canvas widths by the ratio of the two floored sizes reproduces the page. This is why the affected sizes looked like moving "bands".
  • The font cache key holds text-rendering and the zoomed size but not the specified size, which is what sets the optical size (#489579956). A Canvas context at text-rendering: auto can therefore hand the page a font instance made for another size, or get one. In a fresh process, 16px system-ui page text measured 71.24px instead of 81.13px after a Canvas context had made the font first. Measuring in optimizeLegibility contexts keeps a library off the page's cache key. A page that itself sets text-rendering: optimizeLegibility shares it again.
  • What stays, at a device pixel ratio other than 1: under ja and ko below 20px the fallback font is asked from the platform font at the zoomed size (font_cache_mac.mm), and the scaled value can be one LayoutUnit (1/64 px) off at some fractional sizes.
  • Smaller, fixable things: in a list that puts a font without Latin letters before the system font, the measuring size has to be decided per font that actually draws the text; emoji inside a system-ui run are sized from the CSS size; tab stops use the font's raw space advance, which Canvas only gives with the tracking added (simple_font_data.cc).

Firefox

  • An OffscreenCanvas never applies optical sizing. The page does. No measuring recipe recovers that: on system-ui half the line widths and a quarter of the breaks come out wrong. This is Mozilla #2020917 seen from the source side, and it applies to any font with an opsz axis, web fonts included, on every OS.
  • A detached <canvas> element, measured at the device font size (CSS size × DPR, then scaled back), takes its font from the page's own font cache and matches the page: all 2,509 cases at sizes on Canvas's grid pass, every weight, italic, spacing, language and script we tried. It also removes two smaller Canvas/page differences we had seen with named fonts (a 1/60 px per-glyph rounding difference, and synthetic bold offsets).
  • Catches of the element: it needs document, so there is no worker path; and in a document without a presentation shell (a display: none iframe) it silently takes the disconnected path again (153.97px where the page has 171.47px), so a library would have to detect that. Measuring before the page has laid anything out is safe, and we couldn't measure a time cost.
  • What stays on either canvas: Canvas parses font sizes onto a grid of 7 significant bits (CanvasRenderingContext2D.cpp). Every case at 13.33px, 16.8px and 17.3px fails line widths by about 0.24px a line. 13.33px is the default button font size.

Safari

  • On an OffscreenCanvas, and on a detached <canvas>, system-ui ignores the content language, and its fallback follows the OS language list instead. On a Mac whose first language is Chinese, even English curly quotes, dashes and ellipses come from PingFang in Canvas while the page draws them from SF; with English first, the failures move to CJK pages. That is 405 of our failing cases. It is WebKit #285993 again.
  • A <canvas lang> that is connected to the document gives the page's width on 500 of 500 probe rows. Nothing else we tried does.
  • Fractional sizes were not a problem here.

Other platforms (from source only, untested)

On Windows, Chrome resolves system-ui to the menu font, normally Segoe UI, which has no optical size axis, so none of the above should apply. iOS is Safari's case with the same font. Firefox's two limits are not about macOS at all.

What supporting it would take

  1. Firefox: measure on a detached canvas element at the device size instead of an OffscreenCanvas (one measuring path, no workers), detect documents without a presentation shell, and live with or document the off-grid font sizes.
  2. Safari: measure through a canvas connected to the document with lang set. That is a DOM write in the measuring path, which Pretext has avoided on purpose, so this is the expensive one.
  3. Chrome: keep the floored-size scaling and the optimizeLegibility contexts, decide the measuring size per drawing font in family lists, fix emoji sizing inside system-ui runs, and accept two small classes at DPR ≠ 1.
  4. A system-ui case family in the browser test sets so it stays measured (the generator exists on the branch).

Until someone wants to take that on: keep using a named font where accuracy matters. -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif stacks will lay out slightly differently from what Pretext predicts on macOS, most visibly in Firefox.