-
Notifications
You must be signed in to change notification settings - Fork 27
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
[skrifa] glyf: use gvar for advance delta when HVAR is missing #1312
Conversation
We were using gvar to compute deltas for left side-bearings but not for advance widths when the HVAR table is missing. Fixes #1311
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, tricky little one...
// Modify only LSB | ||
AvailableVarMetrics::MissingSideBearings => points.len() - 3, | ||
// Modify nothing | ||
AvailableVarMetrics::Present => points.len() - 4, |
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.
we know we've always got at least the four phantom points I suppose?
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.
yeah, we ensure at least 4 points at entry to the function:
if iup_buffer.len() < glyph.points.len() || glyph.points.len() < PHANTOM_POINT_COUNT { |
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.
Why isn't it written as len - PHANTOM_POINT_COUNT
?
MissingSideBearings, | ||
/// No variable metrics table. | ||
Missing, | ||
} |
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 I would expect these to be named for what is available not what isn't? - e.g. All, Advances, None as opposed to Present/MissingSide/Missing
} | ||
} | ||
None => AvailableVarMetrics::Missing, | ||
}; |
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.
IMHO this might still read better (closer to left-to-right top to bottom) as map? - something like glyph_metrics.hvar.map(|hvar| hvar.lsb_mapping.map(present).unwrap_or(missing sides)).unwrap_or(missing everything)
} | ||
AvailableVarMetrics::MissingSideBearings => { | ||
self.phantom[0].x += deltas[count - 4].x; | ||
} |
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.
Reading deltas at count - magic #
is recurring, I wonder if there is an opportunity to make a helper fn or newtype with a nicely named (and probably always inlined) accessor?
@rsheeter sure, will do a follow up with some of these changes |
Additional code cleanup suggested after merging #1312
Fixes issue with advance width computation for variable fonts that lack an HVAR table, for details see [1]. Updated crates: * skrifa: 0.26.3 => 0.26.4 * [email protected] vetted for does-not-implement-crypto, safe-to-deploy, ub-risk-0 [1] googlefonts/fontations#1312 Fixed: chromium:385924890 Change-Id: I294d3286071fbf25d416a3225489ec9618125f15 Cq-Include-Trybots: chromium/try:android-rust-arm32-rel Cq-Include-Trybots: chromium/try:android-rust-arm64-dbg Cq-Include-Trybots: chromium/try:android-rust-arm64-rel Cq-Include-Trybots: chromium/try:linux-rust-x64-dbg Cq-Include-Trybots: chromium/try:linux-rust-x64-rel Cq-Include-Trybots: chromium/try:win-rust-x64-dbg Cq-Include-Trybots: chromium/try:win-rust-x64-rel Disable-Rts: True Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6163787 Commit-Queue: Dominik Röttsches <[email protected]> Reviewed-by: Łukasz Anforowicz <[email protected]> Cr-Commit-Position: refs/heads/main@{#1404768}
We were using gvar to compute deltas for left side-bearings but not for advance widths when the HVAR table is missing.
This only affects the TrueType interpreter (for Skia's usage) and hinted VFs are rare so it took a while to catch this one.
Fixes #1311