Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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
'''animate individual characters in a variable font'''
fontName = 'Skia'
txt = 'variablefonts'
# steps between min/max range
steps = 12
# variable font range
variations = listFontVariations(fontName)
from vanilla import *
from AppKit import NSDragOperationCopy
genericListPboardType = "genericListPboardType"
class DragAndDropListItemsDemo:
weekdays = {
'Mon' : [],
'Tue' : [],
@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 = []
@gferreira
gferreira / bulk-list.py
Last active August 6, 2019 15:51 — forked from okay-type/bulk-list.py
dropfile-ui
# jackson # [email protected]
import os
from AppKit import NSFilenamesPboardType, NSDragOperationCopy
from vanilla import Window, List, Button
class doThing():
def __init__(self, path):