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 / 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 / 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 / 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 / Report Area in Square Units.py
Created July 27, 2019 21:57
Report black vs. white area
#MenuTitle: Report Area in Square Units
# -*- coding: utf-8 -*-
__doc__="""
Calculates the area of each selected glyph, and outputs it in square units. Increase precision by changing the value for PRECISION in line 9 (script will slow down).
"""
PRECISION = 2 # higher numbers = more precision, but slower
@mekkablue
mekkablue / Compare Font Spacings.py
Created July 27, 2019 21:55
Compare Font Spacings
#MenuTitle: Compare Font Spacings
# -*- coding: utf-8 -*-
__doc__="""
Compare spacing of open fonts, output in the Macro Window.
"""
abc = "abcdefghijklmnopqrstuvwxyz"
frequencies = { # Source: Wikipedia
@mekkablue
mekkablue / Steal colors.py
Created July 27, 2019 21:53
Steal colors
#MenuTitle: Steal Colors from Font
"""Copy glyph colors from one font to another."""
import vanilla
class GroupsCopy(object):
"""GUI for copying colors from one font to another"""
def __init__(self):
self.w = vanilla.FloatingWindow((400, 70), "Steal colors")
#MenuTitle: Extract kern strings (1st character)
# -*- coding: utf-8 -*-
__doc__="""
Analyze a textfile: look for certain characters and output all letter combinations occurring in the text file to the Macro Window.
"""
import vanilla
from PyObjCTools.AppHelper import callAfter