# config: configure fontTools

Define all configuration options that can affect the working of fontTools modules. E.g. optimization levels of varLib IUP, otlLib GPOS compression level, etc. If this file gets too big, split it into smaller files per-module.

An instance of the Config class can be attached to a TTFont object, so that the various modules can access their configuration options from it.

class fontTools.config.Config(values: Union[AbstractConfig, Dict[Union[Option, str], Any]] = {}, parse_values: bool = False, skip_unknown: bool = False)
  clear() → None. Remove all items from D.
  copy()
  get(option_or_name: ~typing.Union[~fontTools.misc.configTools.Option, str], default: ~typing.Any = <object object>) → Any

    Get the value of an option. The value which is returned is the first provided among:

    1. a user-provided value in the options’s `self._values` dict

    2. a caller-provided default value to this method call

    3. the global default for the option provided in `fontTools.config`

    This is to provide the ability to migrate progressively from config options passed as arguments to fontTools APIs to config options read from the current TTFont, e.g.

        def fontToolsAPI(font, some_option):
            value = font.cfg.get("someLib.module:SOME_OPTION", some_option)
            # use value

    That way, the function will work the same for users of the API that still pass the option to the function call, but will favour the new config mechanism if the given font specifies a value for that option.

  items() → a set-like object providing a view on D's items
  keys() → a set-like object providing a view on D's keys
  options: ClassVar[Options] = Options({ 'fontTools.otlLib.optimize.gpos:COMPRESSION_LEVEL': Option(default=0, ...), 'fontTools.ttLib.tables.otBase:USE_HARFBUZZ_REPACKER': Option(default=None, ...), })
  pop(k[, d]) → v, remove specified key and return the corresponding value.

    If key is not found, d is returned if given, otherwise KeyError is raised.

  popitem() → (k, v), remove and return some (key, value) pair

    as a 2-tuple; but raise KeyError if D is empty.

  classmethod register_option(name: str, help: str, default: Any, parse: Callable[[str], Any], validate: Optional[Callable[[Any], bool]] = None) → Option

    Register an available option in this config system.

  set(option_or_name: Union[Option, str], value: Any, parse_values: bool = False, skip_unknown: bool = False)

    Set the value of an option.

    Parameters

      - option_or_name (*) – an Option object or its name (str).

      - value (*) – the value to be assigned to given option.

      - parse_values (*) – parse the configuration value from a string into its proper type, as per its Option object. The default behavior is to raise ConfigValueValidationError when the value is not of the right type. Useful when reading options from a file type that doesn’t support as many types as Python.

      - skip_unknown (*) – skip unknown configuration options. The default behaviour is to raise ConfigUnknownOptionError. Useful when reading options from a configuration file that has extra entries (e.g. for a later version of fontTools)

  setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
  update([E, ]**F) → None. Update D from mapping/iterable E and F.

    If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

  values() → an object providing a view on D's values