Last active
July 23, 2018 08:54
-
-
Save irori/b0d5f53b6298efab4e526d68be2eab8d to your computer and use it in GitHub Desktop.
Test program for https://github.com/googlei18n/ufo2ft/issues/266
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import defcon | |
from ufo2ft import compileOTF | |
def random_moves(c, n): | |
for i in range(n): | |
x = random.randint(0, 1024) | |
y = random.randint(0, 1024) | |
c.appendPoint(defcon.Point((x, y), 'line')) | |
def step_moves(c, n, x, y): | |
for i in range(n): | |
if i % 2 == 0: | |
x += 10 | |
else: | |
y += 10 | |
c.appendPoint(defcon.Point((x, y), 'line')) | |
font = defcon.Font() | |
font.info.familyName = 'Test' | |
font.info.unitsPerEm = 1024 | |
font.info.descender = -124 | |
font.info.xHeight = 700 | |
font.info.capHeight = 900 | |
font.info.ascender = 900 | |
for i in range(10): | |
g = font.newGlyph('g%d' % i) | |
# Add random moves to pile up numbers in the stack. | |
c1 = defcon.Contour() | |
random_moves(c1, 24) | |
c1.appendPoint(defcon.Point((200, 200), 'line')) | |
g.appendContour(c1) | |
# Fixed moves to be subroutinized. | |
c2 = defcon.Contour() | |
step_moves(c2, 10, 100, 100) | |
g.appendContour(c2) | |
otf = compileOTF(font) | |
otf.save('out.otf') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment