Skip to content

Instantly share code, notes, and snippets.

@agyeiarcher
agyeiarcher / rotatingsquares.py
Created January 16, 2018 22:44
Rotating Squares
BG = 1500
NSQUARES = 50
SQUARESIZE = 2000
NFRAMES = 96
TOTALROTATION=15
from random import seed
from fontTools.pens.basePen import BasePen
rad = width()/4
nFrames=40
class BezierPathPen(BasePen):
"""FontTools pen -> BezierPath adapter."""
@agyeiarcher
agyeiarcher / xlrd-connect.py
Created March 16, 2018 17:00
xlrd: Connect to a Database
from xlrd import open_workbook
wb = open_workbook('simple.xls')
for s in wb.sheets():
print 'Sheet:',s.name
for row in range(s.nrows):
values = []
for col in range(s.ncols):
values.append(s.cell(row,col).value)
print ','.join(values)
print
size(500,500)
txt="how \n to \n deal?"
path = BezierPath()
path.text((txt), font="Helvetica", fontSize=150, offset=(2, 380))
NLINES=100
def makelines(amt):
canvas=500
divider=10
# made in drawbot - drawbot.com #
### this is a 'grid builder' that does the math separates the grid into random integers that add up to fill the entire thing. The variance in randomness can be controlled with the multiplier on the variance variable. we will use two arrays from this function, one to build rows, and the other to build columns. I based it off code found here: http://sunny.today/generate-random-integers-with-fixed-sum/ ###
def generate_random_integers(_sum, n):
@agyeiarcher
agyeiarcher / UpdateCurrentGlyphView.py
Last active October 21, 2019 16:22
A simple script to update the current view for all current glyph windows to the one in the current glyph window, for easy switching between master glyphs.
from mojo.UI import *
f=CurrentFont()
g=FindGlyph(f)
for k in AllFonts():
OpenGlyphWindow(k[g.name])
@agyeiarcher
agyeiarcher / matchWidths.py
Last active March 15, 2020 21:39
A robofont script that filters through a folder of font masters for minimum and maximum grade(labelled "MinGrade" and "MaxGrade" but that can get variable-assigned), and does the math and matching to equate the glyph widths (this assumes equal advance weights and only addresses potential spacing problems)
def makePairs(path, stylename, maxVal, minVal):
separatemasters(path, maxVal, minVal)
listName = []
for f in maxFonts:
if stylename in f:
listName.append(f)
for m in minFonts:
if stylename in m:
listName.append(m)
return(list(dict.fromkeys(listName))) #list(dict.fromkeys(x)) is a good way to get a list with stripped duplicates
# creates a Markdown table in Python using a designspace file, outlining instance names and corresponding axis values
import markdown
from fontTools.designspaceLib import DesignSpaceDocument
instanceNameString = "| Instance Name |"
filePath = "file_name_here.designspace"
def carpenter(designSpaceFile):
headerString = ""