-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix integer types for font metrics in PyGlyph class #7781
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
Conversation
The PyGlyph class defined in the freetype wrapper code pulls in some font metric values from freetype when initialized. All these values have type FT_Pos in freetype, which is a signed long, but in the PyMemberDef structure used to store those values in the Python class, their types were set to T_INT - signed int. We should set them to T_LONG instead. This fixes several hundred test suite errors on big-endian arches.
@mdboom (original author) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're not even an abstract FT_Pos
; the PyGlyph
struct defines them as long
directly!
Oh, I was just going by the API reference, which says FT_Pos: https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Glyph_Metrics |
It appears that |
Yes, but the lines you've changed are about |
sounds plausible! could account for some of the remaining errors. I was gonna take a look at 'em tomorrow. |
well, I think if I'm following the code right, we're dealing with
...which means it returns an Did I get anything wrong? :) edit: ahhh, but I see what you mean: up in the |
This is correct, but you've gone just a bit too deep. Assigning anything to the members of The problem is solely within the I think I may have found a couple more incorrect pointer types; if you don't mind, I can push them to this PR directly. |
I have a branch with several more myself: how does that compare to yours? |
Oh, you've got a pretty good head start there; I'll leave you to it. |
That's all the ones I saw, I think. I guess I'll send that as a separate PR, and you can add any others you've spotted to it... |
Current coverage is 62.12% (diff: 100%)@@ master #7781 diff @@
==========================================
Files 174 174
Lines 56028 56028
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
Hits 34805 34805
Misses 21223 21223
Partials 0 0
|
On the topic of when this was broken, similarly to #7791 , this was changed in ba40160 , "Remove use of PyCXX in core C++ extensions", which has been around since (I think) 1.5.0. Again, I can't say for 100% sure if the old code worked, but it was different, and I think more likely to have worked:
|
👍 |
Backported to v2.x as 50237bd |
Fix integer types for font metrics in PyGlyph class
The PyGlyph class defined in the freetype wrapper code pulls
in some font metric values from freetype when initialized. All
these values have type FT_Pos in freetype, which is a signed
long, but in the PyMemberDef structure used to store those
values in the Python class, their types were set to T_INT -
signed int. We should set them to T_LONG instead. This fixes
several hundred test suite errors on big-endian arches.