Demand side: collapsing a self written text into a code point checklist
The trigger was small. I had a piece of filler text on hand for trying out font weights, and I wanted to know how many distinct characters it really uses. Counting by eye is not reliable, so the plan was to collapse the repeated lines first and then expand every surviving line into its code points. Every reconciliation later in this article starts from that one "must be covered" code point checklist. The corpus is 19 segments of self written DEMO text: the words are invented, and no real names or events appear anywhere in it.
Collapsing the checklist runs through text sorting and deduplication: this corpus comes out as 12 lines after deduplication, and those lines expand into 60 code points. Since the page had to be opened anyway, all four modes were measured against the 6 line sample the page ships by default (apple / banana / apple / cherry / banana / date).
| Mode | Lines kept | Three statistics | Output |
|---|---|---|---|
| first | 4 | 6 / 4 / 2 | keeps the first occurrence, original order |
| last | 4 | 6 / 4 / 2 | keeps the position of the last occurrence |
| dup | 2 | 6 / 2 / 2 | prints only the repeated keys |
| unique | 2 | 6 / 2 / 4 | cherry, date |
Line conservation adds up in all four modes, and unique is the one that is easy to misread. The output really is the 2 lines cherry and date, which matches the wording "show only unique items"; but the third figure in the statistics area is computed as totalLines minus result.length, so what it means is "lines that were not unique", not "lines deleted". Swapping samples makes that obvious. Feed in the fully duplicated a / a / b / b / c / c and the third figure reads 6. Feed in the six line set where only apple repeats and it comes back to 2. Feed in the four line sample apple / banana / apple / cherry, 2 lines survive, and the third figure is 2 again.
Two switches also decide how wide the checklist ends up. With case sensitivity turned off, Apple, apple and APPLE merge into a single line and the first spelling is kept, while fullwidth digits stay separate from halfwidth ones. With blank line removal turned off, the 19 segments are counted as 19 lines and the empty lines pass straight into the output. A line that ends in a carriage return and the same line without one are treated as two different rows in a mixed ending sample.
Supply side: reconciling the checklist with the TTF binary
With the checklist in hand, the next question is whether a font package really holds those points. That needs no installation and no rendering: walk the sfnt table directory and read cmap and maxp. The cmap subtables decide whether a code point can be looked up at all, numGlyphs in maxp says how large the whole glyph set is, and a code point counts as covered only when it resolves to a non-zero glyph id.
Starting with the local copy of LXGW WenKai GB, whose six weights were parsed one TTF at a time, the result is clean. The cmap unions of the WenKai family and the Mono family are 46,926 and 46,946 code points. The format4 subtable of the WenKai family reaches only 43,493, and it is the format12 subtable that fills the rest of the way to 46,926, so reading format4 alone loses several thousand code points. The 20 points the Mono family carries extra all sit in the private use area (the U+E0A0 kind), and the two-way difference measures 20 and 0: not one code point of the WenKai family is absent from the other side. numGlyphs drifts between 47,276 and 47,299, and Light and Regular cover exactly the same ground, so the difference between weights is not about coverage.
Figure 1: the same 60 code point checklist landing on the cmap unions of two fonts; 59 plus 1 and 12 plus 48 both close back to 60.
The other side: 1,363 code points for a coding font
The same reading applied to the three TTF files of JetBrains Mono gives one cmap union of 1,363 code points shared by Regular, NL-Regular and the variable build, while numGlyphs is 1,743 for the static Regular and 1,590 for the NL cut. Put into the same table the contrast is blunt: the CJK Basic Block, U+4E00 through U+9FFF, holds 20,992 code points and its coverage reads 0, so the Han range is absent as a whole. That is why the 60 point checklist lands on only 12 of them and misses 48, and the missing examples include U+2103, U+3000 and U+3007, three points that look unremarkable and were in fact never drawn.
Block ledger: fully covered ranges and one huge gap
Scanning block by block tells you more than a single total. WenKai GB covers the CJK Basic Block at 20,992 and Extension A at 6,592 completely, with a gap of 0. Extension B, U+20000 through U+2A6DF, contains 42,720 code points, of which 1,970 are covered and 40,750 are not. The CJK Symbols block of 64 points misses four of them, namely U+302E, U+302F, U+3031 and U+3032. These figures come from enumerating every code point in each Unicode block rather than from sampling; the layer of an official common character table was not measured this round, because there is no source file for it on this machine.
Figure 2: coverage across four blocks, with bar length scaled by the code point count of each block and labels carrying measured values.
The packages themselves: file counts and bytes
The byte figures below are totals measured item by item inside the unpacked directories; the unpacked size displayed on the resource page is not used.
| Package | Files | Unpacked total (bytes) | Breakdown | RAR (bytes) |
|---|---|---|---|---|
| WenKai GB | 7 | 159,967,277 | 6 TTF files totalling 159,962,104; OFL.txt 5,173 | 64,347,457 |
| JetBrains Mono | 52 | 9,934,133 | 34 TTF files (32 static plus 2 variable) totalling 8,409,240; 16 WOFF2 files totalling 1,520,144; AUTHORS.txt 350 and OFL.txt 4,399 | 5,130,746 |
For the WenKai package the compressed to unpacked ratio is 0.402. On permissions this article records exactly one fact: each of the two packages does ship an OFL.txt, 5,173 bytes and 4,399 bytes, and the Mono package adds an AUTHORS.txt of 350 bytes. Whether the file is there and how large it is can be measured; what the text of such a file says and how the fonts may be used falls outside the scope of this article.
Boundaries people tend to ask about
Q: is the one missing code point on the checklist a Chinese character?
Not at all. The only point missed by all six weights is U+1F600: it is on the checklist, but no weight has a cmap entry pointing at it. The Chinese characters are covered without exception, and the gaps sit on symbols and on code point boundaries.
Q: why does the third figure under unique deserve a second look?
It is computed as totalLines minus result.length, so what it prints is the number of non-unique lines. With the default sample, 2 lines survive and the third figure reads 4, which looks like 4 deletions; in reality it counts the lines excluded from the unique set. The output itself is unaffected, only the reading should not be taken literally.
Q: what about WOFF2 and behaviour in the browser?
This round parsed only cmap and maxp of the TTF files. WOFF2 was not unpacked and missing glyph fallback was never exercised in a browser, so for those 16 WOFF2 files the only thing on record is the byte total 1,520,144; nothing about their coverage is concluded here.
The payoff of going around this loop is practical. The next time you need to decide whether one font library can carry a given text, run that text through this page to compress it into a code point checklist, read the cmap and reconcile the two, and coverage plus gap will be integers that add up. The gap of 40,750 in Extension B is worth remembering as well: the more rare characters a text uses, the earlier that ledger has to be drawn up.