Skip to content

Instantly share code, notes, and snippets.

@typemytype
typemytype / stringToGlyphNames.py
Last active August 29, 2015 14:09
string to glyph names
"""
The MIT License (MIT)
Copyright (c) 2015 Frederik Berlaen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@typemytype
typemytype / searchDescriptiveSSNames.py
Created November 18, 2014 08:16
search for Descriptive Style Set Names
from fontTools.ttLib import TTFont
from robofab.interface.all.dialogs import GetFolder
from lib.tools.misc import walkDirectoryForFile
root = GetFolder("Folder with .otf / .ttf files...")
found = {}
@typemytype
typemytype / addMeasurement.py
Created December 10, 2014 20:48
add a measurement line in RoboFont
from AppKit import NSPoint
from mojo.events import MeasurementTool
measurement = MeasurementTool.measurementClass()
measurement.startPoint = NSPoint(100, 100)
measurement.endPoint = NSPoint(200, 200)
g = CurrentGlyph()
g.naked().measurements.append(measurement)
g.update()
@typemytype
typemytype / embedGroupInScrollview.py
Created December 15, 2014 13:57
proposal for vanilla.ScrollView to support embedded vanilla.Group
from vanilla import *
import vanilla
from vanilla.vanillaBase import VanillaError
class ScrollView(vanilla.ScrollView):
def __init__(self, posSize, nsView, hasHorizontalScroller=True, hasVerticalScroller=True,
autohidesScrollers=False, backgroundColor=None, clipView=None,
drawsBackground=True):
@typemytype
typemytype / pinkyfier.py
Last active August 29, 2015 14:12
creates a pink app icon
from AppKit import *
icon = NSApp().applicationIconImage()
w, h = icon.size()
new = NSImage.alloc().initWithSize_((w, h))
imageRect = NSMakeRect(0, 0, w, h)
new.lockFocus()
@typemytype
typemytype / testURLhandler.py
Created January 15, 2015 13:52
RoboFont url handler
f = CurrentFont()
print f
@typemytype
typemytype / defaultFontInfoChanger.py
Created February 22, 2015 20:40
Change default font info values
from lib.settings import defaultFontInfoAttributes
defaultFontInfoAttributes["descender"] = -200
defaultFontInfoAttributes["ascender"] = 800
@typemytype
typemytype / fixStrikeout.py
Created April 17, 2015 08:49
fix Strikeout
import os
from fontTools.ttLib import TTFont
from mojo.events import addObserver
from ufo2fdk.fontInfoData import getAttrWithFallback
from ufo2fdk.outlineOTF import _roundInt
class FixBinaryOutput(object):
def __init__(self):
@typemytype
typemytype / extendedSliderVariable.py
Created June 22, 2015 13:31
DrawBot Variable slider example
Variable([
dict(name="myVariable", ui="Slider",
args=dict( # add some vanilla Slider specific attributes
value=10,
minValue=0,
maxValue=100,
tickMarkCount=11,
stopOnTickMarks=True)),
], globals())
from drawBot import *
from drawBot.ui.drawView import DrawView
from vanilla import *
class DrawBotViewer(object):
def __init__(self):
# create a window
self.w = Window((400, 400), minSize=(200, 200))