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

make sure masters for global/glyph/layout metrics are rounded before computing deltas #1082

Merged
merged 4 commits into from
Nov 1, 2024

Conversation

anthrotype
Copy link
Member

Fixes #1043

Cargo.toml Outdated Show resolved Hide resolved
// a VF at the masters' location is expected to be equivalent to building
// individual masters as static fonts. fontmake does the same, see
// https://github.com/googlefonts/fontc/issues/1043
let value: f32 = value.into_inner().ot_round();
Copy link
Contributor

Choose a reason for hiding this comment

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

should we ot_round to f64 and avoid f32 then f64? - I recall we need to add that to otround, maybe we should do that first?

Copy link
Member Author

@anthrotype anthrotype Nov 1, 2024

Choose a reason for hiding this comment

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

I already added OtRound<f64> for f64 and OtRound<f32> for f32 here:
googlefonts/fontations#1209 (unreleased yet, which is why this PR is fetching fontations from github)

Are you saying we should also add OtRound<f64> for f32? Then why not any other combinations of primitive number types? It feels to me a bit out of scope for a rounding trait that we are casting f32 as f64 because of some other API which works best with those.

Copy link
Contributor

@rsheeter rsheeter left a comment

Choose a reason for hiding this comment

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

LGTM if tested. Seems like there should be inputs with observably different results?

@anthrotype
Copy link
Member Author

anthrotype commented Nov 1, 2024

Seems like there should be inputs with observably different results?

yes, I mentioned Teachers-Italic.glyphs in #1043 (comment), which contains a composite with a scaled component that gets its anchors propagated as float coordinates and produces different deltas when these get rounded beforehand. I can add a subset of that one the fontc/lib.rs integration tests.
It's harder to find real world examples of masters where advance widths or kerning values or global font metrics contain floats, because designers normally use whole integer numbers. Of course I could make them up.

anthrotype added a commit that referenced this pull request Nov 1, 2024
the deltas for Teachers-Italic.glyphs' ordfeminine 'top' anchor are off-by-one because the anchor's master values are un-rounded floats.

#1082 will fix this and similar others.
@anthrotype
Copy link
Member Author

I made a test in a separate branch to show it failing on main: #1087
but I'll cherry pick it here anyway so I'll close that as soon CI fails

the deltas for Teachers-Italic.glyphs' ordfeminine 'top' anchor are off-by-one because the anchor's master values are un-rounded floats.

#1082 will fix this and similar others.
@anthrotype anthrotype added this pull request to the merge queue Nov 1, 2024
Merged via the queue into main with commit 810ec56 Nov 1, 2024
10 checks passed
@anthrotype anthrotype deleted the ot-round-everything branch November 1, 2024 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

master values should be ot-rounded *before* computing deltas in order to match fontmake
2 participants