Skip to content

Instantly share code, notes, and snippets.

View frankrolf's full-sized avatar
😸
meow

Frank Grießhammer frankrolf

😸
meow
View GitHub Profile
<html>
<head>
<script src='http://code.jquery.com/jquery-1.5.1.min.js'></script>
</head>
<body>
<h2>Naive canvas</h2>
<canvas id="naive" width="400" height="50"></canvas>
<h2>High-def Canvas</h2>
@frankrolf
frankrolf / gist:56caaa0ef2ca74d99ccd
Created May 10, 2015 21:22
Use external module in Drawbot
''' Use external module in Drawbot '''
import sys
import os
# the path to my module:
modDir = os.path.expanduser('~/Desktop')
# add the path to sys.path
if not modDir in sys.path:
sys.path.append(modDir)
# Robofont script to remove broken image paths, keeping good ones intact.
import os
f = CurrentFont()
layerOrder = ['foreground']
layerOrder.extend(f.layerOrder)
for g in f:
for layerName in layerOrder:
layeredGlyph = g.getLayer(layerName)
@frankrolf
frankrolf / mark_crayons.py
Created January 26, 2017 02:25
Set Robofont’s mark colors to be OSX’s Crayon colors
# coding: utf-8
# Sets Robofont’s Mark Colors to OSX’s Crayon colors.
# Beware: your old colors will be gone (but they were ugly anyway)
from AppKit import NSColorList
from mojo.UI import exportPreferences, importPreferences
from plistlib import readPlist, writePlist
import colorsys
@frankrolf
frankrolf / spacecenter_to_PNG.py
Created June 14, 2017 19:09
Export Robofont’s space center as a PNG file
import os
from AppKit import NSBitmapImageRep, NSPNGFileType, NSColor
from mojo.UI import CurrentSpaceCenter
def export_space_center_to_png(url):
sp = CurrentSpaceCenter()
sp_view = sp.glyphLineView.getNSScrollView()
sp_view.lockFocus()
rep = NSBitmapImageRep.alloc().initWithFocusedViewRect_(sp_view.bounds())
@frankrolf
frankrolf / flipped_preview.py
Created March 14, 2018 16:53
Flipped glyph preview in Robofont
from mojo.events import BaseEventTool, addObserver
from AppKit import NSColor
from fontTools.pens.basePen import BasePen
from fontTools.pens.cocoaPen import CocoaPen
class CocoaGlyphPen(BasePen):
def __init__(self, onCurveSize, offCurveSize, selection=[]):
self.glyphPen = CocoaPen(None)
@frankrolf
frankrolf / timm_ulrichs.py
Created May 2, 2018 06:56
DrawBot script to create an animated version of “Anthologie zur Visuellen Poesie” by Timm Ulrichs
# DrawBot script to create an animated version of
# "Anthologie zur Visuellen Poesie" by Timm Ulrichs (1968),
# as requested by Nick Sherman here: https://www.instagram.com/p/BiAjODfHwCO/
# Thanks to Letterform Archive for sharing.
def e_square(x, y, side, rotation):
'''
Draw letter e in a square defined by its center
and the length of the sides.
@frankrolf
frankrolf / rf_ufo3_to_ufo2.py
Created May 4, 2018 22:44
Save UFO2 files from Robofont 3
import os
from defcon import Font
def remap_item_name(name):
'''
Remaps a single item name from public.kern style to @MMK style
'''
if 'public.kern1.' in name:
return name.replace('public.kern1.', '@MMK_L_')
@frankrolf
frankrolf / ldot_contextual_kerning.py
Last active January 17, 2023 20:56
Create contextual kerning for Catalan l·l combination
'''
Create contextual kerning for the /l /periodcenterd /l pair to reproduce
the positioning found in the built-in (but obsolete) /ldot glyph.
This script expects the /ldot composite glyph to be built from
/l and /periodcentered components.
'''
from defcon import Font
@frankrolf
frankrolf / drawbot_interpolate_glyph_gif.py
Created June 3, 2018 23:16
DrawBot script to create joyful GIF animations of interpolated glyphs
'''
Type@Cooper West, June 2018
Contribution to Andy Clymer's "Expanding a Type Family" workshop
Script to create joyful GIF animations of interpolated glyphs,
either colorful or black & white.
'''
from fontTools.pens.cocoaPen import CocoaPen