boring-expansion-spec icon indicating copy to clipboard operation
boring-expansion-spec copied to clipboard

[`GDEF` / `GSUB`/`GPOS`] Glyph Filtering

Open behdad opened this issue 4 years ago • 4 comments
trafficstars

EDIT: Changed my mind about the details. See updated proposal in comments.

Generalized glyph filtering in GSUB/GPOS based on work Martin Hosken and I proposed in 2016.

Original proposal: https://github.com/OpenType/opentype-layout/blob/63d169c92160832cf5b2333f28b559c80c9a4389/proposals/glyph_filtering.md

~~Details are fleshed out in:~~ https://github.com/OpenType/opentype-layout/issues/21

behdad avatar Sep 17 '21 02:09 behdad

To be done after LookupFlag extension https://github.com/be-fonts/boring-expansion-spec/issues/26.

Allocate two bits from LookupFlag extension (leave the existing OpenType free LookupFlags intact).

The two new bits will be:

  • UseGlyphSkipSet
  • UseGlyphStopSet

For each of those bits, if set, the Lookup structure will be followed by a uint16:

  • uint16 GlyphSkipSet
  • uint16 GlyphStopSet which are indices into GDEF's ~~MarkGlyphSets struct (which we might return to just GlyphSets)~~ UPDATE: (See https://github.com/be-fonts/boring-expansion-spec/issues/25) a new GlyphSets array-of-coverages struct.

The glyph filtering algorithm then will be this:

  • If UseGlyphStopSet is used and current glyph is in the referenced set, stop;
  • If UseGlyphSkipSet is used and current glyph is in the referenced set, skip;
  • Otherwise use the OpenType algorithm.

GDEF version major 1 minor 4 will have the following field follow itemVarStoreOffset:

  Offset24To<GlyphSets> glyphSets;

whereas

struct GlyphSetsFormat1 {
  uint8 format; == 1
  Array24Of<Offset24To<Coverage>> coverages;
};

behdad avatar Sep 17 '21 16:09 behdad

cc @mhosken @jfkthame

behdad avatar Sep 17 '21 16:09 behdad

Currently in GDEF we have a glyph class definition which takes a ClassDef structure but only assigns meaning to four values (base, lig, mark, component) which are special-cased the lookup flags. Allowing glyph classes >4 in the glyph class definition table would give you the ability to subdivide bases etc. into multiple classes for free.

simoncozens avatar Sep 17 '21 17:09 simoncozens

Allowing glyph classes >4 in the glyph class definition table would give you the ability to subdivide bases etc. into multiple classes for free.

That takes us in the wrong direction though...

Mark glyphs were divided so into classes. But it was found that we need overlapping sets. That's when MarkFilteringSets were added. So, dividing glyphs into more disjoint sets doesn't help, hence extending the MarkFilterintSets to all glyphs is the way to go.

behdad avatar Sep 17 '21 17:09 behdad