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] pass explicit axis_count when constructing Gvar #833

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ rayon = "1.6"
icu_properties = "1.4"

# fontations etc
write-fonts = { version = "0.25.0", features = ["serde", "read"] }
skrifa = "0.17.0"
write-fonts = { version = "0.27.0", features = ["serde", "read"] }
skrifa = "0.19.3"
norad = "0.12"

# dev dependencies
Expand Down
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(),
})?;
Comment on lines +58 to +62
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally unwrap here, since I can't imagine this being possible for any conceivable font, but 🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wait a few years :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly prefer Result unless it can't happen. Rationale: if we unwrap all the things that shouldn't happen but plausibly can then it's all but assured we'll hit some of them in production and rue the day we didn't use Result.

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
Loading