1""" 2Define all configuration options that can affect the working of fontTools 3modules. E.g. optimization levels of varLib IUP, otlLib GPOS compression level, 4etc. If this file gets too big, split it into smaller files per-module. 5 6An instance of the Config class can be attached to a TTFont object, so that 7the various modules can access their configuration options from it. 8""" 9 10from textwrap import dedent 11 12from fontTools.misc.configTools import * 13 14 15class Config(AbstractConfig): 16 options = Options() 17 18 19OPTIONS = Config.options 20 21 22Config.register_option( 23 name="fontTools.otlLib.optimize.gpos:COMPRESSION_LEVEL", 24 help=dedent( 25 """\ 26 GPOS Lookup type 2 (PairPos) compression level: 27 0 = do not attempt to compact PairPos lookups; 28 1 to 8 = create at most 1 to 8 new subtables for each existing 29 subtable, provided that it would yield a 50%% file size saving; 30 9 = create as many new subtables as needed to yield a file size saving. 31 Default: 0. 32 33 This compaction aims to save file size, by splitting large class 34 kerning subtables (Format 2) that contain many zero values into 35 smaller and denser subtables. It's a trade-off between the overhead 36 of several subtables versus the sparseness of one big subtable. 37 38 See the pull request: https://github.com/fonttools/fonttools/pull/2326 39 """ 40 ), 41 default=0, 42 parse=int, 43 validate=lambda v: v in range(10), 44) 45 46Config.register_option( 47 name="fontTools.ttLib.tables.otBase:USE_HARFBUZZ_REPACKER", 48 help=dedent( 49 """\ 50 FontTools tries to use the HarfBuzz Repacker to serialize GPOS/GSUB tables 51 if the uharfbuzz python bindings are importable, otherwise falls back to its 52 slower, less efficient serializer. Set to False to always use the latter. 53 Set to True to explicitly request the HarfBuzz Repacker (will raise an 54 error if uharfbuzz cannot be imported). 55 """ 56 ), 57 default=None, 58 parse=Option.parse_optional_bool, 59 validate=Option.validate_optional_bool, 60) 61 62Config.register_option( 63 name="fontTools.otlLib.builder:WRITE_GPOS7", 64 help=dedent( 65 """\ 66 macOS before 13.2 didn’t support GPOS LookupType 7 (non-chaining 67 ContextPos lookups), so FontTools.otlLib.builder disables a file size 68 optimisation that would use LookupType 7 instead of 8 when there is no 69 chaining (no prefix or suffix). Set to True to enable the optimization. 70 """ 71 ), 72 default=False, 73 parse=Option.parse_optional_bool, 74 validate=Option.validate_optional_bool, 75) 76