googlefonts / googlefonts/fontc
Optimize kerning tables by grouping by direction, then by script in subtables
- Dominant language
- Rust
- Stars
- 193
- Forks
- 21
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 65
Description
@anthrotype had an idea: Make a large lookup for LTR and RTL kerning and within them make subtables per script (or script agglomerates, if cross script kerning is present). This will hopefully result in compact tables with little waste, while making kerning just work in InDesign's default shaper and making `fonttools otlLib.optimize` redundant.
The current design of the kerning feature writer is based on ufo2ft's kerning writer, which tries to split the kerning data by script (or script agglomerates, if cross script kerning is present). Ideally, this leads to compact GPOS tables.
The old kerning writer often lead to bigger font file sizes by splitting just by direction instead, which on bigger fonts lead to overflowing tables full of zeroes and lots of time spent repacking them. @belluzj once wrote the GPOS compacter in fontTools to split the latter tables up and, depending on the font, markedly reduce file size. It works, but the whole process is slow. Internally, we revived the older kerning writer as https://github.com/googlefonts/ufo2ft/blob/main/Lib/ufo2ft/featureWriters/kernFeatureWriter2.py, because we stumbled over a problem with the default shaper in Adobe InDesign. If you don't have cross script kerning, splitting by script ensures that only kerning for the currently selected language in an InDesign document is applied (i.e. select "Greek" for a mixed text and suddenly the Latin kerning is not applied any more). This is worked around by splitting kerning by direction, so that InDesign can access all kerning for all scripts of that direction, regardless of which language is selected.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating fontc's kerning feature writer and compare its current table grouping with ufo2ft's featureWriters/kernFeatureWriter2.py, which the issue identifies as a reference. Verify the resulting GPOS tables on fonts with LTR, RTL, and cross-script kerning, checking that tables are compact and that InDesign's default shaper applies kerning across scripts without relying on a separate compaction step.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100