排版印刷

Font Fallback

The mechanism by which a rendering engine substitutes glyphs from a secondary font when the primary font lacks coverage for a character. Ensures characters display instead of showing □ (tofu).

What is Font Fallback?

Font fallback is the mechanism by which a rendering system selects an alternative font when the primary font does not contain a glyph for a particular character. Because no single font covers the entire Unicode character set (which has over 149,000 assigned characters across 161 scripts), every text renderer must implement a strategy for gracefully handling characters that fall outside any single font's coverage.

When a font lacks a glyph for a character, the renderer walks through a prioritized list of alternative fonts until it finds one with the required glyph. If no font in the system covers the character, the renderer typically displays a fallback glyph — commonly a rectangular box, often called "tofu" (□), or a question mark in a box (▯).

CSS Font-Family Stacks

Web developers control font fallback through the CSS font-family property, which accepts a comma-separated list of fonts in priority order:

body {
  font-family:
    "Inter",           /* Preferred: Latin, Greek, Cyrillic */
    "Noto Sans",       /* Wide Unicode coverage fallback */
    -apple-system,     /* System UI font (Apple) */
    BlinkMacSystemFont,/* System UI font (Chrome/macOS) */
    "Segoe UI",        /* System UI font (Windows) */
    sans-serif;        /* Generic family (last resort) */
}

For multilingual sites, the stack should include fonts with strong coverage of the expected scripts. The Noto font family (Google's "No Tofu" project) provides consistent coverage across all Unicode scripts.

System Font Fallback Chains

Operating systems maintain their own fallback chains that activate after the CSS stack is exhausted. These are platform-specific:

Platform CJK Fallback Arabic Fallback Emoji Fallback
macOS PingFang SC/TC/HK, Hiragino Geeza Pro Apple Color Emoji
Windows Microsoft YaHei, Meiryo Segoe UI Historic Segoe UI Emoji
Android Noto Sans CJK Noto Naskh Arabic Noto Color Emoji
Linux Noto Sans CJK Noto Naskh Arabic Noto Color Emoji

Tofu: The Fallback-of-Last-Resort Glyph

When no font in the entire fallback chain covers a character, the renderer displays a tofu glyph — the term coined by Google engineers during the Noto project. The name comes from the block's resemblance to a cube of tofu. The standard tofu glyph is typically a rectangular box (□, U+25A1) or a box containing the character's hex code point.

The Last Resort Font (published by Unicode Consortium) is a special font designed specifically for this case. It contains a distinct representative glyph for every Unicode block, displaying a block-specific symbol inside a rectangular frame. This helps users and developers identify which script a character belongs to, even when no rendering font is available.

Performance and CJK Challenges

CJK fonts present special performance challenges in the fallback model because CJK fonts are enormous — a full CJK font covering all unified ideographs can be 5–30 MB. Loading multiple CJK fonts as part of a fallback chain has severe performance implications for web pages.

The unicode-range CSS descriptor allows a font to declare which code points it covers, so the browser can skip loading a font if none of the page's characters fall in its range.

Quick Facts

Property Value
Fallback trigger Character missing from primary font's cmap table
Fallback glyph name "Tofu" — empty rectangular box
Last Resort Font Published by Unicode Consortium, script-labelled boxes
CSS property font-family (comma-separated priority list)
CSS optimization unicode-range descriptor (selective loading)
Google's goal "Noto" — No Tofu across all scripts
CJK font size Typically 5–30 MB for full coverage

相关术语

排版印刷 中的更多内容

CSS unicode-range

CSS @font-face descriptor specifying which Unicode code points a font should cover. …

OpenType

Modern font format developed by Microsoft and Adobe supporting up to 65,535 …

RTL(从右到左)

字符从右向左流动的文本方向,用于阿拉伯语、希伯来语、塔阿纳等文字,正确显示需要双向算法。

Web Fonts

Fonts downloaded by the browser to render text, declared via CSS @font-face. …

不换行空格

U+00A0,防止在该位置换行的空格。HTML中为 ,用于数字与单位之间(100 km)、专有名词(Mr. Smith)和缩写之后。

全角 / 半角(排版单位)

全角(Em):等于字号的宽度;半角(En):全角的一半,用于定义全角破折号宽度、全角空格、半角空格和CSS单位(1em、0.5em)。

变音符号 / 附加符号

附加在字母上以改变发音或意义的符号,可以是预组合形式(é U+00E9)或组合形式(e + ◌́ U+0065+U+0301),包括重音、变音符、软音符和波浪号等。

字体

特定大小、字重和样式的字型实现,在数字排版中指包含字形定义和度量的字体文件(TTF、OTF、WOFF2)。

字形

字体渲染的字符视觉表现形式。一个字符可有多个字形(连字、上下文形式),一个字形也可表示多个字符。

字距调整

为视觉美观而调整特定字符对(如AV、To、LT)之间间距的操作,是字体特性而非Unicode概念,但会影响Unicode文本的渲染。