Skip to content

Instantly share code, notes, and snippets.

Avatar

Rainer Erich Scheichelbauer mekkablue

View GitHub Profile
@mekkablue
mekkablue / mergeLayers.py
Created Sep 12, 2019
Glyphs: merge paths from other master layers into current master (for selected glyphs)
View mergeLayers.py
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())
View Report Area in Square Units.py
#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
View Compare Font Spacings.py
#MenuTitle: Compare Font Spacings
# -*- coding: utf-8 -*-
__doc__="""
Compare spacing of open fonts, output in the Macro Window.
"""
abc = "abcdefghijklmnopqrstuvwxyz"
frequencies = { # Source: Wikipedia
View Steal colors.py
#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")
View Extract kern strings 1st char.py
#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
View Paste in View Center.py
#MenuTitle: Paste in View Center
# -*- coding: utf-8 -*-
__doc__="""
Pastes components and paths in clipboard into the center of the Edit view.
"""
import math
def transform(shiftX=0.0, shiftY=0.0, rotate=0.0, skew=0.0, scale=1.0):
myTransform = NSAffineTransform.transform()
View SVN Update.py
#MenuTitle: SVN Update
# -*- coding: utf-8 -*-
__doc__="""
Issues an SVN Update command on specified folders and reports to the Macro Window.
"""
import vanilla, subprocess
class SVNUpdate( object ):
def __init__( self ):
@mekkablue
mekkablue / Save as PNGs.py
Created Jul 27, 2019
Save Glyphs as PNGs
View Save as PNGs.py
#MenuTitle: Save Selected Glyphs as PNG
# -*- coding: utf-8 -*-
__doc__="""
Saves selected glyphs as PNGs. Uses ascender and descender for top and bottom edges of the images.
"""
from AppKit import NSCalibratedRGBColorSpace, NSPNGFileType
def transform(shiftX=0.0, shiftY=0.0, rotate=0.0, scale=1.0):
"""
View Fix Stuck Macro Window.py
#MenuTitle: Fix Stuck Macro Window
# -*- coding: utf-8 -*-
__doc__="""
If you cannot resize your Macro window anymore, run this script.
"""
import os
terminalCommand = 'defaults delete com.GeorgSeifert.Glyphs2 "NSWindow Frame MacroPanel"'
os.system( terminalCommand )
@mekkablue
mekkablue / Insert #exit and #entry at Baseline.py
Created Jul 27, 2019
Insert #exit and #entry at Baseline
View Insert #exit and #entry at Baseline.py
#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]