Created
October 12, 2017 16:28
-
-
Save weiweihuanghuang/4c6c35fb95f50f74055abada18b88b32 to your computer and use it in GitHub Desktop.
Center Glyphs
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: Center Glyphs Mine | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
""" | |
import GlyphsApp | |
thisFont = Glyphs.font # frontmost font | |
listOfSelectedLayers = thisFont.selectedLayers # active layers of selected glyphs | |
def process( thisLayer ): | |
LSB = thisLayer.LSB | |
RSB = thisLayer.RSB | |
width = thisLayer.width | |
halfSB = (LSB + RSB)/2 | |
thisLayer.LSB = int(halfSB) | |
thisLayer.RSB = int(halfSB) | |
thisLayer.width = width | |
thisFont.disableUpdateInterface() # suppresses UI updates in Font View | |
for thisLayer in listOfSelectedLayers: | |
thisGlyph = thisLayer.parent | |
numberOfLayers = len( thisGlyph.layers ) | |
for i in range( numberOfLayers )[::-1]: | |
thisOtherLayer = thisGlyph.layers[i] | |
print "Processing", thisGlyph.name | |
thisGlyph.beginUndo() # begin undo grouping | |
process( thisOtherLayer ) | |
thisGlyph.endUndo() # end undo grouping | |
thisFont.enableUpdateInterface() # re-enables UI updates in Font View |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment