summaryrefslogtreecommitdiff
blob: f9581ad35f424fea16b7378d1f9600410edf796b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
From 65619185a42bd52bb4a4894c1714d78d96ed4175 Mon Sep 17 00:00:00 2001
From: Jeremy Tan <jtanx@outlook.com>
Date: Sun, 26 Apr 2020 18:57:58 +1000
Subject: [PATCH 1/2] tottfgpos.c: fix incorrect sizing of the scripts array

latn contains 58 entries (29 pairs), meaning the size was too small
to fit the 0 marker at the end of the array
---
 fontforge/tottfgpos.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fontforge/tottfgpos.c b/fontforge/tottfgpos.c
index 5de5164ed1..e12a0b8a79 100644
--- a/fontforge/tottfgpos.c
+++ b/fontforge/tottfgpos.c
@@ -60,7 +60,7 @@ int use_second_indic_scripts = false;
 /* scripts (for opentype) that I understand */
     /* see also list in lookups.c mapping script tags to friendly names */
 
-static uint32 scripts[][59] = {
+static uint32 scripts[][61] = {
 /* Adlam */	{ CHR('a','d','l','m'), 0x1e900, 0x1e95f },
 /* Ahom */	{ CHR('a','h','o','m'), 0x11700, 0x1173f },
 /* Anatolian */	{ CHR('h','l','u','w'), 0x14400, 0x1467f },

From fde85b13382595cb3ab889e38570b4944edad808 Mon Sep 17 00:00:00 2001
From: Jeremy Tan <jtanx@outlook.com>
Date: Sun, 26 Apr 2020 19:00:04 +1000
Subject: [PATCH 2/2] python.c: fix type specifier on long input/return values

int is guaranteed to be at least 16 bits, while long is at least
32 bits. So for uint32/int32 values, parse longs with the "l"/"k"
specifier and cast return values to long.

The cast is necessary as on amd64 a long is 64 bits
---
 fontforge/python.c | 68 +++++++++++++++++++++++-----------------------
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/fontforge/python.c b/fontforge/python.c
index 5344b0f60f..6c9675fa4e 100644
--- a/fontforge/python.c
+++ b/fontforge/python.c
@@ -760,7 +760,7 @@ static PyObject *PyFF_UnicodeAnnotationFromLib(PyObject *UNUSED(self), PyObject
     char *temp;
     long val;
 
-    if ( !PyArg_ParseTuple(args,"|i",&val) )
+    if ( !PyArg_ParseTuple(args,"|l",&val) )
 	return( NULL );
 
     if ( (temp=unicode_annot(val))==NULL ) {
@@ -777,7 +777,7 @@ static PyObject *PyFF_UnicodeNameFromLib(PyObject *UNUSED(self), PyObject *args)
     char *temp;
     long val;
 
-    if ( !PyArg_ParseTuple(args,"|i",&val) )
+    if ( !PyArg_ParseTuple(args,"|l",&val) )
 	return( NULL );
 
     if ( (temp=unicode_name(val))==NULL ) {
@@ -798,10 +798,10 @@ static PyObject *PyFF_UnicodeBlockStartFromLib(PyObject *UNUSED(self), PyObject
 /* Use this function with UnicodeBlockNameFromLib(n) & UnicodeBlockEndFromLib(n). */
     long val;
 
-    if ( !PyArg_ParseTuple(args,"|i",&val) )
+    if ( !PyArg_ParseTuple(args,"|l",&val) )
 	return( NULL );
 
-    return( Py_BuildValue("i", unicode_block_start(val)) );
+    return( Py_BuildValue("l", (long)unicode_block_start(val)) );
 }
 
 static PyObject *PyFF_UnicodeBlockEndFromLib(PyObject *UNUSED(self), PyObject *args) {
@@ -809,10 +809,10 @@ static PyObject *PyFF_UnicodeBlockEndFromLib(PyObject *UNUSED(self), PyObject *a
 /* Use this function with UnicodeBlockStartFromLib(n), UnicodeBlockNameFromLib(n) */
     long val;
 
-    if ( !PyArg_ParseTuple(args,"|i",&val) )
+    if ( !PyArg_ParseTuple(args,"|l",&val) )
 	return( NULL );
 
-    return( Py_BuildValue("i", unicode_block_end(val)) );
+    return( Py_BuildValue("l", (long)unicode_block_end(val)) );
 }
 
 static PyObject *PyFF_UnicodeBlockNameFromLib(PyObject *UNUSED(self), PyObject *args) {
@@ -822,7 +822,7 @@ static PyObject *PyFF_UnicodeBlockNameFromLib(PyObject *UNUSED(self), PyObject *
     char *temp;
     long val;
 
-    if ( !PyArg_ParseTuple(args,"|i",&val) )
+    if ( !PyArg_ParseTuple(args,"|l",&val) )
 	return( NULL );
 
     if ( (temp=unicode_block_name(val))==NULL ) {
@@ -853,24 +853,24 @@ static PyObject *PyFF_UnicodeNames2GetCntFromLib(PyObject *UNUSED(self), PyObjec
 static PyObject *PyFF_UnicodeNames2GetNxtFromLib(PyObject *UNUSED(self), PyObject *args) {
     long val;
 
-    if ( !PyArg_ParseTuple(args,"|i",&val) )
+    if ( !PyArg_ParseTuple(args,"|l",&val) )
 	return( NULL );
-    return( Py_BuildValue("i", unicode_names2getUtabLoc(val)) );
+    return( Py_BuildValue("l", (long)unicode_names2getUtabLoc(val)) );
 }
 
 static PyObject *PyFF_UnicodeNames2NxtUniFromLib(PyObject *UNUSED(self), PyObject *args) {
     long val;
 
-    if ( !PyArg_ParseTuple(args,"|i",&val) )
+    if ( !PyArg_ParseTuple(args,"|l",&val) )
 	return( NULL );
-    return( Py_BuildValue("i", unicode_names2valFrmTab(val)) );
+    return( Py_BuildValue("l", (long)unicode_names2valFrmTab(val)) );
 }
 
 static PyObject *PyFF_UnicodeNames2FrmTabFromLib(PyObject *UNUSED(self), PyObject *args) {
     long val;
     char *temp;
 
-    if ( !PyArg_ParseTuple(args,"|i",&val) )
+    if ( !PyArg_ParseTuple(args,"|l",&val) )
 	return( NULL );
     if ( (temp=unicode_name2FrmTab(val))==NULL ) {
 	return Py_BuildValue("s", "");
@@ -883,7 +883,7 @@ static PyObject *PyFF_UnicodeNames2FromLib(PyObject *UNUSED(self), PyObject *arg
     long val;
     char *temp;
 
-    if ( !PyArg_ParseTuple(args,"|i",&val) )
+    if ( !PyArg_ParseTuple(args,"|l",&val) )
 	return( NULL );
     if ( (temp=unicode_name2(val))==NULL ) {
 	return Py_BuildValue("s", "");
@@ -899,7 +899,7 @@ static PyObject *PyFF_UnicodeNames2FromLib(PyObject *UNUSED(self), PyObject *arg
 static PyObject *PyFF_isligature(PyObject *UNUSED(self), PyObject *args) {
     long codepoint;
 
-    if ( !PyArg_ParseTuple(args,"|i",&codepoint) )
+    if ( !PyArg_ParseTuple(args,"|l",&codepoint) )
 	return( NULL );
 
     return( Py_BuildValue("i", is_LIGATURE(codepoint)==0?1:0) );
@@ -908,7 +908,7 @@ static PyObject *PyFF_isligature(PyObject *UNUSED(self), PyObject *args) {
 static PyObject *PyFF_isvulgarfraction(PyObject *UNUSED(self), PyObject *args) {
     long codepoint;
 
-    if ( !PyArg_ParseTuple(args,"|i",&codepoint) )
+    if ( !PyArg_ParseTuple(args,"|l",&codepoint) )
 	return( NULL );
 
     return( Py_BuildValue("i", is_VULGAR_FRACTION(codepoint)==0?1:0) );
@@ -917,7 +917,7 @@ static PyObject *PyFF_isvulgarfraction(PyObject *UNUSED(self), PyObject *args) {
 static PyObject *PyFF_isotherfraction(PyObject *UNUSED(self), PyObject *args) {
     long codepoint;
 
-    if ( !PyArg_ParseTuple(args,"|i",&codepoint) )
+    if ( !PyArg_ParseTuple(args,"|l",&codepoint) )
 	return( NULL );
 
     return( Py_BuildValue("i", is_OTHER_FRACTION(codepoint)==0?1:0) );
@@ -926,7 +926,7 @@ static PyObject *PyFF_isotherfraction(PyObject *UNUSED(self), PyObject *args) {
 static PyObject *PyFF_isfraction(PyObject *UNUSED(self), PyObject *args) {
     long codepoint;
 
-    if ( !PyArg_ParseTuple(args,"|i",&codepoint) )
+    if ( !PyArg_ParseTuple(args,"|l",&codepoint) )
 	return( NULL );
 
     return( Py_BuildValue("i", (is_VULGAR_FRACTION(codepoint)==0 || \
@@ -957,28 +957,28 @@ static PyObject *PyFF_FracChartGetCnt(PyObject *UNUSED(self), PyObject *UNUSED(a
 static PyObject *PyFF_LigChartGetNxt(PyObject *UNUSED(self), PyObject *args) {
     long val;
 
-    if ( !PyArg_ParseTuple(args,"|i",&val) )
+    if ( !PyArg_ParseTuple(args,"|l",&val) )
 	return( NULL );
 
-    return( Py_BuildValue("i", Ligature_get_U(val)) );
+    return( Py_BuildValue("l", (long)Ligature_get_U(val)) );
 }
 
 static PyObject *PyFF_VulChartGetNxt(PyObject *UNUSED(self), PyObject *args) {
     long val;
 
-    if ( !PyArg_ParseTuple(args,"|i",&val) )
+    if ( !PyArg_ParseTuple(args,"|l",&val) )
 	return( NULL );
 
-    return( Py_BuildValue("i", VulgFrac_get_U(val)) );
+    return( Py_BuildValue("l", (long)VulgFrac_get_U(val)) );
 }
 
 static PyObject *PyFF_OFracChartGetNxt(PyObject *UNUSED(self), PyObject *args) {
     long val;
 
-    if ( !PyArg_ParseTuple(args,"|i",&val) )
+    if ( !PyArg_ParseTuple(args,"|l",&val) )
 	return( NULL );
 
-    return( Py_BuildValue("i", Fraction_get_U(val)) );
+    return( Py_BuildValue("l", (long)Fraction_get_U(val)) );
 }
 
 /* If you have a unicode ligature, or fraction, these routines return loc n. */
@@ -987,7 +987,7 @@ static PyObject *PyFF_OFracChartGetNxt(PyObject *UNUSED(self), PyObject *args) {
 static PyObject *PyFF_LigChartGetLoc(PyObject *UNUSED(self), PyObject *args) {
     long codepoint;
 
-    if ( !PyArg_ParseTuple(args,"|i",&codepoint) )
+    if ( !PyArg_ParseTuple(args,"|l",&codepoint) )
 	return( NULL );
 
     return( Py_BuildValue("i", Ligature_find_N(codepoint)) );
@@ -996,7 +996,7 @@ static PyObject *PyFF_LigChartGetLoc(PyObject *UNUSED(self), PyObject *args) {
 static PyObject *PyFF_VulChartGetLoc(PyObject *UNUSED(self), PyObject *args) {
     long codepoint;
 
-    if ( !PyArg_ParseTuple(args,"|i",&codepoint) )
+    if ( !PyArg_ParseTuple(args,"|l",&codepoint) )
 	return( NULL );
 
     return( Py_BuildValue("i", VulgFrac_find_N(codepoint)) );
@@ -1005,7 +1005,7 @@ static PyObject *PyFF_VulChartGetLoc(PyObject *UNUSED(self), PyObject *args) {
 static PyObject *PyFF_OFracChartGetLoc(PyObject *UNUSED(self), PyObject *args) {
     long codepoint;
 
-    if ( !PyArg_ParseTuple(args,"|i",&codepoint) )
+    if ( !PyArg_ParseTuple(args,"|l",&codepoint) )
 	return( NULL );
 
     return( Py_BuildValue("i", Fraction_find_N(codepoint)) );
@@ -1066,7 +1066,7 @@ static PyObject *PyFF_LigChartGetAltVal(PyObject *UNUSED(self), PyObject *args)
 
     if ( !PyArg_ParseTuple(args,"ll",&nthCode, &altN) )
 	return( NULL );
-    return( Py_BuildValue("i", Ligature_alt_getV(nthCode,altN)) );
+    return( Py_BuildValue("l", (long)Ligature_alt_getV(nthCode,altN)) );
 }
 
 static PyObject *PyFF_LigChartUGetAltVal(PyObject *UNUSED(self), PyObject *args) {
@@ -1074,7 +1074,7 @@ static PyObject *PyFF_LigChartUGetAltVal(PyObject *UNUSED(self), PyObject *args)
 
     if ( !PyArg_ParseTuple(args,"ll",&nthCode, &altN) )
 	return( NULL );
-    return( Py_BuildValue("i", LigatureU_alt_getV(nthCode,altN)) );
+    return( Py_BuildValue("l", (long)LigatureU_alt_getV(nthCode,altN)) );
 }
 
 static PyObject *PyFF_VulChartGetAltVal(PyObject *UNUSED(self), PyObject *args) {
@@ -1082,7 +1082,7 @@ static PyObject *PyFF_VulChartGetAltVal(PyObject *UNUSED(self), PyObject *args)
 
     if ( !PyArg_ParseTuple(args,"ll",&nthCode, &altN) )
 	return( NULL );
-    return( Py_BuildValue("i", VulgFrac_alt_getV(nthCode,altN)) );
+    return( Py_BuildValue("l", (long)VulgFrac_alt_getV(nthCode,altN)) );
 }
 
 static PyObject *PyFF_VulChartUGetAltVal(PyObject *UNUSED(self), PyObject *args) {
@@ -1090,7 +1090,7 @@ static PyObject *PyFF_VulChartUGetAltVal(PyObject *UNUSED(self), PyObject *args)
 
     if ( !PyArg_ParseTuple(args,"ll",&nthCode, &altN) )
 	return( NULL );
-    return( Py_BuildValue("i", VulgFracU_alt_getV(nthCode,altN)) );
+    return( Py_BuildValue("l", (long)VulgFracU_alt_getV(nthCode,altN)) );
 }
 
 static PyObject *PyFF_OFracChartGetAltVal(PyObject *UNUSED(self), PyObject *args) {
@@ -1098,7 +1098,7 @@ static PyObject *PyFF_OFracChartGetAltVal(PyObject *UNUSED(self), PyObject *args
 
     if ( !PyArg_ParseTuple(args,"ll",&nthCode, &altN) )
 	return( NULL );
-    return( Py_BuildValue("i", Fraction_alt_getV(nthCode,altN)) );
+    return( Py_BuildValue("l", (long)Fraction_alt_getV(nthCode,altN)) );
 }
 
 static PyObject *PyFF_OFracChartUGetAltVal(PyObject *UNUSED(self), PyObject *args) {
@@ -1106,7 +1106,7 @@ static PyObject *PyFF_OFracChartUGetAltVal(PyObject *UNUSED(self), PyObject *arg
 
     if ( !PyArg_ParseTuple(args,"ll",&nthCode, &altN) )
 	return( NULL );
-    return( Py_BuildValue("i", FractionU_alt_getV(nthCode,altN)) );
+    return( Py_BuildValue("l", (long)FractionU_alt_getV(nthCode,altN)) );
 }
 
 static PyObject *PyFF_Version(PyObject *UNUSED(self), PyObject *UNUSED(args)) {
@@ -1542,8 +1542,8 @@ return( ret );
 }
 
 static PyObject *PyFF_scriptFromUnicode(PyObject *UNUSED(self), PyObject *args) {
-    long u;
-    if ( !PyArg_ParseTuple(args,"i",&u) )
+    unsigned long u;
+    if ( !PyArg_ParseTuple(args,"k",&u) )
 	return( NULL );
 
     uint32 script = ScriptFromUnicode(u, NULL);