Skip to content

Instantly share code, notes, and snippets.

@LettError
LettError / scriptingSimilarity.py
Created April 20, 2022 09:02
This shows how to call the similarity extension to find similar glyphs to the current. Needs https://github.com/LettError/similarity to be installed.
import cosineSimilarity
from cosineSimilarity import cosineSimilarity, SimilarGlyphsKey
print('SimilarGlyphsKey', SimilarGlyphsKey)
g = CurrentGlyph()
font = CurrentFont()
from mojo.UI import *
"""
RoboFont Script
- Type: Composites
- Purpose: To create RoboFont glyph construction syntax out of the exisiting
composites inside a font using the anchor names.
- Specifications:
- Determines the base letter and marks according to anchor names.
- Reconstruct the glyphConstruction syntax from the anchor names.
- Publish Date: 7 Dec 2020
@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 / 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 / syncAnchors.py
Last active September 27, 2023 16:09
Sync Anchors
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber, disableSubscriberEvents
'''
A startup script to help keep anchors in-sync across glyphs
The script will not append anchors, only move existing anchors
To set a linked glyph, add 'LinkedGlyphs:' in your main glyph's .note
On that same line add a comma separated list of glyph names (no spaces)
Adding a ! after a glyph name with a semicolon separated list will add
an exception and only those anchors will be moved
e.g.
@connordavenport
connordavenport / SyncMMWindows.py
Last active June 6, 2023 16:18
A small script to keep certain MM windows in sync
import metricsMachine
from mm4.mmScripting import MetricsMachineScriptingError
from vanilla import FloatingWindow, List, CheckBox, PopUpButton
from mojo.events import addObserver, removeObserver
from AppKit import *
from mojo.UI import Message
class SyncMM:
def __init__(self):
@frankrolf
frankrolf / mm_toggle.py
Last active January 17, 2023 13:09
Toggle Metrics Machine pair list
'''
Toggle the pair list of an open MetricsMachine (extension) window
from all kerning pairs (sorted by glyph order) to exceptions and back.
'''
import metricsMachine
import mm4
f = CurrentFont()
@frankrolf
frankrolf / flip_phrase.py
Last active September 3, 2020 11:09
Table-flip any phrase you like! (╯°□°)╯︵ ǝsɐɹɥd
'''
table-flip any phrase you like!
If the expression contains spaces, please use quotes.
python flip_phrase.py fontlab
>>> (╯°□°)╯︵ qɐlʇuoɟ
'''
import sys
import unicodedata
@khaledhosny
khaledhosny / cldr-coverage.py
Last active February 10, 2025 16:37
Calculate font script and language coverage based on ICU exemplar data
# Copyright 2020 Khaled Hosny
#
# 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
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@arrowtype
arrowtype / 00-toggle-darkmode.robofont.py
Last active February 3, 2022 05:57
A script to toggle darkmode in RoboFont, for app UI and Font View. Also includes a dark theme for the RoboFont Theme Editor.
"""
Toggle a dark mode in RoboFont.
For a dark mode in the Glyph Edit view, install Theme Editor:
https://github.com/connordavenport/Theme-Manager
...and import the "Dark Connor" theme from this Gist
(https://gist.github.com/arrowtype/ce0cee426f47c2fe7e82aa07d1e0a450).
Also offers to edit the markColor of glyphs with a high opacity in their markColor,
which will disrupt the visual effect of a dark mode on the Font View. However,