__init__.py 2.6 KB

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