-
Notifications
You must be signed in to change notification settings - Fork 103
/
MakeProdunctionFont.py
65 lines (55 loc) · 1.95 KB
/
MakeProdunctionFont.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#MenuTitle: make Production Font
# encoding: utf-8
"""
MakeProdunctionFont.py
Created by Georg Seifert on 2011-05-11.
Copyright (c) 2010 schriftgestaltung.de. All rights reserved.
"""
import sys
import os
from GlyphsApp import *
def main():
Doc = Glyphs.currentDocument
Font = Doc.font
Font.setDisablesNiceNames_(True)
FontMaster = Font.fontMasters()[0]
removeOverlapFilter = NSClassFromString("GlyphsFilterRemoveOverlap").alloc().init()
Font.disableUpdateInterface()
for Glyph in Font.glyphs:
if not Glyph.export:
continue
Glyph.undoManager().beginUndoGrouping()
Layer = Glyph.layerForKey_(FontMaster.id)
Components = Layer.components
for i in range(2):
for Component in Components:
if not Component.component:
print Glyph.name, " > Component", Component, Component.component
ComponentGlyph = Font.glyphs[Component.componentName]
ComponentLayer = ComponentGlyph.layerForKey_(FontMaster.id)
if (ComponentGlyph and not ComponentGlyph.export) or len(Layer.paths) > 0 or len(ComponentLayer.components) > 0:
Component.decompose()
if Glyph.leftKerningGroup:
Glyph.leftKerningGroup = Glyph.leftKerningGroup.replace("-", "")
if Glyph.rightKerningGroup:
Glyph.rightKerningGroup = Glyph.rightKerningGroup.replace("-", "")
for Component in Layer.components:
if not Component.transformStruct()[0] == 1.0 or not Component.transformStruct()[3] == 1.0:
Layer.decomposeComponents()
break
if len(Layer.paths) > 0 and len(Layer.components) > 0:
Layer.decomposeComponents()
removeOverlapFilter.runFilterWithLayer_error_(Layer, None)
Glyph.undoManager().endUndoGrouping()
for Glyph in Font.glyphs:
Glyph.undoManager().beginUndoGrouping()
GlyphsInfo = GSGlyphsInfo.glyphInfoForName_(Glyph.name)
try:
if GlyphsInfo and GlyphsInfo.legacy() != None:
Glyph.setName_(GlyphsInfo.legacy())
except:
pass
Glyph.undoManager().endUndoGrouping()
Font.enableUpdateInterface()
if __name__ == '__main__':
main()