Skip to content

Instantly share code, notes, and snippets.

View connordavenport's full-sized avatar

Connor Davenport connordavenport

View GitHub Profile
@connordavenport
connordavenport / RContourRSegment_interpolate.py
Created March 5, 2021 15:50
A startup script that adds interpolate() functions to RContour RSegment objects. There is also a faux RSegment.copy() function.
from fontParts.base.errors import FontPartsError
from fontPens.digestPointPen import DigestPointStructurePen
def isStrictCompatible(path1,path2):
# check interpolation compatibility
if type(path1).__name__.split(".")[-1] == "RSegment":
if path1.type == path2.type:
@connordavenport
connordavenport / WASD.py
Last active March 18, 2021 16:41
Convert arrow functions to ASWD keys in the glyphView. If you have shortcuts already set up for any of these keys you will run into issues!
from vanilla import FloatingWindow
from mojo.events import addObserver, extractNSEvent
class WASDTool:
def __init__(self):
addObserver(self, "keyWasPressed", "keyDown")
def keyWasPressed(self, info):
glyph = info["glyph"]
@connordavenport
connordavenport / removeOverlapPreview.py
Last active October 27, 2023 16:32
A startup script to preview a glyph with no overlap. Idea stolen from Glyphs (I still hate Glyphs)
from mojo.roboFont import RGlyph
from mojo.UI import getDefault, setDefault, inDarkMode
from lib.tools.notifications import PostNotification
from fontTools.pens.basePen import BasePen
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber, unregisterGlyphEditorSubscriber, listRegisteredSubscribers
class MyCopyDecomposingPen(BasePen):
def __init__(self, glyphSet, outPen):
super(MyCopyDecomposingPen, self).__init__(glyphSet)
@connordavenport
connordavenport / anchorHelper.py
Last active April 19, 2021 14:25 — forked from okay-type/anchorHelper.py
the rough start of a rf4 anchor tool
from vanilla import *
import merz
import mojo.subscriber as subs
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber
from mojo.subscriber import registerSubscriberEvent, getRegisteredSubscriberEvents
from mojo.extensions import registerExtensionDefaults, setExtensionDefault, getExtensionDefault, removeExtensionDefault
from mojo.drawingTools import *
from mojo.UI import SetCurrentGlyphByName
from math import radians, tan, pi
from AppKit import NSColor
@connordavenport
connordavenport / syncLayerWidths.py
Last active April 20, 2021 14:45
An observer script to sync background layers with foreground layer
from mojo.events import addObserver, removeObserver
class syncLayerWidths:
def __init__(self):
self.font = None
self.glyph = None
addObserver(self, "glyphChanged", "currentGlyphChanged")
@connordavenport
connordavenport / IceBath.py
Last active January 26, 2022 21:45
My version of PyFtFeaFreeze.py (By Adam Twardoch). Some code taken from it.
from AppKit import NSFilenamesPboardType, NSDragOperationCopy, NSEvent
from mojo.events import BaseEventObserver
from mojo.UI import GetFile,PostBannerNotification
import os
from fontTools.ttLib import TTFont
import vanilla
from fontParts.world import RGlyph
try:
from AppKit import NSRadioButtonType
@connordavenport
connordavenport / listGSUBFeatures.py
Last active April 29, 2021 23:30
List GSUB Features in SFNT
import sys
from fontTools.ttLib import TTFont
'''
usage:
$ python listGSUBFeatures.py path/to/font.otf
'''
def main():
if len(sys.argv) < 2:
@connordavenport
connordavenport / ForumlaOne.py
Last active April 30, 2021 20:02
A SFNT glyph copier. I want to stop using OTMaster so this replaces that tool. The name is random.
from AppKit import NSFilenamesPboardType, NSDragOperationCopy
from mojo.events import BaseEventObserver
import os
import vanilla
from fontParts.world import RGlyph
from fontTools.ttLib import TTFont
from fontTools.subset.cff import *
from fontTools.ttLib.tables._g_l_y_f import Glyph
from fontTools.pens.ttGlyphPen import TTGlyphPen
import difflib
@connordavenport
connordavenport / checkGitStatus.py
Created February 2, 2022 21:25
A RF script that simply just tells you the status of your Git repo ( if your open fonts are being tracked through Git )
import git
import os
from mojo.UI import OutputWindow
OutputWindow().clear()
fontDirs = list(set([os.path.dirname(f.path) for f in AllFonts()]))
for dirs in fontDirs:
if ".git" in os.listdir(dirs):
r = git.Repo(dirs)
print("pulling git status for...")
@connordavenport
connordavenport / RGlyph-GetScriptCat.py
Last active February 9, 2022 00:35
A start up script to simply access a glyph's script or unicode category
from mojo.roboFont import RGlyph
'''
A start up script to simply access a glyph's script or unicode category
for g in CurrentFont(): | print(CurrentGlyph().getScript()) | print(CurrentGlyph().getCat(verbose=True))
print(g.getScript()) | |
| |
| |
>> Latin | >> Cyrillic | >> Ll : Letter (lowercase)