CSS unicode-range
CSS @font-face descriptor specifying which Unicode code points a font should cover. Enables downloading only the font subset needed for the page content, improving load performance.
What is the CSS unicode-range Descriptor?
The CSS unicode-range descriptor, used inside @font-face rules, specifies the range of Unicode code points for which a font resource should be downloaded and applied. It is a critical performance optimization tool: when a browser encounters a @font-face declaration with a unicode-range descriptor, it only downloads the font file if the page actually contains characters that fall within the declared range. If the page has no such characters, the font is never fetched.
Without unicode-range, a page that includes multiple @font-face declarations for Latin, Greek, Cyrillic, and CJK would trigger all font downloads on page load, even if the page contains only Latin text.
Syntax
The unicode-range value accepts one or more comma-separated ranges in the following formats:
@font-face {
font-family: "MyFont";
src: url("myfont-latin.woff2") format("woff2");
/* Single code point */
unicode-range: U+0041;
/* Range */
unicode-range: U+0020-007F;
/* Wildcard range (? matches any hex digit) */
unicode-range: U+26??;
/* Multiple ranges */
unicode-range: U+0020-007F, U+00A0-00FF, U+0100-017F;
}
Google Fonts Usage
Google Fonts uses unicode-range to serve optimally subsetted fonts for each script, dramatically reducing file sizes. Instead of one monolithic font file, Google Fonts serves a CSS file that declares many small @font-face blocks, each covering a different Unicode range:
/* Google Fonts pattern (simplified) */
@font-face {
font-family: "Noto Sans";
src: url("noto-latin.woff2") format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, ...;
}
@font-face {
font-family: "Noto Sans";
src: url("noto-cyrillic.woff2") format("woff2");
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, ...;
}
@font-face {
font-family: "Noto Sans";
src: url("noto-greek.woff2") format("woff2");
unicode-range: U+0370-03FF;
}
A page in English only downloads noto-latin.woff2. A page in Russian additionally downloads noto-cyrillic.woff2. The browser makes the decision autonomously by scanning the page's text content against each declared range.
Performance Optimization
unicode-range is especially powerful for CJK content. A full CJK font can be 5–20 MB, but a typical Chinese web page uses only a few hundred distinct characters. Combined with font subsetting tools, unicode-range enables:
- Script subsetting: Separate font files per script (Latin, Cyrillic, CJK, Arabic)
- Glyph subsetting: Font files containing only the characters actually used on the page
- Progressive loading: Critical characters load first, rare characters load on demand
Quick Facts
| Property | Value |
|---|---|
| CSS property type | Descriptor (inside @font-face) |
| Download trigger | Font only downloaded if page contains matching characters |
| Syntax | U+XXXX, U+XXXX-YYYY, U+XX?? (wildcard) |
| Google Fonts | Uses 5–15 @font-face blocks per font family |
| Browser support | All modern browsers (since ~2014) |
| Key benefit | Eliminates unnecessary font downloads |
| CJK impact | Reduces CJK font downloads from 20MB to <100KB per page |
相关术语
排版印刷 中的更多内容
The mechanism by which a rendering engine substitutes glyphs from a secondary …
Modern font format developed by Microsoft and Adobe supporting up to 65,535 …
字符从右向左流动的文本方向,用于阿拉伯语、希伯来语、塔阿纳等文字,正确显示需要双向算法。
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文本的渲染。