I have gotten as far as showing the reference glyph but it’s always aligned with the left sidebearing I and I can’t figure out how to shift it over the right amount (currentGlyph.width - referenceGlyph.width) for each glyph it’s displayed in. I tried messing around with the NSAffineTransform methods but I don’t know how to implement it correctly. Here is my plugin.py code:
from GlyphsApp.plugins import *
from Foundation import NSPoint
This is my first attempt at writing a plugin. I’ve tried to read as much documentaion as possible but I’m just not getting it. I’dI really appreciate any help on this.
Thanks!
thanks for that. However, I still don’t understand how to apply the transformation. The “t” in Layer.transform_checkForSelection_doComponents_(t,False,True) is not defined or I don’t know what it is supposed to be referring to. I’ve tried to deconstruct other plugins that use NSAffineTransform but it isn’t clear to me how it all goes together. Does the transformation get applied before or after the outlines are drawn? Does the transformation need to act on a layer, paths or nodes? I feel like I just need a simple example but I haven’t been able to find one.
Sorry, I’ve been trying my best to figure it out. Thanks for any help you can give me.
It is an NSAffineTransform object, which is explained in the 2nd line of the comment:
Returns an NSAffineTransform object for transforming layers.
Apply an NSAffineTransform t object like this:
Layer.transform_checkForSelection_doComponents_(t,False,True)
Access its transformation matrix like this:
tMatrix = t.transformStruct() # returns the 6-float tuple
Apply the matrix tuple like this:
Layer.applyTransform(tMatrix)
Component.applyTransform(tMatrix)
Path.applyTransform(tMatrix)
Chain multiple NSAffineTransform objects t1, t2 like this:
t1.appendTransform_(t2)