Vector & CSS Delivery Formats
CSS @font-face & Metric Overrides
CSS Fonts Module Level 4 defines @font-face declarations, unicode-range chunk loading, font-display timelines, and metric overrides (size-adjust, ascent-override) that eliminate Cumulative Layout Shift.
Strengths
- Lets browsers download only matching unicode-range font slices for active page characters
- size-adjust and ascent/descent-override match system fallback proportions to eliminate CLS jump
- Self-hosted CSS eliminates external Google Fonts CDN tracking for GDPR compliance
Trade-offs
- Incorrect ascent/descent or missing unicode-range declarations cause FOIT/FOUT flicker or fallback mismatch
- Requires accurate OS/2 vs hhea metric calculations per fallback font family
Convert & optimize CSS @font-face locally
Related engineering guides
All 18 guidesHow to Shrink 15 MB CJK Fonts to 60 KB via Subsetting & unicode-range Splitting
Cut 15–25 MB Chinese, Japanese, and Korean fonts down to 58 KB subsets or auto-split into CSS unicode-range WOFF2 chunks locally without 5 MB caps.
Zero Layout Shift Web Fonts: Calculating size-adjust & ascent-override
Eliminate Cumulative Layout Shift (CLS) on web font swap using exact OS/2 vs hhea formulas for size-adjust, ascent-override, and descent-override.
Self-Hosting Google Fonts for GDPR Compliance & Zero Third-Party Requests
Eliminate external fonts.googleapis.com requests for European GDPR compliance by packing local WOFF2 fonts, @font-face CSS, and CLS fallbacks.
Variable Fonts: Static Weight Instancing vs. Trimming Axis Ranges
Use HarfBuzz WASM in your browser to pin Variable Font axes (wght/wdth) into lightweight static weights or trim axis spans without Python fonttools.
Production @font-face CSS: Preload, crossorigin, and font-display Strategy
Write bulletproof @font-face CSS with font-display: swap vs optional, crossorigin preload hints, and metric-matched fallbacks for fast LCP.
Removing Font Hinting (fpgm/prep/cvt): Saving 8–15% Bytes on Retina Screens
Strip legacy TrueType bytecode hinting tables (fpgm, prep, cvt) with HarfBuzz WASM to save 8%–15% WOFF2 bytes for macOS, iOS, and modern HiDPI screens.
- Build a Custom SVG-to-WOFF2 IconFont in Your Browser Without Node CLIBundle monochrome SVG UI icons into a lightweight WOFF2 + TTF IconFont with CSS classes and demo.html locally — zero Node tools or cloud uploads.
- Fixing Missing Glyphs & Tofu Boxes: cmap Coverage and CSS FallbacksDebug missing glyph tofu boxes (.notdef), audit cmap table coverage before subsetting, keep punctuation intact, and build safe CSS fallback stacks.
- Base64 Inline WOFF2 vs. External Font Files: When Data URIs Make SenseWeigh Base64 Data URI fonts (+33% overhead and CSSOM blocking) against external WOFF2 files—and learn when inline subsetting actually wins.
- Migrating Legacy EOT and WOFF 1.0 Web Fonts to Modern Brotli WOFF2Rescue legacy IE .eot and zlib .woff web fonts into modern Brotli .woff2, clean up obsolete #iefix @font-face CSS, and batch-upgrade stacks.
CSS @font-face frequently asked questions
How does size-adjust stop font Cumulative Layout Shift (CLS)?
size-adjust scales the local fallback font's x-height and advance width to match your webfont so line breaks and paragraph heights stay identical during swap.
Which font-display value should I use in production?
font-display: swap shows text immediately with fallback metrics and swaps seamlessly when combined with size-adjust overrides; optional prevents swaps on slow links.
Why pair @font-face CSS with link rel=preload?
Preloading primary above-the-fold WOFF2 files starts the font fetch alongside HTML/CSS parsing instead of waiting for stylesheet discovery.