summaryrefslogtreecommitdiff
path: root/misc/glyphs-scripts/copy-guides.py
blob: b444ab585cada899e5f093b1f8d395b2ba29349f (plain)
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
#MenuTitle: Copy guides from Regular & Italic to other masters
# -*- coding: utf-8 -*-
import GlyphsApp
import copy

Glyphs.clearLog()
font = Glyphs.font

romanMasterName = "Regular"
italicMasterName = "Italic"

guidesRoman = None
guidesItalic = None

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]