Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. Font = Glyphs.font
  2. selectedLayers = Font.selectedLayers
  3.  
  4. def process( thisGlyph ):
  5.  
  6.     numberOfLayers = len( thisGlyph.layers )
  7.     for i in range( numberOfLayers )[::-1]:
  8.         thisLayer = thisGlyph.layers[i]
  9.  
  10.         thisLayer.width = 0
  11.         if thisLayer.layerId == thisLayer.associatedMasterId:
  12.             for eachAnchor in thisLayer.anchors:
  13.                 if eachAnchor.name[0] == "_":
  14.                     # Getting the x position of the x = 0 when italic bounding box is on
  15.                     thisMasterItalicRadian = math.radians( Font.masters[thisLayer.associatedMasterId].italicAngle )
  16.                     xZero = math.tan( thisMasterItalicRadian ) * eachAnchor.position.y
  17.                     xAnchor = eachAnchor.position.x
  18.                     shift = xAnchor - xZero
  19.                     shiftMatrix = transform(shiftX=shift*-1).transformStruct()
  20.                     thisLayer.applyTransform( shiftMatrix )
  21.                     break
  22.  
  23.  
  24. Font.disableUpdateInterface()
  25.  
  26. for thisLayer in selectedLayers:
  27.     thisGlyph = thisLayer.parent
  28.  
  29.     thisGlyph.beginUndo()
  30.     process( thisGlyph )
  31.     thisGlyph.endUndo()
  32.  
  33. Font.enableUpdateInterface()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement