arXiv:2610.24937cs.LGOct 2026

Manuscript Offprint

arXiv:2610.24937

MLFont: Machine Learning-Driven Font Subsetting and Range-Compact Unicode-Range Slicing for Low-Latency Web Typography

Quan Wang, Yiran Mao

Abstract

CSS3 @font-face rules with unicode-range descriptors partition web fonts into downloadable slices. While Latin fonts need ~20 KB in WOFF2, Pan-European (LGC) and East Asian (CJK) fonts contain 2,297–30,759 codepoints (158 KB–5.9 MB in WOFF2), where heuristic partitioning causes unused-glyph downloads, high HTTP RTT, CSS bloat, or missing-glyph fallbacks. We present MLFont, a machine learning and optimization framework that learns font slicing strategies from corpora via three stages: (1) a Zipfian High-Frequency Tier (most) isolating top-frequency codepoints; (2) a Latent Co-Occurrence Topic Tier using Online Variational Bayes LDA (Online LDA) or a Deep Neural Network Topic Model (DNNTM) with Shannon Entropy Difference Loss and Sinkhorn-Knopp normalization; and (3) a Memetic Range-Compact Genetic Algorithm (GA) with Potts-Viterbi dynamic programming and island bridging that minimizes topic discrepancy and CSS fragmentation. Across five Google Noto fonts (LGC, KR, JP, TC, SC), MLFont cuts 3G per-glyph latency by 56.7%–75.3% over single-file delivery and 46.1%–66.3% over equal-bin baselines on CJK with 100% coverage, reduces CSS intervals by 17.9%–41.7%, and achieves 1.56×–6.09× cold-cache speedups (65.4%–84.9% CJK and 44.7% LGC bandwidth savings) across 20 websites in simulator and Headless Chrome benchmarks (45/45 exact slice-set parity).

Code: https://github.com/wq2012/mlfont

Models: https://huggingface.co/collections/wq2012/mlfont

1 Introduction

Web fonts are a foundational pillar of modern digital typography, enabling consistent visual identity and multilingual rendering across heterogeneous client operating systems [4, 8]. However, serving heavy font libraries over the web presents a severe systems and networking bottleneck known as the Heavy Web Font Loading Problem. Whereas a standard Western Latin typeface contains 200–400 glyphs and compresses to 15–30 KB under WOFF2 Brotli compression [1, 8], Pan-Unicode typefaces such as Noto Sans (Latin-Greek-Cyrillic, 2,297 codepoints) and East Asian CJK typefaces such as Noto Sans CJK (16,663 to 30,759 codepoints across Japanese, Traditional Chinese, Korean, and Simplified Chinese) span 3.0 MB to 5.9 MB per font weight even after WOFF2 compression [9]. Downloading a multi-megabyte font file over cellular or emerging-market networks (e.g., 2G/3G) causes multi-second render-blocking delays, manifesting as Flash of Invisible Text (FOIT) or jarring layout shifts from Flash of Unstyled Text (FOUT).

To mitigate full-font downloads, the W3C CSS Fonts Module Level 3 specification introduced the unicode-range descriptor within @font-face rules [4]. This mechanism allows a single logical typeface to be partitioned into K disjoint physical WOFF2 subset files (slices) S1,…,SKS_{1}, \ldots, S_{K}. When a browser parses a web page, it inspects the active DOM characters and lazily fetches only those slices whose unicode-range intervals intersect the page's character set. Unlike patch-based protocols such as the W3C Incremental Font Transfer (IFT) specification [14]—which require precomputed patch sets and a client-side patch-application engine—static unicode-range slicing operates purely over standard immutable CDN files and is supported by all major modern web browsers; MLFont's learned co-occurrence partitions can also inform IFT patch-table groupings.

Despite widespread browser support for unicode-range, designing an optimal codepoint partition S={S1,…,SK}\mathcal{S} = \{S_1, \ldots, S_K\} for a font of VV codepoints is a challenging combinatorial optimization problem governed by three competing physical forces:

(1) Bandwidth Waste (Over-fetching): If a slice SkS_k groups together characters that rarely co-occur on the same web page, downloading SkS_k for a single needed character forces the client to download hundreds of unused glyphs, resulting in poor glyph utilization (< 6%).

(2) HTTP Request Overhead (RTT Multiplication): If characters that frequently co-occur on a single web page are scattered across many slices, rendering a single page triggers dozens of distinct HTTP requests, multiplying network Round-Trip Time (RTT) overhead.

(a) Zipfian Codepoint Document-Frequency Decay

Figure

(b) Latency vs. CSS Unicode-Range Pareto Frontier (Noto Sans SC)

Total CSS unicode-range Intervals (log scale, lower is more compact)

Figure 1: (a) Empirical Zipfian decay of codepoint document frequencies across five Google Noto fonts on Wikipedia corpora, motivating Tier-1 high-frequency isolation (most_1..M). (b) Pareto trade-off between mean per-glyph download latency (GIN-3g, session length L = 10) and total CSS unicode-range intervals on Noto Sans SC (30,759 codepoints).

(3) CSS Stylesheet Fragmentation: In a CSS @font-face rule, each slice's codepoint set must be serialized as a comma-separated list of hexadecimal intervals (e.g., U+4E00-4E05, U+4E08). If a slicing strategy assigns numerically adjacent Unicode codepoints to different slices, the resulting CSS stylesheet explodes to tens of thousands of disjoint hex intervals, inflating the render-blocking CSS payload itself.

Traditional heuristics fail to reconcile these three objectives. Uniform codepoint binning (equal_bin) preserves contiguous Unicode ranges but ignores semantic character co-occurrence, causing nearly every slice to be fetched on every CJK page. Static language/script subsetting (language_slice) works for coarse script separation (e.g., Latin vs. Cyrillic) but breaks down on CJK Unified Ideographs—where 20,000+ Han characters share a single Unicode block—and leaves thousands of font codepoints unassigned (causing missing-glyph tofu whenever pages contain cross-script citations, rare Hanja/Kanji, or symbols).

In this work, we present MLFont, an open-source reproduction and algorithmic extension of Google’s machine learning font slicing technology [19, 5] that learns font slicing strategies from large-scale web document corpora. Our key contributions are:

• Two-Tier Frequency and Topic Co-Occurrence Architecture: We exploit the steep Zipfian power-law decay of character document frequencies (Figure 1a) by isolating the top most frequent codepoints into deterministic, universally cached Tier-1 slices (most), and modeling latent co-occurrence across the remaining VremV_{rem} tail codepoints via Online Variational Bayes LDA (Online LDA) or a Deep Neural Network Topic Model (DNNTM) that unifies discriminative non-negative Shannon Entropy Difference Losses [15] with nonnegative sparse autoencoder reconstruction [10, 17], paired with two-tier Hungarian contiguous-bin Bayes alignment.

• Bi-Stochastic Affinity Normalization and Memetic Range-Compact GA: We analyze five topic-codepoint normalization schemes (topic_sum, row_sum, global_max, spectral_norm, and Sinkhorn-Knopp bi-stochastic scaling sinkhorn [16]) and introduce a Memetic Range-Compact Genetic Algorithm (GA) with a power-law slice-capacity curriculum max_diff(t), Lagrangian 1D Potts-Viterbi dynamic programming relaxation [13, 18], sparse-tail monochromatic island bridging, and tier-capacity invariance that compacts fragmented Unicode assignments into contiguous unicode-range runs (-17.9% to -41.7% intervals) while strictly enforcing balanced slice capacities.

• Multi-Page Session Network Simulator, Real-Website Browser Benchmarking, and Open-Source Release: We formulate a realistic multi-page browsing session evaluator across seven network/session profiles, evaluate both canonical fixed-byte and physical WOFF2 slice sizes across five Google Noto fonts, validate end-to-end page font loading across 20 multi-domain websites in both our analytical simulator and real Headless Chrome (1.56× to 6.09× cold-cache speedups and 45/45 [100.0%] exact slice-set agreement with Chrome), and release our open-source library (https://github.com/wq2012/mlfont) and pretrained Noto model bundles (https://huggingface.co/collections/wq2012/mlfont).