This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MacroTab.title = "Check ()[]{}" | |
Glyphs.clearLog() | |
Glyphs.showMacroWindow() | |
# adapt as needed: | |
threshold = 1.0 | |
font = Glyphs.font | |
print(font.familyName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MacroTab.title = "Align ĦŁł..." | |
glyphsToAlign = ( | |
"Hbar", | |
"Lslash", | |
"lslash", | |
# add more glyph names here | |
) | |
Glyphs.clearLog() | |
Glyphs.showMacroWindow() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#MenuTitle: Baseline Wiggle | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
Create pseudorandom GPOS baseline shift for all glyphs. | |
""" | |
import random | |
random.seed() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 ) |
NewerOlder