Self-hosting .woff2 files removes third-party DNS lookups and TLS handshakes from Google Fonts or Typekit—a reliable boost to First Contentful Paint. Earlier revisions of this portfolio had gone too far in the other direction by embedding base64 fonts directly inside root.css, bloating the stylesheet to roughly 8 MB and stalling initial CSS parsing.
Switching to preloaded local /fonts/*.woff2 files slashed root.css down to 7.67 KB gzipped, but exposed the second half of web typography performance: font-display: swap causes visible Cumulative Layout Shift whenever the local fallback face has different character advance widths or vertical ascent metrics than the webfont.
| Metric | Before (Base64 / Unadjusted) | After (Local WOFF2 + Tipo) |
|---|---|---|
| Root Stylesheet Payload | ~8 MB (base64) | 7.67 KB gzip |
| Font-Swap CLS | 0.09–0.14 | 0.000 |
| WOFF2 Parser WASM Cost | 250+ KB Brotli WASM | 0 KB (Pure TS) |
| Ginto Nord Width Compensation | 100% (reflows) | size-adjust: 135.87% |
The Exact Math Behind size-adjust, ascent-override & descent-override
Modern browsers support four @font-face descriptors that reshape a local system font so its line boxes and word wraps match your custom typeface before the .woff2 arrives: size-adjust, ascent-override, descent-override, and line-gap-override.
Guessing those values by eye is brittle. Tipo reads four binary tables straight out of the font file: head (unitsPerEm), hhea and OS/2 (typographic ascender, descender, and lineGap), cmap (Unicode code point to glyph ID mapping), and hmtx (horizontal advance width per glyph). It weights character advance widths against real English and Spanish letter frequencies, compares that weighted width against calibrated profiles for local system faces (Arial, Verdana, Georgia, Helvetica Neue), and computes the exact scale factor.
@font-face {
font-family: 'Ginto Fallback';
src: local('Arial');
size-adjust: 101.84%;
ascent-override: 99.86%;
descent-override: 28.67%;
line-gap-override: 0%;
}
@font-face {
font-family: 'Ginto Nord Fallback';
src: local('Verdana');
size-adjust: 135.87%;
ascent-override: 74.85%;
descent-override: 21.49%;
line-gap-override: 0%;
}Parsing WOFF2 & hmtx Transform-1 in Pure TypeScript (Zero WASM)
Most existing font metric calculators require native Node C++ bindings, bundle a heavy WebAssembly Brotli decoder, or refuse compressed .woff2 files altogether—forcing engineers to track down desktop .ttf originals just to generate CSS for a .woff2 already sitting in public/fonts/.
Tipo implements the WOFF2 container reader, pure-JavaScript Brotli decompression, and WOFF2 hmtx transform-1 reconstruction directly in TypeScript. Because there is zero WebAssembly or native addon dependency, the exact same parseFont(bytes) function runs identically in CI build scripts and inside the browser drag-and-drop calculator in Roier Lab where zero font files ever leave your device.
- Auto-recommends the closest system fallback: pairs
GintowithArialand widerGinto Norddisplay lettering withVerdanaautomatically. - Copy-ready production CSS + preload tags: outputs both
@font-facefallback rules and<link rel="preload" as="font" crossorigin>HTML. - Live 900 ms blink comparator: visually toggle between raw system fallback and Tipo-adjusted fallback right inside the browser.