summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2022-07-07 22:40:50 +0300
committerRasmus Andersson <rasmus@notion.se>2022-07-07 22:40:50 +0300
commit0d2f80760aa3206a4a9916b7c640a88263fb8ad7 (patch)
treec2d3483b8ad26ac8fc858822521a00d1e6196e35 /misc
parentbfbf71f0c453d48980b1b4d7a9b234e4b3d985d8 (diff)
downloadinter-0d2f80760aa3206a4a9916b7c640a88263fb8ad7.tar.xz
update misc/glyphs-scripts/copy-guides.py
Diffstat (limited to 'misc')
-rw-r--r--misc/glyphs-scripts/copy-guides.py51
1 files changed, 17 insertions, 34 deletions
diff --git a/misc/glyphs-scripts/copy-guides.py b/misc/glyphs-scripts/copy-guides.py
index b444ab585..2830bd41d 100644
--- a/misc/glyphs-scripts/copy-guides.py
+++ b/misc/glyphs-scripts/copy-guides.py
@@ -1,4 +1,4 @@
-#MenuTitle: Copy guides from Regular & Italic to other masters
+#MenuTitle: Copy global guides from roman to italic masters
# -*- coding: utf-8 -*-
import GlyphsApp
import copy
@@ -6,38 +6,21 @@ import copy
Glyphs.clearLog()
font = Glyphs.font
-romanMasterName = "Regular"
-italicMasterName = "Italic"
+romanMasters = [m for m in font.masters if m.italicAngle == 0.0]
+#print(romanMasters)
-guidesRoman = None
-guidesItalic = None
+def find_matching_roman(im):
+ wght = im.axes[0]
+ opsz = im.axes[2]
+ for rm in romanMasters:
+ if wght == rm.axes[0] and opsz == rm.axes[2]:
+ return rm
-guideNames = [
- "cap center", # 0
- "low center", # 1
- "",
- "",
-]
-
-for master in font.masters:
- if master.name == "Regular":
- guidesRoman = master.guides
- if master.name == "Italic":
- guidesItalic = master.guides
-
-# rename guides (order is horizontal top to bottom, then vertical)
-for i in range(0, len(guidesRoman)):
- guidesRoman[i].name = guideNames[i]
- guidesItalic[i].name = guideNames[i]
-
-if regularGuides is None:
- print("mainMasterName=%r master not found" % mainMasterName)
-else:
- for master in font.masters:
- print(master.name)
- if master.name.find("Italic") != -1:
- if master.name != guidesItalic:
- master.guides = [copy.copy(u) for u in guidesItalic]
- else:
- if master.name != guidesRoman:
- master.guides = [copy.copy(u) for u in guidesRoman]
+for im in font.masters:
+ if im.italicAngle == 0.0:
+ continue
+ rm = find_matching_roman(im)
+ if rm is None:
+ raise Exception("rm not found (im=%r)" % im.name)
+ print(im.name, '<-', rm.name)
+ im.guides = [copy.copy(g) for g in rm.guides]