Skip to content

Commit 68d5e75

Browse files
committed
Fix compiler warnings
1 parent ecc66f4 commit 68d5e75

7 files changed

+147
-127
lines changed

src/bitmap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Py_Bitmap_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
110110

111111

112112
static int
113-
Py_Bitmap_init()
113+
Py_Bitmap_init(void)
114114
{
115115
PyErr_SetString(
116116
PyExc_RuntimeError,

src/freetypy.c

+2-12
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,11 @@ FT_Library get_ft_library()
6666
return ft_library;
6767
}
6868

69-
7069
static PyMethodDef module_methods[] = {
7170
{NULL} /* Sentinel */
7271
};
7372

7473

75-
struct freetypy_module_state {
76-
int dummy;
77-
};
78-
7974
/* TODO: Hide all exported symbols in the shared library except this one */
8075

8176
#if PY3K
@@ -85,18 +80,16 @@ struct freetypy_module_state {
8580
FT_Done_FreeType(ft_library);
8681
}
8782

88-
#define GET_MODULE_STATE(m) ((struct freetypy_module_state*)PyModule_GetState((m)))
89-
9083
static struct PyModuleDef moduledef = {
9184
PyModuleDef_HEAD_INIT,
9285
"_freetypy",
9386
NULL,
94-
sizeof(struct freetypy_module_state),
87+
0,
9588
module_methods,
9689
NULL,
9790
NULL,
9891
NULL,
99-
freetypy_module_dealloc
92+
(freefunc)freetypy_module_dealloc
10093
};
10194

10295
#define INITERROR return NULL
@@ -106,9 +99,6 @@ struct freetypy_module_state {
10699
#else
107100
#define INITERROR return
108101

109-
#define GET_MODULE_STATE(m) (&_state)
110-
static struct freetypy_module_state _state;
111-
112102
PyMODINIT_FUNC
113103
init_freetypy(void)
114104
#endif

src/freetypy.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ either expressed or implied, of the FreeBSD Project.
4747
#include FT_FREETYPE_H
4848

4949

50-
FT_Library get_ft_library();
50+
FT_Library get_ft_library(void);
5151

5252

5353
#include "freetypy_error.h"

src/freetypy_error.c

+131-109
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,16 @@ typedef struct
3838
} error_def;
3939

4040

41-
static error_def errors[83];
42-
static const unsigned int nerrors = 83;
43-
44-
45-
static int error_finder(const void *key, const void *member)
46-
{
47-
FT_Error err = *((FT_Error *)key);
48-
error_def *entry = (error_def *)member;
49-
50-
if (entry->code == err) {
51-
return 0;
52-
} else if (entry->code < err) {
53-
return 1;
54-
} else {
55-
return -1;
56-
}
57-
}
41+
static error_def errors[256];
5842

5943

6044
int ftpy_exc(FT_Error error)
6145
{
6246
error_def *entry;
6347

6448
if (error) {
65-
entry = (error_def *)bsearch(
66-
&error, errors, nerrors, sizeof(error_def), error_finder);
67-
if (entry == NULL) {
49+
entry = &errors[error];
50+
if (entry->code == 0) {
6851
PyErr_Format(
6952
PyExc_RuntimeError, "unknown freetype exception %x", error);
7053
return 1;
@@ -77,95 +60,134 @@ int ftpy_exc(FT_Error error)
7760
return 0;
7861
}
7962

80-
#define DEF_ERROR(c, m, x) \
81-
errors[i].code = c; errors[i].msg = m; errors[i].cls = x; ++i;
82-
83-
int setup_errors() {
84-
unsigned int i = 0;
85-
86-
DEF_ERROR(0x00, "no error", PyExc_Exception);
87-
DEF_ERROR(0x01, "cannot open resource", PyExc_IOError);
88-
DEF_ERROR(0x02, "unknown file format", PyExc_ValueError);
89-
DEF_ERROR(0x03, "broken file", PyExc_IOError);
90-
DEF_ERROR(0x04, "invalid FreeType version", PyExc_RuntimeError);
91-
DEF_ERROR(0x05, "module version is too low", PyExc_RuntimeError);
92-
DEF_ERROR(0x06, "invalid argument", PyExc_ValueError);
93-
DEF_ERROR(0x07, "unimplemented feature", PyExc_NotImplementedError);
94-
DEF_ERROR(0x08, "broken table", PyExc_ValueError);
95-
DEF_ERROR(0x09, "broken offset within table", PyExc_ValueError);
96-
DEF_ERROR(0x10, "invalid glyph index", PyExc_IndexError);
97-
DEF_ERROR(0x11, "invalid character code", PyExc_ValueError);
98-
DEF_ERROR(0x12, "unsupported glyph image format", PyExc_ValueError);
99-
DEF_ERROR(0x13, "cannot render this glyph format", PyExc_NotImplementedError);
100-
DEF_ERROR(0x14, "invalid outline", PyExc_ValueError);
101-
DEF_ERROR(0x15, "invalid composite glyph", PyExc_ValueError);
102-
DEF_ERROR(0x16, "too many hints", PyExc_ValueError);
103-
DEF_ERROR(0x17, "invalid pixel size", PyExc_ValueError);
104-
DEF_ERROR(0x20, "invalid object handle", PyExc_ValueError);
105-
DEF_ERROR(0x21, "invalid library handle", PyExc_ValueError);
106-
DEF_ERROR(0x22, "invalid module handle", PyExc_ValueError);
107-
DEF_ERROR(0x23, "invalid face handle", PyExc_ValueError);
108-
DEF_ERROR(0x24, "invalid size handle", PyExc_ValueError);
109-
DEF_ERROR(0x25, "invalid glyph slot handle", PyExc_ValueError);
110-
DEF_ERROR(0x26, "invalid charmap handle", PyExc_ValueError);
111-
DEF_ERROR(0x27, "invalid cache manager handle", PyExc_ValueError);
112-
DEF_ERROR(0x28, "invalid stream handle", PyExc_ValueError);
113-
DEF_ERROR(0x30, "too many modules", PyExc_MemoryError);
114-
DEF_ERROR(0x31, "too many extensions", PyExc_MemoryError);
115-
DEF_ERROR(0x40, "out of memory", PyExc_MemoryError);
116-
DEF_ERROR(0x41, "unlisted object", PyExc_KeyError);
117-
DEF_ERROR(0x51, "cannot open stream", PyExc_IOError);
118-
DEF_ERROR(0x52, "invalid stream seek", PyExc_IOError);
119-
DEF_ERROR(0x53, "invalid stream skip", PyExc_IOError);
120-
DEF_ERROR(0x54, "invalid stream read", PyExc_IOError);
121-
DEF_ERROR(0x55, "invalid stream operation", PyExc_IOError);
122-
DEF_ERROR(0x56, "invalid frame operation", PyExc_IOError);
123-
DEF_ERROR(0x57, "nested frame access", PyExc_IOError);
124-
DEF_ERROR(0x58, "invalid frame read", PyExc_IOError);
125-
DEF_ERROR(0x60, "raster uninitialized", PyExc_ValueError);
126-
DEF_ERROR(0x61, "raster corrupted", PyExc_ValueError);
127-
DEF_ERROR(0x62, "raster overflow", PyExc_OverflowError);
128-
DEF_ERROR(0x63, "negative height while rastering", PyExc_ValueError);
129-
DEF_ERROR(0x70, "too many registered caches", PyExc_MemoryError);
130-
DEF_ERROR(0x80, "invalid opcode", PyExc_ValueError);
131-
DEF_ERROR(0x81, "too few arguments", PyExc_TypeError);
132-
DEF_ERROR(0x82, "stack overflow", PyExc_RuntimeError);
133-
DEF_ERROR(0x83, "code overflow", PyExc_OverflowError);
134-
DEF_ERROR(0x84, "bad argument", PyExc_TypeError);
135-
DEF_ERROR(0x85, "division by zero", PyExc_ZeroDivisionError);
136-
DEF_ERROR(0x86, "invalid reference", PyExc_ValueError);
137-
DEF_ERROR(0x87, "found debug opcode", PyExc_SyntaxError);
138-
DEF_ERROR(0x88, "found ENDF opcode in execution stream", PyExc_SyntaxError);
139-
DEF_ERROR(0x89, "nested DEFS", PyExc_SyntaxError);
140-
DEF_ERROR(0x8A, "invalid code range", PyExc_ValueError);
141-
DEF_ERROR(0x8B, "execution context too long", PyExc_RuntimeError);
142-
DEF_ERROR(0x8C, "too many function definitions", PyExc_MemoryError);
143-
DEF_ERROR(0x8D, "too many instruction definitions", PyExc_MemoryError);
144-
DEF_ERROR(0x8E, "SFNT font table missing", PyExc_AttributeError);
145-
DEF_ERROR(0x8F, "horizontal header (hhea) table missing", PyExc_AttributeError);
146-
DEF_ERROR(0x90, "locations (loca) table missing", PyExc_AttributeError);
147-
DEF_ERROR(0x91, "name table missing", PyExc_AttributeError);
148-
DEF_ERROR(0x92, "character map (cmap) table missing", PyExc_AttributeError);
149-
DEF_ERROR(0x93, "horizontal metrics (hmtx) table missing", PyExc_AttributeError);
150-
DEF_ERROR(0x94, "PostScript (post) table missing", PyExc_AttributeError);
151-
DEF_ERROR(0x95, "invalid horizontal metrics", PyExc_ValueError);
152-
DEF_ERROR(0x96, "invalid character map (cmap) format", PyExc_ValueError);
153-
DEF_ERROR(0x97, "invalid ppem value", PyExc_ValueError);
154-
DEF_ERROR(0x98, "invalid vertical metrics", PyExc_ValueError);
155-
DEF_ERROR(0x99, "could not find context", PyExc_AttributeError);
156-
DEF_ERROR(0x9A, "invalid PostScript (post, table format", PyExc_ValueError);
157-
DEF_ERROR(0x9B, "invalid PostScript (post, table", PyExc_ValueError);
158-
DEF_ERROR(0xA0, "opcode syntax error", PyExc_SyntaxError);
159-
DEF_ERROR(0xA1, "argument stack underflow", PyExc_RuntimeError);
160-
DEF_ERROR(0xA2, "ignore", PyExc_Exception);
161-
DEF_ERROR(0xB0, "`STARTFONT` field missing", PyExc_KeyError);
162-
DEF_ERROR(0xB1, "`FONT` field missing", PyExc_KeyError);
163-
DEF_ERROR(0xB2, "`SIZE` field missing", PyExc_KeyError);
164-
DEF_ERROR(0xB3, "`CHARS` field missing", PyExc_KeyError);
165-
DEF_ERROR(0xB4, "`STARTCHAR` field missing", PyExc_KeyError);
166-
DEF_ERROR(0xB5, "`ENCODING` field missing", PyExc_KeyError);
167-
DEF_ERROR(0xB6, "`BBX` field missing", PyExc_KeyError);
168-
DEF_ERROR(0xB7, "`BBX` too big", PyExc_MemoryError);
63+
#define DEF_ERROR(c, ignored, m, x) \
64+
errors[c].code = c; errors[c].msg = m; errors[c].cls = x;
65+
66+
int setup_errors(void) {
67+
memset(errors, 0, sizeof(error_def) * 256);
68+
69+
DEF_ERROR(FT_Err_Ok, 0x00, "no error", PyExc_Exception);
70+
71+
DEF_ERROR(FT_Err_Cannot_Open_Resource, 0x01, "cannot open resource", PyExc_IOError);
72+
DEF_ERROR(FT_Err_Unknown_File_Format, 0x02, "unknown file format", PyExc_ValueError);
73+
DEF_ERROR(FT_Err_Invalid_File_Format, 0x03, "broken file", PyExc_IOError);
74+
DEF_ERROR(FT_Err_Invalid_Version, 0x04, "invalid FreeType version", PyExc_RuntimeError);
75+
DEF_ERROR(FT_Err_Lower_Module_Version, 0x05, "module version is too low", PyExc_RuntimeError);
76+
DEF_ERROR(FT_Err_Invalid_Argument, 0x06, "invalid argument", PyExc_ValueError);
77+
DEF_ERROR(FT_Err_Unimplemented_Feature, 0x07, "unimplemented feature", PyExc_NotImplementedError);
78+
DEF_ERROR(FT_Err_Invalid_Table, 0x08, "broken table", PyExc_ValueError);
79+
DEF_ERROR(FT_Err_Invalid_Offset, 0x09, "broken offset within table", PyExc_ValueError);
80+
DEF_ERROR(FT_Err_Array_Too_Large, 0x0A, "array allocation size too large", PyExc_MemoryError);
81+
DEF_ERROR(FT_Err_Missing_Module, 0x0B, "missing module", PyExc_RuntimeError);
82+
DEF_ERROR(FT_Err_Missing_Property, 0x0C, "missing property", PyExc_KeyError);
83+
84+
/* glyph/character errors */
85+
86+
DEF_ERROR(FT_Err_Invalid_Glyph_Index, 0x10, "invalid glyph index", PyExc_IndexError);
87+
DEF_ERROR(FT_Err_Invalid_Character_Code, 0x11, "invalid character code", PyExc_ValueError);
88+
DEF_ERROR(FT_Err_Invalid_Glyph_Format, 0x12, "unsupported glyph image format", PyExc_ValueError);
89+
DEF_ERROR(FT_Err_Cannot_Render_Glyph, 0x13, "cannot render this glyph format", PyExc_RuntimeError);
90+
DEF_ERROR(FT_Err_Invalid_Outline, 0x14, "invalid outline", PyExc_ValueError);
91+
DEF_ERROR(FT_Err_Invalid_Composite, 0x15, "invalid composite glyph", PyExc_ValueError);
92+
DEF_ERROR(FT_Err_Too_Many_Hints, 0x16, "too many hints", PyExc_ValueError);
93+
DEF_ERROR(FT_Err_Invalid_Pixel_Size, 0x17, "invalid pixel size", PyExc_ValueError);
94+
95+
/* handle errors */
96+
97+
DEF_ERROR(FT_Err_Invalid_Handle, 0x20, "invalid object handle", PyExc_ValueError);
98+
DEF_ERROR(FT_Err_Invalid_Library_Handle, 0x21, "invalid library handle", PyExc_ValueError);
99+
DEF_ERROR(FT_Err_Invalid_Driver_Handle, 0x22, "invalid module handle", PyExc_ValueError);
100+
DEF_ERROR(FT_Err_Invalid_Face_Handle, 0x23, "invalid face handle", PyExc_ValueError);
101+
DEF_ERROR(FT_Err_Invalid_Size_Handle, 0x24, "invalid size handle", PyExc_ValueError);
102+
DEF_ERROR(FT_Err_Invalid_Slot_Handle, 0x25, "invalid glyph slot handle", PyExc_ValueError);
103+
DEF_ERROR(FT_Err_Invalid_CharMap_Handle, 0x26, "invalid charmap handle", PyExc_ValueError);
104+
DEF_ERROR(FT_Err_Invalid_Cache_Handle, 0x27, "invalid cache manager handle", PyExc_ValueError);
105+
DEF_ERROR(FT_Err_Invalid_Stream_Handle, 0x28, "invalid stream handle", PyExc_ValueError);
106+
107+
/* driver errors */
108+
109+
DEF_ERROR(FT_Err_Too_Many_Drivers, 0x30, "too many modules", PyExc_ValueError);
110+
DEF_ERROR(FT_Err_Too_Many_Extensions, 0x31, "too many extensions", PyExc_ValueError);
111+
112+
/* memory errors */
113+
114+
DEF_ERROR(FT_Err_Out_Of_Memory, 0x40, "out of memory", PyExc_MemoryError);
115+
DEF_ERROR(FT_Err_Unlisted_Object, 0x41, "unlisted object", PyExc_MemoryError);
116+
117+
/* stream errors */
118+
119+
DEF_ERROR(FT_Err_Cannot_Open_Stream, 0x51, "cannot open stream", PyExc_IOError);
120+
DEF_ERROR(FT_Err_Invalid_Stream_Seek, 0x52, "invalid stream seek", PyExc_IOError);
121+
DEF_ERROR(FT_Err_Invalid_Stream_Skip, 0x53, "invalid stream skip", PyExc_IOError);
122+
DEF_ERROR(FT_Err_Invalid_Stream_Read, 0x54, "invalid stream read", PyExc_IOError);
123+
DEF_ERROR(FT_Err_Invalid_Stream_Operation, 0x55, "invalid stream operation", PyExc_IOError);
124+
DEF_ERROR(FT_Err_Invalid_Frame_Operation, 0x56, "invalid frame operation", PyExc_IOError);
125+
DEF_ERROR(FT_Err_Nested_Frame_Access, 0x57, "nested frame access", PyExc_IOError);
126+
DEF_ERROR(FT_Err_Invalid_Frame_Read, 0x58, "invalid frame read", PyExc_IOError);
127+
128+
/* raster errors */
129+
130+
DEF_ERROR(FT_Err_Raster_Uninitialized, 0x60, "raster uninitialized", PyExc_ValueError);
131+
DEF_ERROR(FT_Err_Raster_Corrupted, 0x61, "raster corrupted", PyExc_ValueError);
132+
DEF_ERROR(FT_Err_Raster_Overflow, 0x62, "raster overflow", PyExc_ValueError);
133+
DEF_ERROR(FT_Err_Raster_Negative_Height, 0x63, "negative height while rastering", PyExc_ValueError);
134+
135+
/* cache errors */
136+
137+
DEF_ERROR(FT_Err_Too_Many_Caches, 0x70, "too many registered caches", PyExc_MemoryError);
138+
139+
/* TrueType and SFNT errors */
140+
141+
DEF_ERROR(FT_Err_Invalid_Opcode, 0x80, "invalid opcode", PyExc_ValueError);
142+
DEF_ERROR(FT_Err_Too_Few_Arguments, 0x81, "too few arguments", PyExc_ValueError);
143+
DEF_ERROR(FT_Err_Stack_Overflow, 0x82, "stack overflow", PyExc_ValueError);
144+
DEF_ERROR(FT_Err_Code_Overflow, 0x83, "code overflow", PyExc_ValueError);
145+
DEF_ERROR(FT_Err_Bad_Argument, 0x84, "bad argument", PyExc_ValueError);
146+
DEF_ERROR(FT_Err_Divide_By_Zero, 0x85, "division by zero", PyExc_ValueError);
147+
DEF_ERROR(FT_Err_Invalid_Reference, 0x86, "invalid reference", PyExc_ValueError);
148+
DEF_ERROR(FT_Err_Debug_OpCode, 0x87, "found debug opcode", PyExc_ValueError);
149+
DEF_ERROR(FT_Err_ENDF_In_Exec_Stream, 0x88, "found ENDF opcode in execution stream", PyExc_ValueError);
150+
DEF_ERROR(FT_Err_Nested_DEFS, 0x89, "nested DEFS", PyExc_ValueError);
151+
DEF_ERROR(FT_Err_Invalid_CodeRange, 0x8A, "invalid code range", PyExc_ValueError);
152+
DEF_ERROR(FT_Err_Execution_Too_Long, 0x8B, "execution context too long", PyExc_ValueError);
153+
DEF_ERROR(FT_Err_Too_Many_Function_Defs, 0x8C, "too many function definitions", PyExc_ValueError);
154+
DEF_ERROR(FT_Err_Too_Many_Instruction_Defs, 0x8D, "too many instruction definitions", PyExc_ValueError);
155+
DEF_ERROR(FT_Err_Table_Missing, 0x8E, "SFNT font table missing", PyExc_ValueError);
156+
DEF_ERROR(FT_Err_Horiz_Header_Missing, 0x8F, "horizontal header (FT_Err_hhea) table missing", PyExc_ValueError);
157+
DEF_ERROR(FT_Err_Locations_Missing, 0x90, "locations (FT_Err_loca) table missing", PyExc_ValueError);
158+
DEF_ERROR(FT_Err_Name_Table_Missing, 0x91, "name table missing", PyExc_ValueError);
159+
DEF_ERROR(FT_Err_CMap_Table_Missing, 0x92, "character map (FT_Err_cmap) table missing", PyExc_ValueError);
160+
DEF_ERROR(FT_Err_Hmtx_Table_Missing, 0x93, "horizontal metrics (FT_Err_hmtx) table missing", PyExc_ValueError);
161+
DEF_ERROR(FT_Err_Post_Table_Missing, 0x94, "PostScript (FT_Err_post) table missing", PyExc_ValueError);
162+
DEF_ERROR(FT_Err_Invalid_Horiz_Metrics, 0x95, "invalid horizontal metrics", PyExc_ValueError);
163+
DEF_ERROR(FT_Err_Invalid_CharMap_Format, 0x96, "invalid character map (FT_Err_cmap) format", PyExc_ValueError);
164+
DEF_ERROR(FT_Err_Invalid_PPem, 0x97, "invalid ppem value", PyExc_ValueError);
165+
DEF_ERROR(FT_Err_Invalid_Vert_Metrics, 0x98, "invalid vertical metrics", PyExc_ValueError);
166+
DEF_ERROR(FT_Err_Could_Not_Find_Context, 0x99, "could not find context", PyExc_ValueError);
167+
DEF_ERROR(FT_Err_Invalid_Post_Table_Format, 0x9A, "invalid PostScript (FT_Err_post) table format", PyExc_ValueError);
168+
DEF_ERROR(FT_Err_Invalid_Post_Table, 0x9B, "invalid PostScript (FT_Err_post) table", PyExc_ValueError);
169+
170+
/* CFF, CID, and Type 1 errors */
171+
172+
DEF_ERROR(FT_Err_Syntax_Error, 0xA0, "opcode syntax error", PyExc_ValueError);
173+
DEF_ERROR(FT_Err_Stack_Underflow, 0xA1, "argument stack underflow", PyExc_ValueError);
174+
DEF_ERROR(FT_Err_Ignore, 0xA2, "ignore", PyExc_ValueError);
175+
DEF_ERROR(FT_Err_No_Unicode_Glyph_Name, 0xA3, "no Unicode glyph name found", PyExc_ValueError);
176+
DEF_ERROR(FT_Err_Glyph_Too_Big, 0xA4, "glyph to big for hinting", PyExc_ValueError);
177+
178+
/* BDF errors */
179+
180+
DEF_ERROR(FT_Err_Missing_Startfont_Field, 0xB0, "`STARTFONT' field missing", PyExc_ValueError);
181+
DEF_ERROR(FT_Err_Missing_Font_Field, 0xB1, "`FONT' field missing", PyExc_ValueError);
182+
DEF_ERROR(FT_Err_Missing_Size_Field, 0xB2, "`SIZE' field missing", PyExc_ValueError);
183+
DEF_ERROR(FT_Err_Missing_Fontboundingbox_Field, 0xB3, "`FONTBOUNDINGBOX' field missing", PyExc_ValueError);
184+
DEF_ERROR(FT_Err_Missing_Chars_Field, 0xB4, "`CHARS' field missing", PyExc_ValueError);
185+
DEF_ERROR(FT_Err_Missing_Startchar_Field, 0xB5, "`STARTCHAR' field missing", PyExc_ValueError);
186+
DEF_ERROR(FT_Err_Missing_Encoding_Field, 0xB6, "`ENCODING' field missing", PyExc_ValueError);
187+
DEF_ERROR(FT_Err_Missing_Bbx_Field, 0xB7, "`BBX' field missing", PyExc_ValueError);
188+
DEF_ERROR(FT_Err_Bbx_Too_Big, 0xB8, "`BBX' too big", PyExc_ValueError);
189+
DEF_ERROR(FT_Err_Corrupted_Font_Header, 0xB9, "Font header corrupted or missing fields", PyExc_ValueError);
190+
DEF_ERROR(FT_Err_Corrupted_Font_Glyphs, 0xBA, "Font glyphs corrupted or missing !fields", PyExc_ValueError);
169191

170192
return 0;
171193
}

src/freetypy_error.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ either expressed or implied, of the FreeBSD Project.
3434

3535
int ftpy_exc(FT_Error error);
3636

37-
int setup_errors();
37+
int setup_errors(void);
3838

3939
#endif

src/glyph.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static PyObject *metrics_get(Py_Glyph *self, PyObject *closure)
143143
static PyObject *linear_hori_advance_get(Py_Glyph *self, PyObject *closure)
144144
{
145145
if (self->load_flags & FT_LOAD_LINEAR_DESIGN) {
146-
return PyInt_FromLong(self->x->linearHoriAdvance);
146+
return PyLong_FromLong(self->x->linearHoriAdvance);
147147
} else {
148148
return ftpy_PyFloat_FromFT_FIXED(self->x->linearHoriAdvance);
149149
}
@@ -153,7 +153,7 @@ static PyObject *linear_hori_advance_get(Py_Glyph *self, PyObject *closure)
153153
static PyObject *linear_vert_advance_get(Py_Glyph *self, PyObject *closure)
154154
{
155155
if (self->load_flags & FT_LOAD_LINEAR_DESIGN) {
156-
return PyInt_FromLong(self->x->linearVertAdvance);
156+
return PyLong_FromLong(self->x->linearVertAdvance);
157157
} else {
158158
return ftpy_PyFloat_FromFT_FIXED(self->x->linearVertAdvance);
159159
}

src/tt_pclt.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,15 @@ static PyObject *type_face_get(Py_TT_Pclt *self, PyObject *closure)
110110

111111
static PyObject *character_complement_get(Py_TT_Pclt *self, PyObject *closure)
112112
{
113-
return PyLong_FromUnsignedLong(*((long unsigned *)&self->x->CharacterComplement));
113+
unsigned long result;
114+
int i;
115+
116+
result = 0;
117+
for (i = 0; i < 8; ++i) {
118+
result |= (self->x->CharacterComplement[i] << (CHAR_BIT * i));
119+
}
120+
121+
return PyLong_FromUnsignedLong(result);
114122
}
115123

116124

0 commit comments

Comments
 (0)