Skip to content

Instantly share code, notes, and snippets.

View typesupply's full-sized avatar

Tal Leming typesupply

View GitHub Profile
"""
This is some very old code that implemented a doctest-like
format for .fea files. It was useful, but I seemed to be
the only person using it so it fell off my radar. I still
think this, or something like it would be extremely useful
in the font development workflow.
The syntax is defined below. This implementation uses a
test file that is separate from the .fea file. It shouldn't
be too hard to make it work with tests that are embedded
@typesupply
typesupply / speed.py
Last active June 14, 2018 17:30 — forked from typemytype/quick_ufoLibTest.py
Test for ufoLib validation and speed improvements.
"""
This compares the speed of experimental changes in ufoLib
with the experimental ufoLib in fontTools. This requires the
"Roboto-Regular.ufo" font to be located next to this script.
"""
import os
import shutil
import timeit
import cProfile
import sys
sys.path.insert(0, '/Users/frederik/Downloads/fonttools-ufoLib/Lib')
import os
import shutil
import ufoLib
from fontTools.pens.basePen import NullPen
import sys
sys.path.insert(0, '/Users/frederik/Downloads/fonttools-ufoLib/Lib')
import os
import shutil
import ufoLib
from fontTools.pens.basePen import NullPen
import time
from random import shuffle
# ----------
# The Inputs
# ----------
pageSize = 500
maximumFrameCalculationDuration = 0.1
minimumPixelSize = 5
from objc import python_method
from AppKit import *
import Quartz
import vanilla
class LayerTestView(vanilla.Group):
def __init__(self, posSize):
super(LayerTestView, self).__init__(posSize)
import os
import shutil
from mojo.events import addObserver
"""
Goal: Create a UFOZ automatically when a UFO is saved.
Off the top of my head, I can think of a few ways to do this:
1. Make a copy of the font object, save as UFOZ, discard the
# This is a comment, which shouldn't be visible!
# This is a script declaration:
^ latn
# This is a language declaration:
@ None
# This is a writing direction start point declaration:
* left
# the options are "left" for left to right
# and "right" for right to left.
from mojo import events
import metricsMachine
class MMCurrentPairObserver(object):
def __init__(self):
self.previousPair = None
events.addObserver(
self,
"currentPairChangedCallback",
from urllib.request import build_opener
import bs4
from nltk.tokenize import PunktSentenceTokenizer
# Pull some text from a Wikipedia entry.
# The text could also come from a string, file or whatever.
url = "https://en.wikipedia.org/wiki/Font,_Switzerland"
opener = build_opener()