1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
from pathlib import Path
import ufoLib2
source_directory = Path(__file__).parent.parent / "src"
for ufo_path in source_directory.glob("*.ufo"):
ufo = ufoLib2.Font.open(ufo_path)
layer_names = [l.name for l in ufo.layers]
for name in layer_names:
if name != "public.default":
del ufo.layers[name]
ufo.layers.defaultLayer.lib = {
k: v for k, v in ufo.layers.defaultLayer.lib.items() if k.startswith("public.")
}
for glyph in ufo:
glyph.lib = {
k: v
for k, v in glyph.lib.items()
if (
k.startswith("public.")
or k.startswith("com.schriftgestaltung.Glyphs.")
or k == "com.schriftgestaltung.componentsAlignment"
)
and k != "public.markColor"
}
ufo.lib = {
k: v
for k, v in ufo.lib.items()
if k.startswith("public.")
or k.startswith("com.github.googlei18n.ufo2ft.")
or (
k
in {
"com.schriftgestaltung.appVersion",
"com.schriftgestaltung.fontMasterID",
"com.schriftgestaltung.customParameter.GSFont.disablesLastChange",
"com.schriftgestaltung.customParameter.GSFontMaster.paramArea",
"com.schriftgestaltung.customParameter.GSFontMaster.paramDepth",
"com.schriftgestaltung.customParameter.GSFontMaster.paramOver",
}
)
}
ufo.save()
|