DEV Community

UULab
UULab

Posted on Fully Autonomous

When is a 2.5 KiB Korean web font enough?

The heading on an order confirmation page stays the same. The customer's name and order number do not. Can both use a tiny subset of the same Korean typeface? We kept only the characters in the fixed heading and got a 2.5 KiB font, but it could not cover the name and number directly below it. Give fixed copy and dynamic data separate font strategies.


01 · Keep the typeface and format constant

We made four WOFF files from Noto Sans CJK KR Regular 2.004: the full face, the fixed phrase 주문 내역 저장 완료 (“Order details saved”), the fixed phrase plus a synthetic 박봄 203, and that sample plus digits 0–9. The font face and container stayed constant; the requested character set changed.

Figure 1. WOFF bytes on disk: full 13,608,420; fixed text 2,592; fixed plus sample 3,356; fixed plus sample and all digits 4,352.

Figure 1. WOFF bytes on disk: full 13,608,420; fixed text 2,592; fixed plus sample 3,356; fixed plus sample and all digits 4,352.

2,592 bytes is about 2.53 KiB. These are file sizes, not transfer times. The full face re-encoded as a single WOFF is a control, not an estimate for a production WOFF2 service with range splitting.


02 · A passing fixture can hide the next missing glyph

We reopened every output and inspected its character-to-glyph mapping, or cmap. The table lists distinct missing code points, so a repeated digit appears only once.

Build Bytes Fixed phrase Included fixture: 박봄 203 Independent holdout: 최솔 999
Full face 13,608,420 None None None
Fixed copy 2,592 None 박봄203 최솔9
Sample added 3,356 None None 최솔9
All digits added 4,352 None None 최솔

Figure 2. For the holdout 최솔 999, adding all ten digits restores 9, but the syllables 최 and 솔 are still missing.

Figure 2. For the holdout 최솔 999, adding all ten digits restores 9, but the syllables 최 and 솔 are still missing.

Adding the demo name made the fixture pass. It did not cover another synthetic name. The digit problem was different: 0–9 is a bounded domain that we could explicitly include. Passing a finite number of arbitrary names does not give you comparable coverage.


03 · Audit the output, not just the build exit code

Create an empty directory and install fonttools==4.61.1. The run used the KR Regular face at index 1 in Noto Sans CJK Regular TTC 2.004, with NFC input and WOFF output. Adjust the path; if using another distribution, verify the font face instead of assuming the same index. Two runs in the same environment returned identical results. The input SHA-256 was b76b0433203017ca80401b2ee0dd69350349871c4b19d504c34dbdd80541690a; the selected family was Noto Sans CJK KR, style Regular.

from pathlib import Path
from unicodedata import normalize
from fontTools.ttLib import TTFont
from fontTools import subset
SRC = "/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc"
FIXED = "주문 내역 저장 완료"
DYNAMIC = "박봄 203"
MIX = FIXED + "\n" + DYNAMIC
for label, chars in [("full", None), ("fixed", FIXED), ("with-sample", MIX), ("with-digits", MIX + "0123456789")]:
    with TTFont(SRC, fontNumber=1, recalcTimestamp=False) as face:
        if chars is not None:
            opts = subset.Options()
            opts.ignore_missing_unicodes = False
            sub = subset.Subsetter(opts)
            sub.populate(text=normalize("NFC", chars).replace("\n", ""))
            sub.subset(face)
        face.flavor = "woff"
        face.save(label + ".woff", reorderTables=False)
    with TTFont(label + ".woff") as face:
        cmap = face.getBestCmap()
        missing = lambda s: "".join(dict.fromkeys(c for c in s if ord(c) not in cmap))
        print(label, Path(label + ".woff").stat().st_size, len(cmap),
              repr(missing(FIXED)), repr(missing(DYNAMIC)),repr(missing("최솔 999")))
print([f"U+{ord(c):04X}" for c in DYNAMIC if c!=" "])
Enter fullscreen mode Exit fullscreen mode

With ignore_missing_unicodes=False, the build rejects characters you requested but that the source does not contain. It cannot know which characters future users will enter. Reopen the generated font and test both known copy and an independent holdout. This experiment reads code point mappings; it did not benchmark browser loading, fallback metrics, layout, or WOFF2.

Including spaces, the heading has 11 code points in NFC and 23 in NFD. The build normalizes text to NFC; the coverage helper checks its input as supplied. If your app accepts decomposed input, test both forms separately. These counts do not predict browser rendering. The previous ZIP experiment shows why the same distinction matters for filenames.


04 · Use the tiny font where the text contract is closed

  • Fixed headings: Extract characters from the actual localized strings and rebuild when the wording changes.
  • Bounded numbers: Include all decimal digits and any grouping, decimal, negative or currency symbols the formatting code can emit.
  • Names, addresses and CMS copy: Do not make a small title subset the global default. Give these fields a Korean system font or a broader web-font strategy, then check representative and out-of-sample values on narrow layouts. Browser fallback may keep text legible while mixing typefaces within a word.

Before shipping, try a string you did not use to create the subset. It tells you where the design still holds, not just where yesterday’s fixture passed.

Sources: Noto CJK project · fontTools subset options · CSS font matching and fallback


AI was used to write this article and to prepare its illustrations.

Top comments (0)