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

[glyphs] Parse kerning as floats #1145

Merged
merged 1 commit into from
Nov 28, 2024
Merged

[glyphs] Parse kerning as floats #1145

merged 1 commit into from
Nov 28, 2024

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Nov 26, 2024

Glyphs kern values can be floats, but we were parsing them as integers.

This also uncovered something else fishy: our integer parsing logic in glyps-reader/ascii-plist-derive will happy parse something like "1.321" as an integer, by parsing to a float and casting.

I think this is incorrect? I think it is reasonable to go the other way (to accept an integer value as a float) and it might be reasonable to accept an integer value with no fractional component as a float, but I definitely don't think we should parse a float with a fractional value as an integer; it hides bugs like this.

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.

Good catch, lgtm

Glyphs kern values can be floats, but we were parsing them as integers.

This also uncovered something else fishy: our integer parsing logic in
glyps-reader/ascii-plist-derive will happy parse something like "1.321"
as an integer, by parsing to a float and casting.

I think this is incorrect? I think it is reasonable to go the other way
(to accept an integer value as a float) and it _might_ be reasonable to
accept an integer value with no fractional component as a float, but I
definitely don't think we should parse a float with a fractional value
as an integer; it hides bugs like this.
@cmyr cmyr force-pushed the glyphs-kern-floats branch from 9d3af31 to a99597e Compare November 28, 2024 23:27
@cmyr cmyr added this pull request to the merge queue Nov 28, 2024
Merged via the queue into main with commit ce8c851 Nov 28, 2024
10 checks passed
@cmyr cmyr deleted the glyphs-kern-floats branch November 28, 2024 23:35
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.

2 participants