diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-12-18 10:16:08 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-12-18 10:29:14 +0300 |
commit | 691a35e0546dbd763dd51657b1a3816a3c40e094 (patch) | |
tree | 651c5813885adb4fa8993f44b364a0a7a148e7ad /contrib/python/fonttools/fontTools/ttLib/ttGlyphSet.py | |
parent | 72b6bf1f88ac4ec4ed2adf6dda915278c5d2b924 (diff) | |
download | ydb-691a35e0546dbd763dd51657b1a3816a3c40e094.tar.gz |
Intermediate changes
commit_hash:1a5e9f4585838729a12fdcba5306caddb2c0c7ac
Diffstat (limited to 'contrib/python/fonttools/fontTools/ttLib/ttGlyphSet.py')
-rw-r--r-- | contrib/python/fonttools/fontTools/ttLib/ttGlyphSet.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/contrib/python/fonttools/fontTools/ttLib/ttGlyphSet.py b/contrib/python/fonttools/fontTools/ttLib/ttGlyphSet.py index 446c81e7db..e8dd007c5c 100644 --- a/contrib/python/fonttools/fontTools/ttLib/ttGlyphSet.py +++ b/contrib/python/fonttools/fontTools/ttLib/ttGlyphSet.py @@ -119,19 +119,35 @@ class _TTGlyphSetCFF(_TTGlyphSet): tableTag = "CFF2" if "CFF2" in font else "CFF " self.charStrings = list(font[tableTag].cff.values())[0].CharStrings super().__init__(font, location, self.charStrings) + self.setLocation(location) + + def __getitem__(self, glyphName): + return _TTGlyphCFF(self, glyphName) + + def setLocation(self, location): self.blender = None if location: + # TODO Optimize by using instancer.setLocation() + from fontTools.varLib.varStore import VarStoreInstancer varStore = getattr(self.charStrings, "varStore", None) if varStore is not None: instancer = VarStoreInstancer( - varStore.otVarStore, font["fvar"].axes, location + varStore.otVarStore, self.font["fvar"].axes, location ) self.blender = instancer.interpolateFromDeltas + else: + self.blender = None - def __getitem__(self, glyphName): - return _TTGlyphCFF(self, glyphName) + @contextmanager + def pushLocation(self, location, reset: bool): + self.setLocation(location) + with _TTGlyphSet.pushLocation(self, location, reset) as value: + try: + yield value + finally: + self.setLocation(self.location) class _TTGlyphSetVARC(_TTGlyphSet): @@ -335,7 +351,6 @@ class _TTGlyphVARC(_TTGlyph): ) for comp in glyph.components: - if comp.flags & VarComponentFlags.HAVE_CONDITION: condition = varc.ConditionList.ConditionTable[comp.conditionIndex] if not _evaluateCondition( |