diff options
Diffstat (limited to 'Lib/fontTools/otlLib/builder.py')
-rw-r--r-- | Lib/fontTools/otlLib/builder.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Lib/fontTools/otlLib/builder.py b/Lib/fontTools/otlLib/builder.py index e3f33551..233edec2 100644 --- a/Lib/fontTools/otlLib/builder.py +++ b/Lib/fontTools/otlLib/builder.py @@ -12,8 +12,7 @@ from fontTools.ttLib.tables.otBase import ( from fontTools.ttLib.tables import otBase from fontTools.feaLib.ast import STATNameStatement from fontTools.otlLib.optimize.gpos import ( - GPOS_COMPACT_MODE_DEFAULT, - GPOS_COMPACT_MODE_ENV_KEY, + _compression_level_from_env, compact_lookup, ) from fontTools.otlLib.error import OpenTypeLibError @@ -367,9 +366,15 @@ class ChainContextualBuilder(LookupBuilder): contextual positioning lookup. """ subtables = [] - chaining = False + rulesets = self.rulesets() chaining = any(ruleset.hasPrefixOrSuffix for ruleset in rulesets) + # Unfortunately, as of 2022-03-07, Apple's CoreText renderer does not + # correctly process GPOS7 lookups, so for now we force contextual + # positioning lookups to be chaining (GPOS8). + if self.subtable_type == "Pos": # horrible separation of concerns breach + chaining = True + for ruleset in rulesets: # Determine format strategy. We try to build formats 1, 2 and 3 # subtables and then work out which is best. candidates list holds @@ -1408,10 +1413,14 @@ class PairPosBuilder(LookupBuilder): # Compact the lookup # This is a good moment to do it because the compaction should create # smaller subtables, which may prevent overflows from happening. - mode = os.environ.get(GPOS_COMPACT_MODE_ENV_KEY, GPOS_COMPACT_MODE_DEFAULT) - if mode and mode != "0": + # Keep reading the value from the ENV until ufo2ft switches to the config system + level = self.font.cfg.get( + "fontTools.otlLib.optimize.gpos:COMPRESSION_LEVEL", + default=_compression_level_from_env(), + ) + if level != 0: log.info("Compacting GPOS...") - compact_lookup(self.font, mode, lookup) + compact_lookup(self.font, level, lookup) return lookup |