From 6755acceee73efd0605be168702c29ab975b2843 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 31 Jan 2023 12:46:17 -0700 Subject: [PATCH] [woff2] Add fvar to glyf dependencies Since the VarComposites added fvar to glyf dependencies in ttLib. Add test for VarComposite to woff2 tests. --- Lib/fontTools/ttLib/woff2.py | 5 +++-- Tests/ttLib/woff2_test.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Lib/fontTools/ttLib/woff2.py b/Lib/fontTools/ttLib/woff2.py index 6be06be0a..02e273d2e 100644 --- a/Lib/fontTools/ttLib/woff2.py +++ b/Lib/fontTools/ttLib/woff2.py @@ -294,8 +294,9 @@ class WOFF2Writer(SFNTWriter): if self.sfntVersion == "OTTO": return - for tag in ("maxp", "head", "loca", "glyf"): - self._decompileTable(tag) + for tag in ("maxp", "head", "loca", "glyf", "fvar"): + if tag in self.tables: + self._decompileTable(tag) self.ttFont["glyf"].padding = padding for tag in ("glyf", "loca"): self._compileTable(tag) diff --git a/Tests/ttLib/woff2_test.py b/Tests/ttLib/woff2_test.py index cfc7b1bc3..0a89b8b43 100644 --- a/Tests/ttLib/woff2_test.py +++ b/Tests/ttLib/woff2_test.py @@ -1491,6 +1491,20 @@ class UShort255Test(unittest.TestCase): ) +class VarCompositeTest(unittest.TestCase): + def test_var_composite(self): + input_path = os.path.join(data_dir, "varc-ac00-ac01.ttf") + ttf = ttLib.TTFont(input_path) + ttf.flavor = "woff2" + out = BytesIO() + ttf.save(out) + + ttf = ttLib.TTFont(out) + ttf.flavor = None + out = BytesIO() + ttf.save(out) + + if __name__ == "__main__": import sys