googlefonts / googlefonts/ufo2ft

skipExportGlyphs should be later in the pipeline

Open
#692 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
176
Forks
49
PR merge metrics
No merged PRs in 30d

Description

I suggest that `skipExportGlyphs` should be processed later in the pipeline, at least later than `flattenComponents` (which is already after `decomposeComponents`). The current implementation results in unnecessary font bloat.

Consider this common situation: an encoded composite glyph references a component glyph that is itself a composite. Here is a concrete example (with non-relevant detail omitted) from Arabic, but it happens in Latin and other scripts as well:
```









...

```
We have `_dot2h` used as a component (of `qaf-ar`) but is itself a composite glyph consisting of two references to `_dot1`.

GoogleFonts team requires this to be flattened, so we include the `flattenComponents` filter which will then flatten the `qaf-ar` glyph. The resulting glyph, if represented in UFO-speak, would be:
```





```

This was confirmed by building the TTF and dumping with ttx, which yields:
```





```

Now, of course, the `_dot2h` is no longer used — it is not encoded and all other composites referencing it would similarly have been flattened. As a result, fontBakery legitimately complains that the `_dot2h` glyph is unreachable.

It would be nice to now be able to utilize the `skipExportGlyphs` mechanism to remove the unreachable `_dot2h` from the resulting font and quiet the fontBakery warning.

**However**, since ufo2ft processes `skipExportGlyphs` _first_, and at this point `qaf-ar` still references `_dot2h`, adding `_dot2h` to `public.skipExportGlyphs` will cause the `qaf-ar` glyph to be [needlessly] fully decomposed into a contour glyph.

Multiplying this over all the glyphs in the font that get similarly decomposed results in a significant increase in the glyph table size. In the [Lateef project](https://github.com/silnrsi/font-lateef), adding just `_dot2h` to `public.skipExportGlyphs` increased the glyph table by 14 kb.

If the `skipExportGlyphs` process were run later in the pipeline, at least after `flattenComponents`, then it could have the desired effect of making the font smaller.

Contributor guide

No contributing guide indexed for this repository

Research direction

Trace the ufo2ft pipeline around skipExportGlyphs, decomposeComponents, and flattenComponents, then reproduce the Lateef-style composite-glyph case described in the issue. Build a TTF and inspect the resulting glyph table with ttx; done means skipExportGlyphs runs after flattenComponents without unnecessarily decomposing affected composites or leaving unreachable glyphs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.