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.
Files changed (353) hide show
  1. fontTools/__init__.py +8 -0
  2. fontTools/__main__.py +35 -0
  3. fontTools/afmLib.py +439 -0
  4. fontTools/agl.py +5233 -0
  5. fontTools/annotations.py +30 -0
  6. fontTools/cffLib/CFF2ToCFF.py +258 -0
  7. fontTools/cffLib/CFFToCFF2.py +305 -0
  8. fontTools/cffLib/__init__.py +3694 -0
  9. fontTools/cffLib/specializer.py +927 -0
  10. fontTools/cffLib/transforms.py +495 -0
  11. fontTools/cffLib/width.py +210 -0
  12. fontTools/colorLib/__init__.py +0 -0
  13. fontTools/colorLib/builder.py +664 -0
  14. fontTools/colorLib/errors.py +2 -0
  15. fontTools/colorLib/geometry.py +143 -0
  16. fontTools/colorLib/table_builder.py +223 -0
  17. fontTools/colorLib/unbuilder.py +81 -0
  18. fontTools/config/__init__.py +90 -0
  19. fontTools/cu2qu/__init__.py +15 -0
  20. fontTools/cu2qu/__main__.py +6 -0
  21. fontTools/cu2qu/benchmark.py +54 -0
  22. fontTools/cu2qu/cli.py +198 -0
  23. fontTools/cu2qu/cu2qu.c +15817 -0
  24. fontTools/cu2qu/cu2qu.cp311-win32.pyd +0 -0
  25. fontTools/cu2qu/cu2qu.py +563 -0
  26. fontTools/cu2qu/errors.py +77 -0
  27. fontTools/cu2qu/ufo.py +363 -0
  28. fontTools/designspaceLib/__init__.py +3343 -0
  29. fontTools/designspaceLib/__main__.py +6 -0
  30. fontTools/designspaceLib/split.py +475 -0
  31. fontTools/designspaceLib/statNames.py +260 -0
  32. fontTools/designspaceLib/types.py +147 -0
  33. fontTools/encodings/MacRoman.py +258 -0
  34. fontTools/encodings/StandardEncoding.py +258 -0
  35. fontTools/encodings/__init__.py +1 -0
  36. fontTools/encodings/codecs.py +135 -0
  37. fontTools/feaLib/__init__.py +4 -0
  38. fontTools/feaLib/__main__.py +78 -0
  39. fontTools/feaLib/ast.py +2143 -0
  40. fontTools/feaLib/builder.py +1814 -0
  41. fontTools/feaLib/error.py +22 -0
  42. fontTools/feaLib/lexer.c +17029 -0
  43. fontTools/feaLib/lexer.cp311-win32.pyd +0 -0
  44. fontTools/feaLib/lexer.py +287 -0
  45. fontTools/feaLib/location.py +12 -0
  46. fontTools/feaLib/lookupDebugInfo.py +12 -0
  47. fontTools/feaLib/parser.py +2394 -0
  48. fontTools/feaLib/variableScalar.py +118 -0
  49. fontTools/fontBuilder.py +1014 -0
  50. fontTools/help.py +36 -0
  51. fontTools/merge/__init__.py +248 -0
  52. fontTools/merge/__main__.py +6 -0
  53. fontTools/merge/base.py +81 -0
  54. fontTools/merge/cmap.py +173 -0
  55. fontTools/merge/layout.py +526 -0
  56. fontTools/merge/options.py +85 -0
  57. fontTools/merge/tables.py +352 -0
  58. fontTools/merge/unicode.py +78 -0
  59. fontTools/merge/util.py +143 -0
  60. fontTools/misc/__init__.py +1 -0
  61. fontTools/misc/arrayTools.py +424 -0
  62. fontTools/misc/bezierTools.c +39731 -0
  63. fontTools/misc/bezierTools.cp311-win32.pyd +0 -0
  64. fontTools/misc/bezierTools.py +1500 -0
  65. fontTools/misc/classifyTools.py +170 -0
  66. fontTools/misc/cliTools.py +53 -0
  67. fontTools/misc/configTools.py +349 -0
  68. fontTools/misc/cython.py +27 -0
  69. fontTools/misc/dictTools.py +83 -0
  70. fontTools/misc/eexec.py +119 -0
  71. fontTools/misc/encodingTools.py +72 -0
  72. fontTools/misc/enumTools.py +23 -0
  73. fontTools/misc/etree.py +456 -0
  74. fontTools/misc/filenames.py +245 -0
  75. fontTools/misc/filesystem/__init__.py +68 -0
  76. fontTools/misc/filesystem/_base.py +134 -0
  77. fontTools/misc/filesystem/_copy.py +45 -0
  78. fontTools/misc/filesystem/_errors.py +54 -0
  79. fontTools/misc/filesystem/_info.py +75 -0
  80. fontTools/misc/filesystem/_osfs.py +164 -0
  81. fontTools/misc/filesystem/_path.py +67 -0
  82. fontTools/misc/filesystem/_subfs.py +92 -0
  83. fontTools/misc/filesystem/_tempfs.py +34 -0
  84. fontTools/misc/filesystem/_tools.py +34 -0
  85. fontTools/misc/filesystem/_walk.py +55 -0
  86. fontTools/misc/filesystem/_zipfs.py +204 -0
  87. fontTools/misc/fixedTools.py +253 -0
  88. fontTools/misc/intTools.py +25 -0
  89. fontTools/misc/iterTools.py +12 -0
  90. fontTools/misc/lazyTools.py +42 -0
  91. fontTools/misc/loggingTools.py +543 -0
  92. fontTools/misc/macCreatorType.py +56 -0
  93. fontTools/misc/macRes.py +261 -0
  94. fontTools/misc/plistlib/__init__.py +681 -0
  95. fontTools/misc/plistlib/py.typed +0 -0
  96. fontTools/misc/psCharStrings.py +1511 -0
  97. fontTools/misc/psLib.py +398 -0
  98. fontTools/misc/psOperators.py +572 -0
  99. fontTools/misc/py23.py +96 -0
  100. fontTools/misc/roundTools.py +110 -0
  101. fontTools/misc/sstruct.py +227 -0
  102. fontTools/misc/symfont.py +242 -0
  103. fontTools/misc/testTools.py +233 -0
  104. fontTools/misc/textTools.py +156 -0
  105. fontTools/misc/timeTools.py +88 -0
  106. fontTools/misc/transform.py +516 -0
  107. fontTools/misc/treeTools.py +45 -0
  108. fontTools/misc/vector.py +147 -0
  109. fontTools/misc/visitor.py +158 -0
  110. fontTools/misc/xmlReader.py +188 -0
  111. fontTools/misc/xmlWriter.py +231 -0
  112. fontTools/mtiLib/__init__.py +1400 -0
  113. fontTools/mtiLib/__main__.py +5 -0
  114. fontTools/otlLib/__init__.py +1 -0
  115. fontTools/otlLib/builder.py +3465 -0
  116. fontTools/otlLib/error.py +11 -0
  117. fontTools/otlLib/maxContextCalc.py +96 -0
  118. fontTools/otlLib/optimize/__init__.py +53 -0
  119. fontTools/otlLib/optimize/__main__.py +6 -0
  120. fontTools/otlLib/optimize/gpos.py +439 -0
  121. fontTools/pens/__init__.py +1 -0
  122. fontTools/pens/areaPen.py +52 -0
  123. fontTools/pens/basePen.py +475 -0
  124. fontTools/pens/boundsPen.py +98 -0
  125. fontTools/pens/cairoPen.py +26 -0
  126. fontTools/pens/cocoaPen.py +26 -0
  127. fontTools/pens/cu2quPen.py +325 -0
  128. fontTools/pens/explicitClosingLinePen.py +101 -0
  129. fontTools/pens/filterPen.py +433 -0
  130. fontTools/pens/freetypePen.py +462 -0
  131. fontTools/pens/hashPointPen.py +89 -0
  132. fontTools/pens/momentsPen.c +13378 -0
  133. fontTools/pens/momentsPen.cp311-win32.pyd +0 -0
  134. fontTools/pens/momentsPen.py +879 -0
  135. fontTools/pens/perimeterPen.py +69 -0
  136. fontTools/pens/pointInsidePen.py +192 -0
  137. fontTools/pens/pointPen.py +643 -0
  138. fontTools/pens/qtPen.py +29 -0
  139. fontTools/pens/qu2cuPen.py +105 -0
  140. fontTools/pens/quartzPen.py +43 -0
  141. fontTools/pens/recordingPen.py +335 -0
  142. fontTools/pens/reportLabPen.py +79 -0
  143. fontTools/pens/reverseContourPen.py +96 -0
  144. fontTools/pens/roundingPen.py +130 -0
  145. fontTools/pens/statisticsPen.py +312 -0
  146. fontTools/pens/svgPathPen.py +310 -0
  147. fontTools/pens/t2CharStringPen.py +88 -0
  148. fontTools/pens/teePen.py +55 -0
  149. fontTools/pens/transformPen.py +115 -0
  150. fontTools/pens/ttGlyphPen.py +335 -0
  151. fontTools/pens/wxPen.py +29 -0
  152. fontTools/qu2cu/__init__.py +15 -0
  153. fontTools/qu2cu/__main__.py +7 -0
  154. fontTools/qu2cu/benchmark.py +56 -0
  155. fontTools/qu2cu/cli.py +125 -0
  156. fontTools/qu2cu/qu2cu.c +16682 -0
  157. fontTools/qu2cu/qu2cu.cp311-win32.pyd +0 -0
  158. fontTools/qu2cu/qu2cu.py +405 -0
  159. fontTools/subset/__init__.py +4096 -0
  160. fontTools/subset/__main__.py +6 -0
  161. fontTools/subset/cff.py +184 -0
  162. fontTools/subset/svg.py +253 -0
  163. fontTools/subset/util.py +25 -0
  164. fontTools/svgLib/__init__.py +3 -0
  165. fontTools/svgLib/path/__init__.py +65 -0
  166. fontTools/svgLib/path/arc.py +154 -0
  167. fontTools/svgLib/path/parser.py +322 -0
  168. fontTools/svgLib/path/shapes.py +183 -0
  169. fontTools/t1Lib/__init__.py +648 -0
  170. fontTools/tfmLib.py +460 -0
  171. fontTools/ttLib/__init__.py +30 -0
  172. fontTools/ttLib/__main__.py +148 -0
  173. fontTools/ttLib/macUtils.py +54 -0
  174. fontTools/ttLib/removeOverlaps.py +395 -0
  175. fontTools/ttLib/reorderGlyphs.py +285 -0
  176. fontTools/ttLib/scaleUpem.py +436 -0
  177. fontTools/ttLib/sfnt.py +661 -0
  178. fontTools/ttLib/standardGlyphOrder.py +271 -0
  179. fontTools/ttLib/tables/B_A_S_E_.py +14 -0
  180. fontTools/ttLib/tables/BitmapGlyphMetrics.py +64 -0
  181. fontTools/ttLib/tables/C_B_D_T_.py +113 -0
  182. fontTools/ttLib/tables/C_B_L_C_.py +19 -0
  183. fontTools/ttLib/tables/C_F_F_.py +61 -0
  184. fontTools/ttLib/tables/C_F_F__2.py +26 -0
  185. fontTools/ttLib/tables/C_O_L_R_.py +165 -0
  186. fontTools/ttLib/tables/C_P_A_L_.py +305 -0
  187. fontTools/ttLib/tables/D_S_I_G_.py +158 -0
  188. fontTools/ttLib/tables/D__e_b_g.py +35 -0
  189. fontTools/ttLib/tables/DefaultTable.py +49 -0
  190. fontTools/ttLib/tables/E_B_D_T_.py +835 -0
  191. fontTools/ttLib/tables/E_B_L_C_.py +718 -0
  192. fontTools/ttLib/tables/F_F_T_M_.py +52 -0
  193. fontTools/ttLib/tables/F__e_a_t.py +149 -0
  194. fontTools/ttLib/tables/G_D_E_F_.py +13 -0
  195. fontTools/ttLib/tables/G_M_A_P_.py +148 -0
  196. fontTools/ttLib/tables/G_P_K_G_.py +133 -0
  197. fontTools/ttLib/tables/G_P_O_S_.py +14 -0
  198. fontTools/ttLib/tables/G_S_U_B_.py +13 -0
  199. fontTools/ttLib/tables/G_V_A_R_.py +5 -0
  200. fontTools/ttLib/tables/G__l_a_t.py +235 -0
  201. fontTools/ttLib/tables/G__l_o_c.py +85 -0
  202. fontTools/ttLib/tables/H_V_A_R_.py +13 -0
  203. fontTools/ttLib/tables/J_S_T_F_.py +13 -0
  204. fontTools/ttLib/tables/L_T_S_H_.py +58 -0
  205. fontTools/ttLib/tables/M_A_T_H_.py +13 -0
  206. fontTools/ttLib/tables/M_E_T_A_.py +352 -0
  207. fontTools/ttLib/tables/M_V_A_R_.py +13 -0
  208. fontTools/ttLib/tables/O_S_2f_2.py +752 -0
  209. fontTools/ttLib/tables/S_I_N_G_.py +99 -0
  210. fontTools/ttLib/tables/S_T_A_T_.py +15 -0
  211. fontTools/ttLib/tables/S_V_G_.py +223 -0
  212. fontTools/ttLib/tables/S__i_l_f.py +1040 -0
  213. fontTools/ttLib/tables/S__i_l_l.py +92 -0
  214. fontTools/ttLib/tables/T_S_I_B_.py +13 -0
  215. fontTools/ttLib/tables/T_S_I_C_.py +14 -0
  216. fontTools/ttLib/tables/T_S_I_D_.py +13 -0
  217. fontTools/ttLib/tables/T_S_I_J_.py +13 -0
  218. fontTools/ttLib/tables/T_S_I_P_.py +13 -0
  219. fontTools/ttLib/tables/T_S_I_S_.py +13 -0
  220. fontTools/ttLib/tables/T_S_I_V_.py +26 -0
  221. fontTools/ttLib/tables/T_S_I__0.py +70 -0
  222. fontTools/ttLib/tables/T_S_I__1.py +163 -0
  223. fontTools/ttLib/tables/T_S_I__2.py +17 -0
  224. fontTools/ttLib/tables/T_S_I__3.py +22 -0
  225. fontTools/ttLib/tables/T_S_I__5.py +60 -0
  226. fontTools/ttLib/tables/T_T_F_A_.py +14 -0
  227. fontTools/ttLib/tables/TupleVariation.py +884 -0
  228. fontTools/ttLib/tables/V_A_R_C_.py +12 -0
  229. fontTools/ttLib/tables/V_D_M_X_.py +249 -0
  230. fontTools/ttLib/tables/V_O_R_G_.py +165 -0
  231. fontTools/ttLib/tables/V_V_A_R_.py +13 -0
  232. fontTools/ttLib/tables/__init__.py +98 -0
  233. fontTools/ttLib/tables/_a_n_k_r.py +15 -0
  234. fontTools/ttLib/tables/_a_v_a_r.py +193 -0
  235. fontTools/ttLib/tables/_b_s_l_n.py +15 -0
  236. fontTools/ttLib/tables/_c_i_d_g.py +24 -0
  237. fontTools/ttLib/tables/_c_m_a_p.py +1591 -0
  238. fontTools/ttLib/tables/_c_v_a_r.py +94 -0
  239. fontTools/ttLib/tables/_c_v_t.py +56 -0
  240. fontTools/ttLib/tables/_f_e_a_t.py +15 -0
  241. fontTools/ttLib/tables/_f_p_g_m.py +62 -0
  242. fontTools/ttLib/tables/_f_v_a_r.py +261 -0
  243. fontTools/ttLib/tables/_g_a_s_p.py +63 -0
  244. fontTools/ttLib/tables/_g_c_i_d.py +13 -0
  245. fontTools/ttLib/tables/_g_l_y_f.py +2311 -0
  246. fontTools/ttLib/tables/_g_v_a_r.py +340 -0
  247. fontTools/ttLib/tables/_h_d_m_x.py +127 -0
  248. fontTools/ttLib/tables/_h_e_a_d.py +130 -0
  249. fontTools/ttLib/tables/_h_h_e_a.py +147 -0
  250. fontTools/ttLib/tables/_h_m_t_x.py +164 -0
  251. fontTools/ttLib/tables/_k_e_r_n.py +289 -0
  252. fontTools/ttLib/tables/_l_c_a_r.py +13 -0
  253. fontTools/ttLib/tables/_l_o_c_a.py +70 -0
  254. fontTools/ttLib/tables/_l_t_a_g.py +72 -0
  255. fontTools/ttLib/tables/_m_a_x_p.py +147 -0
  256. fontTools/ttLib/tables/_m_e_t_a.py +112 -0
  257. fontTools/ttLib/tables/_m_o_r_t.py +14 -0
  258. fontTools/ttLib/tables/_m_o_r_x.py +15 -0
  259. fontTools/ttLib/tables/_n_a_m_e.py +1242 -0
  260. fontTools/ttLib/tables/_o_p_b_d.py +14 -0
  261. fontTools/ttLib/tables/_p_o_s_t.py +319 -0
  262. fontTools/ttLib/tables/_p_r_e_p.py +16 -0
  263. fontTools/ttLib/tables/_p_r_o_p.py +12 -0
  264. fontTools/ttLib/tables/_s_b_i_x.py +129 -0
  265. fontTools/ttLib/tables/_t_r_a_k.py +332 -0
  266. fontTools/ttLib/tables/_v_h_e_a.py +139 -0
  267. fontTools/ttLib/tables/_v_m_t_x.py +19 -0
  268. fontTools/ttLib/tables/asciiTable.py +20 -0
  269. fontTools/ttLib/tables/grUtils.py +92 -0
  270. fontTools/ttLib/tables/otBase.py +1458 -0
  271. fontTools/ttLib/tables/otConverters.py +2068 -0
  272. fontTools/ttLib/tables/otData.py +6400 -0
  273. fontTools/ttLib/tables/otTables.py +2703 -0
  274. fontTools/ttLib/tables/otTraverse.py +163 -0
  275. fontTools/ttLib/tables/sbixGlyph.py +149 -0
  276. fontTools/ttLib/tables/sbixStrike.py +177 -0
  277. fontTools/ttLib/tables/table_API_readme.txt +91 -0
  278. fontTools/ttLib/tables/ttProgram.py +594 -0
  279. fontTools/ttLib/ttCollection.py +125 -0
  280. fontTools/ttLib/ttFont.py +1148 -0
  281. fontTools/ttLib/ttGlyphSet.py +490 -0
  282. fontTools/ttLib/ttVisitor.py +32 -0
  283. fontTools/ttLib/woff2.py +1680 -0
  284. fontTools/ttx.py +479 -0
  285. fontTools/ufoLib/__init__.py +2575 -0
  286. fontTools/ufoLib/converters.py +407 -0
  287. fontTools/ufoLib/errors.py +30 -0
  288. fontTools/ufoLib/etree.py +6 -0
  289. fontTools/ufoLib/filenames.py +356 -0
  290. fontTools/ufoLib/glifLib.py +2120 -0
  291. fontTools/ufoLib/kerning.py +141 -0
  292. fontTools/ufoLib/plistlib.py +47 -0
  293. fontTools/ufoLib/pointPen.py +6 -0
  294. fontTools/ufoLib/utils.py +107 -0
  295. fontTools/ufoLib/validators.py +1208 -0
  296. fontTools/unicode.py +50 -0
  297. fontTools/unicodedata/Blocks.py +817 -0
  298. fontTools/unicodedata/Mirrored.py +446 -0
  299. fontTools/unicodedata/OTTags.py +50 -0
  300. fontTools/unicodedata/ScriptExtensions.py +832 -0
  301. fontTools/unicodedata/Scripts.py +3639 -0
  302. fontTools/unicodedata/__init__.py +306 -0
  303. fontTools/varLib/__init__.py +1600 -0
  304. fontTools/varLib/__main__.py +6 -0
  305. fontTools/varLib/avar/__init__.py +0 -0
  306. fontTools/varLib/avar/__main__.py +72 -0
  307. fontTools/varLib/avar/build.py +79 -0
  308. fontTools/varLib/avar/map.py +108 -0
  309. fontTools/varLib/avar/plan.py +1004 -0
  310. fontTools/varLib/avar/unbuild.py +271 -0
  311. fontTools/varLib/avarPlanner.py +8 -0
  312. fontTools/varLib/builder.py +215 -0
  313. fontTools/varLib/cff.py +631 -0
  314. fontTools/varLib/errors.py +219 -0
  315. fontTools/varLib/featureVars.py +703 -0
  316. fontTools/varLib/hvar.py +113 -0
  317. fontTools/varLib/instancer/__init__.py +2052 -0
  318. fontTools/varLib/instancer/__main__.py +5 -0
  319. fontTools/varLib/instancer/featureVars.py +190 -0
  320. fontTools/varLib/instancer/names.py +388 -0
  321. fontTools/varLib/instancer/solver.py +309 -0
  322. fontTools/varLib/interpolatable.py +1209 -0
  323. fontTools/varLib/interpolatableHelpers.py +399 -0
  324. fontTools/varLib/interpolatablePlot.py +1269 -0
  325. fontTools/varLib/interpolatableTestContourOrder.py +82 -0
  326. fontTools/varLib/interpolatableTestStartingPoint.py +107 -0
  327. fontTools/varLib/interpolate_layout.py +124 -0
  328. fontTools/varLib/iup.c +19815 -0
  329. fontTools/varLib/iup.cp311-win32.pyd +0 -0
  330. fontTools/varLib/iup.py +490 -0
  331. fontTools/varLib/merger.py +1717 -0
  332. fontTools/varLib/models.py +642 -0
  333. fontTools/varLib/multiVarStore.py +253 -0
  334. fontTools/varLib/mutator.py +529 -0
  335. fontTools/varLib/mvar.py +40 -0
  336. fontTools/varLib/plot.py +238 -0
  337. fontTools/varLib/stat.py +149 -0
  338. fontTools/varLib/varStore.py +739 -0
  339. fontTools/voltLib/__init__.py +5 -0
  340. fontTools/voltLib/__main__.py +206 -0
  341. fontTools/voltLib/ast.py +452 -0
  342. fontTools/voltLib/error.py +12 -0
  343. fontTools/voltLib/lexer.py +99 -0
  344. fontTools/voltLib/parser.py +664 -0
  345. fontTools/voltLib/voltToFea.py +911 -0
  346. fonttools-4.60.2.data/data/share/man/man1/ttx.1 +225 -0
  347. fonttools-4.60.2.dist-info/METADATA +2250 -0
  348. fonttools-4.60.2.dist-info/RECORD +353 -0
  349. fonttools-4.60.2.dist-info/WHEEL +5 -0
  350. fonttools-4.60.2.dist-info/entry_points.txt +5 -0
  351. fonttools-4.60.2.dist-info/licenses/LICENSE +21 -0
  352. fonttools-4.60.2.dist-info/licenses/LICENSE.external +388 -0
  353. fonttools-4.60.2.dist-info/top_level.txt +1 -0
fontTools/ttx.py ADDED
@@ -0,0 +1,479 @@
1
+ """\
2
+ usage: ttx [options] inputfile1 [... inputfileN]
3
+
4
+ TTX -- From OpenType To XML And Back
5
+
6
+ If an input file is a TrueType or OpenType font file, it will be
7
+ decompiled to a TTX file (an XML-based text format).
8
+ If an input file is a TTX file, it will be compiled to whatever
9
+ format the data is in, a TrueType or OpenType/CFF font file.
10
+ A special input value of - means read from the standard input.
11
+
12
+ Output files are created so they are unique: an existing file is
13
+ never overwritten.
14
+
15
+ General options
16
+ ===============
17
+
18
+ -h Help print this message.
19
+ --version show version and exit.
20
+ -d <outputfolder> Specify a directory where the output files are
21
+ to be created.
22
+ -o <outputfile> Specify a file to write the output to. A special
23
+ value of - would use the standard output.
24
+ -f Overwrite existing output file(s), ie. don't append
25
+ numbers.
26
+ -v Verbose: more messages will be written to stdout
27
+ about what is being done.
28
+ -q Quiet: No messages will be written to stdout about
29
+ what is being done.
30
+ -a allow virtual glyphs ID's on compile or decompile.
31
+
32
+ Dump options
33
+ ============
34
+
35
+ -l List table info: instead of dumping to a TTX file, list
36
+ some minimal info about each table.
37
+ -t <table> Specify a table to dump. Multiple -t options
38
+ are allowed. When no -t option is specified, all tables
39
+ will be dumped.
40
+ -x <table> Specify a table to exclude from the dump. Multiple
41
+ -x options are allowed. -t and -x are mutually exclusive.
42
+ -s Split tables: save the TTX data into separate TTX files per
43
+ table and write one small TTX file that contains references
44
+ to the individual table dumps. This file can be used as
45
+ input to ttx, as long as the table files are in the
46
+ same directory.
47
+ -g Split glyf table: Save the glyf data into separate TTX files
48
+ per glyph and write a small TTX for the glyf table which
49
+ contains references to the individual TTGlyph elements.
50
+ NOTE: specifying -g implies -s (no need for -s together
51
+ with -g)
52
+ -i Do NOT disassemble TT instructions: when this option is
53
+ given, all TrueType programs (glyph programs, the font
54
+ program and the pre-program) will be written to the TTX
55
+ file as hex data instead of assembly. This saves some time
56
+ and makes the TTX file smaller.
57
+ -z <format> Specify a bitmap data export option for EBDT:
58
+ {'raw', 'row', 'bitwise', 'extfile'} or for the CBDT:
59
+ {'raw', 'extfile'} Each option does one of the following:
60
+
61
+ -z raw
62
+ export the bitmap data as a hex dump
63
+ -z row
64
+ export each row as hex data
65
+ -z bitwise
66
+ export each row as binary in an ASCII art style
67
+ -z extfile
68
+ export the data as external files with XML references
69
+
70
+ If no export format is specified 'raw' format is used.
71
+ -e Don't ignore decompilation errors, but show a full traceback
72
+ and abort.
73
+ -y <number> Select font number for TrueType Collection (.ttc/.otc),
74
+ starting from 0.
75
+ --unicodedata <UnicodeData.txt>
76
+ Use custom database file to write character names in the
77
+ comments of the cmap TTX output.
78
+ --newline <value>
79
+ Control how line endings are written in the XML file. It
80
+ can be 'LF', 'CR', or 'CRLF'. If not specified, the
81
+ default platform-specific line endings are used.
82
+
83
+ Compile options
84
+ ===============
85
+
86
+ -m Merge with TrueType-input-file: specify a TrueType or
87
+ OpenType font file to be merged with the TTX file. This
88
+ option is only valid when at most one TTX file is specified.
89
+ -b Don't recalc glyph bounding boxes: use the values in the
90
+ TTX file as-is.
91
+ --recalc-timestamp
92
+ Set font 'modified' timestamp to current time.
93
+ By default, the modification time of the TTX file will be
94
+ used.
95
+ --no-recalc-timestamp
96
+ Keep the original font 'modified' timestamp.
97
+ --flavor <type>
98
+ Specify flavor of output font file. May be 'woff' or 'woff2'.
99
+ Note that WOFF2 requires the Brotli Python extension,
100
+ available at https://github.com/google/brotli
101
+ --with-zopfli
102
+ Use Zopfli instead of Zlib to compress WOFF. The Python
103
+ extension is available at https://pypi.python.org/pypi/zopfli
104
+ --optimize-font-speed
105
+ Enable optimizations that prioritize speed over file size.
106
+ This mainly affects how glyf t able and gvar / VARC tables are
107
+ compiled. The produced fonts will be larger, but rendering
108
+ performance will be improved with HarfBuzz and other text
109
+ layout engines.
110
+ """
111
+
112
+ from fontTools.ttLib import OPTIMIZE_FONT_SPEED, TTFont, TTLibError
113
+ from fontTools.misc.macCreatorType import getMacCreatorAndType
114
+ from fontTools.unicode import setUnicodeData
115
+ from fontTools.misc.textTools import Tag, tostr
116
+ from fontTools.misc.timeTools import timestampSinceEpoch
117
+ from fontTools.misc.loggingTools import Timer
118
+ from fontTools.misc.cliTools import makeOutputFileName
119
+ import os
120
+ import sys
121
+ import getopt
122
+ import re
123
+ import logging
124
+
125
+
126
+ log = logging.getLogger("fontTools.ttx")
127
+
128
+ opentypeheaderRE = re.compile("""sfntVersion=['"]OTTO["']""")
129
+
130
+
131
+ class Options(object):
132
+ listTables = False
133
+ outputDir = None
134
+ outputFile = None
135
+ overWrite = False
136
+ verbose = False
137
+ quiet = False
138
+ splitTables = False
139
+ splitGlyphs = False
140
+ disassembleInstructions = True
141
+ mergeFile = None
142
+ recalcBBoxes = True
143
+ ignoreDecompileErrors = True
144
+ bitmapGlyphDataFormat = "raw"
145
+ unicodedata = None
146
+ newlinestr = "\n"
147
+ recalcTimestamp = None
148
+ flavor = None
149
+ useZopfli = False
150
+ optimizeFontSpeed = False
151
+
152
+ def __init__(self, rawOptions, numFiles):
153
+ self.onlyTables = []
154
+ self.skipTables = []
155
+ self.fontNumber = -1
156
+ for option, value in rawOptions:
157
+ # general options
158
+ if option == "-h":
159
+ print(__doc__)
160
+ sys.exit(0)
161
+ elif option == "--version":
162
+ from fontTools import version
163
+
164
+ print(version)
165
+ sys.exit(0)
166
+ elif option == "-d":
167
+ if not os.path.isdir(value):
168
+ raise getopt.GetoptError(
169
+ "The -d option value must be an existing directory"
170
+ )
171
+ self.outputDir = value
172
+ elif option == "-o":
173
+ self.outputFile = value
174
+ elif option == "-f":
175
+ self.overWrite = True
176
+ elif option == "-v":
177
+ self.verbose = True
178
+ elif option == "-q":
179
+ self.quiet = True
180
+ # dump options
181
+ elif option == "-l":
182
+ self.listTables = True
183
+ elif option == "-t":
184
+ # pad with space if table tag length is less than 4
185
+ value = value.ljust(4)
186
+ self.onlyTables.append(value)
187
+ elif option == "-x":
188
+ # pad with space if table tag length is less than 4
189
+ value = value.ljust(4)
190
+ self.skipTables.append(value)
191
+ elif option == "-s":
192
+ self.splitTables = True
193
+ elif option == "-g":
194
+ # -g implies (and forces) splitTables
195
+ self.splitGlyphs = True
196
+ self.splitTables = True
197
+ elif option == "-i":
198
+ self.disassembleInstructions = False
199
+ elif option == "-z":
200
+ validOptions = ("raw", "row", "bitwise", "extfile")
201
+ if value not in validOptions:
202
+ raise getopt.GetoptError(
203
+ "-z does not allow %s as a format. Use %s"
204
+ % (option, validOptions)
205
+ )
206
+ self.bitmapGlyphDataFormat = value
207
+ elif option == "-y":
208
+ self.fontNumber = int(value)
209
+ # compile options
210
+ elif option == "-m":
211
+ self.mergeFile = value
212
+ elif option == "-b":
213
+ self.recalcBBoxes = False
214
+ elif option == "-e":
215
+ self.ignoreDecompileErrors = False
216
+ elif option == "--unicodedata":
217
+ self.unicodedata = value
218
+ elif option == "--newline":
219
+ validOptions = ("LF", "CR", "CRLF")
220
+ if value == "LF":
221
+ self.newlinestr = "\n"
222
+ elif value == "CR":
223
+ self.newlinestr = "\r"
224
+ elif value == "CRLF":
225
+ self.newlinestr = "\r\n"
226
+ else:
227
+ raise getopt.GetoptError(
228
+ "Invalid choice for --newline: %r (choose from %s)"
229
+ % (value, ", ".join(map(repr, validOptions)))
230
+ )
231
+ elif option == "--recalc-timestamp":
232
+ self.recalcTimestamp = True
233
+ elif option == "--no-recalc-timestamp":
234
+ self.recalcTimestamp = False
235
+ elif option == "--flavor":
236
+ self.flavor = value
237
+ elif option == "--with-zopfli":
238
+ self.useZopfli = True
239
+ elif option == "--optimize-font-speed":
240
+ self.optimizeFontSpeed = True
241
+ if self.verbose and self.quiet:
242
+ raise getopt.GetoptError("-q and -v options are mutually exclusive")
243
+ if self.verbose:
244
+ self.logLevel = logging.DEBUG
245
+ elif self.quiet:
246
+ self.logLevel = logging.WARNING
247
+ else:
248
+ self.logLevel = logging.INFO
249
+ if self.mergeFile and self.flavor:
250
+ raise getopt.GetoptError("-m and --flavor options are mutually exclusive")
251
+ if self.onlyTables and self.skipTables:
252
+ raise getopt.GetoptError("-t and -x options are mutually exclusive")
253
+ if self.mergeFile and numFiles > 1:
254
+ raise getopt.GetoptError(
255
+ "Must specify exactly one TTX source file when using -m"
256
+ )
257
+ if self.flavor != "woff" and self.useZopfli:
258
+ raise getopt.GetoptError("--with-zopfli option requires --flavor 'woff'")
259
+
260
+
261
+ def ttList(input, output, options):
262
+ ttf = TTFont(input, fontNumber=options.fontNumber, lazy=True)
263
+ reader = ttf.reader
264
+ tags = sorted(reader.keys())
265
+ print('Listing table info for "%s":' % input)
266
+ format = " %4s %10s %8s %8s"
267
+ print(format % ("tag ", " checksum", " length", " offset"))
268
+ print(format % ("----", "----------", "--------", "--------"))
269
+ for tag in tags:
270
+ entry = reader.tables[tag]
271
+ if ttf.flavor == "woff2":
272
+ # WOFF2 doesn't store table checksums, so they must be calculated
273
+ from fontTools.ttLib.sfnt import calcChecksum
274
+
275
+ data = entry.loadData(reader.transformBuffer)
276
+ checkSum = calcChecksum(data)
277
+ else:
278
+ checkSum = int(entry.checkSum)
279
+ if checkSum < 0:
280
+ checkSum = checkSum + 0x100000000
281
+ checksum = "0x%08X" % checkSum
282
+ print(format % (tag, checksum, entry.length, entry.offset))
283
+ print()
284
+ ttf.close()
285
+
286
+
287
+ @Timer(log, "Done dumping TTX in %(time).3f seconds")
288
+ def ttDump(input, output, options):
289
+ input_name = input
290
+ if input == "-":
291
+ input, input_name = sys.stdin.buffer, sys.stdin.name
292
+ output_name = output
293
+ if output == "-":
294
+ output, output_name = sys.stdout, sys.stdout.name
295
+ log.info('Dumping "%s" to "%s"...', input_name, output_name)
296
+ if options.unicodedata:
297
+ setUnicodeData(options.unicodedata)
298
+ ttf = TTFont(
299
+ input,
300
+ 0,
301
+ ignoreDecompileErrors=options.ignoreDecompileErrors,
302
+ fontNumber=options.fontNumber,
303
+ )
304
+ ttf.saveXML(
305
+ output,
306
+ tables=options.onlyTables,
307
+ skipTables=options.skipTables,
308
+ splitTables=options.splitTables,
309
+ splitGlyphs=options.splitGlyphs,
310
+ disassembleInstructions=options.disassembleInstructions,
311
+ bitmapGlyphDataFormat=options.bitmapGlyphDataFormat,
312
+ newlinestr=options.newlinestr,
313
+ )
314
+ ttf.close()
315
+
316
+
317
+ @Timer(log, "Done compiling TTX in %(time).3f seconds")
318
+ def ttCompile(input, output, options):
319
+ input_name = input
320
+ if input == "-":
321
+ input, input_name = sys.stdin, sys.stdin.name
322
+ output_name = output
323
+ if output == "-":
324
+ output, output_name = sys.stdout.buffer, sys.stdout.name
325
+ log.info('Compiling "%s" to "%s"...' % (input_name, output))
326
+ if options.useZopfli:
327
+ from fontTools.ttLib import sfnt
328
+
329
+ sfnt.USE_ZOPFLI = True
330
+ ttf = TTFont(
331
+ options.mergeFile,
332
+ flavor=options.flavor,
333
+ recalcBBoxes=options.recalcBBoxes,
334
+ recalcTimestamp=options.recalcTimestamp,
335
+ )
336
+ if options.optimizeFontSpeed:
337
+ ttf.cfg[OPTIMIZE_FONT_SPEED] = options.optimizeFontSpeed
338
+ ttf.importXML(input)
339
+
340
+ if options.recalcTimestamp is None and "head" in ttf and input is not sys.stdin:
341
+ # use TTX file modification time for head "modified" timestamp
342
+ mtime = os.path.getmtime(input)
343
+ ttf["head"].modified = timestampSinceEpoch(mtime)
344
+
345
+ ttf.save(output)
346
+
347
+
348
+ def guessFileType(fileName):
349
+ if fileName == "-":
350
+ header = sys.stdin.buffer.peek(256)
351
+ ext = ""
352
+ else:
353
+ base, ext = os.path.splitext(fileName)
354
+ try:
355
+ with open(fileName, "rb") as f:
356
+ header = f.read(256)
357
+ except IOError:
358
+ return None
359
+
360
+ if header.startswith(b"\xef\xbb\xbf<?xml"):
361
+ header = header.lstrip(b"\xef\xbb\xbf")
362
+ cr, tp = getMacCreatorAndType(fileName)
363
+ if tp in ("sfnt", "FFIL"):
364
+ return "TTF"
365
+ if ext == ".dfont":
366
+ return "TTF"
367
+ head = Tag(header[:4])
368
+ if head == "OTTO":
369
+ return "OTF"
370
+ elif head == "ttcf":
371
+ return "TTC"
372
+ elif head in ("\0\1\0\0", "true"):
373
+ return "TTF"
374
+ elif head == "wOFF":
375
+ return "WOFF"
376
+ elif head == "wOF2":
377
+ return "WOFF2"
378
+ elif head == "<?xm":
379
+ # Use 'latin1' because that can't fail.
380
+ header = tostr(header, "latin1")
381
+ if opentypeheaderRE.search(header):
382
+ return "OTX"
383
+ else:
384
+ return "TTX"
385
+ return None
386
+
387
+
388
+ def parseOptions(args):
389
+ rawOptions, files = getopt.gnu_getopt(
390
+ args,
391
+ "ld:o:fvqht:x:sgim:z:baey:",
392
+ [
393
+ "unicodedata=",
394
+ "recalc-timestamp",
395
+ "no-recalc-timestamp",
396
+ "flavor=",
397
+ "version",
398
+ "with-zopfli",
399
+ "newline=",
400
+ "optimize-font-speed",
401
+ ],
402
+ )
403
+
404
+ options = Options(rawOptions, len(files))
405
+ jobs = []
406
+
407
+ if not files:
408
+ raise getopt.GetoptError("Must specify at least one input file")
409
+
410
+ for input in files:
411
+ if input != "-" and not os.path.isfile(input):
412
+ raise getopt.GetoptError('File not found: "%s"' % input)
413
+ tp = guessFileType(input)
414
+ if tp in ("OTF", "TTF", "TTC", "WOFF", "WOFF2"):
415
+ extension = ".ttx"
416
+ if options.listTables:
417
+ action = ttList
418
+ else:
419
+ action = ttDump
420
+ elif tp == "TTX":
421
+ extension = "." + options.flavor if options.flavor else ".ttf"
422
+ action = ttCompile
423
+ elif tp == "OTX":
424
+ extension = "." + options.flavor if options.flavor else ".otf"
425
+ action = ttCompile
426
+ else:
427
+ raise getopt.GetoptError('Unknown file type: "%s"' % input)
428
+
429
+ if options.outputFile:
430
+ output = options.outputFile
431
+ else:
432
+ if input == "-":
433
+ raise getopt.GetoptError("Must provide -o when reading from stdin")
434
+ output = makeOutputFileName(
435
+ input, options.outputDir, extension, options.overWrite
436
+ )
437
+ # 'touch' output file to avoid race condition in choosing file names
438
+ if action != ttList:
439
+ open(output, "a").close()
440
+ jobs.append((action, input, output))
441
+ return jobs, options
442
+
443
+
444
+ def process(jobs, options):
445
+ for action, input, output in jobs:
446
+ action(input, output, options)
447
+
448
+
449
+ def main(args=None):
450
+ """Convert OpenType fonts to XML and back"""
451
+ from fontTools import configLogger
452
+
453
+ if args is None:
454
+ args = sys.argv[1:]
455
+ try:
456
+ jobs, options = parseOptions(args)
457
+ except getopt.GetoptError as e:
458
+ print("%s\nERROR: %s" % (__doc__, e), file=sys.stderr)
459
+ sys.exit(2)
460
+
461
+ configLogger(level=options.logLevel)
462
+
463
+ try:
464
+ process(jobs, options)
465
+ except KeyboardInterrupt:
466
+ log.error("(Cancelled.)")
467
+ sys.exit(1)
468
+ except SystemExit:
469
+ raise
470
+ except TTLibError as e:
471
+ log.error(e)
472
+ sys.exit(1)
473
+ except:
474
+ log.exception("Unhandled exception has occurred")
475
+ sys.exit(1)
476
+
477
+
478
+ if __name__ == "__main__":
479
+ sys.exit(main())