Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fontbe/gvar] ensure axis_count == fvar.axis_count even for empty gvar #832

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion fontbe/src/gvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ 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 = axis_order.len() as u16;
let glyph_order = context.ir.glyph_order.get();

let variations: Vec<_> = make_variations(&glyph_order, |glyph_name| {
Expand All @@ -60,7 +61,17 @@ 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 mut gvar = Gvar::new(variations).map_err(Error::GvarError)?;
// if there are no glyph variations, the gvar.axis_count computed by write-fonts
// from these empty deltas is 0, but the spec requires it to be the same as
// fvar's axis_count, so we make sure this is the case.
// Technically, a gvar table is optional in a variable font, but some
// applications expect one to be present, so we always generate one even if
// empty, like fonttools does:
// https://github.com/googlefonts/fontc/issues/815#issuecomment-2127834077
if gvar.axis_count == 0 && axis_count > 0 {
gvar.axis_count = axis_count;
}

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