Skip to content

Instantly share code, notes, and snippets.

View connordavenport's full-sized avatar

Connor Davenport connordavenport

View GitHub Profile
@connordavenport
connordavenport / CustomMeasureTool.py
Last active May 11, 2024 09:58
custom measure tool to include guidelines
import math
import merz
from mojo.UI import PostBannerNotification, getDefault, setDefault, UpdateCurrentGlyphView, getGlyphViewDisplaySettings, setGlyphViewDisplaySettings, preferencesChanged, inDarkMode
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber, unregisterGlyphEditorSubscriber, listRegisteredSubscribers
from ufoProcessor.emptyPen import DecomposePointPen
class CustomMeasureTool(Subscriber):
debug = True
font("Zapata-Light")
w,h,b,o,i,q=width(),height(),(0,.05,.1),(.9,.2,0),0,.75
def nfs(wi,wd):
fontSize(20)
return(wd/textSize(wi)[0])*20
fill(*b)
rect(0,0,w,h)
for wr in "YOU NEED PYTHON".split():
fill(*o)if wr[0]!="P"else fill(1)
fs=nfs(wr,w-40)
@connordavenport
connordavenport / RKerning_SmartSet.py
Created February 14, 2024 16:08
An RKerning add on to allow for setting kerning pairs without having to know the group names
def smartSet(self, pair, value, exceptionType=None):
'''
pair must be a tuple, its contents can be a glyphName or a group's name
value must be an integer, why would you even kern on fractions....
exceptionType is the level of searching the function will do
None : use the top level group or glyph names, no exceptions
g2G : glyph to Group exception
g2g : glyph to glyph exception
G2g : Group to glyph exception
@connordavenport
connordavenport / SetHighGamutPairList.py
Created January 15, 2024 20:40
a script to set MetricsMachine pair lists with high gamut ranges. functions taken from Frank's Kern-a-lytics
import metricsMachine as mm
# --------------------------------
# functions taken from Kern-a-lytics
# --------------------------------
import itertools
import collections
def high_gamut_dict(cmb_kerning, approx_amount=100):
@connordavenport
connordavenport / CatDog.py
Created December 21, 2023 23:03
a subclass of EditingTool for adjusting the /Ldot spacing
#!/usr/bin/env python3
import AppKit
from mojo.subscriber import Subscriber, WindowController
from mojo.UI import getDefault
from mojo.events import EditingTool, installTool
from mojo.subscriber import registerGlyphEditorSubscriber, unregisterGlyphEditorSubscriber
from mojo.roboFont import OpenWindow
from mojo.tools import IntersectGlyphWithLine
@connordavenport
connordavenport / PairListSetter.py
Created December 15, 2023 19:20
a little script to switch pair lists super fast!
import ezui
from mm4.tools.pairListParser import *
import metricsMachine
from mm4.mmScripting import MetricsMachineScriptingError
class PairListSetter(ezui.WindowController):
def build(self):
content = """
@connordavenport
connordavenport / CentroidHull.py
Created December 3, 2023 17:08
a RF script to preview a glyphs "convex hull" and "centroid"...
from mojo.roboFont import RGlyph
from fontTools.pens.basePen import BasePen
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber, unregisterGlyphEditorSubscriber, listRegisteredSubscribers
from fontPens.flattenPen import flattenGlyph
from scipy.spatial import ConvexHull
class MyCopyDecomposingPen(BasePen):
def __init__(self, glyphSet, outPen):
super(MyCopyDecomposingPen, self).__init__(glyphSet)
self._moveTo = outPen.moveTo
@connordavenport
connordavenport / PrintExtensionDateOrder.py
Created December 2, 2023 20:53
a rf script to print extensions in order of building
from mojo.extensions import ExtensionBundle as bb
import datetime
import collections
from pprint import pprint
ext = bb.allExtensions()
i = {}
for e in ext:
time = bb(e).infoDictionary.get("timeStamp")
formatted_date = datetime.datetime.utcfromtimestamp(time).strftime('%Y-%m-%d %H:%M:%S')
i[time] = (e,formatted_date)
@connordavenport
connordavenport / frontAndCenterPopover.py
Last active December 7, 2023 20:27
a simply RF popover to jump between fonts
import ezui
from merz.tools.drawingTools import NSImageDrawingTools
from mojo.UI import AllFontWindows, CurrentFontWindow, AllWindows, CurrentGlyphWindow
class frontAndCenter(ezui.WindowController):
def build(self, parent, viewType):
self.buttonMap = {}
self.parent = parent
@connordavenport
connordavenport / makeAlternatesMenu.py
Last active November 17, 2023 18:06
a contextual menu for the font overview that adds an alternate glyph next to the default glyph
from mojo.events import addObserver
import ezui
from mojo.subscriber import Subscriber, registerFontOverviewSubscriber
from mojo.UI import CurrentFontWindow
class alternatesController(ezui.WindowController):
def build(self, parent):
content = """