Skip to content

Commit f051d02

Browse files
committed
[instanceworker] use zopfli compression on woff files
1 parent f2b4e0c commit f051d02

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

src/slice/instanceworker.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import traceback
1919

2020
from fontTools.misc.textTools import num2binary
21+
from fontTools.ttLib import sfnt
2122
from fontTools.ttLib.ttFont import TTFont
2223
from fontTools.varLib.instancer import (
2324
instantiateVariableFont as partial_instantiateVariableFont,
@@ -66,6 +67,9 @@ def run(self):
6667
# edit bit flags
6768
self.edit_bit_flags()
6869
# write to disk
70+
# set fonttools to use zopfli compression on woff files
71+
sfnt.USE_ZOPFLI = True
72+
# sfnt.ZLIB_COMPRESSION_LEVEL = 9
6973
self.ttfont.save(self.outpath)
7074
except Exception as e:
7175
self.signals.error.emit(f"{e}")
@@ -95,13 +99,9 @@ def instantiate_variable_font(self):
9599
self.ttfont, axis_instance_data, inplace=True, optimize=True
96100
)
97101
else:
98-
static_instantiateVariableFont(
99-
self.ttfont, axis_instance_data, inplace=True
100-
)
102+
static_instantiateVariableFont(self.ttfont, axis_instance_data, inplace=True)
101103
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}")
105105
print(f"Partial instance: {is_partial_instance}")
106106

107107
def edit_name_table(self):
@@ -161,18 +161,10 @@ def edit_name_table(self):
161161
print(f"nameID3: {self.ttfont['name'].getName(3, *name_record_plat_enc_lang)}")
162162
print(f"nameID4: {self.ttfont['name'].getName(4, *name_record_plat_enc_lang)}")
163163
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)}")
176168

177169
def edit_bit_flags(self):
178170
# edit the OS/2.fsSelection bit flag
@@ -205,6 +197,4 @@ def edit_bit_flags(self):
205197
f"{self.bit_model.get_head_instance_data()}"
206198
)
207199
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

Comments
 (0)