Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mekkablue's full-sized avatar

Rainer Erich Scheichelbauer mekkablue

View GitHub Profile
@mekkablue
mekkablue / twister.py
Last active February 26, 2024 15:25
Macro window script for the current glyph, checks for point pairs getting twisted
# brings macro window to front and clears its log:
Glyphs.clearLog()
Glyphs.showMacroWindow()
from math import sqrt, acos, degrees
def dot_product(v1, v2):
return v1[0] * v2[0] + v1[1] * v2[1]
def magnitude(v):
@mekkablue
mekkablue / check_parentheses.py
Created February 14, 2024 18:40
Quick script: Check ()[]{}
MacroTab.title = "Check ()[]{}"
Glyphs.clearLog()
Glyphs.showMacroWindow()
# adapt as needed:
threshold = 1.0
font = Glyphs.font
print(font.familyName)
@mekkablue
mekkablue / fix_parentheses.py
Created February 14, 2024 18:32
Quick script: Fix ()[]{}
MacroTab.title = "Fix ()[]{}"
Glyphs.clearLog()
Glyphs.showMacroWindow()
font = Glyphs.font
print(font.familyName)
collectedLayers = []
threshold = 1.0
for m in font.masters:
mid = m.id
for bracket in ("paren", "bracket", "brace"):
@mekkablue
mekkablue / check_small_figures.py
Created February 14, 2024 18:37
Quick script: Check small figures
MacroTab.title = "Check small figures"
Glyphs.clearLog()
Glyphs.showMacroWindow()
# please adapt as needed (Glyphs defaults as comments):
defaultExtension = ".denominator" # ".dnom"
extensions = (
".numerator", # ".numr"
"superscript", # "superior"
@mekkablue
mekkablue / align_composites_with_offsets.py
Created February 14, 2024 18:34
Quick script: Align ĦŁł...
MacroTab.title = "Align ĦŁł..."
glyphsToAlign = (
"Hbar",
"Lslash",
"lslash",
# add more glyph names here
)
Glyphs.clearLog()
Glyphs.showMacroWindow()
@mekkablue
mekkablue / Isopsephy.py
Last active August 11, 2022 09:55
Creating an Isopsephy OT feature
alphabet = list( "abcdefghijklmnopqrstuvwxyz" )
alphabetLength = len(alphabet)
wordlength = 5
figures = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
def wordForNumber( thisNumber ):
figurelist = [ figures[int( x )] for x in str( thisNumber ) ]
return "_".join( figurelist )
def lookupWithContent( lookupName, content ):
@mekkablue
mekkablue / mergeLayers.py
Created September 12, 2019 18:41
Glyphs: merge paths from other master layers into current master (for selected glyphs)
m = Font.selectedFontMaster
for sl in Font.selectedLayers:
g = sl.parent
print "Processing %s:" % g.name,
targetLayer = g.layers[m.id]
pathcount = 0
for l in g.layers:
if l.isMasterLayer and l != targetLayer:
for p in l.paths:
targetLayer.paths.append(p.copy())
@mekkablue
mekkablue / Baseline Wiggle.py
Created July 27, 2019 15:50
Baseline Wiggle
#MenuTitle: Baseline Wiggle
# -*- coding: utf-8 -*-
__doc__="""
Create pseudorandom GPOS baseline shift for all glyphs.
"""
import random
random.seed()
@mekkablue
mekkablue / Insert #exit and #entry at Baseline.py
Created July 27, 2019 21:24
Insert #exit and #entry at Baseline
#MenuTitle: Insert #exit and #entry at Baseline
# -*- coding: utf-8 -*-
__doc__="""
Adds #exit and #entry anchors at the sidebearings on the baseline. Useful for glyphs like period that are reused in glyphs like ellipsis.
"""
def process( thisLayer ):
for thisAnchorInfo in (("#entry",0),("#exit",1),):
newAnchor = GSAnchor()
newAnchor.name = thisAnchorInfo[0]
@mekkablue
mekkablue / Select Same Color.py
Last active July 28, 2019 09:10
Select Same Glyph/Layer Color
#MenuTitle: Select Same Color
# -*- coding: utf-8 -*-
__doc__="""
In Font view, select glyphs with the same color(s) as the currently selected one(s).
"""
from AppKit import NSIndexSet
def indexSetWithIndex( index ):
indexSet = NSIndexSet.alloc().initWithIndex_( index )