fonttools 4.60.2__cp311-cp311-win32.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.
- fontTools/__init__.py +8 -0
- fontTools/__main__.py +35 -0
- fontTools/afmLib.py +439 -0
- fontTools/agl.py +5233 -0
- fontTools/annotations.py +30 -0
- fontTools/cffLib/CFF2ToCFF.py +258 -0
- fontTools/cffLib/CFFToCFF2.py +305 -0
- fontTools/cffLib/__init__.py +3694 -0
- fontTools/cffLib/specializer.py +927 -0
- fontTools/cffLib/transforms.py +495 -0
- fontTools/cffLib/width.py +210 -0
- fontTools/colorLib/__init__.py +0 -0
- fontTools/colorLib/builder.py +664 -0
- fontTools/colorLib/errors.py +2 -0
- fontTools/colorLib/geometry.py +143 -0
- fontTools/colorLib/table_builder.py +223 -0
- fontTools/colorLib/unbuilder.py +81 -0
- fontTools/config/__init__.py +90 -0
- fontTools/cu2qu/__init__.py +15 -0
- fontTools/cu2qu/__main__.py +6 -0
- fontTools/cu2qu/benchmark.py +54 -0
- fontTools/cu2qu/cli.py +198 -0
- fontTools/cu2qu/cu2qu.c +15817 -0
- fontTools/cu2qu/cu2qu.cp311-win32.pyd +0 -0
- fontTools/cu2qu/cu2qu.py +563 -0
- fontTools/cu2qu/errors.py +77 -0
- fontTools/cu2qu/ufo.py +363 -0
- fontTools/designspaceLib/__init__.py +3343 -0
- fontTools/designspaceLib/__main__.py +6 -0
- fontTools/designspaceLib/split.py +475 -0
- fontTools/designspaceLib/statNames.py +260 -0
- fontTools/designspaceLib/types.py +147 -0
- fontTools/encodings/MacRoman.py +258 -0
- fontTools/encodings/StandardEncoding.py +258 -0
- fontTools/encodings/__init__.py +1 -0
- fontTools/encodings/codecs.py +135 -0
- fontTools/feaLib/__init__.py +4 -0
- fontTools/feaLib/__main__.py +78 -0
- fontTools/feaLib/ast.py +2143 -0
- fontTools/feaLib/builder.py +1814 -0
- fontTools/feaLib/error.py +22 -0
- fontTools/feaLib/lexer.c +17029 -0
- fontTools/feaLib/lexer.cp311-win32.pyd +0 -0
- fontTools/feaLib/lexer.py +287 -0
- fontTools/feaLib/location.py +12 -0
- fontTools/feaLib/lookupDebugInfo.py +12 -0
- fontTools/feaLib/parser.py +2394 -0
- fontTools/feaLib/variableScalar.py +118 -0
- fontTools/fontBuilder.py +1014 -0
- fontTools/help.py +36 -0
- fontTools/merge/__init__.py +248 -0
- fontTools/merge/__main__.py +6 -0
- fontTools/merge/base.py +81 -0
- fontTools/merge/cmap.py +173 -0
- fontTools/merge/layout.py +526 -0
- fontTools/merge/options.py +85 -0
- fontTools/merge/tables.py +352 -0
- fontTools/merge/unicode.py +78 -0
- fontTools/merge/util.py +143 -0
- fontTools/misc/__init__.py +1 -0
- fontTools/misc/arrayTools.py +424 -0
- fontTools/misc/bezierTools.c +39731 -0
- fontTools/misc/bezierTools.cp311-win32.pyd +0 -0
- fontTools/misc/bezierTools.py +1500 -0
- fontTools/misc/classifyTools.py +170 -0
- fontTools/misc/cliTools.py +53 -0
- fontTools/misc/configTools.py +349 -0
- fontTools/misc/cython.py +27 -0
- fontTools/misc/dictTools.py +83 -0
- fontTools/misc/eexec.py +119 -0
- fontTools/misc/encodingTools.py +72 -0
- fontTools/misc/enumTools.py +23 -0
- fontTools/misc/etree.py +456 -0
- fontTools/misc/filenames.py +245 -0
- fontTools/misc/filesystem/__init__.py +68 -0
- fontTools/misc/filesystem/_base.py +134 -0
- fontTools/misc/filesystem/_copy.py +45 -0
- fontTools/misc/filesystem/_errors.py +54 -0
- fontTools/misc/filesystem/_info.py +75 -0
- fontTools/misc/filesystem/_osfs.py +164 -0
- fontTools/misc/filesystem/_path.py +67 -0
- fontTools/misc/filesystem/_subfs.py +92 -0
- fontTools/misc/filesystem/_tempfs.py +34 -0
- fontTools/misc/filesystem/_tools.py +34 -0
- fontTools/misc/filesystem/_walk.py +55 -0
- fontTools/misc/filesystem/_zipfs.py +204 -0
- fontTools/misc/fixedTools.py +253 -0
- fontTools/misc/intTools.py +25 -0
- fontTools/misc/iterTools.py +12 -0
- fontTools/misc/lazyTools.py +42 -0
- fontTools/misc/loggingTools.py +543 -0
- fontTools/misc/macCreatorType.py +56 -0
- fontTools/misc/macRes.py +261 -0
- fontTools/misc/plistlib/__init__.py +681 -0
- fontTools/misc/plistlib/py.typed +0 -0
- fontTools/misc/psCharStrings.py +1511 -0
- fontTools/misc/psLib.py +398 -0
- fontTools/misc/psOperators.py +572 -0
- fontTools/misc/py23.py +96 -0
- fontTools/misc/roundTools.py +110 -0
- fontTools/misc/sstruct.py +227 -0
- fontTools/misc/symfont.py +242 -0
- fontTools/misc/testTools.py +233 -0
- fontTools/misc/textTools.py +156 -0
- fontTools/misc/timeTools.py +88 -0
- fontTools/misc/transform.py +516 -0
- fontTools/misc/treeTools.py +45 -0
- fontTools/misc/vector.py +147 -0
- fontTools/misc/visitor.py +158 -0
- fontTools/misc/xmlReader.py +188 -0
- fontTools/misc/xmlWriter.py +231 -0
- fontTools/mtiLib/__init__.py +1400 -0
- fontTools/mtiLib/__main__.py +5 -0
- fontTools/otlLib/__init__.py +1 -0
- fontTools/otlLib/builder.py +3465 -0
- fontTools/otlLib/error.py +11 -0
- fontTools/otlLib/maxContextCalc.py +96 -0
- fontTools/otlLib/optimize/__init__.py +53 -0
- fontTools/otlLib/optimize/__main__.py +6 -0
- fontTools/otlLib/optimize/gpos.py +439 -0
- fontTools/pens/__init__.py +1 -0
- fontTools/pens/areaPen.py +52 -0
- fontTools/pens/basePen.py +475 -0
- fontTools/pens/boundsPen.py +98 -0
- fontTools/pens/cairoPen.py +26 -0
- fontTools/pens/cocoaPen.py +26 -0
- fontTools/pens/cu2quPen.py +325 -0
- fontTools/pens/explicitClosingLinePen.py +101 -0
- fontTools/pens/filterPen.py +433 -0
- fontTools/pens/freetypePen.py +462 -0
- fontTools/pens/hashPointPen.py +89 -0
- fontTools/pens/momentsPen.c +13378 -0
- fontTools/pens/momentsPen.cp311-win32.pyd +0 -0
- fontTools/pens/momentsPen.py +879 -0
- fontTools/pens/perimeterPen.py +69 -0
- fontTools/pens/pointInsidePen.py +192 -0
- fontTools/pens/pointPen.py +643 -0
- fontTools/pens/qtPen.py +29 -0
- fontTools/pens/qu2cuPen.py +105 -0
- fontTools/pens/quartzPen.py +43 -0
- fontTools/pens/recordingPen.py +335 -0
- fontTools/pens/reportLabPen.py +79 -0
- fontTools/pens/reverseContourPen.py +96 -0
- fontTools/pens/roundingPen.py +130 -0
- fontTools/pens/statisticsPen.py +312 -0
- fontTools/pens/svgPathPen.py +310 -0
- fontTools/pens/t2CharStringPen.py +88 -0
- fontTools/pens/teePen.py +55 -0
- fontTools/pens/transformPen.py +115 -0
- fontTools/pens/ttGlyphPen.py +335 -0
- fontTools/pens/wxPen.py +29 -0
- fontTools/qu2cu/__init__.py +15 -0
- fontTools/qu2cu/__main__.py +7 -0
- fontTools/qu2cu/benchmark.py +56 -0
- fontTools/qu2cu/cli.py +125 -0
- fontTools/qu2cu/qu2cu.c +16682 -0
- fontTools/qu2cu/qu2cu.cp311-win32.pyd +0 -0
- fontTools/qu2cu/qu2cu.py +405 -0
- fontTools/subset/__init__.py +4096 -0
- fontTools/subset/__main__.py +6 -0
- fontTools/subset/cff.py +184 -0
- fontTools/subset/svg.py +253 -0
- fontTools/subset/util.py +25 -0
- fontTools/svgLib/__init__.py +3 -0
- fontTools/svgLib/path/__init__.py +65 -0
- fontTools/svgLib/path/arc.py +154 -0
- fontTools/svgLib/path/parser.py +322 -0
- fontTools/svgLib/path/shapes.py +183 -0
- fontTools/t1Lib/__init__.py +648 -0
- fontTools/tfmLib.py +460 -0
- fontTools/ttLib/__init__.py +30 -0
- fontTools/ttLib/__main__.py +148 -0
- fontTools/ttLib/macUtils.py +54 -0
- fontTools/ttLib/removeOverlaps.py +395 -0
- fontTools/ttLib/reorderGlyphs.py +285 -0
- fontTools/ttLib/scaleUpem.py +436 -0
- fontTools/ttLib/sfnt.py +661 -0
- fontTools/ttLib/standardGlyphOrder.py +271 -0
- fontTools/ttLib/tables/B_A_S_E_.py +14 -0
- fontTools/ttLib/tables/BitmapGlyphMetrics.py +64 -0
- fontTools/ttLib/tables/C_B_D_T_.py +113 -0
- fontTools/ttLib/tables/C_B_L_C_.py +19 -0
- fontTools/ttLib/tables/C_F_F_.py +61 -0
- fontTools/ttLib/tables/C_F_F__2.py +26 -0
- fontTools/ttLib/tables/C_O_L_R_.py +165 -0
- fontTools/ttLib/tables/C_P_A_L_.py +305 -0
- fontTools/ttLib/tables/D_S_I_G_.py +158 -0
- fontTools/ttLib/tables/D__e_b_g.py +35 -0
- fontTools/ttLib/tables/DefaultTable.py +49 -0
- fontTools/ttLib/tables/E_B_D_T_.py +835 -0
- fontTools/ttLib/tables/E_B_L_C_.py +718 -0
- fontTools/ttLib/tables/F_F_T_M_.py +52 -0
- fontTools/ttLib/tables/F__e_a_t.py +149 -0
- fontTools/ttLib/tables/G_D_E_F_.py +13 -0
- fontTools/ttLib/tables/G_M_A_P_.py +148 -0
- fontTools/ttLib/tables/G_P_K_G_.py +133 -0
- fontTools/ttLib/tables/G_P_O_S_.py +14 -0
- fontTools/ttLib/tables/G_S_U_B_.py +13 -0
- fontTools/ttLib/tables/G_V_A_R_.py +5 -0
- fontTools/ttLib/tables/G__l_a_t.py +235 -0
- fontTools/ttLib/tables/G__l_o_c.py +85 -0
- fontTools/ttLib/tables/H_V_A_R_.py +13 -0
- fontTools/ttLib/tables/J_S_T_F_.py +13 -0
- fontTools/ttLib/tables/L_T_S_H_.py +58 -0
- fontTools/ttLib/tables/M_A_T_H_.py +13 -0
- fontTools/ttLib/tables/M_E_T_A_.py +352 -0
- fontTools/ttLib/tables/M_V_A_R_.py +13 -0
- fontTools/ttLib/tables/O_S_2f_2.py +752 -0
- fontTools/ttLib/tables/S_I_N_G_.py +99 -0
- fontTools/ttLib/tables/S_T_A_T_.py +15 -0
- fontTools/ttLib/tables/S_V_G_.py +223 -0
- fontTools/ttLib/tables/S__i_l_f.py +1040 -0
- fontTools/ttLib/tables/S__i_l_l.py +92 -0
- fontTools/ttLib/tables/T_S_I_B_.py +13 -0
- fontTools/ttLib/tables/T_S_I_C_.py +14 -0
- fontTools/ttLib/tables/T_S_I_D_.py +13 -0
- fontTools/ttLib/tables/T_S_I_J_.py +13 -0
- fontTools/ttLib/tables/T_S_I_P_.py +13 -0
- fontTools/ttLib/tables/T_S_I_S_.py +13 -0
- fontTools/ttLib/tables/T_S_I_V_.py +26 -0
- fontTools/ttLib/tables/T_S_I__0.py +70 -0
- fontTools/ttLib/tables/T_S_I__1.py +163 -0
- fontTools/ttLib/tables/T_S_I__2.py +17 -0
- fontTools/ttLib/tables/T_S_I__3.py +22 -0
- fontTools/ttLib/tables/T_S_I__5.py +60 -0
- fontTools/ttLib/tables/T_T_F_A_.py +14 -0
- fontTools/ttLib/tables/TupleVariation.py +884 -0
- fontTools/ttLib/tables/V_A_R_C_.py +12 -0
- fontTools/ttLib/tables/V_D_M_X_.py +249 -0
- fontTools/ttLib/tables/V_O_R_G_.py +165 -0
- fontTools/ttLib/tables/V_V_A_R_.py +13 -0
- fontTools/ttLib/tables/__init__.py +98 -0
- fontTools/ttLib/tables/_a_n_k_r.py +15 -0
- fontTools/ttLib/tables/_a_v_a_r.py +193 -0
- fontTools/ttLib/tables/_b_s_l_n.py +15 -0
- fontTools/ttLib/tables/_c_i_d_g.py +24 -0
- fontTools/ttLib/tables/_c_m_a_p.py +1591 -0
- fontTools/ttLib/tables/_c_v_a_r.py +94 -0
- fontTools/ttLib/tables/_c_v_t.py +56 -0
- fontTools/ttLib/tables/_f_e_a_t.py +15 -0
- fontTools/ttLib/tables/_f_p_g_m.py +62 -0
- fontTools/ttLib/tables/_f_v_a_r.py +261 -0
- fontTools/ttLib/tables/_g_a_s_p.py +63 -0
- fontTools/ttLib/tables/_g_c_i_d.py +13 -0
- fontTools/ttLib/tables/_g_l_y_f.py +2311 -0
- fontTools/ttLib/tables/_g_v_a_r.py +340 -0
- fontTools/ttLib/tables/_h_d_m_x.py +127 -0
- fontTools/ttLib/tables/_h_e_a_d.py +130 -0
- fontTools/ttLib/tables/_h_h_e_a.py +147 -0
- fontTools/ttLib/tables/_h_m_t_x.py +164 -0
- fontTools/ttLib/tables/_k_e_r_n.py +289 -0
- fontTools/ttLib/tables/_l_c_a_r.py +13 -0
- fontTools/ttLib/tables/_l_o_c_a.py +70 -0
- fontTools/ttLib/tables/_l_t_a_g.py +72 -0
- fontTools/ttLib/tables/_m_a_x_p.py +147 -0
- fontTools/ttLib/tables/_m_e_t_a.py +112 -0
- fontTools/ttLib/tables/_m_o_r_t.py +14 -0
- fontTools/ttLib/tables/_m_o_r_x.py +15 -0
- fontTools/ttLib/tables/_n_a_m_e.py +1242 -0
- fontTools/ttLib/tables/_o_p_b_d.py +14 -0
- fontTools/ttLib/tables/_p_o_s_t.py +319 -0
- fontTools/ttLib/tables/_p_r_e_p.py +16 -0
- fontTools/ttLib/tables/_p_r_o_p.py +12 -0
- fontTools/ttLib/tables/_s_b_i_x.py +129 -0
- fontTools/ttLib/tables/_t_r_a_k.py +332 -0
- fontTools/ttLib/tables/_v_h_e_a.py +139 -0
- fontTools/ttLib/tables/_v_m_t_x.py +19 -0
- fontTools/ttLib/tables/asciiTable.py +20 -0
- fontTools/ttLib/tables/grUtils.py +92 -0
- fontTools/ttLib/tables/otBase.py +1458 -0
- fontTools/ttLib/tables/otConverters.py +2068 -0
- fontTools/ttLib/tables/otData.py +6400 -0
- fontTools/ttLib/tables/otTables.py +2703 -0
- fontTools/ttLib/tables/otTraverse.py +163 -0
- fontTools/ttLib/tables/sbixGlyph.py +149 -0
- fontTools/ttLib/tables/sbixStrike.py +177 -0
- fontTools/ttLib/tables/table_API_readme.txt +91 -0
- fontTools/ttLib/tables/ttProgram.py +594 -0
- fontTools/ttLib/ttCollection.py +125 -0
- fontTools/ttLib/ttFont.py +1148 -0
- fontTools/ttLib/ttGlyphSet.py +490 -0
- fontTools/ttLib/ttVisitor.py +32 -0
- fontTools/ttLib/woff2.py +1680 -0
- fontTools/ttx.py +479 -0
- fontTools/ufoLib/__init__.py +2575 -0
- fontTools/ufoLib/converters.py +407 -0
- fontTools/ufoLib/errors.py +30 -0
- fontTools/ufoLib/etree.py +6 -0
- fontTools/ufoLib/filenames.py +356 -0
- fontTools/ufoLib/glifLib.py +2120 -0
- fontTools/ufoLib/kerning.py +141 -0
- fontTools/ufoLib/plistlib.py +47 -0
- fontTools/ufoLib/pointPen.py +6 -0
- fontTools/ufoLib/utils.py +107 -0
- fontTools/ufoLib/validators.py +1208 -0
- fontTools/unicode.py +50 -0
- fontTools/unicodedata/Blocks.py +817 -0
- fontTools/unicodedata/Mirrored.py +446 -0
- fontTools/unicodedata/OTTags.py +50 -0
- fontTools/unicodedata/ScriptExtensions.py +832 -0
- fontTools/unicodedata/Scripts.py +3639 -0
- fontTools/unicodedata/__init__.py +306 -0
- fontTools/varLib/__init__.py +1600 -0
- fontTools/varLib/__main__.py +6 -0
- fontTools/varLib/avar/__init__.py +0 -0
- fontTools/varLib/avar/__main__.py +72 -0
- fontTools/varLib/avar/build.py +79 -0
- fontTools/varLib/avar/map.py +108 -0
- fontTools/varLib/avar/plan.py +1004 -0
- fontTools/varLib/avar/unbuild.py +271 -0
- fontTools/varLib/avarPlanner.py +8 -0
- fontTools/varLib/builder.py +215 -0
- fontTools/varLib/cff.py +631 -0
- fontTools/varLib/errors.py +219 -0
- fontTools/varLib/featureVars.py +703 -0
- fontTools/varLib/hvar.py +113 -0
- fontTools/varLib/instancer/__init__.py +2052 -0
- fontTools/varLib/instancer/__main__.py +5 -0
- fontTools/varLib/instancer/featureVars.py +190 -0
- fontTools/varLib/instancer/names.py +388 -0
- fontTools/varLib/instancer/solver.py +309 -0
- fontTools/varLib/interpolatable.py +1209 -0
- fontTools/varLib/interpolatableHelpers.py +399 -0
- fontTools/varLib/interpolatablePlot.py +1269 -0
- fontTools/varLib/interpolatableTestContourOrder.py +82 -0
- fontTools/varLib/interpolatableTestStartingPoint.py +107 -0
- fontTools/varLib/interpolate_layout.py +124 -0
- fontTools/varLib/iup.c +19815 -0
- fontTools/varLib/iup.cp311-win32.pyd +0 -0
- fontTools/varLib/iup.py +490 -0
- fontTools/varLib/merger.py +1717 -0
- fontTools/varLib/models.py +642 -0
- fontTools/varLib/multiVarStore.py +253 -0
- fontTools/varLib/mutator.py +529 -0
- fontTools/varLib/mvar.py +40 -0
- fontTools/varLib/plot.py +238 -0
- fontTools/varLib/stat.py +149 -0
- fontTools/varLib/varStore.py +739 -0
- fontTools/voltLib/__init__.py +5 -0
- fontTools/voltLib/__main__.py +206 -0
- fontTools/voltLib/ast.py +452 -0
- fontTools/voltLib/error.py +12 -0
- fontTools/voltLib/lexer.py +99 -0
- fontTools/voltLib/parser.py +664 -0
- fontTools/voltLib/voltToFea.py +911 -0
- fonttools-4.60.2.data/data/share/man/man1/ttx.1 +225 -0
- fonttools-4.60.2.dist-info/METADATA +2250 -0
- fonttools-4.60.2.dist-info/RECORD +353 -0
- fonttools-4.60.2.dist-info/WHEEL +5 -0
- fonttools-4.60.2.dist-info/entry_points.txt +5 -0
- fonttools-4.60.2.dist-info/licenses/LICENSE +21 -0
- fonttools-4.60.2.dist-info/licenses/LICENSE.external +388 -0
- fonttools-4.60.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
from fontTools.misc import sstruct
|
|
2
|
+
from fontTools.misc.fixedTools import floatToFixedToStr
|
|
3
|
+
from fontTools.misc.textTools import safeEval
|
|
4
|
+
|
|
5
|
+
# from itertools import *
|
|
6
|
+
from functools import partial
|
|
7
|
+
from . import DefaultTable
|
|
8
|
+
from . import grUtils
|
|
9
|
+
import struct
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Glat_format_0 = """
|
|
13
|
+
> # big endian
|
|
14
|
+
version: 16.16F
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
Glat_format_3 = """
|
|
18
|
+
>
|
|
19
|
+
version: 16.16F
|
|
20
|
+
compression:L # compression scheme or reserved
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
Glat_format_1_entry = """
|
|
24
|
+
>
|
|
25
|
+
attNum: B # Attribute number of first attribute
|
|
26
|
+
num: B # Number of attributes in this run
|
|
27
|
+
"""
|
|
28
|
+
Glat_format_23_entry = """
|
|
29
|
+
>
|
|
30
|
+
attNum: H # Attribute number of first attribute
|
|
31
|
+
num: H # Number of attributes in this run
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
Glat_format_3_octabox_metrics = """
|
|
35
|
+
>
|
|
36
|
+
subboxBitmap: H # Which subboxes exist on 4x4 grid
|
|
37
|
+
diagNegMin: B # Defines minimum negatively-sloped diagonal (si)
|
|
38
|
+
diagNegMax: B # Defines maximum negatively-sloped diagonal (sa)
|
|
39
|
+
diagPosMin: B # Defines minimum positively-sloped diagonal (di)
|
|
40
|
+
diagPosMax: B # Defines maximum positively-sloped diagonal (da)
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
Glat_format_3_subbox_entry = """
|
|
44
|
+
>
|
|
45
|
+
left: B # xi
|
|
46
|
+
right: B # xa
|
|
47
|
+
bottom: B # yi
|
|
48
|
+
top: B # ya
|
|
49
|
+
diagNegMin: B # Defines minimum negatively-sloped diagonal (si)
|
|
50
|
+
diagNegMax: B # Defines maximum negatively-sloped diagonal (sa)
|
|
51
|
+
diagPosMin: B # Defines minimum positively-sloped diagonal (di)
|
|
52
|
+
diagPosMax: B # Defines maximum positively-sloped diagonal (da)
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class _Object:
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class _Dict(dict):
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class table_G__l_a_t(DefaultTable.DefaultTable):
|
|
65
|
+
"""Graphite Glyph Attributes table
|
|
66
|
+
|
|
67
|
+
See also https://graphite.sil.org/graphite_techAbout#graphite-font-tables
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
def __init__(self, tag=None):
|
|
71
|
+
DefaultTable.DefaultTable.__init__(self, tag)
|
|
72
|
+
self.scheme = 0
|
|
73
|
+
|
|
74
|
+
def decompile(self, data, ttFont):
|
|
75
|
+
sstruct.unpack2(Glat_format_0, data, self)
|
|
76
|
+
self.version = float(floatToFixedToStr(self.version, precisionBits=16))
|
|
77
|
+
if self.version <= 1.9:
|
|
78
|
+
decoder = partial(self.decompileAttributes12, fmt=Glat_format_1_entry)
|
|
79
|
+
elif self.version <= 2.9:
|
|
80
|
+
decoder = partial(self.decompileAttributes12, fmt=Glat_format_23_entry)
|
|
81
|
+
elif self.version >= 3.0:
|
|
82
|
+
(data, self.scheme) = grUtils.decompress(data)
|
|
83
|
+
sstruct.unpack2(Glat_format_3, data, self)
|
|
84
|
+
self.hasOctaboxes = (self.compression & 1) == 1
|
|
85
|
+
decoder = self.decompileAttributes3
|
|
86
|
+
|
|
87
|
+
gloc = ttFont["Gloc"]
|
|
88
|
+
self.attributes = {}
|
|
89
|
+
count = 0
|
|
90
|
+
for s, e in zip(gloc, gloc[1:]):
|
|
91
|
+
self.attributes[ttFont.getGlyphName(count)] = decoder(data[s:e])
|
|
92
|
+
count += 1
|
|
93
|
+
|
|
94
|
+
def decompileAttributes12(self, data, fmt):
|
|
95
|
+
attributes = _Dict()
|
|
96
|
+
while len(data) > 3:
|
|
97
|
+
e, data = sstruct.unpack2(fmt, data, _Object())
|
|
98
|
+
keys = range(e.attNum, e.attNum + e.num)
|
|
99
|
+
if len(data) >= 2 * e.num:
|
|
100
|
+
vals = struct.unpack_from((">%dh" % e.num), data)
|
|
101
|
+
attributes.update(zip(keys, vals))
|
|
102
|
+
data = data[2 * e.num :]
|
|
103
|
+
return attributes
|
|
104
|
+
|
|
105
|
+
def decompileAttributes3(self, data):
|
|
106
|
+
if self.hasOctaboxes:
|
|
107
|
+
o, data = sstruct.unpack2(Glat_format_3_octabox_metrics, data, _Object())
|
|
108
|
+
numsub = bin(o.subboxBitmap).count("1")
|
|
109
|
+
o.subboxes = []
|
|
110
|
+
for b in range(numsub):
|
|
111
|
+
if len(data) >= 8:
|
|
112
|
+
subbox, data = sstruct.unpack2(
|
|
113
|
+
Glat_format_3_subbox_entry, data, _Object()
|
|
114
|
+
)
|
|
115
|
+
o.subboxes.append(subbox)
|
|
116
|
+
attrs = self.decompileAttributes12(data, Glat_format_23_entry)
|
|
117
|
+
if self.hasOctaboxes:
|
|
118
|
+
attrs.octabox = o
|
|
119
|
+
return attrs
|
|
120
|
+
|
|
121
|
+
def compile(self, ttFont):
|
|
122
|
+
data = sstruct.pack(Glat_format_0, self)
|
|
123
|
+
if self.version <= 1.9:
|
|
124
|
+
encoder = partial(self.compileAttributes12, fmt=Glat_format_1_entry)
|
|
125
|
+
elif self.version <= 2.9:
|
|
126
|
+
encoder = partial(self.compileAttributes12, fmt=Glat_format_1_entry)
|
|
127
|
+
elif self.version >= 3.0:
|
|
128
|
+
self.compression = (self.scheme << 27) + (1 if self.hasOctaboxes else 0)
|
|
129
|
+
data = sstruct.pack(Glat_format_3, self)
|
|
130
|
+
encoder = self.compileAttributes3
|
|
131
|
+
|
|
132
|
+
glocs = []
|
|
133
|
+
for n in range(len(self.attributes)):
|
|
134
|
+
glocs.append(len(data))
|
|
135
|
+
data += encoder(self.attributes[ttFont.getGlyphName(n)])
|
|
136
|
+
glocs.append(len(data))
|
|
137
|
+
ttFont["Gloc"].set(glocs)
|
|
138
|
+
|
|
139
|
+
if self.version >= 3.0:
|
|
140
|
+
data = grUtils.compress(self.scheme, data)
|
|
141
|
+
return data
|
|
142
|
+
|
|
143
|
+
def compileAttributes12(self, attrs, fmt):
|
|
144
|
+
data = b""
|
|
145
|
+
for e in grUtils.entries(attrs):
|
|
146
|
+
data += sstruct.pack(fmt, {"attNum": e[0], "num": e[1]}) + struct.pack(
|
|
147
|
+
(">%dh" % len(e[2])), *e[2]
|
|
148
|
+
)
|
|
149
|
+
return data
|
|
150
|
+
|
|
151
|
+
def compileAttributes3(self, attrs):
|
|
152
|
+
if self.hasOctaboxes:
|
|
153
|
+
o = attrs.octabox
|
|
154
|
+
data = sstruct.pack(Glat_format_3_octabox_metrics, o)
|
|
155
|
+
numsub = bin(o.subboxBitmap).count("1")
|
|
156
|
+
for b in range(numsub):
|
|
157
|
+
data += sstruct.pack(Glat_format_3_subbox_entry, o.subboxes[b])
|
|
158
|
+
else:
|
|
159
|
+
data = ""
|
|
160
|
+
return data + self.compileAttributes12(attrs, Glat_format_23_entry)
|
|
161
|
+
|
|
162
|
+
def toXML(self, writer, ttFont):
|
|
163
|
+
writer.simpletag("version", version=self.version, compressionScheme=self.scheme)
|
|
164
|
+
writer.newline()
|
|
165
|
+
for n, a in sorted(
|
|
166
|
+
self.attributes.items(), key=lambda x: ttFont.getGlyphID(x[0])
|
|
167
|
+
):
|
|
168
|
+
writer.begintag("glyph", name=n)
|
|
169
|
+
writer.newline()
|
|
170
|
+
if hasattr(a, "octabox"):
|
|
171
|
+
o = a.octabox
|
|
172
|
+
formatstring, names, fixes = sstruct.getformat(
|
|
173
|
+
Glat_format_3_octabox_metrics
|
|
174
|
+
)
|
|
175
|
+
vals = {}
|
|
176
|
+
for k in names:
|
|
177
|
+
if k == "subboxBitmap":
|
|
178
|
+
continue
|
|
179
|
+
vals[k] = "{:.3f}%".format(getattr(o, k) * 100.0 / 255)
|
|
180
|
+
vals["bitmap"] = "{:0X}".format(o.subboxBitmap)
|
|
181
|
+
writer.begintag("octaboxes", **vals)
|
|
182
|
+
writer.newline()
|
|
183
|
+
formatstring, names, fixes = sstruct.getformat(
|
|
184
|
+
Glat_format_3_subbox_entry
|
|
185
|
+
)
|
|
186
|
+
for s in o.subboxes:
|
|
187
|
+
vals = {}
|
|
188
|
+
for k in names:
|
|
189
|
+
vals[k] = "{:.3f}%".format(getattr(s, k) * 100.0 / 255)
|
|
190
|
+
writer.simpletag("octabox", **vals)
|
|
191
|
+
writer.newline()
|
|
192
|
+
writer.endtag("octaboxes")
|
|
193
|
+
writer.newline()
|
|
194
|
+
for k, v in sorted(a.items()):
|
|
195
|
+
writer.simpletag("attribute", index=k, value=v)
|
|
196
|
+
writer.newline()
|
|
197
|
+
writer.endtag("glyph")
|
|
198
|
+
writer.newline()
|
|
199
|
+
|
|
200
|
+
def fromXML(self, name, attrs, content, ttFont):
|
|
201
|
+
if name == "version":
|
|
202
|
+
self.version = float(safeEval(attrs["version"]))
|
|
203
|
+
self.scheme = int(safeEval(attrs["compressionScheme"]))
|
|
204
|
+
if name != "glyph":
|
|
205
|
+
return
|
|
206
|
+
if not hasattr(self, "attributes"):
|
|
207
|
+
self.attributes = {}
|
|
208
|
+
gname = attrs["name"]
|
|
209
|
+
attributes = _Dict()
|
|
210
|
+
for element in content:
|
|
211
|
+
if not isinstance(element, tuple):
|
|
212
|
+
continue
|
|
213
|
+
tag, attrs, subcontent = element
|
|
214
|
+
if tag == "attribute":
|
|
215
|
+
k = int(safeEval(attrs["index"]))
|
|
216
|
+
v = int(safeEval(attrs["value"]))
|
|
217
|
+
attributes[k] = v
|
|
218
|
+
elif tag == "octaboxes":
|
|
219
|
+
self.hasOctaboxes = True
|
|
220
|
+
o = _Object()
|
|
221
|
+
o.subboxBitmap = int(attrs["bitmap"], 16)
|
|
222
|
+
o.subboxes = []
|
|
223
|
+
del attrs["bitmap"]
|
|
224
|
+
for k, v in attrs.items():
|
|
225
|
+
setattr(o, k, int(float(v[:-1]) * 255.0 / 100.0 + 0.5))
|
|
226
|
+
for element in subcontent:
|
|
227
|
+
if not isinstance(element, tuple):
|
|
228
|
+
continue
|
|
229
|
+
(tag, attrs, subcontent) = element
|
|
230
|
+
so = _Object()
|
|
231
|
+
for k, v in attrs.items():
|
|
232
|
+
setattr(so, k, int(float(v[:-1]) * 255.0 / 100.0 + 0.5))
|
|
233
|
+
o.subboxes.append(so)
|
|
234
|
+
attributes.octabox = o
|
|
235
|
+
self.attributes[gname] = attributes
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from fontTools.misc import sstruct
|
|
2
|
+
from fontTools.misc.textTools import safeEval
|
|
3
|
+
from . import DefaultTable
|
|
4
|
+
import array
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Gloc_header = """
|
|
9
|
+
> # big endian
|
|
10
|
+
version: 16.16F # Table version
|
|
11
|
+
flags: H # bit 0: 1=long format, 0=short format
|
|
12
|
+
# bit 1: 1=attribute names, 0=no names
|
|
13
|
+
numAttribs: H # NUmber of attributes
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class table_G__l_o_c(DefaultTable.DefaultTable):
|
|
18
|
+
"""Graphite Index to Glyph Atttributes table
|
|
19
|
+
|
|
20
|
+
See also https://graphite.sil.org/graphite_techAbout#graphite-font-tables
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
dependencies = ["Glat"]
|
|
24
|
+
|
|
25
|
+
def __init__(self, tag=None):
|
|
26
|
+
DefaultTable.DefaultTable.__init__(self, tag)
|
|
27
|
+
self.attribIds = None
|
|
28
|
+
self.numAttribs = 0
|
|
29
|
+
|
|
30
|
+
def decompile(self, data, ttFont):
|
|
31
|
+
_, data = sstruct.unpack2(Gloc_header, data, self)
|
|
32
|
+
flags = self.flags
|
|
33
|
+
del self.flags
|
|
34
|
+
self.locations = array.array("I" if flags & 1 else "H")
|
|
35
|
+
self.locations.frombytes(data[: len(data) - self.numAttribs * (flags & 2)])
|
|
36
|
+
if sys.byteorder != "big":
|
|
37
|
+
self.locations.byteswap()
|
|
38
|
+
self.attribIds = array.array("H")
|
|
39
|
+
if flags & 2:
|
|
40
|
+
self.attribIds.frombytes(data[-self.numAttribs * 2 :])
|
|
41
|
+
if sys.byteorder != "big":
|
|
42
|
+
self.attribIds.byteswap()
|
|
43
|
+
|
|
44
|
+
def compile(self, ttFont):
|
|
45
|
+
data = sstruct.pack(
|
|
46
|
+
Gloc_header,
|
|
47
|
+
dict(
|
|
48
|
+
version=1.0,
|
|
49
|
+
flags=(bool(self.attribIds) << 1) + (self.locations.typecode == "I"),
|
|
50
|
+
numAttribs=self.numAttribs,
|
|
51
|
+
),
|
|
52
|
+
)
|
|
53
|
+
if sys.byteorder != "big":
|
|
54
|
+
self.locations.byteswap()
|
|
55
|
+
data += self.locations.tobytes()
|
|
56
|
+
if sys.byteorder != "big":
|
|
57
|
+
self.locations.byteswap()
|
|
58
|
+
if self.attribIds:
|
|
59
|
+
if sys.byteorder != "big":
|
|
60
|
+
self.attribIds.byteswap()
|
|
61
|
+
data += self.attribIds.tobytes()
|
|
62
|
+
if sys.byteorder != "big":
|
|
63
|
+
self.attribIds.byteswap()
|
|
64
|
+
return data
|
|
65
|
+
|
|
66
|
+
def set(self, locations):
|
|
67
|
+
long_format = max(locations) >= 65536
|
|
68
|
+
self.locations = array.array("I" if long_format else "H", locations)
|
|
69
|
+
|
|
70
|
+
def toXML(self, writer, ttFont):
|
|
71
|
+
writer.simpletag("attributes", number=self.numAttribs)
|
|
72
|
+
writer.newline()
|
|
73
|
+
|
|
74
|
+
def fromXML(self, name, attrs, content, ttFont):
|
|
75
|
+
if name == "attributes":
|
|
76
|
+
self.numAttribs = int(safeEval(attrs["number"]))
|
|
77
|
+
|
|
78
|
+
def __getitem__(self, index):
|
|
79
|
+
return self.locations[index]
|
|
80
|
+
|
|
81
|
+
def __len__(self):
|
|
82
|
+
return len(self.locations)
|
|
83
|
+
|
|
84
|
+
def __iter__(self):
|
|
85
|
+
return iter(self.locations)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .otBase import BaseTTXConverter
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class table_H_V_A_R_(BaseTTXConverter):
|
|
5
|
+
"""Horizontal Metrics Variations table
|
|
6
|
+
|
|
7
|
+
The ``HVAR`` table contains variations in horizontal glyph metrics
|
|
8
|
+
in variable fonts.
|
|
9
|
+
|
|
10
|
+
See also https://learn.microsoft.com/en-us/typography/opentype/spec/hvar
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
pass
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .otBase import BaseTTXConverter
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class table_J_S_T_F_(BaseTTXConverter):
|
|
5
|
+
"""Justification table
|
|
6
|
+
|
|
7
|
+
The ``JSTF`` table contains glyph substitution and positioning
|
|
8
|
+
data used to perform text justification.
|
|
9
|
+
|
|
10
|
+
See also https://learn.microsoft.com/en-us/typography/opentype/spec/jstf
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
pass
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from fontTools.misc.textTools import safeEval
|
|
2
|
+
from . import DefaultTable
|
|
3
|
+
import struct
|
|
4
|
+
import array
|
|
5
|
+
|
|
6
|
+
# XXX I've lowered the strictness, to make sure Apple's own Chicago
|
|
7
|
+
# XXX gets through. They're looking into it, I hope to raise the standards
|
|
8
|
+
# XXX back to normal eventually.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class table_L_T_S_H_(DefaultTable.DefaultTable):
|
|
12
|
+
"""Linear Threshold table
|
|
13
|
+
|
|
14
|
+
The ``LTSH`` table contains per-glyph settings indicating the ppem sizes
|
|
15
|
+
at which the advance width metric should be scaled linearly, despite the
|
|
16
|
+
effects of any TrueType instructions that might otherwise alter the
|
|
17
|
+
advance width.
|
|
18
|
+
|
|
19
|
+
See also https://learn.microsoft.com/en-us/typography/opentype/spec/ltsh
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def decompile(self, data, ttFont):
|
|
23
|
+
version, numGlyphs = struct.unpack(">HH", data[:4])
|
|
24
|
+
data = data[4:]
|
|
25
|
+
assert version == 0, "unknown version: %s" % version
|
|
26
|
+
assert (len(data) % numGlyphs) < 4, "numGlyphs doesn't match data length"
|
|
27
|
+
# ouch: the assertion is not true in Chicago!
|
|
28
|
+
# assert numGlyphs == ttFont['maxp'].numGlyphs
|
|
29
|
+
yPels = array.array("B")
|
|
30
|
+
yPels.frombytes(data)
|
|
31
|
+
self.yPels = {}
|
|
32
|
+
for i in range(numGlyphs):
|
|
33
|
+
self.yPels[ttFont.getGlyphName(i)] = yPels[i]
|
|
34
|
+
|
|
35
|
+
def compile(self, ttFont):
|
|
36
|
+
version = 0
|
|
37
|
+
names = list(self.yPels.keys())
|
|
38
|
+
numGlyphs = len(names)
|
|
39
|
+
yPels = [0] * numGlyphs
|
|
40
|
+
# ouch: the assertion is not true in Chicago!
|
|
41
|
+
# assert len(self.yPels) == ttFont['maxp'].numGlyphs == numGlyphs
|
|
42
|
+
for name in names:
|
|
43
|
+
yPels[ttFont.getGlyphID(name)] = self.yPels[name]
|
|
44
|
+
yPels = array.array("B", yPels)
|
|
45
|
+
return struct.pack(">HH", version, numGlyphs) + yPels.tobytes()
|
|
46
|
+
|
|
47
|
+
def toXML(self, writer, ttFont):
|
|
48
|
+
names = sorted(self.yPels.keys())
|
|
49
|
+
for name in names:
|
|
50
|
+
writer.simpletag("yPel", name=name, value=self.yPels[name])
|
|
51
|
+
writer.newline()
|
|
52
|
+
|
|
53
|
+
def fromXML(self, name, attrs, content, ttFont):
|
|
54
|
+
if not hasattr(self, "yPels"):
|
|
55
|
+
self.yPels = {}
|
|
56
|
+
if name != "yPel":
|
|
57
|
+
return # ignore unknown tags
|
|
58
|
+
self.yPels[attrs["name"]] = safeEval(attrs["value"])
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .otBase import BaseTTXConverter
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class table_M_A_T_H_(BaseTTXConverter):
|
|
5
|
+
"""Mathematical Typesetting table
|
|
6
|
+
|
|
7
|
+
The ``MATH`` table contains a variety of information needed to
|
|
8
|
+
typeset glyphs in mathematical formulas and expressions.
|
|
9
|
+
|
|
10
|
+
See also https://learn.microsoft.com/en-us/typography/opentype/spec/math
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
pass
|