| 格式 | 支援瀏覽器 | 備註 |
|---|---|---|
| .woff2 | 所有現代瀏覽器 (Chrome 36+, FF 39+, Edge 14+, Safari 12+) | 壓縮最佳,優先使用 |
| .woff | IE9+, 所有現代瀏覽器 | 次優選,廣泛相容 |
| .ttf / .otf | Firefox 3.5+, Safari, Opera, Chrome | 未壓縮,體積較大 |
| .eot | IE 4-8 (舊版 IE 專用) | 僅 IE 舊版需求 |
| .svg | 舊版 iOS Safari, Android Browser | 現代環境已可捨棄 |
@font-face {
font-family: 'MyCustomFont';
/* 現代瀏覽器:WOFF2 優先 */
src: url('fonts/MyCustomFont.woff2') format('woff2'),
url('fonts/MyCustomFont.woff') format('woff');
/* 可選:支援極舊瀏覽器 */
/* src: url('fonts/MyCustomFont.eot'); */
/* src: url('fonts/MyCustomFont.eot?#iefix') format('embedded-opentype'), */
/* url('fonts/MyCustomFont.ttf') format('truetype'), */
/* url('fonts/MyCustomFont.svg#MyCustomFont') format('svg'); */
font-weight: normal;
font-style: normal;
font-display: swap; /* 關鍵:避免字體載入期間文字隱形 (FOIT) */
}
.custom-title { font-family: 'MyCustomFont', sans-serif; }
中文字體動輒 3-10MB,全量載入不可接受。解決方案:只保留網站實際用到的字元,生成子集字體。
MyFont-Subset.ttf(體積驟降至 20-80KB)。



Font Squirrel 限制上傳 1MB。中文子集化後通常 < 100KB,輕鬆通過。若仍超過,進一步精減字表或使用 pyftsubset (fonttools) 命令列工具精準控制。
@font-face {
/* ... */
font-display: swap;
}
swap:立即使用備用字體顯示文字,字體載入完成後無縫切換,無閃爍 (FOIT)、無版面位移 (CLS)。optional:極弱網路下直接用備用字體,不下載自定義字體,極致效能優先。system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif) 零下載、極速渲染。font-display: swap + CDN 快取 + preload 提示。<link> 標籤。