Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit74ab0a6

Browse files
committed
Use exact types for Py_BuildValue.
IIRC, most ABI upcast values passed to vararg functions anyway, butthere might be some other ABIs that require the exact correct type.
1 parent81075b5 commit74ab0a6

File tree

2 files changed

+60
-57
lines changed

2 files changed

+60
-57
lines changed

‎src/ft2font.h

Lines 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-
#defineFIXED_MAJOR(val) (long)((val &0xffff000) >>16)
22-
#defineFIXED_MINOR(val) (long)(val &0xffff)
21+
#defineFIXED_MAJOR(val) (unsignedshort)((val &0xffff000) >>16)
22+
#defineFIXED_MINOR(val) (unsignedshort)(val &0xffff)
2323

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

‎src/ft2font_wrapper.cpp

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static void PyGlyph_dealloc(PyGlyph *self)
276276
static PyObject *PyGlyph_get_bbox(PyGlyph *self,void *closure)
277277
{
278278
returnPy_BuildValue(
279-
"iiii", self->bbox.xMin, self->bbox.yMin, self->bbox.xMax, self->bbox.yMax);
279+
"llll", self->bbox.xMin, self->bbox.yMin, self->bbox.xMax, self->bbox.yMax);
280280
}
281281

282282
static PyTypeObject *PyGlyph_init_type(PyObject *m, PyTypeObject *type)
@@ -1025,7 +1025,7 @@ static PyObject *PyFT2Font_get_sfnt(PyFT2Font *self, PyObject *args, PyObject *k
10251025
}
10261026

10271027
PyObject *key =Py_BuildValue(
1028-
"iiii", sfnt.platform_id, sfnt.encoding_id, sfnt.language_id, sfnt.name_id);
1028+
"HHHH", sfnt.platform_id, sfnt.encoding_id, sfnt.language_id, sfnt.name_id);
10291029
if (key ==NULL) {
10301030
Py_DECREF(names);
10311031
returnNULL;
@@ -1089,7 +1089,7 @@ static PyObject *PyFT2Font_get_ps_font_info(PyFT2Font *self, PyObject *args, PyO
10891089
returnNULL;
10901090
}
10911091

1092-
returnPy_BuildValue("sssssliii",
1092+
returnPy_BuildValue("ssssslbhH",
10931093
fontinfo.version ? fontinfo.version :"",
10941094
fontinfo.notice ? fontinfo.notice :"",
10951095
fontinfo.full_name ? fontinfo.full_name :"",
@@ -1134,8 +1134,8 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11341134
switch (tag) {
11351135
case0: {
11361136
char head_dict[] =
1137-
"{s:(h,h), s:(h,h), s:l, s:l, s:i, s:i,"
1138-
"s:(l,l), s:(l,l), s:h, s:h, s:h, s:h, s:i, s:i, s:h, s:h, s:h}";
1137+
"{s:(H,H), s:(H,H), s:l, s:l, s:H, s:H,"
1138+
"s:(l,l), s:(l,l), s:h, s:h, s:h, s:h, s:H, s:H, s:h, s:h, s:h}";
11391139
TT_Header *t = (TT_Header *)table;
11401140
returnPy_BuildValue(head_dict,
11411141
"version",
@@ -1149,9 +1149,9 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11491149
"magicNumber",
11501150
t->Magic_Number,
11511151
"flags",
1152-
(unsigned)t->Flags,
1152+
t->Flags,
11531153
"unitsPerEm",
1154-
(unsigned)t->Units_Per_EM,
1154+
t->Units_Per_EM,
11551155
"created",
11561156
t->Created[0],
11571157
t->Created[1],
@@ -1167,9 +1167,9 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11671167
"yMax",
11681168
t->yMax,
11691169
"macStyle",
1170-
(unsigned)t->Mac_Style,
1170+
t->Mac_Style,
11711171
"lowestRecPPEM",
1172-
(unsigned)t->Lowest_Rec_PPEM,
1172+
t->Lowest_Rec_PPEM,
11731173
"fontDirectionHint",
11741174
t->Font_Direction,
11751175
"indexToLocFormat",
@@ -1179,64 +1179,64 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11791179
}
11801180
case1: {
11811181
char maxp_dict[] =
1182-
"{s:(h,h), s:i, s:i, s:i, s:i, s:i, s:i,"
1183-
"s:i, s:i, s:i, s:i, s:i, s:i, s:i, s:i}";
1182+
"{s:(h,h), s:H, s:H, s:H, s:H, s:H, s:H,"
1183+
"s:H, s:H, s:H, s:H, s:H, s:H, s:H, s:H}";
11841184
TT_MaxProfile *t = (TT_MaxProfile *)table;
11851185
returnPy_BuildValue(maxp_dict,
11861186
"version",
11871187
FIXED_MAJOR(t->version),
11881188
FIXED_MINOR(t->version),
11891189
"numGlyphs",
1190-
(unsigned)t->numGlyphs,
1190+
t->numGlyphs,
11911191
"maxPoints",
1192-
(unsigned)t->maxPoints,
1192+
t->maxPoints,
11931193
"maxContours",
1194-
(unsigned)t->maxContours,
1194+
t->maxContours,
11951195
"maxComponentPoints",
1196-
(unsigned)t->maxCompositePoints,
1196+
t->maxCompositePoints,
11971197
"maxComponentContours",
1198-
(unsigned)t->maxCompositeContours,
1198+
t->maxCompositeContours,
11991199
"maxZones",
1200-
(unsigned)t->maxZones,
1200+
t->maxZones,
12011201
"maxTwilightPoints",
1202-
(unsigned)t->maxTwilightPoints,
1202+
t->maxTwilightPoints,
12031203
"maxStorage",
1204-
(unsigned)t->maxStorage,
1204+
t->maxStorage,
12051205
"maxFunctionDefs",
1206-
(unsigned)t->maxFunctionDefs,
1206+
t->maxFunctionDefs,
12071207
"maxInstructionDefs",
1208-
(unsigned)t->maxInstructionDefs,
1208+
t->maxInstructionDefs,
12091209
"maxStackElements",
1210-
(unsigned)t->maxStackElements,
1210+
t->maxStackElements,
12111211
"maxSizeOfInstructions",
1212-
(unsigned)t->maxSizeOfInstructions,
1212+
t->maxSizeOfInstructions,
12131213
"maxComponentElements",
1214-
(unsigned)t->maxComponentElements,
1214+
t->maxComponentElements,
12151215
"maxComponentDepth",
1216-
(unsigned)t->maxComponentDepth);
1216+
t->maxComponentDepth);
12171217
}
12181218
case2: {
12191219
#if PY3K
12201220
char os_2_dict[] =
1221-
"{s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h,"
1222-
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:y#, s:(llll),"
1223-
"s:y#, s:h, s:h, s:h}";
1221+
"{s:H, s:h, s:H, s:H, s:H, s:h, s:h, s:h,"
1222+
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:y#, s:(kkkk),"
1223+
"s:y#, s:H, s:H, s:H}";
12241224
#else
12251225
char os_2_dict[] =
1226-
"{s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h,"
1227-
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:s#, s:(llll),"
1228-
"s:s#, s:h, s:h, s:h}";
1226+
"{s:H, s:h, s:H, s:H, s:H, s:h, s:h, s:h,"
1227+
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:s#, s:(kkkk),"
1228+
"s:s#, s:H, s:H, s:H}";
12291229
#endif
12301230
TT_OS2 *t = (TT_OS2 *)table;
12311231
returnPy_BuildValue(os_2_dict,
12321232
"version",
1233-
(unsigned)t->version,
1233+
t->version,
12341234
"xAvgCharWidth",
12351235
t->xAvgCharWidth,
12361236
"usWeightClass",
1237-
(unsigned)t->usWeightClass,
1237+
t->usWeightClass,
12381238
"usWidthClass",
1239-
(unsigned)t->usWidthClass,
1239+
t->usWidthClass,
12401240
"fsType",
12411241
t->fsType,
12421242
"ySubscriptXSize",
@@ -1265,24 +1265,24 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
12651265
t->panose,
12661266
10,
12671267
"ulCharRange",
1268-
(unsignedlong)t->ulUnicodeRange1,
1269-
(unsignedlong)t->ulUnicodeRange2,
1270-
(unsignedlong)t->ulUnicodeRange3,
1271-
(unsignedlong)t->ulUnicodeRange4,
1268+
t->ulUnicodeRange1,
1269+
t->ulUnicodeRange2,
1270+
t->ulUnicodeRange3,
1271+
t->ulUnicodeRange4,
12721272
"achVendID",
12731273
t->achVendID,
12741274
4,
12751275
"fsSelection",
1276-
(unsigned)t->fsSelection,
1276+
t->fsSelection,
12771277
"fsFirstCharIndex",
1278-
(unsigned)t->usFirstCharIndex,
1278+
t->usFirstCharIndex,
12791279
"fsLastCharIndex",
1280-
(unsigned)t->usLastCharIndex);
1280+
t->usLastCharIndex);
12811281
}
12821282
case3: {
12831283
char hhea_dict[] =
1284-
"{s:(h,h), s:h, s:h, s:h, s:i, s:h, s:h, s:h,"
1285-
"s:h, s:h, s:h, s:h, s:i}";
1284+
"{s:(H,H), s:h, s:h, s:h, s:H, s:h, s:h, s:h,"
1285+
"s:h, s:h, s:h, s:h, s:H}";
12861286
TT_HoriHeader *t = (TT_HoriHeader *)table;
12871287
returnPy_BuildValue(hhea_dict,
12881288
"version",
@@ -1295,7 +1295,7 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
12951295
"lineGap",
12961296
t->Line_Gap,
12971297
"advanceWidthMax",
1298-
(unsigned)t->advance_Width_Max,
1298+
t->advance_Width_Max,
12991299
"minLeftBearing",
13001300
t->min_Left_Side_Bearing,
13011301
"minRightBearing",
@@ -1311,12 +1311,12 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
13111311
"metricDataFormat",
13121312
t->metric_Data_Format,
13131313
"numOfLongHorMetrics",
1314-
(unsigned)t->number_Of_HMetrics);
1314+
t->number_Of_HMetrics);
13151315
}
13161316
case4: {
13171317
char vhea_dict[] =
1318-
"{s:(h,h), s:h, s:h, s:h, s:i, s:h, s:h, s:h,"
1319-
"s:h, s:h, s:h, s:h, s:i}";
1318+
"{s:(H,H), s:h, s:h, s:h, s:H, s:h, s:h, s:h,"
1319+
"s:h, s:h, s:h, s:h, s:H}";
13201320
TT_VertHeader *t = (TT_VertHeader *)table;
13211321
returnPy_BuildValue(vhea_dict,
13221322
"version",
@@ -1329,7 +1329,7 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
13291329
"vertTypoLineGap",
13301330
t->Line_Gap,
13311331
"advanceHeightMax",
1332-
(unsigned)t->advance_Height_Max,
1332+
t->advance_Height_Max,
13331333
"minTopSideBearing",
13341334
t->min_Top_Side_Bearing,
13351335
"minBottomSizeBearing",
@@ -1345,10 +1345,10 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
13451345
"metricDataFormat",
13461346
t->metric_Data_Format,
13471347
"numOfLongVerMetrics",
1348-
(unsigned)t->number_Of_VMetrics);
1348+
t->number_Of_VMetrics);
13491349
}
13501350
case5: {
1351-
char post_dict[] ="{s:(h,h), s:(h,h), s:h, s:h, s:k, s:k, s:k, s:k, s:k}";
1351+
char post_dict[] ="{s:(H,H), s:(H,H), s:h, s:h, s:k, s:k, s:k, s:k, s:k}";
13521352
TT_Postscript *t = (TT_Postscript *)table;
13531353
returnPy_BuildValue(post_dict,
13541354
"format",
@@ -1375,12 +1375,12 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
13751375
case6: {
13761376
#if PY3K
13771377
char pclt_dict[] =
1378-
"{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,"
1379-
"s:b}";
1378+
"{s:(H,H), s:k, s:H, s:H, s:H, s:H, s:H, s:H, s:y#, s:y#, s:b,"
1379+
"s:b, s:b}";
13801380
#else
13811381
char pclt_dict[] =
1382-
"{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,"
1383-
"s:b}";
1382+
"{s:(H,H), s:k, s:H, s:H, s:H, s:H, s:H, s:H, s:s#, s:s#, s:b,"
1383+
"s:b, s:b}";
13841384
#endif
13851385
TT_PCLT *t = (TT_PCLT *)table;
13861386
returnPy_BuildValue(pclt_dict,
@@ -1403,8 +1403,10 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
14031403
t->SymbolSet,
14041404
"typeFace",
14051405
t->TypeFace,
1406+
16,
14061407
"characterComplement",
14071408
t->CharacterComplement,
1409+
8,
14081410
"strokeWeight",
14091411
t->StrokeWeight,
14101412
"widthType",
@@ -1527,7 +1529,8 @@ static PyObject *PyFT2Font_get_bbox(PyFT2Font *self, void *closure)
15271529
{
15281530
FT_BBox *bbox = &(self->x->get_face()->bbox);
15291531

1530-
returnPy_BuildValue("iiii", bbox->xMin, bbox->yMin, bbox->xMax, bbox->yMax);
1532+
returnPy_BuildValue("llll",
1533+
bbox->xMin, bbox->yMin, bbox->xMax, bbox->yMax);
15311534
}
15321535

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp