Skip to content

Instantly share code, notes, and snippets.

View mekkablue's full-sized avatar

Rainer Erich Scheichelbauer mekkablue

View GitHub Profile
@mekkablue
mekkablue / Paste in View Center.py
Created July 27, 2019 21:31
Paste in View Center
#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()
@mekkablue
mekkablue / SVN Update.py
Created July 27, 2019 21:31
SVN Update
#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 July 27, 2019 21:29
Save Glyphs as PNGs
#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):
"""
@mekkablue
mekkablue / Fix Stuck Macro Window.py
Created July 27, 2019 21:29
Glyphs App Helper Scripts
#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 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 )
@mekkablue
mekkablue / selectNodeNext.py
Created July 27, 2019 21:17
Select next/previous on-curve
#MenuTitle: Select following on-curve point
# -*- coding: utf-8 -*-
__doc__="""
From the currently selected point, go to the next on-curve.
"""
def getTheFirstPoint(selection):
for thisItem in selection:
if type(thisItem) == GSNode:
return thisItem
#MenuTitle: Make c2sc from smcp
# -*- coding: utf-8 -*-
__doc__="""
Makes component based c2sc glyphs, using the smcp glyphs as components.
Ignores selected glyphs without an .smcp ending.
"""
Font = Glyphs.font
@mekkablue
mekkablue / Copy kerning classes from smcp to c2sc.py
Created July 27, 2019 21:12
Copy kerning classes from smcp to c2sc
#MenuTitle: Copy kerning classes from smcp to c2sc
# -*- coding: utf-8 -*-
__doc__="""
Goes through all selected .c2sc glyphs that have no kerning classes,
checks if there is a corresponding .smcp glyph,
and if so, copies the .smcp kerning classes to the .c2sc glyph.
"""
@mekkablue
mekkablue / Export Kerning CSV.py
Created July 27, 2019 17:58
Export Spacing/Kerning CSV
#MenuTitle: Export Kerning Info CSV
# -*- coding: utf-8 -*-
__doc__="""
Export a CSV containing kerning info.
"""
import commands
from types import *