Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
TYP: Make glyph indices distinct from character codes#30143
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Also, check some expected conditions at parse time instead of somewhereduring use of the data.
Previously, these were both typed as `int`, which means you could mixand match them erroneously. While the character code can't be made adistinct type (because it's used for `chr`/`ord`), typing glyph indicesas a distinct type means these can't be fully swapped.Unfortunately, you can still go back to the base type, so glyph indicesstill work as character codes. But this is still sufficient to catcherrors such as the wrong call to `FT2Font.get_kerning` in`_mathtext.py`.
Note, fixing this would require updating 20 images (for very minimal changes), which I originally rolled into#29816, but it could be moved here. |
The `FontInfo.num` value returned by `TruetypeFonts._get_info` is acharacter code, but `FT2Font.get_kerning` takes *glyph indices*, meaningthat kerning was likely off in most cases.
Since#29816 is nowjust the FreeType change, I've moved the kerning correction here. |
PR summary
Previously, these were both typed as
int
, which means you could mix and match them erroneously. While the character code can't be made a distinct type (because it's used forchr
/ord
), typing glyph indices as a distinct type means these can't be fully swapped.Unfortunately, you can still go back to the base type, so glyph indices still work as character codes. But this is still sufficient to catch errors such as the wrong call to
FT2Font.get_kerning
in_mathtext.py
.This depends on#30134.
PR checklist