fonttools 4.59.0__cp310-cp310-musllinux_1_2_aarch64.whl → 4.59.2__cp310-cp310-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.
Potentially problematic release.
This version of fonttools might be problematic. Click here for more details.
- fontTools/__init__.py +1 -1
- fontTools/cffLib/CFF2ToCFF.py +40 -10
- fontTools/cffLib/transforms.py +11 -6
- fontTools/cu2qu/cu2qu.c +751 -643
- fontTools/cu2qu/cu2qu.cpython-310-aarch64-linux-gnu.so +0 -0
- fontTools/cu2qu/cu2qu.py +17 -2
- fontTools/feaLib/builder.py +15 -4
- fontTools/feaLib/lexer.c +21 -6
- fontTools/feaLib/lexer.cpython-310-aarch64-linux-gnu.so +0 -0
- fontTools/feaLib/parser.py +11 -1
- fontTools/feaLib/variableScalar.py +6 -1
- fontTools/misc/bezierTools.c +24 -9
- fontTools/misc/bezierTools.cpython-310-aarch64-linux-gnu.so +0 -0
- fontTools/misc/psCharStrings.py +17 -2
- fontTools/misc/textTools.py +4 -2
- fontTools/pens/momentsPen.c +11 -4
- fontTools/pens/momentsPen.cpython-310-aarch64-linux-gnu.so +0 -0
- fontTools/qu2cu/qu2cu.c +23 -8
- fontTools/qu2cu/qu2cu.cpython-310-aarch64-linux-gnu.so +0 -0
- fontTools/subset/__init__.py +1 -0
- fontTools/ttLib/tables/_a_v_a_r.py +4 -2
- fontTools/ttLib/tables/_g_v_a_r.py +6 -3
- fontTools/ttLib/tables/_h_m_t_x.py +7 -3
- fontTools/ttLib/tables/_n_a_m_e.py +11 -6
- fontTools/varLib/__init__.py +80 -1
- fontTools/varLib/featureVars.py +8 -0
- fontTools/varLib/instancer/__init__.py +120 -22
- fontTools/varLib/iup.c +23 -8
- fontTools/varLib/iup.cpython-310-aarch64-linux-gnu.so +0 -0
- fontTools/varLib/mutator.py +11 -0
- {fonttools-4.59.0.dist-info → fonttools-4.59.2.dist-info}/METADATA +38 -10
- {fonttools-4.59.0.dist-info → fonttools-4.59.2.dist-info}/RECORD +38 -38
- {fonttools-4.59.0.data → fonttools-4.59.2.data}/data/share/man/man1/ttx.1 +0 -0
- {fonttools-4.59.0.dist-info → fonttools-4.59.2.dist-info}/WHEEL +0 -0
- {fonttools-4.59.0.dist-info → fonttools-4.59.2.dist-info}/entry_points.txt +0 -0
- {fonttools-4.59.0.dist-info → fonttools-4.59.2.dist-info}/licenses/LICENSE +0 -0
- {fonttools-4.59.0.dist-info → fonttools-4.59.2.dist-info}/licenses/LICENSE.external +0 -0
- {fonttools-4.59.0.dist-info → fonttools-4.59.2.dist-info}/top_level.txt +0 -0
fontTools/__init__.py
CHANGED
fontTools/cffLib/CFF2ToCFF.py
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
from fontTools.ttLib import TTFont, newTable
|
|
4
4
|
from fontTools.misc.cliTools import makeOutputFileName
|
|
5
|
+
from fontTools.misc.psCharStrings import T2StackUseExtractor
|
|
5
6
|
from fontTools.cffLib import (
|
|
6
7
|
TopDictIndex,
|
|
7
8
|
buildOrder,
|
|
8
9
|
buildDefaults,
|
|
9
10
|
topDictOperators,
|
|
10
11
|
privateDictOperators,
|
|
12
|
+
FDSelect,
|
|
11
13
|
)
|
|
14
|
+
from .transforms import desubroutinizeCharString
|
|
15
|
+
from .specializer import specializeProgram
|
|
12
16
|
from .width import optimizeWidths
|
|
13
17
|
from collections import defaultdict
|
|
14
18
|
import logging
|
|
@@ -27,7 +31,7 @@ def _convertCFF2ToCFF(cff, otFont):
|
|
|
27
31
|
The CFF2 font cannot be variable. (TODO Accept those and convert to the
|
|
28
32
|
default instance?)
|
|
29
33
|
|
|
30
|
-
This assumes a decompiled
|
|
34
|
+
This assumes a decompiled CFF2 table. (i.e. that the object has been
|
|
31
35
|
filled via :meth:`decompile` and e.g. not loaded from XML.)"""
|
|
32
36
|
|
|
33
37
|
cff.major = 1
|
|
@@ -51,9 +55,14 @@ def _convertCFF2ToCFF(cff, otFont):
|
|
|
51
55
|
if hasattr(topDict, key):
|
|
52
56
|
delattr(topDict, key)
|
|
53
57
|
|
|
54
|
-
fdArray = topDict.FDArray
|
|
55
58
|
charStrings = topDict.CharStrings
|
|
56
59
|
|
|
60
|
+
fdArray = topDict.FDArray
|
|
61
|
+
if not hasattr(topDict, "FDSelect"):
|
|
62
|
+
# FDSelect is optional in CFF2, but required in CFF.
|
|
63
|
+
fdSelect = topDict.FDSelect = FDSelect()
|
|
64
|
+
fdSelect.gidArray = [0] * len(charStrings.charStrings)
|
|
65
|
+
|
|
57
66
|
defaults = buildDefaults(privateDictOperators)
|
|
58
67
|
order = buildOrder(privateDictOperators)
|
|
59
68
|
for fd in fdArray:
|
|
@@ -69,6 +78,7 @@ def _convertCFF2ToCFF(cff, otFont):
|
|
|
69
78
|
if hasattr(privateDict, key):
|
|
70
79
|
delattr(privateDict, key)
|
|
71
80
|
|
|
81
|
+
# Add ending operators
|
|
72
82
|
for cs in charStrings.values():
|
|
73
83
|
cs.decompile()
|
|
74
84
|
cs.program.append("endchar")
|
|
@@ -100,23 +110,43 @@ def _convertCFF2ToCFF(cff, otFont):
|
|
|
100
110
|
if width != private.defaultWidthX:
|
|
101
111
|
cs.program.insert(0, width - private.nominalWidthX)
|
|
102
112
|
|
|
113
|
+
# Handle stack use since stack-depth is lower in CFF than in CFF2.
|
|
114
|
+
for glyphName in charStrings.keys():
|
|
115
|
+
cs, fdIndex = charStrings.getItemAndSelector(glyphName)
|
|
116
|
+
if fdIndex is None:
|
|
117
|
+
fdIndex = 0
|
|
118
|
+
private = fdArray[fdIndex].Private
|
|
119
|
+
extractor = T2StackUseExtractor(
|
|
120
|
+
getattr(private, "Subrs", []), cff.GlobalSubrs, private=private
|
|
121
|
+
)
|
|
122
|
+
stackUse = extractor.execute(cs)
|
|
123
|
+
if stackUse > 48: # CFF stack depth is 48
|
|
124
|
+
desubroutinizeCharString(cs)
|
|
125
|
+
cs.program = specializeProgram(cs.program)
|
|
126
|
+
|
|
127
|
+
# Unused subroutines are still in CFF2 (ie. lacking 'return' operator)
|
|
128
|
+
# because they were not decompiled when we added the 'return'.
|
|
129
|
+
# Moreover, some used subroutines may have become unused after the
|
|
130
|
+
# stack-use fixup. So we remove all unused subroutines now.
|
|
131
|
+
cff.remove_unused_subroutines()
|
|
132
|
+
|
|
103
133
|
mapping = {
|
|
104
|
-
name: ("cid" + str(n) if n else ".notdef")
|
|
134
|
+
name: ("cid" + str(n).zfill(5) if n else ".notdef")
|
|
105
135
|
for n, name in enumerate(topDict.charset)
|
|
106
136
|
}
|
|
107
137
|
topDict.charset = [
|
|
108
|
-
"cid" + str(n) if n else ".notdef" for n in range(len(topDict.charset))
|
|
138
|
+
"cid" + str(n).zfill(5) if n else ".notdef" for n in range(len(topDict.charset))
|
|
109
139
|
]
|
|
110
140
|
charStrings.charStrings = {
|
|
111
141
|
mapping[name]: v for name, v in charStrings.charStrings.items()
|
|
112
142
|
}
|
|
113
143
|
|
|
114
|
-
|
|
115
|
-
# the output if I add it.
|
|
116
|
-
# topDict.ROS = ("Adobe", "Identity", 0)
|
|
144
|
+
topDict.ROS = ("Adobe", "Identity", 0)
|
|
117
145
|
|
|
118
146
|
|
|
119
147
|
def convertCFF2ToCFF(font, *, updatePostTable=True):
|
|
148
|
+
if "CFF2" not in font:
|
|
149
|
+
raise ValueError("Input font does not contain a CFF2 table.")
|
|
120
150
|
cff = font["CFF2"].cff
|
|
121
151
|
_convertCFF2ToCFF(cff, font)
|
|
122
152
|
del font["CFF2"]
|
|
@@ -131,7 +161,7 @@ def convertCFF2ToCFF(font, *, updatePostTable=True):
|
|
|
131
161
|
|
|
132
162
|
|
|
133
163
|
def main(args=None):
|
|
134
|
-
"""Convert
|
|
164
|
+
"""Convert CFF2 OTF font to CFF OTF font"""
|
|
135
165
|
if args is None:
|
|
136
166
|
import sys
|
|
137
167
|
|
|
@@ -140,8 +170,8 @@ def main(args=None):
|
|
|
140
170
|
import argparse
|
|
141
171
|
|
|
142
172
|
parser = argparse.ArgumentParser(
|
|
143
|
-
"fonttools cffLib.
|
|
144
|
-
description="
|
|
173
|
+
"fonttools cffLib.CFF2ToCFF",
|
|
174
|
+
description="Convert a non-variable CFF2 font to CFF.",
|
|
145
175
|
)
|
|
146
176
|
parser.add_argument(
|
|
147
177
|
"input", metavar="INPUT.ttf", help="Input OTF file with CFF table."
|
fontTools/cffLib/transforms.py
CHANGED
|
@@ -94,17 +94,22 @@ class _DesubroutinizingT2Decompiler(SimpleT2Decompiler):
|
|
|
94
94
|
cs._patches.append((index, subr._desubroutinized))
|
|
95
95
|
|
|
96
96
|
|
|
97
|
+
def desubroutinizeCharString(cs):
|
|
98
|
+
"""Desubroutinize a charstring in-place."""
|
|
99
|
+
cs.decompile()
|
|
100
|
+
subrs = getattr(cs.private, "Subrs", [])
|
|
101
|
+
decompiler = _DesubroutinizingT2Decompiler(subrs, cs.globalSubrs, cs.private)
|
|
102
|
+
decompiler.execute(cs)
|
|
103
|
+
cs.program = cs._desubroutinized
|
|
104
|
+
del cs._desubroutinized
|
|
105
|
+
|
|
106
|
+
|
|
97
107
|
def desubroutinize(cff):
|
|
98
108
|
for fontName in cff.fontNames:
|
|
99
109
|
font = cff[fontName]
|
|
100
110
|
cs = font.CharStrings
|
|
101
111
|
for c in cs.values():
|
|
102
|
-
c
|
|
103
|
-
subrs = getattr(c.private, "Subrs", [])
|
|
104
|
-
decompiler = _DesubroutinizingT2Decompiler(subrs, c.globalSubrs, c.private)
|
|
105
|
-
decompiler.execute(c)
|
|
106
|
-
c.program = c._desubroutinized
|
|
107
|
-
del c._desubroutinized
|
|
112
|
+
desubroutinizeCharString(c)
|
|
108
113
|
# Delete all the local subrs
|
|
109
114
|
if hasattr(font, "FDArray"):
|
|
110
115
|
for fd in font.FDArray:
|