• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"""
9from textwrap import dedent
10
11from fontTools.misc.configTools import *
12
13
14class Config(AbstractConfig):
15    options = Options()
16
17
18OPTIONS = Config.options
19
20
21Config.register_option(
22    name="fontTools.otlLib.optimize.gpos:COMPRESSION_LEVEL",
23    help=dedent(
24        """\
25        GPOS Lookup type 2 (PairPos) compression level:
26            0 = do not attempt to compact PairPos lookups;
27            1 to 8 = create at most 1 to 8 new subtables for each existing
28                subtable, provided that it would yield a 50%% file size saving;
29            9 = create as many new subtables as needed to yield a file size saving.
30        Default: 0.
31
32        This compaction aims to save file size, by splitting large class
33        kerning subtables (Format 2) that contain many zero values into
34        smaller and denser subtables. It's a trade-off between the overhead
35        of several subtables versus the sparseness of one big subtable.
36
37        See the pull request: https://github.com/fonttools/fonttools/pull/2326
38        """
39    ),
40    default=0,
41    parse=int,
42    validate=lambda v: v in range(10),
43)
44
45Config.register_option(
46    name="fontTools.ttLib.tables.otBase:USE_HARFBUZZ_REPACKER",
47    help=dedent(
48        """\
49        FontTools tries to use the HarfBuzz Repacker to serialize GPOS/GSUB tables
50        if the uharfbuzz python bindings are importable, otherwise falls back to its
51        slower, less efficient serializer. Set to False to always use the latter.
52        Set to True to explicitly request the HarfBuzz Repacker (will raise an
53        error if uharfbuzz cannot be imported).
54        """
55    ),
56    default=None,
57    parse=Option.parse_optional_bool,
58    validate=Option.validate_optional_bool,
59)
60