Skip to content

Instantly share code, notes, and snippets.

@gferreira
gferreira / voronoi-drawbot-example.py
Created June 20, 2019 16:28
Create a Voronoi diagram as a raster image in Python. Converted from PIL to DrawBot.
# http://forum.drawbot.com/topic/148/voronoi-fun/2
import random
import math
def generate_voronoi_diagram(imgx, imgy, num_cells):
nx = []
ny = []
nr = []
from vanilla import *
from AppKit import NSDragOperationCopy
genericListPboardType = "genericListPboardType"
class DragAndDropListItemsDemo:
weekdays = {
'Mon' : [],
'Tue' : [],
'''animate individual characters in a variable font'''
fontName = 'Skia'
txt = 'variablefonts'
# steps between min/max range
steps = 12
# variable font range
variations = listFontVariations(fontName)
@gferreira
gferreira / lockLayerWidths.py
Last active September 29, 2018 10:05
lock/unlock widths of glyph layers
from vanilla import HUDFloatingWindow, SquareButton, CheckBox
from defconAppKit.windows.baseWindow import BaseWindowController
from mojo import drawingTools as ctx
from mojo.events import addObserver, removeObserver
from mojo.UI import UpdateCurrentGlyphView, getDefault
class LockLayerWidthsDialog(BaseWindowController):
key = 'com.hipertipo.lockLayerWidths'
verbose = True
@gferreira
gferreira / SteppersDemo.py
Last active July 19, 2018 16:35
SteppersDemo
from vanilla import Window
from lib.UI.stepper import Stepper, EditStepper, SliderEditStepper
class StepperDemo(object):
def __init__(self):
self.w = Window((300, 100), "Stepper Demo")
self.w.stepper = Stepper((10, 10, -10, 24), value=100)
self.w.open()
@gferreira
gferreira / building-apps.md
Last active September 18, 2017 23:03
partial transcription of presentation at Robothon 2012

Tal Leming: Building Apps

partial transcription of Robothon 2012 presentation

© Tal Leming

Defcon

Robofab was built as a scripting library. It was not built to be fast, it was built to be comfortable.

@gferreira
gferreira / robofab-fontparts.txt
Created June 20, 2017 20:28
differences between RoboFab and fontParts APIs
# Differences between RoboFab and fontParts APIs
====================================================================================================
Robofab fontParts
====================================================================================================
OpenFont(ufoPath, showUI=False) OpenFont(ufoPath, showInterface=False)
----------------------------------------------------------------------------------------------------
font.guides font.guidelines
----------------------------------------------------------------------------------------------------
font.removeGuide font.removeGuideline
@gferreira
gferreira / ttf-to-ufo-cubic.py
Created May 24, 2017 11:53
Convert a TrueType font to UFO with cubic outlines
import extractor
import defcon
ttf_path = u"/Library/Fonts/Georgia.ttf"
ufo_path = u"/Users/gferreira/Documents/test.ufo"
ufo = defcon.Font()
extractor.extractUFO(ttf_path, ufo)
from lib.tools.bezierTools import curveConverter
@gferreira
gferreira / fontParts-objects.py
Last active August 19, 2017 14:46
fontParts object map
# fontParts object map
from grapefruit import Color
from collections import OrderedDict
class FontPartsMap(object):
colors = OrderedDict([
('font' , (80, 0.50, 0.49)),
('font_lib' , (136, 0.42, 0.55)),
@gferreira
gferreira / otspec-stylish.css
Last active September 27, 2016 23:26
css tweak for the OpenType spec (for use with stylish)
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url-prefix("http://www.microsoft.com/typography/otspec/"), url-prefix("https://www.microsoft.com/typography/otspec/") {
body { width: 40em; padding: 1em 4em; }
p { font-size: 16px; line-height: 1.4em; margin: 1em 0; }
code, pre { font-family: "Menlo"; }
td { padding: 1em; }
table.gray { width: 40em; }