roundtripping fontc-built Oswald's cmap table with ttx mysteriously halves its size
I'm still not sure why
$ git clone https://github.com/googlefonts/OswaldFont
$ cd OswaldFont
$ fontc -s sources/Oswald.glyphs
$ ttx -q -o - build/font.ttf | ttx -q -o build/font#1.ttf -
$ ls build/*.ttf
build/font#1.ttf build/font.ttf
$ diff -u <(ttx -q -o - -t cmap build/font.ttf) <(ttx -q -o - -t cmap build/font#1.ttf)
$ echo $?
0
So far no diffs in the high-level XML content after roundtripping through ttx, but if I compare the cmap table sizes before and after ttx, I get:
$ diff -u <(ttx -l build/font.ttf | grep cmap) <(ttx -l build/font#1.ttf | grep cmap)
tag checksum length offset
---- ---------- -------- --------
- cmap 0x8D57590D 6212 30844
+ cmap 0x90BB83AA 2392 4036
The fonttools generated cmap is less than half the size of the fontc/write-fonts generated one.. Why?
interesting, will take a look. :)
The fonttools generated cmap is less than half the size of the fontc/write-fonts generated one.. Why?
For beginners, table sharing?
Also see https://github.com/fonttools/fonttools/blob/main/Lib/fontTools/ttLib/tables/_c_m_a_p.py#L783
Also see https://github.com/fonttools/fonttools/blob/main/Lib/fontTools/ttLib/tables/_c_m_a_p.py#L783
I believe it's this. The number of segments is 772 in fontc-generated font, and 103 in fonttools.
The fonttools generated cmap is less than half the size of the fontc/write-fonts generated one.. Why?
For beginners, table sharing?
Ruled this out.
Also see https://github.com/fonttools/fonttools/blob/main/Lib/fontTools/ttLib/tables/_c_m_a_p.py#L783
I believe it's this. The number of segments is 772 in fontc-generated font, and 103 in fonttools.
And length of glyphIndexArray is 0 in fontc one, and 766 in fonttools. So, the fontc code is not using the glyphIndexArray mechanism at all.
So, the fontc code is not using the
glyphIndexArraymechanism at all.
https://github.com/googlefonts/fontations/blob/main/write-fonts/src/tables/cmap.rs#L56
Also see https://github.com/fonttools/fonttools/blob/main/Lib/fontTools/ttLib/tables/_c_m_a_p.py#L783
And more importantly: https://github.com/fonttools/fonttools/blob/0a3360e52727cdefce2e9b28286b074faf99033c/Lib/fontTools/ttLib/tables/_c_m_a_p.py#L994-L1010
thanks behdad for investigating this! Looks like @rsheeter already had opened an issue about this at the time it was first PR'ed, linking to the same fonttools code: https://github.com/googlefonts/fontations/issues/282