nevu
August 11, 2014, 9:23am
1
Hi everybody,
I’d like to modify a script (mekkablues: “Selection to Center”) to center anchors within the layer-width. (Im coder newbe)
The script run and also can centre in a two-anchored-glyph.
But:
How can I achieve to run the script over more than one selected glyph? Script just run through first glyph of selection.
#MenuTitle: Anker zentrieren
-- coding: utf-8 - -
recourse to the script “selection to center” of mekkablue
doc =""“
Align Anchors to the Horizontal Center.
”""
import GlyphsApp
Font = Glyphs.font
Doc = Glyphs.currentDocument
selectedLayer = Font.selectedLayers[0]
selectedGlyph = selectedLayer.parent.name
layerCenter = selectedLayer.width // 2
print “”“Centered anchors. Deviations from center:
(- left / + right)
”""
try:
selection = selectedLayer.anchors
Font.disableUpdateInterface()
for selectedNode in selection:
myCenter = round(layerCenter - selectedNode.x)
print (round(selectedNode.x) - layerCenter), "in", selectedGlyph, selectedNode.name, " "
selectedNode.x += myCenter
Font.enableUpdateInterface()
except Exception, e:
print e
Tosche
August 11, 2014, 11:16am
2
import GlyphsApp
Font = Glyphs.font
Doc = Glyphs.currentDocument
print “”“Centered anchors. Deviations from center:
(- left / + right)
”""
Font.disableUpdateInterface()
for thisLayer in Font.selectedLayers:
(tab)thisGlyph = thisLayer.parent.name
(tab)layerCenter = thisLayer.width // 2
(tab)try:
(tab)for thisAnchor in thisLayer.anchors:
(tab)(tab)myCenter = round(layerCenter - thisAnchor.x)
(tab)(tab)print (round(thisAnchor.x) - layerCenter), “in”, thisGlyph, thisAnchor.name, " "
(tab)(tab)thisAnchor.x += myCenter
(tab)except Exception, e:
(tab)(tab)print e
nevu
August 11, 2014, 3:48pm
3
Thank you. I have to deal with it more
Tosche
August 11, 2014, 3:54pm
4
I think it can be simplified like: thisAnchor.x = layerCenter
I haven’t tried, but this should do what you want, right?
For manual alignment regarding anchors, there is a way. If you select two nodes (no matter if they’re off- or on-curve) and an anchor, it will be centre-aligned between the nodes.
nevu
August 11, 2014, 7:23pm
5
I will try. I know the 3-Point Trick but first of all I was looking for a ‘global’ method. Thanks again.
if you hit cmp+opt+U Glyphs will regenerate the anchors in its default positions. And for the top and bottom anchor that would be the center.
nevu
August 12, 2014, 10:54am
7
this command was exactly what I was looking for.
Does it work if I select more than one glyph?
But script also works fine.
thanks again to you both
Tosche
August 12, 2014, 11:12am
8
Many menu commands are executable (on multiple glyphs) from the font view.