-
Notifications
You must be signed in to change notification settings - Fork 67
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
Zero offsets in parse_at_offset16
#110
Comments
I would not assume anything in case of TrueType. As you correctly noted, not all offsets are allowed to be NULL and for now you have to check them manually. In other parts of the codebase I specifically use |
From the spec:
Adding a new |
Can you give a link to this doc? I'm not sure if it's talking about the specific table or all of them. Ok, my bad. I got confused with |
In the data types sections: https://learn.microsoft.com/en-us/typography/opentype/spec/otff |
harfbuzz has a clear separation between nullable and non-nullable offsets: link Sadly, I can't read CRTP, so I'm not sure how exactly they handle NULL for non-NULL. But we should do the same. Also, this is OpenType spec. Apple can do whatever they want with their fonts, aka AAT. |
I'm also not able to parse that with confidence. From these lines, it seems that Harfbuzz produces null-pointers for non-nullable offsets (maybe this is never reached due to sanitization) and empty nulled objects for nullable offsets (which are reached). This makes sense insofar as that the GlyphAssembly table, whose offset may be null, is accessed as if it was always present. But I also can't find code in the sanitization that does that. |
@behdad Hi! Sorry for bothering you, but maybe you could clarify how |
That's something else. That's used for a few places (mostly AAT tables and a couple of places in CFF) where a 0 offset is allowed. In other places we always use OffsetTo. Even when the spec says a NULL offset is disallowed, we always allow it, and return a null object. |
Ie. we never treat those as hard error. |
Thanks a lot! @laurmaedje I guess we can invert the default behavior then. And those methods are not used in AAT anyway, at least for now. |
To summarize:
Do you want to only change |
I would suggest to:
After updating everything, try running |
Okay, I tried that. 786 rustybuzz tests passed, but a single one failed. :(
I would have to take a closer look to see what's going on here as the assertion failure message isn't particularly helpful. PS: Math doesn't really work differently from the rest of OpenType and both could make use of the |
rustybuzz has about 1600 tests, I guess cargo stoped earlier. Anyway, as I've said before - there are no easy changes in TrueType. |
Can you publish your current changes so I could run them locally? |
Sure: https://github.com/laurmaedje/ttf-parser |
Ok, so in case of Specifically, in that font So instead of changing the old behavior, you could add a custom one just for |
The
parse_at_offset16
method currently does not check for NULL offsets, leading to bugs where 0 indicates the absence of a subtable. (I experienced the bug in the math table.) Not all OpenType offsets allow 0, but I don't think 0 is ever a valid offset, so I assume it should be fine to just always returnNone
for zero offsets inparse_at_offset16
. If you agree, I can send a PR with fix.The text was updated successfully, but these errors were encountered: