From 03e6101e979dd36e564d3b8ba9f60b8f791dae60 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Tue, 10 Dec 2024 12:28:09 +0100 Subject: [PATCH] Optionally use GVAR instead of gvar --- src/fontra_compile/builder.py | 6 +++++- src/fontra_compile/compile_varc_action.py | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/fontra_compile/builder.py b/src/fontra_compile/builder.py index b2c6e1d..dc1b60f 100644 --- a/src/fontra_compile/builder.py +++ b/src/fontra_compile/builder.py @@ -151,6 +151,7 @@ class Builder: requestedGlyphNames: list = field(default_factory=list) buildCFF2: bool = False subroutinize: bool = True + useExtendedGvar: bool = False async def setup(self) -> None: self.glyphMap = await self.reader.getGlyphMap() @@ -470,7 +471,10 @@ async def buildFont(self) -> TTFont: builder.setupGlyf(getGlyphInfoAttributes(self.glyphInfos, "ttGlyph")) gvarVariations = getGlyphInfoAttributes(self.glyphInfos, "gvarVariations") if gvarVariations: - builder.setupGvar(gvarVariations) + if self.useExtendedGvar: + builder.setupGVAR(gvarVariations) + else: + builder.setupGvar(gvarVariations) else: charStrings = getGlyphInfoAttributes(self.glyphInfos, "charString") charStringSupports = getGlyphInfoAttributes( diff --git a/src/fontra_compile/compile_varc_action.py b/src/fontra_compile/compile_varc_action.py index fba9b06..db2e36f 100644 --- a/src/fontra_compile/compile_varc_action.py +++ b/src/fontra_compile/compile_varc_action.py @@ -16,6 +16,7 @@ class FontraCompileAction: destination: str input: ReadableFontBackend | None = field(init=False, default=None) subroutinize: bool = True + useExtendedGvar: bool = False @asynccontextmanager async def connect( @@ -37,6 +38,7 @@ async def process( reader=self.input, buildCFF2=outputFontPath.suffix.lower() == ".otf", subroutinize=self.subroutinize, + useExtendedGvar=self.useExtendedGvar, ) await builder.setup() ttFont = await builder.build()