Forked from FrankFonts/Basic UFO Master Comparison in RoboFont DrawBot extension
Created
September 29, 2015 17:10
-
-
Save chrissimpkins/d0728124d66161906d19 to your computer and use it in GitHub Desktop.
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
# design settings | |
gutter = 60 | |
radius = 6 | |
pageW = 1600 | |
# draw filled outline or contours | |
contour = False | |
# draw nodes and bluezones and vertical metrics? | |
isFull = True | |
# select your glyphs | |
glyph = [ | |
'a', | |
'c', | |
'f', | |
'j', | |
'r', | |
'y' | |
] | |
# open your ufos | |
ufo1 = OpenFont("yourUFOcomesHere.ufo", showUI = False) | |
ufo2 = OpenFont("yourUFOcomesHere.ufo", showUI = False) | |
fonts = [ufo1, ufo2, ] | |
# functions | |
def drawBox(width): | |
'''draw bounding box''' | |
stroke(1, 0, 0) | |
# x-height | |
line((0, f.info.xHeight), (width, f.info.xHeight)) | |
rect(0, f.info.descender, width, f.info.ascender-f.info.descender) | |
stroke(0) | |
def nodes(g): | |
'''draw nodes''' | |
for contour in g: | |
for segment in contour: | |
for node in segment: | |
if node.type == 'curve': | |
fill(1) | |
stroke(1, 0, 0) | |
elif node.type == 'offCurve': | |
fill(1) | |
stroke(0) | |
else: | |
fill(1) | |
stroke(0, 0, 1) | |
oval(node.x-radius, node.y-radius, radius*2, radius*2) | |
fill(0) | |
stroke(0) | |
fill(None) | |
stroke(0) | |
def blues(width): | |
'''draw blueValues''' | |
blues = f.info.postscriptBlueValues | |
otherBlues = f.info.postscriptOtherBlues | |
fill(0.9, 0.9, 0.9) | |
stroke(None) | |
for i in range(1, len(blues), 2): | |
rect(0, blues[i-1], width, (blues[i]-blues[i-1])) | |
for i in range(1, len(otherBlues), 2): | |
rect(0, otherBlues[i-1], width, (otherBlues[i]-otherBlues[i-1])) | |
fill(None) | |
stroke(0) | |
def full(full): | |
'''draw what you want''' | |
if full: | |
blues(width) | |
drawBox(width) | |
if contour: | |
fill(0) | |
stroke(1) | |
else: | |
fill(1) | |
stroke(0) | |
drawGlyph(f[g]) | |
if full: | |
nodes(f[g]) | |
# do it | |
for g in glyph: | |
newPage(pageW, 1600) | |
# background | |
fill(1) | |
rect(0, 0, pageW, 1600) | |
translate(0, 500) | |
fontSize(1000) | |
strokeWidth(1) | |
fill(None) | |
# baseline | |
stroke(1, 0, 0) | |
line((0, 0), (pageW, 0)) | |
first = True | |
for f in fonts: | |
width = f[g].width | |
# remove components... | |
f[g].decompose() | |
# ..and overlaps | |
f[g].removeOverlap() | |
if first: | |
translate((((pageW/2)-f[g].width) - gutter/2), 0) | |
full(isFull) | |
translate(-(((pageW/2)-f[g].width) - gutter/2), 0) | |
first = False | |
else: | |
translate(((pageW/2) + gutter/2), 0) | |
full(isFull) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment