diff options
author | Rasmus Andersson <rasmus@notion.se> | 2018-11-26 19:57:13 +0300 |
---|---|---|
committer | Rasmus Andersson <rasmus@notion.se> | 2018-11-26 19:57:13 +0300 |
commit | 0eb9bd892f4d65bd470fed7e9d84eef2844f9362 (patch) | |
tree | 6a5607df0cc89f9351211770b340698514dabd0b /misc/glyphs-scripts | |
parent | 30c17551659d0b852fd8c4d028136e64caa2a4c3 (diff) | |
download | inter-0eb9bd892f4d65bd470fed7e9d84eef2844f9362.tar.xz |
scripts
Diffstat (limited to 'misc/glyphs-scripts')
-rw-r--r-- | misc/glyphs-scripts/delanchors.py | 19 | ||||
-rw-r--r-- | misc/glyphs-scripts/fixup-variant.py | 55 |
2 files changed, 74 insertions, 0 deletions
diff --git a/misc/glyphs-scripts/delanchors.py b/misc/glyphs-scripts/delanchors.py new file mode 100644 index 000000000..fe2db97a4 --- /dev/null +++ b/misc/glyphs-scripts/delanchors.py @@ -0,0 +1,19 @@ +delanchors = ['top_dd', 'top0315', 'bottom_dd'] +font = Glyphs.font +font.disableUpdateInterface() +try: + for g in font.glyphs: + g.beginUndo() + try: + for master in font.masters: + layer = g.layers[master.id] + for aname in delanchors: + try: + del(layer.anchors[aname]) + print("del %s in %s", aname, g.name) + except: + pass + finally: + g.endUndo() +finally: + font.enableUpdateInterface() diff --git a/misc/glyphs-scripts/fixup-variant.py b/misc/glyphs-scripts/fixup-variant.py new file mode 100644 index 000000000..c2ac0f652 --- /dev/null +++ b/misc/glyphs-scripts/fixup-variant.py @@ -0,0 +1,55 @@ +# Helper for making variants of a glyph. +# +# e.g. we have 10 glyphs based on "I" and we now want to +# create an alternate "I" called "I.1". +# +# 1. We first make our I.1 manually +# 2. Next we generate all other glyphs: +# Idieresisacute=Idieresisacute.1 +# Istroke=Istroke.1 +# Itildebelow=Itildebelow.1 +# Igrave=Igrave.1 +# Iacute=Iacute.1 +# Icircumflex=Icircumflex.1 +# Itilde=Itilde.1 +# Imacron=Imacron.1 +# Ibreve=Ibreve.1 +# Iogonek=Iogonek.1 +# Which we paset into the "create glyphs" window +# 3. We now have 10 new glyphs. +# 4. Select all those new glyphs +# 5. Open the macro window +# 6. Paste this script and modify `prevcn` and `newcn` +# 7. Run it +# +prevcn = "I" # component to find and replace +newcn = "I.1" # replacement component + +font = Glyphs.font +font.disableUpdateInterface() +try: + for layer in font.selectedLayers: + g = None + if isinstance(layer, GSGlyph): + g = layer + else: + g = layer.parent + print(g) + g.beginUndo() + try: + for master in font.masters: + layer = g.layers[master.id] + print(layer) + if len(layer.components) != 1: + print("not a single component %s" % layer) + continue + layer.components[0].decompose() + for c in layer.components: + if c.name == prevcn: + print("replace %s with %s" % (prevcn, newcn)) + c.name = newcn + finally: + g.endUndo() +finally: + font.enableUpdateInterface() + |