-
Notifications
You must be signed in to change notification settings - Fork 13
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/avar] don't skip no-op segment maps #586
Conversation
GS contains a GRAD axis whose avar segment maps does not have any interesting mappings. It happens to be the last one in the axis order. We were filtering out axis segment maps that contain only identity maps, leading to an avar table with fewer segment maps than there are fvar axes, which is invalid as OTS correctly points out. So we now still emit these when bulding avar and there's at least one segment map that is not an identity map. Note that, despite the OT spec allows for empty segment maps for axis that don't distort the default normalization, we want to match fontmake/fonttools and emit the required {-1:1, 0:0, 1:1} mappings even when no other interesting mappings are present for an axis. Fixes #582 avar axis mismatch OTS error after this GS avar table is the same when built with fontc vs fontmake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I appreciate all the explanation inline.
fontbe/src/avar.rs
Outdated
/// Return true if the SegmentMaps is not a boring identity map | ||
fn is_interesting(segment_map: &SegmentMaps) -> bool { | ||
segment_map | ||
.axis_value_maps | ||
.iter() | ||
.any(|av| av.from_coordinate != av.to_coordinate) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense as a method on the SegmentMaps
type in write-fonts? I'd probably flip the logic and call it is_identity
.
One option would be to add the method there, merge this as-is, and open an issue to fix this when we next publish write-fonts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 making the method is_identity
} | ||
|
||
/// Return a default avar SegmentMaps containing the required {-1:-1, 0:0, 1:1} maps | ||
fn default_segment_map() -> SegmentMaps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this feels like it should probably be the impl of Default
for SegmentMaps
; however we currently autogenerate Default
impls for all write types, and there's no mechanism to override this, so this is probably fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Vigorous +1, it's helpful to us now and incredibly helpful to future editors |
we shall use the SegmentMaps instance method once that is added to write-fonts also, use then() instead of then_some() so it's lazily eval
as proposed in googlefonts/fontc#586 to be used when building avar table in fontc
as proposed in googlefonts/fontc#586 to be used when building avar table in fontc
GS contains a
GRAD
axis whose avar segment maps does not have any interesting mappings.It happens to be the last one in the axis order. We were filtering out axis segment maps that contain only identity maps, leading to an avar table with fewer segment maps than there are fvar axes, which is invalid as OTS correctly points out.
So we now still emit these non-interesting segment maps when bulding avar and there's at least one of them that is not an identity map.
Also note that, despite the OT spec allows for empty segment maps for axis that don't distort the default normalization, we want to match fontmake/fonttools and emit the required {-1:1, 0:0, 1:1} mappings even when no other interesting mappings are present for an axis, because apparently some old implementations need that (see fonttools/fonttools#1026).
Fixes #582 avar axis mismatch OTS error
I can confirm that after this, the GS avar table is the same when built with fontc vs fontmake.