fonttools 4.57.0__py3-none-any.whl → 4.58.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fonttools might be problematic. Click here for more details.

Files changed (46) hide show
  1. fontTools/__init__.py +1 -1
  2. fontTools/cffLib/__init__.py +61 -26
  3. fontTools/designspaceLib/statNames.py +14 -7
  4. fontTools/feaLib/ast.py +84 -10
  5. fontTools/feaLib/builder.py +20 -4
  6. fontTools/feaLib/parser.py +1 -39
  7. fontTools/fontBuilder.py +6 -0
  8. fontTools/misc/etree.py +4 -27
  9. fontTools/mtiLib/__init__.py +0 -2
  10. fontTools/otlLib/builder.py +195 -145
  11. fontTools/otlLib/optimize/gpos.py +42 -62
  12. fontTools/pens/pointPen.py +21 -12
  13. fontTools/subset/__init__.py +11 -0
  14. fontTools/ttLib/tables/G_V_A_R_.py +5 -0
  15. fontTools/ttLib/tables/T_S_I__0.py +14 -3
  16. fontTools/ttLib/tables/T_S_I__5.py +16 -5
  17. fontTools/ttLib/tables/__init__.py +1 -0
  18. fontTools/ttLib/tables/_c_v_t.py +2 -0
  19. fontTools/ttLib/tables/_f_p_g_m.py +3 -1
  20. fontTools/ttLib/tables/_g_l_y_f.py +2 -6
  21. fontTools/ttLib/tables/_g_v_a_r.py +58 -15
  22. fontTools/ttLib/tables/_p_o_s_t.py +5 -2
  23. fontTools/ttLib/tables/otBase.py +1 -0
  24. fontTools/ufoLib/__init__.py +2 -2
  25. fontTools/ufoLib/converters.py +89 -25
  26. fontTools/ufoLib/errors.py +8 -0
  27. fontTools/ufoLib/etree.py +1 -1
  28. fontTools/ufoLib/filenames.py +155 -100
  29. fontTools/ufoLib/glifLib.py +9 -2
  30. fontTools/ufoLib/kerning.py +66 -36
  31. fontTools/ufoLib/utils.py +5 -2
  32. fontTools/unicodedata/Mirrored.py +446 -0
  33. fontTools/unicodedata/__init__.py +6 -2
  34. fontTools/varLib/__init__.py +2 -0
  35. fontTools/voltLib/__main__.py +206 -0
  36. fontTools/voltLib/ast.py +4 -0
  37. fontTools/voltLib/parser.py +16 -8
  38. fontTools/voltLib/voltToFea.py +347 -166
  39. {fonttools-4.57.0.dist-info → fonttools-4.58.0.dist-info}/METADATA +45 -11
  40. {fonttools-4.57.0.dist-info → fonttools-4.58.0.dist-info}/RECORD +46 -42
  41. {fonttools-4.57.0.dist-info → fonttools-4.58.0.dist-info}/WHEEL +1 -1
  42. fonttools-4.58.0.dist-info/licenses/LICENSE.external +359 -0
  43. {fonttools-4.57.0.data → fonttools-4.58.0.data}/data/share/man/man1/ttx.1 +0 -0
  44. {fonttools-4.57.0.dist-info → fonttools-4.58.0.dist-info}/entry_points.txt +0 -0
  45. {fonttools-4.57.0.dist-info → fonttools-4.58.0.dist-info}/licenses/LICENSE +0 -0
  46. {fonttools-4.57.0.dist-info → fonttools-4.58.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,446 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # NOTE: The mappings in this file were generated from the command line:
4
+ # cat BidiMirroring.txt | grep "^[0-9A-F]" | sed "s/;//" | awk '{print " 0x"$1": 0x"$2","}'
5
+ #
6
+ # Source: http://www.unicode.org/Public/UNIDATA/BidiMirroring.txt
7
+ # License: http://unicode.org/copyright.html#License
8
+ #
9
+ # BidiMirroring-16.0.0.txt
10
+ # Date: 2024-01-30
11
+ # © 2024 Unicode®, Inc.
12
+ # Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
13
+ # For terms of use and license, see https://www.unicode.org/terms_of_use.html
14
+ #
15
+ # Unicode Character Database
16
+ # For documentation, see https://www.unicode.org/reports/tr44/
17
+ MIRRORED = {
18
+ 0x0028: 0x0029,
19
+ 0x0029: 0x0028,
20
+ 0x003C: 0x003E,
21
+ 0x003E: 0x003C,
22
+ 0x005B: 0x005D,
23
+ 0x005D: 0x005B,
24
+ 0x007B: 0x007D,
25
+ 0x007D: 0x007B,
26
+ 0x00AB: 0x00BB,
27
+ 0x00BB: 0x00AB,
28
+ 0x0F3A: 0x0F3B,
29
+ 0x0F3B: 0x0F3A,
30
+ 0x0F3C: 0x0F3D,
31
+ 0x0F3D: 0x0F3C,
32
+ 0x169B: 0x169C,
33
+ 0x169C: 0x169B,
34
+ 0x2039: 0x203A,
35
+ 0x203A: 0x2039,
36
+ 0x2045: 0x2046,
37
+ 0x2046: 0x2045,
38
+ 0x207D: 0x207E,
39
+ 0x207E: 0x207D,
40
+ 0x208D: 0x208E,
41
+ 0x208E: 0x208D,
42
+ 0x2208: 0x220B,
43
+ 0x2209: 0x220C,
44
+ 0x220A: 0x220D,
45
+ 0x220B: 0x2208,
46
+ 0x220C: 0x2209,
47
+ 0x220D: 0x220A,
48
+ 0x2215: 0x29F5,
49
+ 0x221F: 0x2BFE,
50
+ 0x2220: 0x29A3,
51
+ 0x2221: 0x299B,
52
+ 0x2222: 0x29A0,
53
+ 0x2224: 0x2AEE,
54
+ 0x223C: 0x223D,
55
+ 0x223D: 0x223C,
56
+ 0x2243: 0x22CD,
57
+ 0x2245: 0x224C,
58
+ 0x224C: 0x2245,
59
+ 0x2252: 0x2253,
60
+ 0x2253: 0x2252,
61
+ 0x2254: 0x2255,
62
+ 0x2255: 0x2254,
63
+ 0x2264: 0x2265,
64
+ 0x2265: 0x2264,
65
+ 0x2266: 0x2267,
66
+ 0x2267: 0x2266,
67
+ 0x2268: 0x2269,
68
+ 0x2269: 0x2268,
69
+ 0x226A: 0x226B,
70
+ 0x226B: 0x226A,
71
+ 0x226E: 0x226F,
72
+ 0x226F: 0x226E,
73
+ 0x2270: 0x2271,
74
+ 0x2271: 0x2270,
75
+ 0x2272: 0x2273,
76
+ 0x2273: 0x2272,
77
+ 0x2274: 0x2275,
78
+ 0x2275: 0x2274,
79
+ 0x2276: 0x2277,
80
+ 0x2277: 0x2276,
81
+ 0x2278: 0x2279,
82
+ 0x2279: 0x2278,
83
+ 0x227A: 0x227B,
84
+ 0x227B: 0x227A,
85
+ 0x227C: 0x227D,
86
+ 0x227D: 0x227C,
87
+ 0x227E: 0x227F,
88
+ 0x227F: 0x227E,
89
+ 0x2280: 0x2281,
90
+ 0x2281: 0x2280,
91
+ 0x2282: 0x2283,
92
+ 0x2283: 0x2282,
93
+ 0x2284: 0x2285,
94
+ 0x2285: 0x2284,
95
+ 0x2286: 0x2287,
96
+ 0x2287: 0x2286,
97
+ 0x2288: 0x2289,
98
+ 0x2289: 0x2288,
99
+ 0x228A: 0x228B,
100
+ 0x228B: 0x228A,
101
+ 0x228F: 0x2290,
102
+ 0x2290: 0x228F,
103
+ 0x2291: 0x2292,
104
+ 0x2292: 0x2291,
105
+ 0x2298: 0x29B8,
106
+ 0x22A2: 0x22A3,
107
+ 0x22A3: 0x22A2,
108
+ 0x22A6: 0x2ADE,
109
+ 0x22A8: 0x2AE4,
110
+ 0x22A9: 0x2AE3,
111
+ 0x22AB: 0x2AE5,
112
+ 0x22B0: 0x22B1,
113
+ 0x22B1: 0x22B0,
114
+ 0x22B2: 0x22B3,
115
+ 0x22B3: 0x22B2,
116
+ 0x22B4: 0x22B5,
117
+ 0x22B5: 0x22B4,
118
+ 0x22B6: 0x22B7,
119
+ 0x22B7: 0x22B6,
120
+ 0x22B8: 0x27DC,
121
+ 0x22C9: 0x22CA,
122
+ 0x22CA: 0x22C9,
123
+ 0x22CB: 0x22CC,
124
+ 0x22CC: 0x22CB,
125
+ 0x22CD: 0x2243,
126
+ 0x22D0: 0x22D1,
127
+ 0x22D1: 0x22D0,
128
+ 0x22D6: 0x22D7,
129
+ 0x22D7: 0x22D6,
130
+ 0x22D8: 0x22D9,
131
+ 0x22D9: 0x22D8,
132
+ 0x22DA: 0x22DB,
133
+ 0x22DB: 0x22DA,
134
+ 0x22DC: 0x22DD,
135
+ 0x22DD: 0x22DC,
136
+ 0x22DE: 0x22DF,
137
+ 0x22DF: 0x22DE,
138
+ 0x22E0: 0x22E1,
139
+ 0x22E1: 0x22E0,
140
+ 0x22E2: 0x22E3,
141
+ 0x22E3: 0x22E2,
142
+ 0x22E4: 0x22E5,
143
+ 0x22E5: 0x22E4,
144
+ 0x22E6: 0x22E7,
145
+ 0x22E7: 0x22E6,
146
+ 0x22E8: 0x22E9,
147
+ 0x22E9: 0x22E8,
148
+ 0x22EA: 0x22EB,
149
+ 0x22EB: 0x22EA,
150
+ 0x22EC: 0x22ED,
151
+ 0x22ED: 0x22EC,
152
+ 0x22F0: 0x22F1,
153
+ 0x22F1: 0x22F0,
154
+ 0x22F2: 0x22FA,
155
+ 0x22F3: 0x22FB,
156
+ 0x22F4: 0x22FC,
157
+ 0x22F6: 0x22FD,
158
+ 0x22F7: 0x22FE,
159
+ 0x22FA: 0x22F2,
160
+ 0x22FB: 0x22F3,
161
+ 0x22FC: 0x22F4,
162
+ 0x22FD: 0x22F6,
163
+ 0x22FE: 0x22F7,
164
+ 0x2308: 0x2309,
165
+ 0x2309: 0x2308,
166
+ 0x230A: 0x230B,
167
+ 0x230B: 0x230A,
168
+ 0x2329: 0x232A,
169
+ 0x232A: 0x2329,
170
+ 0x2768: 0x2769,
171
+ 0x2769: 0x2768,
172
+ 0x276A: 0x276B,
173
+ 0x276B: 0x276A,
174
+ 0x276C: 0x276D,
175
+ 0x276D: 0x276C,
176
+ 0x276E: 0x276F,
177
+ 0x276F: 0x276E,
178
+ 0x2770: 0x2771,
179
+ 0x2771: 0x2770,
180
+ 0x2772: 0x2773,
181
+ 0x2773: 0x2772,
182
+ 0x2774: 0x2775,
183
+ 0x2775: 0x2774,
184
+ 0x27C3: 0x27C4,
185
+ 0x27C4: 0x27C3,
186
+ 0x27C5: 0x27C6,
187
+ 0x27C6: 0x27C5,
188
+ 0x27C8: 0x27C9,
189
+ 0x27C9: 0x27C8,
190
+ 0x27CB: 0x27CD,
191
+ 0x27CD: 0x27CB,
192
+ 0x27D5: 0x27D6,
193
+ 0x27D6: 0x27D5,
194
+ 0x27DC: 0x22B8,
195
+ 0x27DD: 0x27DE,
196
+ 0x27DE: 0x27DD,
197
+ 0x27E2: 0x27E3,
198
+ 0x27E3: 0x27E2,
199
+ 0x27E4: 0x27E5,
200
+ 0x27E5: 0x27E4,
201
+ 0x27E6: 0x27E7,
202
+ 0x27E7: 0x27E6,
203
+ 0x27E8: 0x27E9,
204
+ 0x27E9: 0x27E8,
205
+ 0x27EA: 0x27EB,
206
+ 0x27EB: 0x27EA,
207
+ 0x27EC: 0x27ED,
208
+ 0x27ED: 0x27EC,
209
+ 0x27EE: 0x27EF,
210
+ 0x27EF: 0x27EE,
211
+ 0x2983: 0x2984,
212
+ 0x2984: 0x2983,
213
+ 0x2985: 0x2986,
214
+ 0x2986: 0x2985,
215
+ 0x2987: 0x2988,
216
+ 0x2988: 0x2987,
217
+ 0x2989: 0x298A,
218
+ 0x298A: 0x2989,
219
+ 0x298B: 0x298C,
220
+ 0x298C: 0x298B,
221
+ 0x298D: 0x2990,
222
+ 0x298E: 0x298F,
223
+ 0x298F: 0x298E,
224
+ 0x2990: 0x298D,
225
+ 0x2991: 0x2992,
226
+ 0x2992: 0x2991,
227
+ 0x2993: 0x2994,
228
+ 0x2994: 0x2993,
229
+ 0x2995: 0x2996,
230
+ 0x2996: 0x2995,
231
+ 0x2997: 0x2998,
232
+ 0x2998: 0x2997,
233
+ 0x299B: 0x2221,
234
+ 0x29A0: 0x2222,
235
+ 0x29A3: 0x2220,
236
+ 0x29A4: 0x29A5,
237
+ 0x29A5: 0x29A4,
238
+ 0x29A8: 0x29A9,
239
+ 0x29A9: 0x29A8,
240
+ 0x29AA: 0x29AB,
241
+ 0x29AB: 0x29AA,
242
+ 0x29AC: 0x29AD,
243
+ 0x29AD: 0x29AC,
244
+ 0x29AE: 0x29AF,
245
+ 0x29AF: 0x29AE,
246
+ 0x29B8: 0x2298,
247
+ 0x29C0: 0x29C1,
248
+ 0x29C1: 0x29C0,
249
+ 0x29C4: 0x29C5,
250
+ 0x29C5: 0x29C4,
251
+ 0x29CF: 0x29D0,
252
+ 0x29D0: 0x29CF,
253
+ 0x29D1: 0x29D2,
254
+ 0x29D2: 0x29D1,
255
+ 0x29D4: 0x29D5,
256
+ 0x29D5: 0x29D4,
257
+ 0x29D8: 0x29D9,
258
+ 0x29D9: 0x29D8,
259
+ 0x29DA: 0x29DB,
260
+ 0x29DB: 0x29DA,
261
+ 0x29E8: 0x29E9,
262
+ 0x29E9: 0x29E8,
263
+ 0x29F5: 0x2215,
264
+ 0x29F8: 0x29F9,
265
+ 0x29F9: 0x29F8,
266
+ 0x29FC: 0x29FD,
267
+ 0x29FD: 0x29FC,
268
+ 0x2A2B: 0x2A2C,
269
+ 0x2A2C: 0x2A2B,
270
+ 0x2A2D: 0x2A2E,
271
+ 0x2A2E: 0x2A2D,
272
+ 0x2A34: 0x2A35,
273
+ 0x2A35: 0x2A34,
274
+ 0x2A3C: 0x2A3D,
275
+ 0x2A3D: 0x2A3C,
276
+ 0x2A64: 0x2A65,
277
+ 0x2A65: 0x2A64,
278
+ 0x2A79: 0x2A7A,
279
+ 0x2A7A: 0x2A79,
280
+ 0x2A7B: 0x2A7C,
281
+ 0x2A7C: 0x2A7B,
282
+ 0x2A7D: 0x2A7E,
283
+ 0x2A7E: 0x2A7D,
284
+ 0x2A7F: 0x2A80,
285
+ 0x2A80: 0x2A7F,
286
+ 0x2A81: 0x2A82,
287
+ 0x2A82: 0x2A81,
288
+ 0x2A83: 0x2A84,
289
+ 0x2A84: 0x2A83,
290
+ 0x2A85: 0x2A86,
291
+ 0x2A86: 0x2A85,
292
+ 0x2A87: 0x2A88,
293
+ 0x2A88: 0x2A87,
294
+ 0x2A89: 0x2A8A,
295
+ 0x2A8A: 0x2A89,
296
+ 0x2A8B: 0x2A8C,
297
+ 0x2A8C: 0x2A8B,
298
+ 0x2A8D: 0x2A8E,
299
+ 0x2A8E: 0x2A8D,
300
+ 0x2A8F: 0x2A90,
301
+ 0x2A90: 0x2A8F,
302
+ 0x2A91: 0x2A92,
303
+ 0x2A92: 0x2A91,
304
+ 0x2A93: 0x2A94,
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5A: 0x2E59,
406
+ 0x2E5B: 0x2E5C,
407
+ 0x2E5C: 0x2E5B,
408
+ 0x3008: 0x3009,
409
+ 0x3009: 0x3008,
410
+ 0x300A: 0x300B,
411
+ 0x300B: 0x300A,
412
+ 0x300C: 0x300D,
413
+ 0x300D: 0x300C,
414
+ 0x300E: 0x300F,
415
+ 0x300F: 0x300E,
416
+ 0x3010: 0x3011,
417
+ 0x3011: 0x3010,
418
+ 0x3014: 0x3015,
419
+ 0x3015: 0x3014,
420
+ 0x3016: 0x3017,
421
+ 0x3017: 0x3016,
422
+ 0x3018: 0x3019,
423
+ 0x3019: 0x3018,
424
+ 0x301A: 0x301B,
425
+ 0x301B: 0x301A,
426
+ 0xFE59: 0xFE5A,
427
+ 0xFE5A: 0xFE59,
428
+ 0xFE5B: 0xFE5C,
429
+ 0xFE5C: 0xFE5B,
430
+ 0xFE5D: 0xFE5E,
431
+ 0xFE5E: 0xFE5D,
432
+ 0xFE64: 0xFE65,
433
+ 0xFE65: 0xFE64,
434
+ 0xFF08: 0xFF09,
435
+ 0xFF09: 0xFF08,
436
+ 0xFF1C: 0xFF1E,
437
+ 0xFF1E: 0xFF1C,
438
+ 0xFF3B: 0xFF3D,
439
+ 0xFF3D: 0xFF3B,
440
+ 0xFF5B: 0xFF5D,
441
+ 0xFF5D: 0xFF5B,
442
+ 0xFF5F: 0xFF60,
443
+ 0xFF60: 0xFF5F,
444
+ 0xFF62: 0xFF63,
445
+ 0xFF63: 0xFF62,
446
+ }
@@ -15,8 +15,7 @@ except ImportError: # pragma: no cover
15
15
  # fall back to built-in unicodedata (possibly outdated)
16
16
  from unicodedata import *
17
17
 
18
- from . import Blocks, Scripts, ScriptExtensions, OTTags
19
-
18
+ from . import Blocks, Mirrored, Scripts, ScriptExtensions, OTTags
20
19
 
21
20
  __all__ = [
22
21
  # names from built-in unicodedata module
@@ -46,6 +45,11 @@ __all__ = [
46
45
  ]
47
46
 
48
47
 
48
+ def mirrored(code):
49
+ """If code (unicode codepoint) has a mirrored version returns it, otherwise None."""
50
+ return Mirrored.MIRRORED.get(code)
51
+
52
+
49
53
  def script(char):
50
54
  """Return the four-letter script code assigned to the Unicode character
51
55
  'char' as string.
@@ -555,6 +555,8 @@ def _add_VHVAR(font, axisTags, tableFields, getAdvanceMetrics):
555
555
  varData.addItem(vhAdvanceDeltasAndSupports[glyphName][0], round=noRound)
556
556
  varData.optimize()
557
557
  directStore = builder.buildVarStore(varTupleList, [varData])
558
+ # remove unused regions from VarRegionList
559
+ directStore.prune_regions()
558
560
 
559
561
  # Build optimized indirect mapping
560
562
  storeBuilder = varStore.OnlineVarStoreBuilder(axisTags)
@@ -0,0 +1,206 @@
1
+ import argparse
2
+ import logging
3
+ import sys
4
+ from io import StringIO
5
+ from pathlib import Path
6
+
7
+ from fontTools import configLogger
8
+ from fontTools.feaLib.builder import addOpenTypeFeaturesFromString
9
+ from fontTools.feaLib.error import FeatureLibError
10
+ from fontTools.feaLib.lexer import Lexer
11
+ from fontTools.misc.cliTools import makeOutputFileName
12
+ from fontTools.ttLib import TTFont, TTLibError
13
+ from fontTools.voltLib.parser import Parser
14
+ from fontTools.voltLib.voltToFea import TABLES, VoltToFea
15
+
16
+ log = logging.getLogger("fontTools.feaLib")
17
+
18
+ SUPPORTED_TABLES = TABLES + ["cmap"]
19
+
20
+
21
+ def invalid_fea_glyph_name(name):
22
+ """Check if the glyph name is valid according to FEA syntax."""
23
+ if name[0] not in Lexer.CHAR_NAME_START_:
24
+ return True
25
+ if any(c not in Lexer.CHAR_NAME_CONTINUATION_ for c in name[1:]):
26
+ return True
27
+ return False
28
+
29
+
30
+ def sanitize_glyph_name(name):
31
+ """Sanitize the glyph name to ensure it is valid according to FEA syntax."""
32
+ sanitized = ""
33
+ for i, c in enumerate(name):
34
+ if i == 0 and c not in Lexer.CHAR_NAME_START_:
35
+ sanitized += "a" + c
36
+ elif c not in Lexer.CHAR_NAME_CONTINUATION_:
37
+ sanitized += "_"
38
+ else:
39
+ sanitized += c
40
+
41
+ return sanitized
42
+
43
+
44
+ def main(args=None):
45
+ """Build tables from a MS VOLT project into an OTF font"""
46
+ parser = argparse.ArgumentParser(
47
+ description="Use fontTools to compile MS VOLT projects."
48
+ )
49
+ parser.add_argument(
50
+ "input",
51
+ metavar="INPUT",
52
+ help="Path to the input font/VTP file to process",
53
+ type=Path,
54
+ )
55
+ parser.add_argument(
56
+ "-f",
57
+ "--font",
58
+ metavar="INPUT_FONT",
59
+ help="Path to the input font (if INPUT is a VTP file)",
60
+ type=Path,
61
+ )
62
+ parser.add_argument(
63
+ "-o",
64
+ "--output",
65
+ dest="output",
66
+ metavar="OUTPUT",
67
+ help="Path to the output font.",
68
+ type=Path,
69
+ )
70
+ parser.add_argument(
71
+ "-t",
72
+ "--tables",
73
+ metavar="TABLE_TAG",
74
+ choices=SUPPORTED_TABLES,
75
+ nargs="+",
76
+ help="Specify the table(s) to be built.",
77
+ )
78
+ parser.add_argument(
79
+ "-F",
80
+ "--debug-feature-file",
81
+ help="Write the generated feature file to disk.",
82
+ action="store_true",
83
+ )
84
+ parser.add_argument(
85
+ "--ship",
86
+ help="Remove source VOLT tables from output font.",
87
+ action="store_true",
88
+ )
89
+ parser.add_argument(
90
+ "-v",
91
+ "--verbose",
92
+ help="Increase the logger verbosity. Multiple -v options are allowed.",
93
+ action="count",
94
+ default=0,
95
+ )
96
+ parser.add_argument(
97
+ "-T",
98
+ "--traceback",
99
+ help="show traceback for exceptions.",
100
+ action="store_true",
101
+ )
102
+ options = parser.parse_args(args)
103
+
104
+ levels = ["WARNING", "INFO", "DEBUG"]
105
+ configLogger(level=levels[min(len(levels) - 1, options.verbose)])
106
+
107
+ output_font = options.output or Path(
108
+ makeOutputFileName(options.font or options.input)
109
+ )
110
+ log.info(f"Compiling MS VOLT to '{output_font}'")
111
+
112
+ file_or_path = options.input
113
+ font = None
114
+
115
+ # If the input is a font file, extract the VOLT data from the "TSIV" table
116
+ try:
117
+ font = TTFont(file_or_path)
118
+ if "TSIV" in font:
119
+ file_or_path = StringIO(font["TSIV"].data.decode("utf-8"))
120
+ else:
121
+ log.error('"TSIV" table is missing')
122
+ return 1
123
+ except TTLibError:
124
+ pass
125
+
126
+ # If input is not a font file, the font must be provided
127
+ if font is None:
128
+ if not options.font:
129
+ log.error("Please provide an input font")
130
+ return 1
131
+ font = TTFont(options.font)
132
+
133
+ # FEA syntax does not allow some glyph names that VOLT accepts, so if we
134
+ # found such glyph name we will temporarily rename such glyphs.
135
+ glyphOrder = font.getGlyphOrder()
136
+ tempGlyphOrder = None
137
+ if any(invalid_fea_glyph_name(n) for n in glyphOrder):
138
+ tempGlyphOrder = []
139
+ for n in glyphOrder:
140
+ if invalid_fea_glyph_name(n):
141
+ n = sanitize_glyph_name(n)
142
+ existing = set(tempGlyphOrder) | set(glyphOrder)
143
+ while n in existing:
144
+ n = "a" + n
145
+ tempGlyphOrder.append(n)
146
+ font.setGlyphOrder(tempGlyphOrder)
147
+
148
+ doc = Parser(file_or_path).parse()
149
+
150
+ log.info("Converting VTP data to FEA")
151
+ converter = VoltToFea(doc, font)
152
+ try:
153
+ fea = converter.convert(options.tables, ignore_unsupported_settings=True)
154
+ except NotImplementedError as e:
155
+ if options.traceback:
156
+ raise
157
+ location = getattr(e.args[0], "location", None)
158
+ message = f'"{e}" is not supported'
159
+ if location:
160
+ path, line, column = location
161
+ log.error(f"{path}:{line}:{column}: {message}")
162
+ else:
163
+ log.error(message)
164
+ return 1
165
+
166
+ fea_filename = options.input
167
+ if options.debug_feature_file:
168
+ fea_filename = output_font.with_suffix(".fea")
169
+ log.info(f"Writing FEA to '{fea_filename}'")
170
+ with open(fea_filename, "w") as fp:
171
+ fp.write(fea)
172
+
173
+ log.info("Compiling FEA to OpenType tables")
174
+ try:
175
+ addOpenTypeFeaturesFromString(
176
+ font,
177
+ fea,
178
+ filename=fea_filename,
179
+ tables=options.tables,
180
+ )
181
+ except FeatureLibError as e:
182
+ if options.traceback:
183
+ raise
184
+ log.error(e)
185
+ return 1
186
+
187
+ if options.ship:
188
+ for tag in ["TSIV", "TSIS", "TSIP", "TSID"]:
189
+ if tag in font:
190
+ del font[tag]
191
+
192
+ # Restore original glyph names.
193
+ if tempGlyphOrder:
194
+ import io
195
+
196
+ f = io.BytesIO()
197
+ font.save(f)
198
+ font = TTFont(f)
199
+ font.setGlyphOrder(glyphOrder)
200
+ font["post"].extraNames = []
201
+
202
+ font.save(output_font)
203
+
204
+
205
+ if __name__ == "__main__":
206
+ sys.exit(main())
fontTools/voltLib/ast.py CHANGED
@@ -317,6 +317,10 @@ class SubstitutionLigatureDefinition(SubstitutionDefinition):
317
317
  pass
318
318
 
319
319
 
320
+ class SubstitutionAlternateDefinition(SubstitutionDefinition):
321
+ pass
322
+
323
+
320
324
  class SubstitutionReverseChainingSingleDefinition(SubstitutionDefinition):
321
325
  pass
322
326