I’m running a script that centers anchors in an outline glyph but am noticing that the component (plus another nested component) that it is used in isn’t updating…for example the dot of the
i isn’t aligning to the stem even though the anchors are centered after running this script. It is only after I click on the component that is jumps into the correct position.
I suspect there is some update interface solution. Also thought that it would adjust itself on export or after saving but it doesn’t.
Is there some way to run a script that will force an update on the components and the interface to make sure everything in the file is completely updated?
Okay ChatGPT coming up with a bizarrely human solution…basically the equivalent of hitting an old TV.
Surely there is a more correct way but it worked!
from Foundation import NSPoint
font = Glyphs.font
print("Updating all components...")
for glyph in font.glyphs:
for layer in glyph.layers:
for component in layer.components:
offset = NSPoint(1, 0) # small offset
component.applyTransform([1, 0, 0, 1, offset.x, offset.y]) # move slightly
component.applyTransform([1, 0, 0, 1, -offset.x, -offset.y]) # move back
print("All components updated.")
You can try disabling and reenabling updates for the interface with
font.disableUpdateInterface() and the same thing with
enable. Actually best to put the disable early in the script and the enable late, speeds up the script.
Changing the anchors should be enough. As you can see when you move the anchors manually. Do you have any “disable” calls in that initial script?
It might be that it is only a screen update issue? Maybe click the edit or font view?
If you can’t figure out why it is not aligning, just trigger it directly: