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:
- Rename
font_types::GlyphId
toGlyphId16
and update codegen and resource files accordingly. Add apub type GlyphId = GlyphId16
tofont-types
which should make this transparent to dependencies. - Update
fontc
projects andskrifa
to useGlyphId16
explicitly. - Remove the type alias and add a new
GlyphId
type backed by au32
with appropriate conversions. Some of the utility methods inread-fonts
should probably change to takeimpl Into<GlyphId>
. - Update
fontc
projects andskrifa
to use the newGlyphId
where appropriate. To avoid breaking Skia, we'll likely need to keep a truncatingto_u16()
method onGlyphId
for a transitional period. Alternatively, we can add ato_u32()
method on the current type now and push that change through (this might be the easier route). - 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
#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.