Commit 61f256b
committed
Fix some more integer type inconsistencies in Freetype code
This straightens up some more inconsistencies in the integer
types in ft2font_wrapper.cpp and ft2font.cpp. Referring to the
Freetype 2 API guide:
https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html
1) FT_Get_Kerning's integer arguments are FT_UInt (unsigned int)
but we were passing it signed ints.
2) FT_Load_Glyph's flags argument is an FT_Int32 (signed int...
usually, see footnote) but our set_text and load_glyph were
using FT_UInt32, and converting Python values to unsigned int.
3) FT_Load_Char's flags argument is an FT_Int32 (signed int...
usually, see footnote) but our load_char was using FT_UInt32,
and converting Python values to unsigned int.
4) load_char in ft2font_wrapper declared charcode as a signed
long (and load_char in ft2font does indeed expect a signed long
from the wrapper, though it then turns it into an unsigned
long, I don't know why this is set up that way), but was
converting the Python value to an unsigned long (k) not a
signed long (l).
5) get_glyph_name in ft2font_wrapper declared glyph_number as
unsigned int, and indeed ft2font is expecting an unsigned int
(Freetype is expecting an FT_UInt, which is the same thing),
but it was converting the Python value to a signed int (i)
not an unsigned int (I).
Footnote: the FT_Int32 and FT_UInt32 types that we have to use
for some values are defined as being the signed and unsigned
variants of whichever integer type is *exactly* 32 bits in
size. Freetype defines them as int if it's 32 bits, otherwise
long if *that's* 32 bits, otherwise it gives up and errors out.
However, we simply assume they're always ints, which isn't
technically correct. We could probably fix this with a bit of
`sizeof()` use, but I'm not sure if we want to bother, because
it's almost certainly the case that the int types are 32 bits
in size on all platforms matplotlib is targeting - if there are
still any significant platforms where int is 16 bits and so these
wind up as long, I'd be surprised. I thought it was worth noting,
though.1 parent 109251f commit 61f256b
3 files changed
Lines changed: 27 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
574 | 574 | | |
575 | 575 | | |
576 | 576 | | |
577 | | - | |
| 577 | + | |
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| |||
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
592 | | - | |
| 592 | + | |
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
| |||
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
669 | | - | |
| 669 | + | |
670 | 670 | | |
671 | 671 | | |
672 | 672 | | |
| |||
684 | 684 | | |
685 | 685 | | |
686 | 686 | | |
687 | | - | |
| 687 | + | |
688 | 688 | | |
689 | 689 | | |
690 | 690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
624 | | - | |
| 624 | + | |
| 625 | + | |
625 | 626 | | |
626 | | - | |
| 627 | + | |
627 | 628 | | |
628 | 629 | | |
629 | 630 | | |
| |||
643 | 644 | | |
644 | 645 | | |
645 | 646 | | |
646 | | - | |
| 647 | + | |
647 | 648 | | |
648 | 649 | | |
649 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
650 | 654 | | |
651 | | - | |
| 655 | + | |
652 | 656 | | |
653 | 657 | | |
654 | 658 | | |
| |||
712 | 716 | | |
713 | 717 | | |
714 | 718 | | |
715 | | - | |
| 719 | + | |
716 | 720 | | |
717 | 721 | | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
718 | 725 | | |
719 | | - | |
| 726 | + | |
720 | 727 | | |
721 | 728 | | |
722 | 729 | | |
| |||
747 | 754 | | |
748 | 755 | | |
749 | 756 | | |
750 | | - | |
| 757 | + | |
751 | 758 | | |
752 | 759 | | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
753 | 763 | | |
754 | | - | |
| 764 | + | |
755 | 765 | | |
756 | 766 | | |
757 | 767 | | |
| |||
901 | 911 | | |
902 | 912 | | |
903 | 913 | | |
904 | | - | |
| 914 | + | |
905 | 915 | | |
906 | 916 | | |
907 | 917 | | |
| |||
0 commit comments