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
def intersect( x1, y1, x2, y2, x3, y3, x4, y4 ): | |
"""Calculates the intersection of line P1-P2 with P3-P4.""" | |
slope12 = ( float(y2) - float(y1) ) / ( float(x2) - float(x1) ) | |
slope34 = ( float(y4) - float(y3) ) / ( float(x4) - float(x3) ) | |
x = ( slope12 * x1 - y1 - slope34 * x3 + y3 ) / ( slope12 - slope34 ) | |
y = slope12 * ( x - x1 ) + y1 | |
return x, y | |
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: Grid Switcher | |
# -*- coding: utf-8 -*- | |
"""Turns Grid on and off.""" | |
import vanilla | |
import GlyphsApp | |
class GridOnOff( object ): | |
def __init__( self ): | |
currentGridStep = Glyphs.font.gridMain() |
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
#MenuTitle: Add Hints | |
# -*- coding: utf-8 -*- | |
"""Add Hints for the Selected Nodes. Tries to guess whether it should be H or V. If exactly one node inside a zone is selected, it will add a Ghost Hint.""" | |
import GlyphsApp | |
Font = Glyphs.font | |
FontMaster = Font.selectedFontMaster | |
thisLayer = Font.selectedLayers[0] | |
thisSelection = [ n for n in thisLayer.selection() if n.className() == "GSNode" ] |
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: Invert Selection in Font View | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
Inverts the glyph selection in Font View. | |
""" | |
import GlyphsApp | |
thisFont = Glyphs.font # frontmost font |
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
from subprocess import Popen, PIPE | |
def runAppleScript(scpt, args=[]): | |
p = Popen(['osascript', '-'] + args, stdin=PIPE, stdout=PIPE, stderr=PIPE) | |
stdout, stderr = p.communicate(scpt) | |
return stdout | |
nameOfFont = """ | |
tell application "InDesign" | |
tell front document |
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: Copy Unicode-Sorted Glyph List | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
Creates a glyph list of all encoded glyphs, in Unicode order, and puts it in your clipboard for pasting. | |
""" | |
import GlyphsApp | |
from AppKit import * | |
thisFont = Glyphs.font # frontmost font |
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: Copy Glyph Names to Clipboard | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
Copies a newline-separated list of glyph names to the clipboard. | |
""" | |
import GlyphsApp | |
from AppKit import * | |
separator = "\n" |
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: Open Corner in all Layers | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
Tries to open the corner for a single selected node, in all layers if compatible. | |
""" | |
thisFont = Glyphs.font # frontmost font | |
thisFontMaster = thisFont.selectedFontMaster # active master | |
thisLayer = thisFont.selectedLayers[0] # active layers of selected glyphs | |
selection = thisLayer.selection # node selection in edit mode |
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
from AppKit import NSPateboard, NSStringPboardType | |
myClipboard = NSPasteboard.generalPasteboard() | |
renameString = myClipboard.stringForType_(NSStringPboardType) | |
renameCount = 0 | |
print "Processing: %s" % Font.familyName | |
for renameLine in renameString.strip().splitlines(): |
OlderNewer