Skip to content

Commit

Permalink
Updated to Glyphs 3
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroarilla committed Apr 3, 2021
1 parent 45f273b commit 4aacb97
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 123 deletions.
8 changes: 4 additions & 4 deletions Components/Decompose all corner components.py
@@ -1,16 +1,16 @@
#MenuTitle: Decompose all corner components
# -*- coding: utf-8 -*-
# by Pedro Arilla
from __future__ import division, print_function, unicode_literals
__doc__="""
Decomposes all corner components in selected glyphs.
"""
import GlyphsApp
import time
import GlyphsApp, time
Glyphs.clearLog()
print "Decompose all corner components @ " + time.strftime("%H:%M:%S")
print("Decompose all corner components @ " + time.strftime("%H:%M:%S"))

thisFont = Glyphs.font
for thisLayer in thisFont.selectedLayers:
thisLayer.decomposeCorners()

print "All corner components decomposed."
print("All corner components decomposed.")
8 changes: 4 additions & 4 deletions Components/Decompose all serif components.py
@@ -1,18 +1,18 @@
#MenuTitle: Decompose all serif components
# -*- coding: utf-8 -*-
# by Pedro Arilla
from __future__ import division, print_function, unicode_literals
__doc__="""
Decomposes all serif components in selected glyphs.
"""
import GlyphsApp
import time
import GlyphsApp, time
Glyphs.clearLog()
print "Decompose all serif components @ " + time.strftime("%H:%M:%S")
print("Decompose all serif components @ " + time.strftime("%H:%M:%S"))

thisFont = Glyphs.font
for thisLayer in thisFont.selectedLayers:
for i in range(len(thisLayer.components))[::-1]:
if thisLayer.components[i].componentName.startswith("Serif"):
thisLayer.components[i].decompose()

print "All serif components decomposed."
print("All serif components decomposed.")
8 changes: 4 additions & 4 deletions Components/Make component glyph for all masters.py
@@ -1,14 +1,14 @@
#MenuTitle: Make component glyph for all masters
# -*- coding: utf-8 -*-
# by Pedro Arilla
from __future__ import division, print_function, unicode_literals
__doc__="""
Builds compound glyphs in the selected ones for all masters.
"""

import GlyphsApp
import time
import GlyphsApp, time
Glyphs.clearLog()
print "Make component glyph for all masters @ " + time.strftime("%H:%M:%S")
print("Make component glyph for all masters @ " + time.strftime("%H:%M:%S"))

thisFont = Glyphs.font
listOfSelectedLayers = thisFont.selectedLayers
Expand All @@ -17,4 +17,4 @@
for layer in thisGlyph.layers:
layer.makeComponents()

print "Compound glyphs built."
print("Compound glyphs built.")
10 changes: 5 additions & 5 deletions Components/Make lower-unicase font.py
Expand Up @@ -2,20 +2,20 @@
# encoding: utf-8
# Based on _Make Unicase Font_ by Georg Seifert (@schriftgestalt)
# Modified by Pedro Arilla
from __future__ import division, print_function, unicode_literals
__doc__="""
Makes a lower-unicase font placing the lowercase glyphs (as components) in the uppercasse cells.
"""
import GlyphsApp
import time
import GlyphsApp, time
Glyphs.clearLog()
print "Make lower-unicase font @ " + time.strftime("%H:%M:%S")
print("Make lower-unicase font @ " + time.strftime("%H:%M:%S"))

thisFont = Glyphs.font
allGlyphs = list(thisFont.glyphs)
for lowerGlyph in allGlyphs:
if lowerGlyph.category == "Letter" and lowerGlyph.subCategory == "Lowercase":
upperName = lowerGlyph.name.title()
print "\tUpper", upperName
print("\tUpper", upperName)
upperGlyph = thisFont.glyphs[upperName]
if not upperGlyph:
upperGlyph = GSGlyph(upperName)
Expand All @@ -28,4 +28,4 @@
layer.components = [GSComponent(lowerGlyph.name)]
upperGlyph.leftKerningGroup = lowerGlyph.leftKerningGroup
upperGlyph.rightKerningGroup = lowerGlyph.rightKerningGroup
print "Lower-unicase font made."
print("Lower-unicase font made.")
21 changes: 10 additions & 11 deletions Components/Set default figures.py
@@ -1,13 +1,12 @@
#MenuTitle: Set default figures
# -*- coding: utf-8 -*-
# by Pedro Arilla
from __future__ import division, print_function, unicode_literals
__doc__="""
UI (Vanilla required) for setting the set of numerals selected by the user as default figures. Inserts the figures as components in the ‘Decimal Digit’ cells, enables automatic alignment, and copies kerning groups.
"""

import GlyphsApp
import time
import vanilla
import GlyphsApp, time, vanilla

class setDefaultFigures( object ):
def __init__( self ):
Expand All @@ -33,7 +32,7 @@ def __init__( self ):

# Load Settings:
if not self.LoadPreferences():
print "Note: 'Set default figures' could not load preferences. Will resort to defaults"
print("Note: 'Set default figures' could not load preferences. Will resort to defaults")

# Open window and focus on it:
self.w.open()
Expand Down Expand Up @@ -61,7 +60,7 @@ def LoadPreferences( self ):
def setDefaultFiguresMain( self, sender ):
try:
Glyphs.clearLog()
print "Set default figures @ " + time.strftime("%H:%M:%S")
print("Set default figures @ " + time.strftime("%H:%M:%S"))
thisFont = Glyphs.font
defaultFigures = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
liningFigures = ["zero.lf", "one.lf", "two.lf", "three.lf", "four.lf", "five.lf", "six.lf", "seven.lf", "eight.lf", "nine.lf"]
Expand Down Expand Up @@ -91,20 +90,20 @@ def setDefaultFiguresMain( self, sender ):
targetNumber.leftKerningGroup = sourceNumber.leftKerningGroup
targetNumber.rightKerningGroup = sourceNumber.rightKerningGroup

print "Default figures set succesfully."
print("Default figures set succesfully.")

if not self.SavePreferences( self ):
print "Note: 'Set default figures' could not write preferences."
print("Note: 'Set default figures' could not write preferences.")

self.w.close() # delete if you want window to stay open

except Exception, e:
except Exception as e:
# brings macro window to front and reports error:
Glyphs.clearLog()
print "Set default figures @ " + time.strftime("%H:%M:%S")
print("Set default figures @ " + time.strftime("%H:%M:%S"))
Glyphs.showMacroWindow()
print "Set default figures Error: %s" % e
print("Set default figures Error: %s" % e)
import traceback
print traceback.format_exc()
print(traceback.format_exc())

setDefaultFigures()
8 changes: 4 additions & 4 deletions Labels/Select different colour.py
Expand Up @@ -2,14 +2,14 @@
# -*- coding: utf-8 -*-
# Based on _Select Different Color_ by Rainer Erich Scheichelbauer (@mekkablue)
# Modified by Pedro Arilla
from __future__ import division, print_function, unicode_literals
__doc__="""
In Font view, selects glyphs with a different colour(s) as the currently selected one(s).
"""

import GlyphsApp
import time
import GlyphsApp, time
Glyphs.clearLog()
print "Select different colour @ " + time.strftime("%H:%M:%S")
print("Select different colour @ " + time.strftime("%H:%M:%S"))

from AppKit import NSIndexSet

Expand Down Expand Up @@ -37,4 +37,4 @@ def indexSetWithIndex( index ):
if not displayedGlyphsInFontView[i].colorIndex() in colorIndexes:
fontView.addSelectionIndexes_( indexSetWithIndex(i) )

print "Select different colour."
print("Different colour selected.")
11 changes: 4 additions & 7 deletions Layers/Display next layer.py
@@ -1,17 +1,14 @@
#MenuTitle: Display next layer
# -*- coding: utf-8 -*-
# by Pedro Arilla
from __future__ import division, print_function, unicode_literals
__doc__="""
Switches to the next layer of the current glyph within the current master.
Recommended keyboard shortcut: Ctrl+DownArrow
[via Mac OS System Preferences > Keyboard > Shortcuts > App Shortcuts > Glyphs.app]
"""

import GlyphsApp
import time
import GlyphsApp, time
Glyphs.clearLog()
print "Display next layer @ " + time.strftime("%H:%M:%S")
print("Display next layer @ " + time.strftime("%H:%M:%S"))

layersList = []
thisFont = Glyphs.font
Expand Down Expand Up @@ -48,4 +45,4 @@
singleChar = NSAttributedString.alloc().initWithString_attributes_( unichr(char), { "GSLayerIdAttrib" : layer.layerId } )
string.appendAttributedString_( singleChar )
currentTab.layers._owner.graphicView().textStorage().setText_(string)
print "Next layer active."
print("Next layer active.")
11 changes: 4 additions & 7 deletions Layers/Display previous layer.py
@@ -1,17 +1,14 @@
#MenuTitle: Display previous layer
# -*- coding: utf-8 -*-
# by Pedro Arilla
from __future__ import division, print_function, unicode_literals
__doc__="""
Switches to the previous layer of the current glyph within the current master.
Recommended keyboard shortcut: Ctrl+DownUp
[via Mac OS System Preferences > Keyboard > Shortcuts > App Shortcuts > Glyphs.app]
"""

import GlyphsApp
import time
import GlyphsApp, time
Glyphs.clearLog()
print "Display previous layer @ " + time.strftime("%H:%M:%S")
print("Display previous layer @ " + time.strftime("%H:%M:%S"))

layersList = []
thisFont = Glyphs.font
Expand Down Expand Up @@ -48,4 +45,4 @@
singleChar = NSAttributedString.alloc().initWithString_attributes_( unichr(char), { "GSLayerIdAttrib" : layer.layerId } )
string.appendAttributedString_( singleChar )
currentTab.layers._owner.graphicView().textStorage().setText_(string)
print "Previous layer active."
print("Previous layer active.")
11 changes: 4 additions & 7 deletions Layers/Duplicate current layer.py
@@ -1,17 +1,14 @@
#MenuTitle: Duplicate current layer
# -*- coding: utf-8 -*-
# by Pedro Arilla
from __future__ import division, print_function, unicode_literals
__doc__="""
Duplicates the current layer as a normal glyph layer.
Recommended keyboard shortcut: Cmd+Shift+D
[via Mac OS System Preferences > Keyboard > Shortcuts > App Shortcuts > Glyphs.app]
"""

import GlyphsApp
import time
import GlyphsApp, time
Glyphs.clearLog()
print "Duplicate current layer @ " + time.strftime("%H:%M:%S")
print("Duplicate current layer @ " + time.strftime("%H:%M:%S"))

thisFont = Glyphs.font
currentLayer = thisFont.selectedLayers[0]
Expand All @@ -20,4 +17,4 @@
newLayer.name = '@ '+ time.strftime("%H:%M, %d/%m/%y")
thisFont.glyphs[currentGlyph.name].layers.append(newLayer)

print "Layer duplicated."
print("Layer duplicated.")
13 changes: 5 additions & 8 deletions Layers/Use layer as master.py
@@ -1,17 +1,14 @@
#MenuTitle: Use layer as master
# -*- coding: utf-8 -*-
# by Pedro Arilla
from __future__ import division, print_function, unicode_literals
__doc__="""
Sets the current layer as the master layer.
Recommended keyboard shortcut: Ctrl+Shift+M
[via Mac OS System Preferences > Keyboard > Shortcuts > App Shortcuts > Glyphs.app]
"""

import GlyphsApp
import time
import GlyphsApp, time
Glyphs.clearLog()
print "Use layer as master @ " + time.strftime("%H:%M:%S")
print("Use layer as master @ " + time.strftime("%H:%M:%S"))

thisFont = Glyphs.font
thisLayer = thisFont.selectedLayers[0]
Expand Down Expand Up @@ -44,5 +41,5 @@
del thisGlyph.layers[thisLayer.layerId]
thisGlyph.endUndo()
thisFont.enableUpdateInterface()
print "Layer set as master."
else: print "Error: current layer is the master layer."
print("Layer set as master.")
else: print("Error: current layer is already the master layer.")
61 changes: 0 additions & 61 deletions Metrics/Kerning cleaner.py

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Expand Up @@ -20,7 +20,6 @@ PS, Some of the scripts require @typesupply's Vanilla. No worries, it’s easy:
* **Display next layer:** Switches to the next layer of the current glyph within the current master.
* **Display previous layer:** Switches to the previous layer of the current glyph within the current master.
* **Duplicate current layer:** Duplicates the current layer as a normal glyph layer.
* **Kerning cleaner:** Removes every kerning pair in the current master between -9 and 9, and rounds the others to base 5.
* **Make component glyph for all masters:** Builds compound glyphs in the selected ones for all masters.
* **Make lower-unicase font:** Makes a lower-unicase font placing the lowercase glyphs (as components) in the uppercasse cells.
* **Make zero handles selected glyphs:** Makes zero-length all handles (overlapping nodes) in selected glyphs.
Expand Down

0 comments on commit 4aacb97

Please sign in to comment.