Skip to content

Instantly share code, notes, and snippets.

View mekkablue's full-sized avatar

Rainer Erich Scheichelbauer mekkablue

View GitHub Profile
@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
@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 / 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