Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 57c9a78

Browse filesBrowse files
authored
Merge pull request #7853 from QuLogic/Py_BuildValue-types
[MRG] Use exact types for Py_BuildValue.
2 parents 03b8e19 + ea69e03 commit 57c9a78
Copy full SHA for 57c9a78

File tree

Expand file treeCollapse file tree

2 files changed

+60
-57
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+60
-57
lines changed

‎src/ft2font.h

Copy file name to clipboardExpand all lines: src/ft2font.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ extern "C" {
1818
/*
1919
By definition, FT_FIXED as 2 16bit values stored in a single long.
2020
*/
21-
#define FIXED_MAJOR(val) (long)((val & 0xffff000) >> 16)
22-
#define FIXED_MINOR(val) (long)(val & 0xffff)
21+
#define FIXED_MAJOR(val) (signed short)((val & 0xffff0000) >> 16)
22+
#define FIXED_MINOR(val) (unsigned short)(val & 0xffff)
2323

2424
// the FreeType string rendered into a width, height buffer
2525
class FT2Image

‎src/ft2font_wrapper.cpp

Copy file name to clipboardExpand all lines: src/ft2font_wrapper.cpp
+58-55Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static void PyGlyph_dealloc(PyGlyph *self)
277277
static PyObject *PyGlyph_get_bbox(PyGlyph *self, void *closure)
278278
{
279279
return Py_BuildValue(
280-
"iiii", self->bbox.xMin, self->bbox.yMin, self->bbox.xMax, self->bbox.yMax);
280+
"llll", self->bbox.xMin, self->bbox.yMin, self->bbox.xMax, self->bbox.yMax);
281281
}
282282

283283
static PyTypeObject *PyGlyph_init_type(PyObject *m, PyTypeObject *type)
@@ -1029,7 +1029,7 @@ static PyObject *PyFT2Font_get_sfnt(PyFT2Font *self, PyObject *args, PyObject *k
10291029
}
10301030

10311031
PyObject *key = Py_BuildValue(
1032-
"iiii", sfnt.platform_id, sfnt.encoding_id, sfnt.language_id, sfnt.name_id);
1032+
"HHHH", sfnt.platform_id, sfnt.encoding_id, sfnt.language_id, sfnt.name_id);
10331033
if (key == NULL) {
10341034
Py_DECREF(names);
10351035
return NULL;
@@ -1093,7 +1093,7 @@ static PyObject *PyFT2Font_get_ps_font_info(PyFT2Font *self, PyObject *args, PyO
10931093
return NULL;
10941094
}
10951095

1096-
return Py_BuildValue("sssssliii",
1096+
return Py_BuildValue("ssssslbhH",
10971097
fontinfo.version ? fontinfo.version : "",
10981098
fontinfo.notice ? fontinfo.notice : "",
10991099
fontinfo.full_name ? fontinfo.full_name : "",
@@ -1138,8 +1138,8 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11381138
switch (tag) {
11391139
case 0: {
11401140
char head_dict[] =
1141-
"{s:(h,h), s:(h,h), s:l, s:l, s:i, s:i,"
1142-
"s:(l,l), s:(l,l), s:h, s:h, s:h, s:h, s:i, s:i, s:h, s:h, s:h}";
1141+
"{s:(h,H), s:(h,H), s:l, s:l, s:H, s:H,"
1142+
"s:(l,l), s:(l,l), s:h, s:h, s:h, s:h, s:H, s:H, s:h, s:h, s:h}";
11431143
TT_Header *t = (TT_Header *)table;
11441144
return Py_BuildValue(head_dict,
11451145
"version",
@@ -1153,9 +1153,9 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11531153
"magicNumber",
11541154
t->Magic_Number,
11551155
"flags",
1156-
(unsigned)t->Flags,
1156+
t->Flags,
11571157
"unitsPerEm",
1158-
(unsigned)t->Units_Per_EM,
1158+
t->Units_Per_EM,
11591159
"created",
11601160
t->Created[0],
11611161
t->Created[1],
@@ -1171,9 +1171,9 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11711171
"yMax",
11721172
t->yMax,
11731173
"macStyle",
1174-
(unsigned)t->Mac_Style,
1174+
t->Mac_Style,
11751175
"lowestRecPPEM",
1176-
(unsigned)t->Lowest_Rec_PPEM,
1176+
t->Lowest_Rec_PPEM,
11771177
"fontDirectionHint",
11781178
t->Font_Direction,
11791179
"indexToLocFormat",
@@ -1183,64 +1183,64 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11831183
}
11841184
case 1: {
11851185
char maxp_dict[] =
1186-
"{s:(h,h), s:i, s:i, s:i, s:i, s:i, s:i,"
1187-
"s:i, s:i, s:i, s:i, s:i, s:i, s:i, s:i}";
1186+
"{s:(h,H), s:H, s:H, s:H, s:H, s:H, s:H,"
1187+
"s:H, s:H, s:H, s:H, s:H, s:H, s:H, s:H}";
11881188
TT_MaxProfile *t = (TT_MaxProfile *)table;
11891189
return Py_BuildValue(maxp_dict,
11901190
"version",
11911191
FIXED_MAJOR(t->version),
11921192
FIXED_MINOR(t->version),
11931193
"numGlyphs",
1194-
(unsigned)t->numGlyphs,
1194+
t->numGlyphs,
11951195
"maxPoints",
1196-
(unsigned)t->maxPoints,
1196+
t->maxPoints,
11971197
"maxContours",
1198-
(unsigned)t->maxContours,
1198+
t->maxContours,
11991199
"maxComponentPoints",
1200-
(unsigned)t->maxCompositePoints,
1200+
t->maxCompositePoints,
12011201
"maxComponentContours",
1202-
(unsigned)t->maxCompositeContours,
1202+
t->maxCompositeContours,
12031203
"maxZones",
1204-
(unsigned)t->maxZones,
1204+
t->maxZones,
12051205
"maxTwilightPoints",
1206-
(unsigned)t->maxTwilightPoints,
1206+
t->maxTwilightPoints,
12071207
"maxStorage",
1208-
(unsigned)t->maxStorage,
1208+
t->maxStorage,
12091209
"maxFunctionDefs",
1210-
(unsigned)t->maxFunctionDefs,
1210+
t->maxFunctionDefs,
12111211
"maxInstructionDefs",
1212-
(unsigned)t->maxInstructionDefs,
1212+
t->maxInstructionDefs,
12131213
"maxStackElements",
1214-
(unsigned)t->maxStackElements,
1214+
t->maxStackElements,
12151215
"maxSizeOfInstructions",
1216-
(unsigned)t->maxSizeOfInstructions,
1216+
t->maxSizeOfInstructions,
12171217
"maxComponentElements",
1218-
(unsigned)t->maxComponentElements,
1218+
t->maxComponentElements,
12191219
"maxComponentDepth",
1220-
(unsigned)t->maxComponentDepth);
1220+
t->maxComponentDepth);
12211221
}
12221222
case 2: {
12231223
#if PY3K
12241224
char os_2_dict[] =
1225-
"{s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h,"
1226-
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:y#, s:(llll),"
1227-
"s:y#, s:h, s:h, s:h}";
1225+
"{s:H, s:h, s:H, s:H, s:H, s:h, s:h, s:h,"
1226+
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:y#, s:(kkkk),"
1227+
"s:y#, s:H, s:H, s:H}";
12281228
#else
12291229
char os_2_dict[] =
1230-
"{s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h,"
1231-
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:s#, s:(llll),"
1232-
"s:s#, s:h, s:h, s:h}";
1230+
"{s:H, s:h, s:H, s:H, s:H, s:h, s:h, s:h,"
1231+
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:s#, s:(kkkk),"
1232+
"s:s#, s:H, s:H, s:H}";
12331233
#endif
12341234
TT_OS2 *t = (TT_OS2 *)table;
12351235
return Py_BuildValue(os_2_dict,
12361236
"version",
1237-
(unsigned)t->version,
1237+
t->version,
12381238
"xAvgCharWidth",
12391239
t->xAvgCharWidth,
12401240
"usWeightClass",
1241-
(unsigned)t->usWeightClass,
1241+
t->usWeightClass,
12421242
"usWidthClass",
1243-
(unsigned)t->usWidthClass,
1243+
t->usWidthClass,
12441244
"fsType",
12451245
t->fsType,
12461246
"ySubscriptXSize",
@@ -1269,24 +1269,24 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
12691269
t->panose,
12701270
10,
12711271
"ulCharRange",
1272-
(unsigned long)t->ulUnicodeRange1,
1273-
(unsigned long)t->ulUnicodeRange2,
1274-
(unsigned long)t->ulUnicodeRange3,
1275-
(unsigned long)t->ulUnicodeRange4,
1272+
t->ulUnicodeRange1,
1273+
t->ulUnicodeRange2,
1274+
t->ulUnicodeRange3,
1275+
t->ulUnicodeRange4,
12761276
"achVendID",
12771277
t->achVendID,
12781278
4,
12791279
"fsSelection",
1280-
(unsigned)t->fsSelection,
1280+
t->fsSelection,
12811281
"fsFirstCharIndex",
1282-
(unsigned)t->usFirstCharIndex,
1282+
t->usFirstCharIndex,
12831283
"fsLastCharIndex",
1284-
(unsigned)t->usLastCharIndex);
1284+
t->usLastCharIndex);
12851285
}
12861286
case 3: {
12871287
char hhea_dict[] =
1288-
"{s:(h,h), s:h, s:h, s:h, s:i, s:h, s:h, s:h,"
1289-
"s:h, s:h, s:h, s:h, s:i}";
1288+
"{s:(h,H), s:h, s:h, s:h, s:H, s:h, s:h, s:h,"
1289+
"s:h, s:h, s:h, s:h, s:H}";
12901290
TT_HoriHeader *t = (TT_HoriHeader *)table;
12911291
return Py_BuildValue(hhea_dict,
12921292
"version",
@@ -1299,7 +1299,7 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
12991299
"lineGap",
13001300
t->Line_Gap,
13011301
"advanceWidthMax",
1302-
(unsigned)t->advance_Width_Max,
1302+
t->advance_Width_Max,
13031303
"minLeftBearing",
13041304
t->min_Left_Side_Bearing,
13051305
"minRightBearing",
@@ -1315,12 +1315,12 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
13151315
"metricDataFormat",
13161316
t->metric_Data_Format,
13171317
"numOfLongHorMetrics",
1318-
(unsigned)t->number_Of_HMetrics);
1318+
t->number_Of_HMetrics);
13191319
}
13201320
case 4: {
13211321
char vhea_dict[] =
1322-
"{s:(h,h), s:h, s:h, s:h, s:i, s:h, s:h, s:h,"
1323-
"s:h, s:h, s:h, s:h, s:i}";
1322+
"{s:(h,H), s:h, s:h, s:h, s:H, s:h, s:h, s:h,"
1323+
"s:h, s:h, s:h, s:h, s:H}";
13241324
TT_VertHeader *t = (TT_VertHeader *)table;
13251325
return Py_BuildValue(vhea_dict,
13261326
"version",
@@ -1333,7 +1333,7 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
13331333
"vertTypoLineGap",
13341334
t->Line_Gap,
13351335
"advanceHeightMax",
1336-
(unsigned)t->advance_Height_Max,
1336+
t->advance_Height_Max,
13371337
"minTopSideBearing",
13381338
t->min_Top_Side_Bearing,
13391339
"minBottomSizeBearing",
@@ -1349,10 +1349,10 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
13491349
"metricDataFormat",
13501350
t->metric_Data_Format,
13511351
"numOfLongVerMetrics",
1352-
(unsigned)t->number_Of_VMetrics);
1352+
t->number_Of_VMetrics);
13531353
}
13541354
case 5: {
1355-
char post_dict[] = "{s:(h,h), s:(h,h), s:h, s:h, s:k, s:k, s:k, s:k, s:k}";
1355+
char post_dict[] = "{s:(h,H), s:(h,H), s:h, s:h, s:k, s:k, s:k, s:k, s:k}";
13561356
TT_Postscript *t = (TT_Postscript *)table;
13571357
return Py_BuildValue(post_dict,
13581358
"format",
@@ -1379,12 +1379,12 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
13791379
case 6: {
13801380
#if PY3K
13811381
char pclt_dict[] =
1382-
"{s:(h,h), s:k, s:H, s:H, s:H, s:H, s:H, s:H, s:y, s:y, s:b, s:b, "
1383-
"s:b}";
1382+
"{s:(h,H), s:k, s:H, s:H, s:H, s:H, s:H, s:H, s:y#, s:y#, s:b, "
1383+
"s:b, s:b}";
13841384
#else
13851385
char pclt_dict[] =
1386-
"{s:(h,h), s:k, s:H, s:H, s:H, s:H, s:H, s:H, s:s, s:s, s:b, s:b, "
1387-
"s:b}";
1386+
"{s:(h,H), s:k, s:H, s:H, s:H, s:H, s:H, s:H, s:s#, s:s#, s:b, "
1387+
"s:b, s:b}";
13881388
#endif
13891389
TT_PCLT *t = (TT_PCLT *)table;
13901390
return Py_BuildValue(pclt_dict,
@@ -1407,8 +1407,10 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
14071407
t->SymbolSet,
14081408
"typeFace",
14091409
t->TypeFace,
1410+
16,
14101411
"characterComplement",
14111412
t->CharacterComplement,
1413+
8,
14121414
"strokeWeight",
14131415
t->StrokeWeight,
14141416
"widthType",
@@ -1531,7 +1533,8 @@ static PyObject *PyFT2Font_get_bbox(PyFT2Font *self, void *closure)
15311533
{
15321534
FT_BBox *bbox = &(self->x->get_face()->bbox);
15331535

1534-
return Py_BuildValue("iiii", bbox->xMin, bbox->yMin, bbox->xMax, bbox->yMax);
1536+
return Py_BuildValue("llll",
1537+
bbox->xMin, bbox->yMin, bbox->xMax, bbox->yMax);
15351538
}
15361539

15371540
static PyObject *PyFT2Font_ascender(PyFT2Font *self, void *closure)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.