Web Fonts
Fonts downloaded by the browser to render text, declared via CSS @font-face. WOFF2 is the standard format. Unicode subsetting and unicode-range enable efficient loading of multilingual fonts.
What is a Web Font?
A web font is a font file loaded over HTTP/HTTPS and applied to text in a web page, rather than relying on fonts installed on the user's operating system. The @font-face CSS rule enables web fonts, and the WOFF2 format (Web Open Font Format 2) is the standard delivery format used on the modern web.
Web fonts allow designers to use consistent, brand-specific typography across all devices and operating systems, solving the long-standing limitation of relying on a small set of universally-installed "web-safe" fonts.
WOFF2: The Standard Web Font Format
WOFF2, defined in the W3C specification, is a compressed container format for OpenType fonts. It uses Brotli compression (replacing the zlib used in WOFF1), achieving approximately 30% better compression than WOFF1 and typically 50–70% smaller than the raw OTF/TTF file.
@font-face {
font-family: "Inter";
font-weight: 100 900; /* Variable font weight range */
font-style: normal;
font-display: swap; /* Show fallback immediately, swap when loaded */
src:
url("/fonts/inter-var.woff2") format("woff2"),
url("/fonts/inter-var.ttf") format("truetype"); /* Fallback */
unicode-range: U+0000-00FF, U+0131, U+0152-0153;
}
font-display: Controlling Loading Behavior
The font-display descriptor controls the tradeoff between showing unstyled text immediately (FOUT — Flash of Unstyled Text) and waiting for the font (FOIT — Flash of Invisible Text):
| Value | Behavior |
|---|---|
auto |
Browser default (usually block) |
block |
Hide text briefly, then show with web font |
swap |
Show fallback immediately, swap to web font when loaded |
fallback |
Short block period (100ms), then fallback, swap only if fast |
optional |
Browser decides; may not load on slow connections |
font-display: swap is recommended for body text; optional is recommended for decorative fonts.
CJK Web Font Challenges
CJK (Chinese, Japanese, Korean) web fonts present unique challenges:
- A full CJK font covering all unified ideographs contains 65,000–100,000 glyphs and weighs 5–30 MB
- Even a practical subset of "common" Chinese characters (3,500 characters) produces a font of 1–3 MB
- Loading a 3 MB font on a mobile connection causes significant page weight issues
Strategies for CJK web fonts:
- Unicode-range subsetting: Serve only the characters actually used (see
unicode-rangeCSS descriptor) - On-demand subsetting: Services like Google Fonts and Adobe Fonts generate per-page subsets
- Dynamic subsetting APIs: Font subsetting APIs accept a list of characters and return a minimal font file containing only those glyphs
- System fonts: Fall back to the platform's CJK system font for body text, using web fonts only for headings
# Python font subsetting with fonttools
from fontTools.subset import Subsetter, Options
options = Options()
subsetter = Subsetter(options=options)
subsetter.populate(text="常用漢字テキスト")
# Produces a font with only the required glyphs
Variable Fonts on the Web
Variable fonts (OpenType 1.8+) are increasingly used on the web because a single variable font file replaces multiple separate weight/style files:
- Traditional: 8 files (thin, light, regular, medium, semibold, bold, extrabold, black)
- Variable: 1 file with continuous weight axis from 100–900
For Latin scripts, a variable WOFF2 is typically 80–150 KB — smaller than two traditional static weight files combined.
Quick Facts
| Property | Value |
|---|---|
| Standard format | WOFF2 (W3C spec, Brotli compression) |
| Compression | ~30% better than WOFF1, ~50% smaller than OTF |
| CSS declaration | @font-face rule |
| Loading behavior | Controlled by font-display descriptor |
| CJK font size | 5–30 MB full; 100–500 KB subsetted |
| Variable fonts | Single file replaces 4–8 static weight files |
| Subsetting tool | fonttools Python library |
関連用語
タイポグラフィ のその他の用語
CSS @font-face descriptor specifying which Unicode code points a font should cover. …
Em:フォントサイズと等しい幅。En:Emの半分。エムダッシュ幅・エムスペース・エンスペース・CSSユニット(1em・0.5em)の定義に使われます。
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 …
文字が右から左に流れるテキスト方向。アラビア語・ヘブライ語・ターナ文字などで使われ、正しい表示のために双方向アルゴリズムが必要です。
視覚的な調和のために特定の文字ペア(例:AV・To・LT)間のスペーシングを調整すること。Unicodeの概念ではなくフォント機能ですが、Unicodeテキストのレンダリングに影響します。
フォントによってレンダリングされる文字の視覚的表現。1つの文字が複数のグリフを持つ場合があり(合字・文脈形態)、1つのグリフが複数の文字を表す場合もあります。
小文字の高さの大文字字形。CSS:font-variant: small-caps。Unicodeにはラテン拡張(ᴀ〜ᴢ)に実際のスモールキャップス文字があります。
前進幅がゼロの文字 — レンダリングでは見えませんがテキスト動作に影響します。ZWSP(単語区切り)・ZWJ(結合)・ZWNJ(結合防止)・WJ(改行防止)などがあります。
文の一部を区切ったり範囲を示したりする句読記号。Unicodeはハイフン(‐)・エンダッシュ(–)・エムダッシュ(—)・図表ダッシュ(‒)などを定義しています。