Skip to content

Commit

Permalink
[fontbe] pass explicit axis_count when constructing Gvar
Browse files Browse the repository at this point in the history
Fixes #815

Untested as it requires googlefonts/fontations#919 (and write-fonts dependency bump) to work...
  • Loading branch information
anthrotype committed May 29, 2024
1 parent a347ee5 commit 39af089
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fontbe/src/gvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ impl Work<Context, AnyWorkId, Error> for GvarWork {
// We built the gvar fragments alongside glyphs, now we need to glue them together into a gvar table
let static_metadata = context.ir.static_metadata.get();
let axis_order: Vec<_> = static_metadata.axes.iter().map(|a| a.tag).collect();
let axis_count: u16 = axis_order
.len()
.try_into()
// in the unlikely event that we have more than 65535 axes...
.map_err(|_| Error::OutOfBounds {
what: "axis count".into(),
value: axis_order.len().to_string(),
})?;
let glyph_order = context.ir.glyph_order.get();

let variations: Vec<_> = make_variations(&glyph_order, |glyph_name| {
Expand All @@ -60,7 +68,7 @@ impl Work<Context, AnyWorkId, Error> for GvarWork {
.get(&WorkId::GvarFragment(glyph_name.clone()).into())
.to_deltas(&axis_order)
});
let gvar = Gvar::new(variations).map_err(Error::GvarError)?;
let gvar = Gvar::new(variations, axis_count).map_err(Error::GvarError)?;

let raw_gvar = dump_table(&gvar)
.map_err(|e| Error::DumpTableError {
Expand Down

0 comments on commit 39af089

Please sign in to comment.