googlefonts / fontations

Reading and writing font files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support big glyph ids (beyond 64k)

dfrg opened this issue · comments

in accordance with the spec proposal. I recommend we do this in a few phases to limit breakage:

  1. Rename font_types::GlyphId to GlyphId16 and update codegen and resource files accordingly. Add a pub type GlyphId = GlyphId16 to font-types which should make this transparent to dependencies.
  2. Update fontc projects and skrifa to use GlyphId16 explicitly.
  3. Remove the type alias and add a new GlyphId type backed by a u32 with appropriate conversions. Some of the utility methods in read-fonts should probably change to take impl Into<GlyphId>.
  4. Update fontc projects and skrifa to use the new GlyphId where appropriate. To avoid breaking Skia, we'll likely need to keep a truncating to_u16() method on GlyphId for a transitional period. Alternatively, we can add a to_u32() method on the current type now and push that change through (this might be the easier route).
  5. Add a new GlyphId24 type to support the actual table extensions.

@drott are there any complications I might be missing on the Skia side?

The GlyphId::to_u32() method is now published. @drott can you switch to this rather than to_u16()? That should allow us to make the remaining changes on our end without breaking Skia.

To be fully robust it looks like we’ll also need GlyphId as From<u16> (and replacing new() with from() in Skia). This surprisingly doesn’t already exist.

We can change new() to take impl Into<u32> but that will break when the argument is a bare integer literal and that seems undesirable.

I’ll add the From impl and ping this issue again when it’s released.

@drott this is go to go on our end now

commented

#943 is unable to process big glyph ids until we make progress here. Can we proceed or are we blocked?

Our currently released version is sufficient for transition so we should be okay to proceed as long as the required changes in Skia are made before bumping its dependencies.

For reference, these are the things that need updating:

GlyphId::new(x) -> GlyphId::from(x)

gid.to_u16() -> gid.to_u32(), probably replacing values > u16::MAX with 0 until Skia supports big glyph ids.