Jigmo Webfonts

基於 Jigmo(CC0)的 CJK 生僻字 woff2 分片字型服務,涵蓋 Unicode Extension A–J(U+3400–U+323AF)。 Chunked woff2 webfonts for CJK rare ideograph display — covering Unicode Extensions A through J (U+3400–U+323AF). Based on Jigmo (CC0).

快速上手 Quick Start

<head> 加入一個樣式表: Add one stylesheet to your <head>:

<link rel="stylesheet" href="https://jigmo.digitalhumanities.dev/jigmo.css">

Jigmo 放在 font stack 的末段作為備援——瀏覽器只會下載頁面實際出現字符所在的分片: Use Jigmo as a fallback in your font stack, after your primary font — browsers only fetch the chunks they actually need:

body {
  font-family:
    'Source Serif 4',        /* 拉丁文 / Latin — pairs with Source Han Serif */
    'Source Han Serif TC',   /* 常用漢字 / common CJK */
    'Noto Serif CJK TC',     /* 常用漢字備援 / common CJK fallback */
    'Jigmo',                 /* 生僻字 / rare ideographs (Ext A–J) */
    serif;
}

就這樣。瀏覽器只下載包含頁面字符的 256-碼位分片,含生僻字的頁面通常只增加數 KB 的流量。 That is all. Browsers download only the 256-codepoint chunks containing characters on each page, typically adding a few KB for pages with rare characters.

字型示範 Demo

試試看 — 輸入任意文字  /  Try it — type any text
CJK Extension B — 歷史人名(CBDB)/ Historical person names
𪘏 𢘍 𥲅 𣔳 𤎖 𡼖 𢍰 𩕊 𡸕 𤩪 𤥻 𦒎 𤇸
趙克𪘏 趙叔𢘍 趙與𥲅 石𡼖 齊𤇸
趙𣔳夫 趙時𤎖 趙師𢍰 陳𩕊文
CJK Extension A (U+3400–U+4DBF)
㐅 㐌 㑂 㑞 㒜 㔠 㔶 㙉 㙊 㙋 㙏 㙐 㙑 㙓 㙔 㙖
CJK Extension G / H (U+30000+) — Jigmo3
𰀀 𰀁 𰀂 𰀃 𰀄 𰀅 𰀆 𰀇 𰀈 𰀉 𰀊 𰀋 𰀌 𰀍 𰀎 𰀏
常用字與生僻字混排 / Mixed — regular + rare in context
宋史載,趙克𪘏官至朝奉郎,趙𣔳夫以文學見稱。
石𡼖任提舉,齊𤇸累官至通判。

原理 How It Works

jigmo.css 包含數百條 @font-face 規則,每條對應一個 256 碼位的分片: jigmo.css declares hundreds of @font-face rules, each covering a 256-codepoint block:

@font-face {
  font-family: 'Jigmo';
  font-display: swap;
  src: url('fonts/jigmo-02a600.woff2') format('woff2');
  unicode-range: U+2A600-U+2A6FF;  /* Ext-B 末段 / Ext-B block ending */
}

瀏覽器讀取 unicode-range 描述符,只在頁面包含該範圍字符時才下載對應分片。沒有生僻字的頁面下載零位元組;含一個 Ext-B 字符的頁面只下載一個分片(約 10–40 KB)。 The browser reads the unicode-range descriptor and only downloads a chunk if that page contains a character in that range. A page with no rare characters downloads zero font bytes. A page with one Ext-B character downloads one chunk (~10–40 KB).

此技術與 Google 大規模提供 Noto CJK 時所用的方式相同。 This is the same technique Google uses to serve Noto CJK at scale.

覆蓋範圍 Coverage

字符區塊 / Block Unicode 範圍 / Range 來源字型 / Source TTF 狀態 / Status
CJK URO + 相容表意文字
CJK URO + Compatibility
U+3000–U+9FFF, U+F900–U+FAFF Jigmo.ttf included
CJK 擴充 A
CJK Extension A
U+3400–U+4DBF Jigmo.ttf included
CJK 擴充 B
CJK Extension B
U+20000–U+2A6DF Jigmo2.ttf included
CJK 擴充 C–F, I
CJK Extension C–F, I
U+2A700–U+2EE5F Jigmo2.ttf included
CJK 擴充 G–J
CJK Extension G–J
U+30000–U+323AF Jigmo3.ttf included
合計 / Total 約 145,975 字符(Unicode 17.0)
~145,975 characters (Unicode 17.0)

自架與建置 Self-Hosting / Build

如需自架或從新版 Jigmo 重新生成分片: To host your own instance or regenerate the chunks from an updated Jigmo release:

# 1. 安裝 Python 依賴 / Install Python dependencies
pip install -r requirements.txt

# 2. 建置:下載 Jigmo zip、切片為 woff2、生成 jigmo.css
#    Build: download Jigmo zip, chunk into woff2, write jigmo.css
python build.py

# 3. 將整個目錄部署至任意靜態主機(GitHub Pages、Cloudflare Pages、S3 等)
#    Deploy to any static host — only index.html, jigmo.css, and fonts/ are needed
python split.py   # 拆分為兩個 Cloudflare Pages 專案 / split for two CF Pages projects
wrangler pages deploy dist/jigmo  --project-name jigmo  --branch main
wrangler pages deploy dist/jigmo2 --project-name jigmo2 --branch main

升級 Jigmo 新版本:修改 build.py 頂部的 JIGMO_URL,刪除 src/fonts/ 後重新執行。 To update to a newer Jigmo release, edit JIGMO_URL at the top of build.py, delete src/ and fonts/, and re-run.

# 強制重建所有分片 / Force rebuild of all chunks
rm -rf src/ fonts/
python build.py --force

選項: Options:

python build.py --no-dl    # 跳過下載(src/*.ttf 已存在)/ skip download
python build.py --force    # 重建已有分片 / rebuild existing chunks
python build.py --jobs 8   # 平行 worker 數(預設:CPU 核心數)/ parallel workers

授權 License

Jigmo 由 Kamichi Koichi 與 GlyphWiki 社群以 CC0 1.0 公共領域授權發布。本 repo 的切片腳本同樣採用 CC0。 Jigmo is released under CC0 1.0 Public Domain by Kamichi Koichi and the GlyphWiki community. The chunking scripts in this repository are also CC0.

https://kamichikoichi.github.io/jigmo/