Debian Codegraph @

src/babelfont/fontFilters/__init__.py

raw
1 from typing import Tuple
2
3 from .background import decompose_backgrounds, zero_background_width
4 from .cu2qu import cubic_to_quadratic
5 from .customParameters import apply_custom_parameters
6 from .decomposeMixed import decompose_mixed_glyphs
7 from .dropUnexported import drop_unexported_glyphs
8 from .fillOpentype import fill_opentype_values
9 from .glyphDataXML import bake_in_glyphdata
10 from .glyphs3fea import translate_glyphs3_fea
11 from .intermediateLayer import promote_intermediate_layers
12 from .marks import zero_mark_widths
13 from .rename import rename_glyphs
14
15 FILTERS = {
16 "zeroBackgroundWidths": zero_background_width,
17 "decomposeBackgrounds": decompose_backgrounds,
18 "zeroMarkWidths": zero_mark_widths,
19 "renameGlyphs": rename_glyphs,
20 "decomposeMixedGlyphs": decompose_mixed_glyphs,
21 "dropUnexportedGlyphs": drop_unexported_glyphs,
22 "cubicToQuadratic": cubic_to_quadratic,
23 "glyphData": bake_in_glyphdata,
24 "fillOpentypeValues": fill_opentype_values,
25 "intermediateLayers": promote_intermediate_layers,
26 "glyphsVariableFeatures": translate_glyphs3_fea,
27 "applyCustomParameters": apply_custom_parameters,
28 }
29
30
31 def parse_filter(input: str) -> Tuple[str, dict]:
32 if ":" in input:
33 filtername, args = input.split(":", 1)
34 args = dict([arg.split("=") for arg in args.split(",")])
35 else:
36 filtername = input
37 args = {}
38 if filtername not in FILTERS:
39 raise ValueError(f"Unknown filter {filtername}")
40 return FILTERS[filtername], args