File: generateGlyphDataRoboFont.py

package info (click to toggle)
python-booleanoperations 0.9.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 684 kB
  • sloc: python: 1,249; makefile: 5
file content (43 lines) | stat: -rw-r--r-- 884 bytes parent folder | download | duplicates (4)
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
import booleanOperations
try:
    from mojo.UI import getDefault, setDefault
    hasMojo = True
except ImportError:
    hasMojo = False

try:
    CurrentFont
except NameError:
    class CurrentFont(dict):

        def save(self, path=None):
            pass


f = CurrentFont()

if hasMojo:
    glyphViewRoundValues = getDefault("glyphViewRoundValues")
    setDefault("glyphViewRoundValues", 0)


for g in f:
    g.leftMargin = 0
    g.rightMargin = 0
    n = g.naked()
    d = g.getLayer("union")
    d.clear()
    d.appendGlyph(g)
    d.removeOverlap(round=0)

    if len(g) > 1:
        for method in "xor", "difference", "intersection":
            d = g.getLayer(method)
            d.clear()
            func = getattr(booleanOperations, method)
            func([n[0]], n[1:], d.getPointPen())

f.save()

if hasMojo:
    setDefault("glyphViewRoundValues", glyphViewRoundValues)