|
18 | 18 | import traceback
|
19 | 19 |
|
20 | 20 | from fontTools.misc.textTools import num2binary
|
| 21 | +from fontTools.ttLib import sfnt |
21 | 22 | from fontTools.ttLib.ttFont import TTFont
|
22 | 23 | from fontTools.varLib.instancer import (
|
23 | 24 | instantiateVariableFont as partial_instantiateVariableFont,
|
@@ -66,6 +67,9 @@ def run(self):
|
66 | 67 | # edit bit flags
|
67 | 68 | self.edit_bit_flags()
|
68 | 69 | # write to disk
|
| 70 | + # set fonttools to use zopfli compression on woff files |
| 71 | + sfnt.USE_ZOPFLI = True |
| 72 | + # sfnt.ZLIB_COMPRESSION_LEVEL = 9 |
69 | 73 | self.ttfont.save(self.outpath)
|
70 | 74 | except Exception as e:
|
71 | 75 | self.signals.error.emit(f"{e}")
|
@@ -95,13 +99,9 @@ def instantiate_variable_font(self):
|
95 | 99 | self.ttfont, axis_instance_data, inplace=True, optimize=True
|
96 | 100 | )
|
97 | 101 | else:
|
98 |
| - static_instantiateVariableFont( |
99 |
| - self.ttfont, axis_instance_data, inplace=True |
100 |
| - ) |
| 102 | + static_instantiateVariableFont(self.ttfont, axis_instance_data, inplace=True) |
101 | 103 | print("\nAXIS INSTANCE VALUES")
|
102 |
| - print( |
103 |
| - f"Instantiated variable font with axis definitions:\n{axis_instance_data}" |
104 |
| - ) |
| 104 | + print(f"Instantiated variable font with axis definitions:\n{axis_instance_data}") |
105 | 105 | print(f"Partial instance: {is_partial_instance}")
|
106 | 106 |
|
107 | 107 | def edit_name_table(self):
|
@@ -161,18 +161,10 @@ def edit_name_table(self):
|
161 | 161 | print(f"nameID3: {self.ttfont['name'].getName(3, *name_record_plat_enc_lang)}")
|
162 | 162 | print(f"nameID4: {self.ttfont['name'].getName(4, *name_record_plat_enc_lang)}")
|
163 | 163 | print(f"nameID6: {self.ttfont['name'].getName(6, *name_record_plat_enc_lang)}")
|
164 |
| - print( |
165 |
| - f"nameID16: {self.ttfont['name'].getName(16, *name_record_plat_enc_lang)}" |
166 |
| - ) |
167 |
| - print( |
168 |
| - f"nameID17: {self.ttfont['name'].getName(17, *name_record_plat_enc_lang)}" |
169 |
| - ) |
170 |
| - print( |
171 |
| - f"nameID21: {self.ttfont['name'].getName(21, *name_record_plat_enc_lang)}" |
172 |
| - ) |
173 |
| - print( |
174 |
| - f"nameID22: {self.ttfont['name'].getName(22, *name_record_plat_enc_lang)}" |
175 |
| - ) |
| 164 | + print(f"nameID16: {self.ttfont['name'].getName(16, *name_record_plat_enc_lang)}") |
| 165 | + print(f"nameID17: {self.ttfont['name'].getName(17, *name_record_plat_enc_lang)}") |
| 166 | + print(f"nameID21: {self.ttfont['name'].getName(21, *name_record_plat_enc_lang)}") |
| 167 | + print(f"nameID22: {self.ttfont['name'].getName(22, *name_record_plat_enc_lang)}") |
176 | 168 |
|
177 | 169 | def edit_bit_flags(self):
|
178 | 170 | # edit the OS/2.fsSelection bit flag
|
@@ -205,6 +197,4 @@ def edit_bit_flags(self):
|
205 | 197 | f"{self.bit_model.get_head_instance_data()}"
|
206 | 198 | )
|
207 | 199 | print(f"Pre head.macStyle: {num2binary(pre_head_macstyle_int, bits=16)}")
|
208 |
| - print( |
209 |
| - f"Post head.macStyle: {num2binary(self.ttfont['head'].macStyle, bits=16)}" |
210 |
| - ) |
| 200 | + print(f"Post head.macStyle: {num2binary(self.ttfont['head'].macStyle, bits=16)}") |
0 commit comments