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

Glyph serialization: Error out if any floats are infinite, subnormal, or NaN #198

Open
madig opened this issue Nov 9, 2021 · 4 comments

Comments

@madig
Copy link
Collaborator

madig commented Nov 9, 2021

Norad will currently write out floats like NaN. I am not sure this is a good idea? The spec does not mention it but the definition seems to imply that we don't want float corner cases. ot sure we should error out or instead make their construction impossible with newtypes or something?

@cmyr
Copy link
Member

cmyr commented Nov 10, 2021

I guess the main question is when should we be validating this? I suppose write-time is as good as any?

We could validate any glyph that is added to the font, and we can validate when we load a glyph, but validating every mutation would be annoying.

ctrlcctrlv added a commit to MFEK/glifparser.rlib that referenced this issue Dec 19, 2021
Cf. MFEK/stroke#21 (rationale, we'd catch `NaN` bugs earlier if we
refused to write at all)
Cf. linebender/norad#198 (similar problem in a competing/featurewise
inferior library)
@ctrlcctrlv
Copy link
Contributor

Added to glifparser.rlib recently due to MFEK/stroke#21 and related issues; NaN's shouldn't be getting written into end-user files, if it's stable enough I plan to make it a regular assert! and not a debug_assert! but we'll see:

MFEK/glifparser.rlib@e25bfa0

@madig
Copy link
Collaborator Author

madig commented Mar 9, 2022

In the spec now: unified-font-object/ufo-spec#202

@madig
Copy link
Collaborator Author

madig commented Aug 8, 2023

I stumbled over https://docs.rs/ordered-float/latest/ordered_float/struct.NotNan.html. Maybe a restrictive newtype that forbids all the weirdness could help us here, one day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants