fonttools 4.55.4__cp313-cp313-musllinux_1_2_aarch64.whl → 4.61.1__cp313-cp313-musllinux_1_2_aarch64.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.
Files changed (140) hide show
  1. fontTools/__init__.py +1 -1
  2. fontTools/annotations.py +30 -0
  3. fontTools/cffLib/CFF2ToCFF.py +65 -10
  4. fontTools/cffLib/__init__.py +61 -26
  5. fontTools/cffLib/specializer.py +4 -1
  6. fontTools/cffLib/transforms.py +11 -6
  7. fontTools/config/__init__.py +15 -0
  8. fontTools/cu2qu/cu2qu.c +6567 -5579
  9. fontTools/cu2qu/cu2qu.cpython-313-aarch64-linux-musl.so +0 -0
  10. fontTools/cu2qu/cu2qu.py +36 -4
  11. fontTools/cu2qu/ufo.py +14 -0
  12. fontTools/designspaceLib/__init__.py +8 -3
  13. fontTools/designspaceLib/statNames.py +14 -7
  14. fontTools/feaLib/ast.py +24 -15
  15. fontTools/feaLib/builder.py +139 -66
  16. fontTools/feaLib/error.py +1 -1
  17. fontTools/feaLib/lexer.c +7038 -7995
  18. fontTools/feaLib/lexer.cpython-313-aarch64-linux-musl.so +0 -0
  19. fontTools/feaLib/parser.py +75 -40
  20. fontTools/feaLib/variableScalar.py +6 -1
  21. fontTools/fontBuilder.py +50 -44
  22. fontTools/merge/__init__.py +1 -1
  23. fontTools/merge/cmap.py +33 -1
  24. fontTools/merge/tables.py +12 -1
  25. fontTools/misc/bezierTools.c +14913 -17013
  26. fontTools/misc/bezierTools.cpython-313-aarch64-linux-musl.so +0 -0
  27. fontTools/misc/bezierTools.py +4 -1
  28. fontTools/misc/configTools.py +3 -1
  29. fontTools/misc/enumTools.py +23 -0
  30. fontTools/misc/etree.py +4 -27
  31. fontTools/misc/filesystem/__init__.py +68 -0
  32. fontTools/misc/filesystem/_base.py +134 -0
  33. fontTools/misc/filesystem/_copy.py +45 -0
  34. fontTools/misc/filesystem/_errors.py +54 -0
  35. fontTools/misc/filesystem/_info.py +75 -0
  36. fontTools/misc/filesystem/_osfs.py +164 -0
  37. fontTools/misc/filesystem/_path.py +67 -0
  38. fontTools/misc/filesystem/_subfs.py +92 -0
  39. fontTools/misc/filesystem/_tempfs.py +34 -0
  40. fontTools/misc/filesystem/_tools.py +34 -0
  41. fontTools/misc/filesystem/_walk.py +55 -0
  42. fontTools/misc/filesystem/_zipfs.py +204 -0
  43. fontTools/misc/fixedTools.py +1 -1
  44. fontTools/misc/loggingTools.py +1 -1
  45. fontTools/misc/psCharStrings.py +17 -2
  46. fontTools/misc/sstruct.py +2 -6
  47. fontTools/misc/symfont.py +6 -8
  48. fontTools/misc/testTools.py +5 -1
  49. fontTools/misc/textTools.py +4 -2
  50. fontTools/misc/visitor.py +32 -16
  51. fontTools/misc/xmlWriter.py +44 -8
  52. fontTools/mtiLib/__init__.py +1 -3
  53. fontTools/otlLib/builder.py +402 -155
  54. fontTools/otlLib/optimize/gpos.py +49 -63
  55. fontTools/pens/filterPen.py +218 -26
  56. fontTools/pens/momentsPen.c +5514 -5584
  57. fontTools/pens/momentsPen.cpython-313-aarch64-linux-musl.so +0 -0
  58. fontTools/pens/pointPen.py +61 -18
  59. fontTools/pens/roundingPen.py +2 -2
  60. fontTools/pens/t2CharStringPen.py +31 -11
  61. fontTools/qu2cu/qu2cu.c +6581 -6168
  62. fontTools/qu2cu/qu2cu.cpython-313-aarch64-linux-musl.so +0 -0
  63. fontTools/subset/__init__.py +283 -25
  64. fontTools/subset/svg.py +2 -3
  65. fontTools/ttLib/__init__.py +4 -0
  66. fontTools/ttLib/__main__.py +47 -8
  67. fontTools/ttLib/removeOverlaps.py +7 -5
  68. fontTools/ttLib/reorderGlyphs.py +8 -7
  69. fontTools/ttLib/sfnt.py +11 -9
  70. fontTools/ttLib/tables/D__e_b_g.py +20 -2
  71. fontTools/ttLib/tables/G_V_A_R_.py +5 -0
  72. fontTools/ttLib/tables/S__i_l_f.py +2 -2
  73. fontTools/ttLib/tables/T_S_I__0.py +14 -3
  74. fontTools/ttLib/tables/T_S_I__1.py +2 -5
  75. fontTools/ttLib/tables/T_S_I__5.py +18 -7
  76. fontTools/ttLib/tables/__init__.py +1 -0
  77. fontTools/ttLib/tables/_a_v_a_r.py +12 -3
  78. fontTools/ttLib/tables/_c_m_a_p.py +20 -7
  79. fontTools/ttLib/tables/_c_v_t.py +3 -2
  80. fontTools/ttLib/tables/_f_p_g_m.py +3 -1
  81. fontTools/ttLib/tables/_g_l_y_f.py +45 -21
  82. fontTools/ttLib/tables/_g_v_a_r.py +67 -19
  83. fontTools/ttLib/tables/_h_d_m_x.py +4 -4
  84. fontTools/ttLib/tables/_h_m_t_x.py +7 -3
  85. fontTools/ttLib/tables/_l_o_c_a.py +2 -2
  86. fontTools/ttLib/tables/_n_a_m_e.py +11 -6
  87. fontTools/ttLib/tables/_p_o_s_t.py +9 -7
  88. fontTools/ttLib/tables/otBase.py +5 -12
  89. fontTools/ttLib/tables/otConverters.py +5 -2
  90. fontTools/ttLib/tables/otData.py +1 -1
  91. fontTools/ttLib/tables/otTables.py +33 -30
  92. fontTools/ttLib/tables/otTraverse.py +2 -1
  93. fontTools/ttLib/tables/sbixStrike.py +3 -3
  94. fontTools/ttLib/ttFont.py +666 -120
  95. fontTools/ttLib/ttGlyphSet.py +0 -10
  96. fontTools/ttLib/woff2.py +10 -13
  97. fontTools/ttx.py +13 -1
  98. fontTools/ufoLib/__init__.py +300 -202
  99. fontTools/ufoLib/converters.py +103 -30
  100. fontTools/ufoLib/errors.py +8 -0
  101. fontTools/ufoLib/etree.py +1 -1
  102. fontTools/ufoLib/filenames.py +171 -106
  103. fontTools/ufoLib/glifLib.py +303 -205
  104. fontTools/ufoLib/kerning.py +98 -48
  105. fontTools/ufoLib/utils.py +46 -15
  106. fontTools/ufoLib/validators.py +121 -99
  107. fontTools/unicodedata/Blocks.py +35 -20
  108. fontTools/unicodedata/Mirrored.py +446 -0
  109. fontTools/unicodedata/ScriptExtensions.py +63 -37
  110. fontTools/unicodedata/Scripts.py +173 -152
  111. fontTools/unicodedata/__init__.py +10 -2
  112. fontTools/varLib/__init__.py +198 -109
  113. fontTools/varLib/avar/__init__.py +0 -0
  114. fontTools/varLib/avar/__main__.py +72 -0
  115. fontTools/varLib/avar/build.py +79 -0
  116. fontTools/varLib/avar/map.py +108 -0
  117. fontTools/varLib/avar/plan.py +1004 -0
  118. fontTools/varLib/{avar.py → avar/unbuild.py} +70 -59
  119. fontTools/varLib/avarPlanner.py +3 -999
  120. fontTools/varLib/featureVars.py +21 -7
  121. fontTools/varLib/hvar.py +113 -0
  122. fontTools/varLib/instancer/__init__.py +180 -65
  123. fontTools/varLib/interpolatableHelpers.py +3 -0
  124. fontTools/varLib/iup.c +7564 -6903
  125. fontTools/varLib/iup.cpython-313-aarch64-linux-musl.so +0 -0
  126. fontTools/varLib/models.py +17 -2
  127. fontTools/varLib/mutator.py +11 -0
  128. fontTools/varLib/varStore.py +10 -38
  129. fontTools/voltLib/__main__.py +206 -0
  130. fontTools/voltLib/ast.py +4 -0
  131. fontTools/voltLib/parser.py +16 -8
  132. fontTools/voltLib/voltToFea.py +347 -166
  133. {fonttools-4.55.4.dist-info → fonttools-4.61.1.dist-info}/METADATA +269 -1410
  134. {fonttools-4.55.4.dist-info → fonttools-4.61.1.dist-info}/RECORD +318 -294
  135. {fonttools-4.55.4.dist-info → fonttools-4.61.1.dist-info}/WHEEL +1 -1
  136. fonttools-4.61.1.dist-info/licenses/LICENSE.external +388 -0
  137. {fonttools-4.55.4.data → fonttools-4.61.1.data}/data/share/man/man1/ttx.1 +0 -0
  138. {fonttools-4.55.4.dist-info → fonttools-4.61.1.dist-info}/entry_points.txt +0 -0
  139. {fonttools-4.55.4.dist-info → fonttools-4.61.1.dist-info/licenses}/LICENSE +0 -0
  140. {fonttools-4.55.4.dist-info → fonttools-4.61.1.dist-info}/top_level.txt +0 -0
@@ -1,20 +1,25 @@
1
1
  """Various low level data validators."""
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  import calendar
6
+ from collections.abc import Mapping, Sequence
4
7
  from io import open
5
- import fs.base
6
- import fs.osfs
7
8
 
8
- from collections.abc import Mapping
9
+ import fontTools.misc.filesystem as fs
10
+ from typing import Any, Type, Optional, Union
11
+
12
+ from fontTools.annotations import IntFloat
9
13
  from fontTools.ufoLib.utils import numberTypes
10
14
 
15
+ GenericDict = dict[str, tuple[Union[type, tuple[Type[Any], ...]], bool]]
11
16
 
12
17
  # -------
13
18
  # Generic
14
19
  # -------
15
20
 
16
21
 
17
- def isDictEnough(value):
22
+ def isDictEnough(value: Any) -> bool:
18
23
  """
19
24
  Some objects will likely come in that aren't
20
25
  dicts but are dict-ish enough.
@@ -27,14 +32,14 @@ def isDictEnough(value):
27
32
  return True
28
33
 
29
34
 
30
- def genericTypeValidator(value, typ):
35
+ def genericTypeValidator(value: Any, typ: Type[Any]) -> bool:
31
36
  """
32
37
  Generic. (Added at version 2.)
33
38
  """
34
39
  return isinstance(value, typ)
35
40
 
36
41
 
37
- def genericIntListValidator(values, validValues):
42
+ def genericIntListValidator(values: Any, validValues: Sequence[int]) -> bool:
38
43
  """
39
44
  Generic. (Added at version 2.)
40
45
  """
@@ -50,7 +55,7 @@ def genericIntListValidator(values, validValues):
50
55
  return True
51
56
 
52
57
 
53
- def genericNonNegativeIntValidator(value):
58
+ def genericNonNegativeIntValidator(value: Any) -> bool:
54
59
  """
55
60
  Generic. (Added at version 3.)
56
61
  """
@@ -61,7 +66,7 @@ def genericNonNegativeIntValidator(value):
61
66
  return True
62
67
 
63
68
 
64
- def genericNonNegativeNumberValidator(value):
69
+ def genericNonNegativeNumberValidator(value: Any) -> bool:
65
70
  """
66
71
  Generic. (Added at version 3.)
67
72
  """
@@ -72,7 +77,7 @@ def genericNonNegativeNumberValidator(value):
72
77
  return True
73
78
 
74
79
 
75
- def genericDictValidator(value, prototype):
80
+ def genericDictValidator(value: Any, prototype: GenericDict) -> bool:
76
81
  """
77
82
  Generic. (Added at version 3.)
78
83
  """
@@ -106,7 +111,7 @@ def genericDictValidator(value, prototype):
106
111
  # Data Validators
107
112
 
108
113
 
109
- def fontInfoStyleMapStyleNameValidator(value):
114
+ def fontInfoStyleMapStyleNameValidator(value: Any) -> bool:
110
115
  """
111
116
  Version 2+.
112
117
  """
@@ -114,7 +119,7 @@ def fontInfoStyleMapStyleNameValidator(value):
114
119
  return value in options
115
120
 
116
121
 
117
- def fontInfoOpenTypeGaspRangeRecordsValidator(value):
122
+ def fontInfoOpenTypeGaspRangeRecordsValidator(value: Any) -> bool:
118
123
  """
119
124
  Version 3+.
120
125
  """
@@ -123,7 +128,9 @@ def fontInfoOpenTypeGaspRangeRecordsValidator(value):
123
128
  if len(value) == 0:
124
129
  return True
125
130
  validBehaviors = [0, 1, 2, 3]
126
- dictPrototype = dict(rangeMaxPPEM=(int, True), rangeGaspBehavior=(list, True))
131
+ dictPrototype: GenericDict = dict(
132
+ rangeMaxPPEM=(int, True), rangeGaspBehavior=(list, True)
133
+ )
127
134
  ppemOrder = []
128
135
  for rangeRecord in value:
129
136
  if not genericDictValidator(rangeRecord, dictPrototype):
@@ -142,7 +149,7 @@ def fontInfoOpenTypeGaspRangeRecordsValidator(value):
142
149
  return True
143
150
 
144
151
 
145
- def fontInfoOpenTypeHeadCreatedValidator(value):
152
+ def fontInfoOpenTypeHeadCreatedValidator(value: Any) -> bool:
146
153
  """
147
154
  Version 2+.
148
155
  """
@@ -154,61 +161,61 @@ def fontInfoOpenTypeHeadCreatedValidator(value):
154
161
  return False
155
162
  if value.count(" ") != 1:
156
163
  return False
157
- date, time = value.split(" ")
158
- if date.count("/") != 2:
164
+ strDate, strTime = value.split(" ")
165
+ if strDate.count("/") != 2:
159
166
  return False
160
- if time.count(":") != 2:
167
+ if strTime.count(":") != 2:
161
168
  return False
162
169
  # date
163
- year, month, day = date.split("/")
164
- if len(year) != 4:
170
+ strYear, strMonth, strDay = strDate.split("/")
171
+ if len(strYear) != 4:
165
172
  return False
166
- if len(month) != 2:
173
+ if len(strMonth) != 2:
167
174
  return False
168
- if len(day) != 2:
175
+ if len(strDay) != 2:
169
176
  return False
170
177
  try:
171
- year = int(year)
172
- month = int(month)
173
- day = int(day)
178
+ intYear = int(strYear)
179
+ intMonth = int(strMonth)
180
+ intDay = int(strDay)
174
181
  except ValueError:
175
182
  return False
176
- if month < 1 or month > 12:
183
+ if intMonth < 1 or intMonth > 12:
177
184
  return False
178
- monthMaxDay = calendar.monthrange(year, month)[1]
179
- if day < 1 or day > monthMaxDay:
185
+ monthMaxDay = calendar.monthrange(intYear, intMonth)[1]
186
+ if intDay < 1 or intDay > monthMaxDay:
180
187
  return False
181
188
  # time
182
- hour, minute, second = time.split(":")
183
- if len(hour) != 2:
189
+ strHour, strMinute, strSecond = strTime.split(":")
190
+ if len(strHour) != 2:
184
191
  return False
185
- if len(minute) != 2:
192
+ if len(strMinute) != 2:
186
193
  return False
187
- if len(second) != 2:
194
+ if len(strSecond) != 2:
188
195
  return False
189
196
  try:
190
- hour = int(hour)
191
- minute = int(minute)
192
- second = int(second)
197
+ intHour = int(strHour)
198
+ intMinute = int(strMinute)
199
+ intSecond = int(strSecond)
193
200
  except ValueError:
194
201
  return False
195
- if hour < 0 or hour > 23:
202
+ if intHour < 0 or intHour > 23:
196
203
  return False
197
- if minute < 0 or minute > 59:
204
+ if intMinute < 0 or intMinute > 59:
198
205
  return False
199
- if second < 0 or second > 59:
206
+ if intSecond < 0 or intSecond > 59:
200
207
  return False
201
208
  # fallback
202
209
  return True
203
210
 
204
211
 
205
- def fontInfoOpenTypeNameRecordsValidator(value):
212
+ def fontInfoOpenTypeNameRecordsValidator(value: Any) -> bool:
206
213
  """
207
214
  Version 3+.
208
215
  """
209
216
  if not isinstance(value, list):
210
217
  return False
211
- dictPrototype = dict(
218
+ dictPrototype: GenericDict = dict(
212
219
  nameID=(int, True),
213
220
  platformID=(int, True),
214
221
  encodingID=(int, True),
@@ -221,7 +228,7 @@ def fontInfoOpenTypeNameRecordsValidator(value):
221
228
  return True
222
229
 
223
230
 
224
- def fontInfoOpenTypeOS2WeightClassValidator(value):
231
+ def fontInfoOpenTypeOS2WeightClassValidator(value: Any) -> bool:
225
232
  """
226
233
  Version 2+.
227
234
  """
@@ -232,7 +239,7 @@ def fontInfoOpenTypeOS2WeightClassValidator(value):
232
239
  return True
233
240
 
234
241
 
235
- def fontInfoOpenTypeOS2WidthClassValidator(value):
242
+ def fontInfoOpenTypeOS2WidthClassValidator(value: Any) -> bool:
236
243
  """
237
244
  Version 2+.
238
245
  """
@@ -245,7 +252,7 @@ def fontInfoOpenTypeOS2WidthClassValidator(value):
245
252
  return True
246
253
 
247
254
 
248
- def fontInfoVersion2OpenTypeOS2PanoseValidator(values):
255
+ def fontInfoVersion2OpenTypeOS2PanoseValidator(values: Any) -> bool:
249
256
  """
250
257
  Version 2.
251
258
  """
@@ -260,7 +267,7 @@ def fontInfoVersion2OpenTypeOS2PanoseValidator(values):
260
267
  return True
261
268
 
262
269
 
263
- def fontInfoVersion3OpenTypeOS2PanoseValidator(values):
270
+ def fontInfoVersion3OpenTypeOS2PanoseValidator(values: Any) -> bool:
264
271
  """
265
272
  Version 3+.
266
273
  """
@@ -277,7 +284,7 @@ def fontInfoVersion3OpenTypeOS2PanoseValidator(values):
277
284
  return True
278
285
 
279
286
 
280
- def fontInfoOpenTypeOS2FamilyClassValidator(values):
287
+ def fontInfoOpenTypeOS2FamilyClassValidator(values: Any) -> bool:
281
288
  """
282
289
  Version 2+.
283
290
  """
@@ -296,7 +303,7 @@ def fontInfoOpenTypeOS2FamilyClassValidator(values):
296
303
  return True
297
304
 
298
305
 
299
- def fontInfoPostscriptBluesValidator(values):
306
+ def fontInfoPostscriptBluesValidator(values: Any) -> bool:
300
307
  """
301
308
  Version 2+.
302
309
  """
@@ -312,7 +319,7 @@ def fontInfoPostscriptBluesValidator(values):
312
319
  return True
313
320
 
314
321
 
315
- def fontInfoPostscriptOtherBluesValidator(values):
322
+ def fontInfoPostscriptOtherBluesValidator(values: Any) -> bool:
316
323
  """
317
324
  Version 2+.
318
325
  """
@@ -328,7 +335,7 @@ def fontInfoPostscriptOtherBluesValidator(values):
328
335
  return True
329
336
 
330
337
 
331
- def fontInfoPostscriptStemsValidator(values):
338
+ def fontInfoPostscriptStemsValidator(values: Any) -> bool:
332
339
  """
333
340
  Version 2+.
334
341
  """
@@ -342,7 +349,7 @@ def fontInfoPostscriptStemsValidator(values):
342
349
  return True
343
350
 
344
351
 
345
- def fontInfoPostscriptWindowsCharacterSetValidator(value):
352
+ def fontInfoPostscriptWindowsCharacterSetValidator(value: Any) -> bool:
346
353
  """
347
354
  Version 2+.
348
355
  """
@@ -352,21 +359,21 @@ def fontInfoPostscriptWindowsCharacterSetValidator(value):
352
359
  return True
353
360
 
354
361
 
355
- def fontInfoWOFFMetadataUniqueIDValidator(value):
362
+ def fontInfoWOFFMetadataUniqueIDValidator(value: Any) -> bool:
356
363
  """
357
364
  Version 3+.
358
365
  """
359
- dictPrototype = dict(id=(str, True))
366
+ dictPrototype: GenericDict = dict(id=(str, True))
360
367
  if not genericDictValidator(value, dictPrototype):
361
368
  return False
362
369
  return True
363
370
 
364
371
 
365
- def fontInfoWOFFMetadataVendorValidator(value):
372
+ def fontInfoWOFFMetadataVendorValidator(value: Any) -> bool:
366
373
  """
367
374
  Version 3+.
368
375
  """
369
- dictPrototype = {
376
+ dictPrototype: GenericDict = {
370
377
  "name": (str, True),
371
378
  "url": (str, False),
372
379
  "dir": (str, False),
@@ -379,11 +386,11 @@ def fontInfoWOFFMetadataVendorValidator(value):
379
386
  return True
380
387
 
381
388
 
382
- def fontInfoWOFFMetadataCreditsValidator(value):
389
+ def fontInfoWOFFMetadataCreditsValidator(value: Any) -> bool:
383
390
  """
384
391
  Version 3+.
385
392
  """
386
- dictPrototype = dict(credits=(list, True))
393
+ dictPrototype: GenericDict = dict(credits=(list, True))
387
394
  if not genericDictValidator(value, dictPrototype):
388
395
  return False
389
396
  if not len(value["credits"]):
@@ -403,11 +410,11 @@ def fontInfoWOFFMetadataCreditsValidator(value):
403
410
  return True
404
411
 
405
412
 
406
- def fontInfoWOFFMetadataDescriptionValidator(value):
413
+ def fontInfoWOFFMetadataDescriptionValidator(value: Any) -> bool:
407
414
  """
408
415
  Version 3+.
409
416
  """
410
- dictPrototype = dict(url=(str, False), text=(list, True))
417
+ dictPrototype: GenericDict = dict(url=(str, False), text=(list, True))
411
418
  if not genericDictValidator(value, dictPrototype):
412
419
  return False
413
420
  for text in value["text"]:
@@ -416,11 +423,13 @@ def fontInfoWOFFMetadataDescriptionValidator(value):
416
423
  return True
417
424
 
418
425
 
419
- def fontInfoWOFFMetadataLicenseValidator(value):
426
+ def fontInfoWOFFMetadataLicenseValidator(value: Any) -> bool:
420
427
  """
421
428
  Version 3+.
422
429
  """
423
- dictPrototype = dict(url=(str, False), text=(list, False), id=(str, False))
430
+ dictPrototype: GenericDict = dict(
431
+ url=(str, False), text=(list, False), id=(str, False)
432
+ )
424
433
  if not genericDictValidator(value, dictPrototype):
425
434
  return False
426
435
  if "text" in value:
@@ -430,11 +439,11 @@ def fontInfoWOFFMetadataLicenseValidator(value):
430
439
  return True
431
440
 
432
441
 
433
- def fontInfoWOFFMetadataTrademarkValidator(value):
442
+ def fontInfoWOFFMetadataTrademarkValidator(value: Any) -> bool:
434
443
  """
435
444
  Version 3+.
436
445
  """
437
- dictPrototype = dict(text=(list, True))
446
+ dictPrototype: GenericDict = dict(text=(list, True))
438
447
  if not genericDictValidator(value, dictPrototype):
439
448
  return False
440
449
  for text in value["text"]:
@@ -443,11 +452,11 @@ def fontInfoWOFFMetadataTrademarkValidator(value):
443
452
  return True
444
453
 
445
454
 
446
- def fontInfoWOFFMetadataCopyrightValidator(value):
455
+ def fontInfoWOFFMetadataCopyrightValidator(value: Any) -> bool:
447
456
  """
448
457
  Version 3+.
449
458
  """
450
- dictPrototype = dict(text=(list, True))
459
+ dictPrototype: GenericDict = dict(text=(list, True))
451
460
  if not genericDictValidator(value, dictPrototype):
452
461
  return False
453
462
  for text in value["text"]:
@@ -456,11 +465,15 @@ def fontInfoWOFFMetadataCopyrightValidator(value):
456
465
  return True
457
466
 
458
467
 
459
- def fontInfoWOFFMetadataLicenseeValidator(value):
468
+ def fontInfoWOFFMetadataLicenseeValidator(value: Any) -> bool:
460
469
  """
461
470
  Version 3+.
462
471
  """
463
- dictPrototype = {"name": (str, True), "dir": (str, False), "class": (str, False)}
472
+ dictPrototype: GenericDict = {
473
+ "name": (str, True),
474
+ "dir": (str, False),
475
+ "class": (str, False),
476
+ }
464
477
  if not genericDictValidator(value, dictPrototype):
465
478
  return False
466
479
  if "dir" in value and value.get("dir") not in ("ltr", "rtl"):
@@ -468,11 +481,11 @@ def fontInfoWOFFMetadataLicenseeValidator(value):
468
481
  return True
469
482
 
470
483
 
471
- def fontInfoWOFFMetadataTextValue(value):
484
+ def fontInfoWOFFMetadataTextValue(value: Any) -> bool:
472
485
  """
473
486
  Version 3+.
474
487
  """
475
- dictPrototype = {
488
+ dictPrototype: GenericDict = {
476
489
  "text": (str, True),
477
490
  "language": (str, False),
478
491
  "dir": (str, False),
@@ -485,7 +498,7 @@ def fontInfoWOFFMetadataTextValue(value):
485
498
  return True
486
499
 
487
500
 
488
- def fontInfoWOFFMetadataExtensionsValidator(value):
501
+ def fontInfoWOFFMetadataExtensionsValidator(value: Any) -> bool:
489
502
  """
490
503
  Version 3+.
491
504
  """
@@ -499,11 +512,13 @@ def fontInfoWOFFMetadataExtensionsValidator(value):
499
512
  return True
500
513
 
501
514
 
502
- def fontInfoWOFFMetadataExtensionValidator(value):
515
+ def fontInfoWOFFMetadataExtensionValidator(value: Any) -> bool:
503
516
  """
504
517
  Version 3+.
505
518
  """
506
- dictPrototype = dict(names=(list, False), items=(list, True), id=(str, False))
519
+ dictPrototype: GenericDict = dict(
520
+ names=(list, False), items=(list, True), id=(str, False)
521
+ )
507
522
  if not genericDictValidator(value, dictPrototype):
508
523
  return False
509
524
  if "names" in value:
@@ -516,11 +531,13 @@ def fontInfoWOFFMetadataExtensionValidator(value):
516
531
  return True
517
532
 
518
533
 
519
- def fontInfoWOFFMetadataExtensionItemValidator(value):
534
+ def fontInfoWOFFMetadataExtensionItemValidator(value: Any) -> bool:
520
535
  """
521
536
  Version 3+.
522
537
  """
523
- dictPrototype = dict(id=(str, False), names=(list, True), values=(list, True))
538
+ dictPrototype: GenericDict = dict(
539
+ id=(str, False), names=(list, True), values=(list, True)
540
+ )
524
541
  if not genericDictValidator(value, dictPrototype):
525
542
  return False
526
543
  for name in value["names"]:
@@ -532,11 +549,11 @@ def fontInfoWOFFMetadataExtensionItemValidator(value):
532
549
  return True
533
550
 
534
551
 
535
- def fontInfoWOFFMetadataExtensionNameValidator(value):
552
+ def fontInfoWOFFMetadataExtensionNameValidator(value: Any) -> bool:
536
553
  """
537
554
  Version 3+.
538
555
  """
539
- dictPrototype = {
556
+ dictPrototype: GenericDict = {
540
557
  "text": (str, True),
541
558
  "language": (str, False),
542
559
  "dir": (str, False),
@@ -549,11 +566,11 @@ def fontInfoWOFFMetadataExtensionNameValidator(value):
549
566
  return True
550
567
 
551
568
 
552
- def fontInfoWOFFMetadataExtensionValueValidator(value):
569
+ def fontInfoWOFFMetadataExtensionValueValidator(value: Any) -> bool:
553
570
  """
554
571
  Version 3+.
555
572
  """
556
- dictPrototype = {
573
+ dictPrototype: GenericDict = {
557
574
  "text": (str, True),
558
575
  "language": (str, False),
559
576
  "dir": (str, False),
@@ -571,7 +588,7 @@ def fontInfoWOFFMetadataExtensionValueValidator(value):
571
588
  # ----------
572
589
 
573
590
 
574
- def guidelinesValidator(value, identifiers=None):
591
+ def guidelinesValidator(value: Any, identifiers: Optional[set[str]] = None) -> bool:
575
592
  """
576
593
  Version 3+.
577
594
  """
@@ -590,7 +607,7 @@ def guidelinesValidator(value, identifiers=None):
590
607
  return True
591
608
 
592
609
 
593
- _guidelineDictPrototype = dict(
610
+ _guidelineDictPrototype: GenericDict = dict(
594
611
  x=((int, float), False),
595
612
  y=((int, float), False),
596
613
  angle=((int, float), False),
@@ -600,7 +617,7 @@ _guidelineDictPrototype = dict(
600
617
  )
601
618
 
602
619
 
603
- def guidelineValidator(value):
620
+ def guidelineValidator(value: Any) -> bool:
604
621
  """
605
622
  Version 3+.
606
623
  """
@@ -641,7 +658,7 @@ def guidelineValidator(value):
641
658
  # -------
642
659
 
643
660
 
644
- def anchorsValidator(value, identifiers=None):
661
+ def anchorsValidator(value: Any, identifiers: Optional[set[str]] = None) -> bool:
645
662
  """
646
663
  Version 3+.
647
664
  """
@@ -660,7 +677,7 @@ def anchorsValidator(value, identifiers=None):
660
677
  return True
661
678
 
662
679
 
663
- _anchorDictPrototype = dict(
680
+ _anchorDictPrototype: GenericDict = dict(
664
681
  x=((int, float), False),
665
682
  y=((int, float), False),
666
683
  name=(str, False),
@@ -669,7 +686,7 @@ _anchorDictPrototype = dict(
669
686
  )
670
687
 
671
688
 
672
- def anchorValidator(value):
689
+ def anchorValidator(value: Any) -> bool:
673
690
  """
674
691
  Version 3+.
675
692
  """
@@ -696,7 +713,7 @@ def anchorValidator(value):
696
713
  # ----------
697
714
 
698
715
 
699
- def identifierValidator(value):
716
+ def identifierValidator(value: Any) -> bool:
700
717
  """
701
718
  Version 3+.
702
719
 
@@ -716,8 +733,8 @@ def identifierValidator(value):
716
733
  if len(value) > 100:
717
734
  return False
718
735
  for c in value:
719
- c = ord(c)
720
- if c < validCharactersMin or c > validCharactersMax:
736
+ i = ord(c)
737
+ if i < validCharactersMin or i > validCharactersMax:
721
738
  return False
722
739
  return True
723
740
 
@@ -727,7 +744,7 @@ def identifierValidator(value):
727
744
  # -----
728
745
 
729
746
 
730
- def colorValidator(value):
747
+ def colorValidator(value: Any) -> bool:
731
748
  """
732
749
  Version 3+.
733
750
 
@@ -778,22 +795,21 @@ def colorValidator(value):
778
795
  for part in parts:
779
796
  part = part.strip()
780
797
  converted = False
798
+ number: IntFloat
781
799
  try:
782
- part = int(part)
800
+ number = int(part)
783
801
  converted = True
784
802
  except ValueError:
785
803
  pass
786
804
  if not converted:
787
805
  try:
788
- part = float(part)
806
+ number = float(part)
789
807
  converted = True
790
808
  except ValueError:
791
809
  pass
792
810
  if not converted:
793
811
  return False
794
- if part < 0:
795
- return False
796
- if part > 1:
812
+ if not 0 <= number <= 1:
797
813
  return False
798
814
  return True
799
815
 
@@ -802,9 +818,9 @@ def colorValidator(value):
802
818
  # image
803
819
  # -----
804
820
 
805
- pngSignature = b"\x89PNG\r\n\x1a\n"
821
+ pngSignature: bytes = b"\x89PNG\r\n\x1a\n"
806
822
 
807
- _imageDictPrototype = dict(
823
+ _imageDictPrototype: GenericDict = dict(
808
824
  fileName=(str, True),
809
825
  xScale=((int, float), False),
810
826
  xyScale=((int, float), False),
@@ -832,7 +848,11 @@ def imageValidator(value):
832
848
  return True
833
849
 
834
850
 
835
- def pngValidator(path=None, data=None, fileObj=None):
851
+ def pngValidator(
852
+ path: Optional[str] = None,
853
+ data: Optional[bytes] = None,
854
+ fileObj: Optional[Any] = None,
855
+ ) -> tuple[bool, Any]:
836
856
  """
837
857
  Version 3+.
838
858
 
@@ -858,7 +878,9 @@ def pngValidator(path=None, data=None, fileObj=None):
858
878
  # -------------------
859
879
 
860
880
 
861
- def layerContentsValidator(value, ufoPathOrFileSystem):
881
+ def layerContentsValidator(
882
+ value: Any, ufoPathOrFileSystem: Union[str, fs.base.FS]
883
+ ) -> tuple[bool, Optional[str]]:
862
884
  """
863
885
  Check the validity of layercontents.plist.
864
886
  Version 3+.
@@ -932,7 +954,7 @@ def layerContentsValidator(value, ufoPathOrFileSystem):
932
954
  # ------------
933
955
 
934
956
 
935
- def groupsValidator(value):
957
+ def groupsValidator(value: Any) -> tuple[bool, Optional[str]]:
936
958
  """
937
959
  Check the validity of the groups.
938
960
  Version 3+ (though it's backwards compatible with UFO 1 and UFO 2).
@@ -979,8 +1001,8 @@ def groupsValidator(value):
979
1001
  bogusFormatMessage = "The group data is not in the correct format."
980
1002
  if not isDictEnough(value):
981
1003
  return False, bogusFormatMessage
982
- firstSideMapping = {}
983
- secondSideMapping = {}
1004
+ firstSideMapping: dict[str, str] = {}
1005
+ secondSideMapping: dict[str, str] = {}
984
1006
  for groupName, glyphList in value.items():
985
1007
  if not isinstance(groupName, (str)):
986
1008
  return False, bogusFormatMessage
@@ -1024,7 +1046,7 @@ def groupsValidator(value):
1024
1046
  # -------------
1025
1047
 
1026
1048
 
1027
- def kerningValidator(data):
1049
+ def kerningValidator(data: Any) -> tuple[bool, Optional[str]]:
1028
1050
  """
1029
1051
  Check the validity of the kerning data structure.
1030
1052
  Version 3+ (though it's backwards compatible with UFO 1 and UFO 2).
@@ -1070,7 +1092,7 @@ def kerningValidator(data):
1070
1092
  _bogusLibFormatMessage = "The lib data is not in the correct format: %s"
1071
1093
 
1072
1094
 
1073
- def fontLibValidator(value):
1095
+ def fontLibValidator(value: Any) -> tuple[bool, Optional[str]]:
1074
1096
  """
1075
1097
  Check the validity of the lib.
1076
1098
  Version 3+ (though it's backwards compatible with UFO 1 and UFO 2).
@@ -1142,7 +1164,7 @@ def fontLibValidator(value):
1142
1164
  # --------
1143
1165
 
1144
1166
 
1145
- def glyphLibValidator(value):
1167
+ def glyphLibValidator(value: Any) -> tuple[bool, Optional[str]]:
1146
1168
  """
1147
1169
  Check the validity of the lib.
1148
1170
  Version 3+ (though it's backwards compatible with UFO 1 and UFO 2).