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

piecewise_linear_map: perform internal computations as f64 to increase precision #1120

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

anthrotype
Copy link
Member

@anthrotype anthrotype commented Nov 15, 2024

but keep the outward interface as f32 to limit the scope of changes (otherwise callers would have to deal with f64s and there are a lot)

This seems to fix #1117 in the sense that ttx_diff.py now reports Grenze-Gotisch as "output is identical".

Basically, the loss of precision happened while converting glyphs sources to ir: the instance locations are in design-space in the source; we store them as normalized location

design_location(&axes, &m.axes_values).to_normalized(&axes_by_name),

... but then in the ir::NamedInstance they are in user-space (like in fvar) so they must be converted again to_user:

Some(NamedInstance {
name: inst.name.clone(),
location: font_info
.locations
.get(&inst.axes_values)
.map(|nc| nc.to_user(&axis_map))
.unwrap(),
})

In this particular font, design- and user-space location are the same (there are no axis mappings). The instance at wght=200 (design) is converted to 0.666667 (normalized) and then again to 200 (user). If the lerp is done with f32 we lose precision and instead of 200 we get back 200.00002

I'm not entierly sure this is the best fix but it does seem to improve the situation at least.

@anthrotype
Copy link
Member Author

no idea why I keep getting "bad credentials" while fetching GS
https://github.com/googlefonts/fontc/actions/runs/11856151327/job/33042031132?pr=1120

Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

This seems like a reasonable way to handle this, thanks for taking the ticket. 🏆

@anthrotype anthrotype added this pull request to the merge queue Nov 15, 2024
Merged via the queue into main with commit cc4852f Nov 15, 2024
9 of 10 checks passed
@anthrotype anthrotype deleted the pwlm-f64 branch November 15, 2024 16:56
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.

Rounding differences in fvar
2 participants