Skip to content

Instantly share code, notes, and snippets.

@typemytype
typemytype / pathOpsDrawBotTest.py
Last active August 20, 2018 08:31
visual tests for pathops
import pathops
from booleanOperations.booleanOperationManager import BooleanOperationManager
import time
import math
print("pathops version:", pathops.__version__)
f = CurrentFont()
# url to the image
path = 'https://pbs.twimg.com/media/DgwanJqXUAA9847.jpg'
# amount of frames
frames = 30
# scaling (the image is big)
sc = 0.08
# get the image size
w, h = imageSize(path)
#start the loop
for i in range(frames):
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 os
import shutil
import AppKit
import attr
from plistlib import readPlist, writePlist
from distutils.version import LooseVersion
import tempfile
from drawBot.scriptTools import ScriptRunner
import AppKit
speaker = "com.apple.speech.synthesis.voice.BadNews"
voice = AppKit.NSSpeechSynthesizer.alloc().initWithVoice_(speaker)
voice.startSpeakingString_("awful spacing")
@typemytype
typemytype / chararcterShower.py
Created December 6, 2017 11:01
show all installed fonts for a given string
characters = u"345678"
format = "A4"
margin = 10
t = FormattedString()
for fontName in installedFonts(characters):
t.font(fontName)
t += characters
@typemytype
typemytype / glyphShower.py
Created December 5, 2017 08:17
show all glyph in font
margin = 30
fontName = "CooperBlackStd"
newPage("A4")
t = FormattedString(font=fontName)
glyphNames = t.listFontGlyphNames()
t.appendGlyph(*glyphNames)
textBox(t, (margin, margin, width()-margin*2, height()-margin*2))
from fontTools.pens.basePen import BasePen
program = """void draw(SkCanvas* canvas) {
SkPaint paint;
SkPath path, dummy, result;
SkOpBuilder builder;
paint.setAntiAlias(true);
path.setFillType(SkPath::kWinding_FillType);
import time
import os
repeat = 10000
notExistingPath = u"test-non-existing.txt"
existingPath = 'test-exsisting.txt'
import vanilla
import AppKit
class _CheckBoxManualBuild(vanilla.vanillaCheckBox._CheckBoxManualBuild):
# both the container view and the check box will be adjusted.
# this is necessary to create the appropriate buffer
# and to handle the alignment.