LingDong- / qiji-font

齊伋體 - typeface from Ming Dynasty woodblock printed books
https://qiji-font.netlify.com/
SIL Open Font License 1.1
1.32k stars 71 forks source link

Assign alternate unicode values for duplicate glyphs #9

Open kanou-h opened 4 years ago

kanou-h commented 4 years ago

Assigning multiple Unicode values to each unique glyph image will decrease the size of the font file.

Possibly lines 62-71 of forge_font.py can be rewritten as:

other = other - set(care.values()) if len(other) > 0: glyph.altuni = [ ord(o) for o in other ]

And I suggest the use of glyph.simplify() to remove redundant points from each glyph.

LingDong- commented 4 years ago

Thanks so much for the suggestion! I managed to reduce the size of qiji.ttf by 20% by assigning multiple unicode values to glyphs!

There is a 5% further improvement by using glyph.simplify(), but since it's hard to evaluate how much it modifies the shape I didn't want to risk it. I did add both optimizations to qiji-fallback.ttf, since they're randomly generated anyways.

The woff2 files didn't see much of a reduction though (5.2MB -> 5.1MB)

But still, pretty neat! Thanks for bringing this up. I've updated the releases, and committed 055a5dc1072138c37d70560dd17208f97bf18410