Created
July 27, 2019 16:24
-
-
Save mekkablue/5b5141e98237349cd7c219e8b19410ee to your computer and use it in GitHub Desktop.
Reset Compound Metrics to First Component
This file contains hidden or 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: Reset Compound Metrics to First Component | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
Looks for the first component in a compound glyph and sets it back to x=0 and inherits its width. Useful for syncing numerators and denominators. | |
""" | |
Font = Glyphs.font | |
FontMasterID = Font.selectedFontMaster.id | |
selectedLayers = Font.selectedLayers | |
def process( thisLayer ): | |
if len( thisLayer.components ) > 0: | |
myComp = thisLayer.components[0] | |
myCompName = myComp.componentName | |
print "-- W: %.1f; first Comp: %s (%i, %i)" % ( thisLayer.width, myCompName, myComp.position.x, myComp.position.y ) | |
myCompLayer = Font.glyphs[ myCompName ].layers[ FontMasterID ] | |
print "-- W: %.1f, LSB: %.1f, RSB: %.1f" % ( myCompLayer.width, myCompLayer.LSB, myCompLayer.RSB ) | |
newCompPos = NSPoint( 0, myComp.position.y ) | |
myComp.position = newCompPos | |
thisLayer.width = myCompLayer.width | |
Font.disableUpdateInterface() | |
for thisLayer in selectedLayers: | |
thisGlyph = thisLayer.parent | |
print "Processing", thisGlyph.name | |
thisGlyph.beginUndo() | |
process( thisLayer ) | |
thisGlyph.endUndo() | |
Font.enableUpdateInterface() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment