{"canonical_url":"https://engineer.company/notes/safari-underline-font-subset/","content_markdown":"# The underline that crossed every letter\n\n2026-09-28\n\nOur own site underlines every link, and lets the browser cut a gap where a\nletter's tail crosses the line — the `g`, the `p`, the comma. In Safari it did\nnot. The line ran straight through them. It had been doing so on the English\nand the Danish pages for as long as the site had been\nmultilingual *(the bug nobody reports, because it just looks cheap)*.\n\nThe cause was three font declarations for an alphabet those pages never\ndownload.\n\n## What the browser is supposed to do\n\n`text-decoration-skip-ink` is the property that lifts an underline around a\ndescender. It is on by default, and for years the answer to \"my underline looks\nwrong\" has been to reach for `text-underline-offset` and push the line further\ndown. That is the wrong reflex: moving the line changes the design, and the gap\nis what was actually missing.\n\nWe found two real causes before the interesting one, and both are worth knowing.\n\n- **A `1px` underline gets a `1px`-sized gap.** The break the engine cuts is\n  proportional to the thickness of the line doing the cutting. Our stylesheet\n  pinned the thickness at one pixel, which left about 0.6px of air either side\n  of a stem — technically a gap, visually a line straight through the letter.\n  Setting `text-decoration-thickness: auto` scaled both together and took the\n  gap from 3.5px to 12.4px without moving the underline a single pixel.\n- **`from-font` is not the safe default it sounds like.** It reads the\n  thickness the typeface itself declares, and Ubuntu declares 0.056em for\n  Light, 0.020em for Medium and 0.120em for Bold — a family whose Medium rule\n  is under half the weight of its Light one. At large sizes that is a six-pixel\n  line beside a two-pixel line on the same page.\n\nThat fixed Chrome. Safari still drew the line through everything.\n\n## The part that took the longest\n\nWe measured it properly: drive a real Safari, recolour the underline, screenshot\nat eight times scale, and count the pixels where the line stops and starts.\n\n| | painted thickness | gap around a descender |\n| --- | --- | --- |\n| Chrome | 2.00px | 5.8 / 12.5 / 6.3px |\n| Safari | 1.38px | 1.8 / 1.0 / 1.0px |\n\nSo Safari was cutting a gap. It was just six times narrower than Chrome's, and\nat reading size a one-pixel gap is not a gap. Worse, the usual lever made it\nworse: at a 3px thickness Safari dropped from three gaps to one, at 4px to\nnone, because it does not scale the gap with the line. It pins it at roughly\n0.07em at every size, where Chrome gives 0.6em.\n\nWe swept about twenty declarations against it — `skip-ink: all`, both legacy\nspellings of the property, every thickness from half a pixel to four,\n`text-underline-position`, `font-smoothing`, `text-rendering`, `paint-order`.\nNothing widened it. The honest conclusion at that point was that WebKit simply\ncapped the gap and there was nothing further to do from a stylesheet.\n\nThat conclusion was wrong, and the thing that broke it was\n[a bug report against a font project](https://github.com/fontsource/fontsource/issues/1096):\nSafari ignores skip-ink when a typeface is loaded with a non-Latin subset.\n\n## The actual cause\n\nThe site serves Ubuntu in six pieces — three weights of Latin, three of\nCyrillic — so a Ukrainian page is set in the same typeface as an English one\ninstead of falling back to whatever the system offers. Each piece declares the\nrange of characters it covers, and the browser downloads only the pieces a page\nactually needs.\n\nAll six were declared under the one family name, which is the obvious way to\nwrite it. And that is the trigger, recorded as\n[WebKit bug 255159](https://bugs.webkit.org/show_bug.cgi?id=255159): **when one\nface in a family declares a non-Latin character range, Safari degrades skip-ink\nfor every character in that family** — including Latin text on a page that\nnever fetches the other file.\n\nAn English page was rendering its underlines badly because a Ukrainian font\ndeclaration existed somewhere in the stylesheet. Deleting those three lines at\nruntime, and changing nothing else, took the gaps from 1.8/1.0/1.0px to\n4.5/11.0/5.0px.\n\n## The fix\n\nGive the second script its own family name, and name it in the font stack after\nthe first:\n\n```css\n@font-face {\n    font-family: UbuntuCyrillic;   /* was: Ubuntu */\n    src: url(ubuntu_300_cyrillic.woff2) format('woff2');\n    unicode-range: U+0400-045F, U+0490-0491;\n}\n\n:root {\n    --body-font: Ubuntu, UbuntuCyrillic, system-ui, sans-serif;\n}\n```\n\nA Latin letter is found in the first family and never reaches the second. A\nCyrillic one falls past the first, which has no such glyph, and lands in the\nsecond rather than in a system face. The character ranges still decide what\ngets downloaded, so nothing about the loading changes: English and Danish pages\nfetch three Latin files and no Cyrillic ones, Ukrainian pages the reverse.\n\nThree renamed declarations and one stack entry. Safari's gaps went to\n4.5/11.0/5.0px, Chrome was untouched, the underline did not move, and Ukrainian\nstill sets in Ubuntu at identical widths.\n\n## What we would tell the next person\n\n- **A skip-ink measurement is only true of the engine that produced it.** We\n  had a table of numbers, a correct diagnosis and a real fix, and it was all\n  Chromium. The screenshot that reopened the case came from a person looking at\n  the page.\n- **Reach for the thickness before the offset.** Widening the gap keeps the\n  design; moving the line down replaces it.\n- **Splitting a typeface by script is right, but the split belongs in the\n  family name too.** Sharing one name across scripts reads better and costs you\n  skip-ink in Safari. Merging them back looks like tidying and is a regression.\n- **The loading was never the problem.** Every instinct says a page rendering\n  badly because of a Cyrillic font must be downloading something it should not.\n  It was not. The declaration alone was enough.\n\n## Sources\n\n- [WebKit bug 255159 — `text-decoration-skip-ink` and font subsets](https://bugs.webkit.org/show_bug.cgi?id=255159)\n- [Fontsource issue 1096, which named the trigger](https://github.com/fontsource/fontsource/issues/1096)\n- [MDN: `text-decoration-skip-ink`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-skip-ink)\n- [MDN: `unicode-range`](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range)\n\n\u003chttps://engineer.company/notes/safari-underline-font-subset/\u003e\n","date_modified":"2026-10-20T09:21:41Z","description":"Safari drew our underlines through every descender. The cause was a Cyrillic font subset on pages that never load it.","formats":{"gemtext":"https://engineer.company/notes/safari-underline-font-subset/index.gmi","gopher":"https://engineer.company/notes/safari-underline-font-subset/gophermap","html":"https://engineer.company/notes/safari-underline-font-subset/","json":"https://engineer.company/notes/safari-underline-font-subset/index.json","markdown":"https://engineer.company/notes/safari-underline-font-subset/index.md","pdf":"https://engineer.company/notes/safari-underline-font-subset/index.pdf"},"kind":"page","language":"en","title":"The underline that crossed every letter","url":"https://engineer.company/notes/safari-underline-font-subset/","version":1}