SOLVED [Request] Paste special (i.e. from other vector apps)
ryan last edited by ryan
Can there be a special Paste function that pastes in the middle of the current glyph view regardless of the coordinates of the vector art from which it came in Illustrator? Maybe
I see benefits for the current paste behavior, like if you pay close attention to position and want RF to honor it. But I think that often if vector art is pasted from elsewhere, it's lost off the main work area, and then it becomes a game of hide-and-seek. Video
Would be great to have the option to paste it within view.
gferreira last edited by
here’s a quick way to move the pasted glyph contours to the origin position:
g = CurrentGlyph() L, B, R, T = g.bounds g.moveBy((-L, -B))
hope this helps!
ryan last edited by
Great thanks @gferreira! Is there a way before that to get the bezier data from the pasteboard and append that to CurrentGlyph? Is it NSPasteboard?
gferreira last edited by
the pasted contours are selected, so you can get the selection bounds and move only the selected contours to the origin:
from mojo.events import addObserver class MyCustomPaste: def __init__(self): addObserver(self, "pasteCallback", "paste") def pasteCallback(self, notification): g = notification['glyph'] L = min([c.bounds for c in g.selectedContours]) B = min([c.bounds for c in g.selectedContours]) for c in g.selectedContours: c.moveBy((-L, -B)) MyCustomPaste()
a small example of getting copied vector data and draw it in the current glyph scaled to the x-height
from lib.contrib.aicbTools import readAICBFromPasteboard, drawAICBOutlines data = readAICBFromPasteboard() source = RGlyph() drawAICBOutlines(data, source.getPen()) dest = CurrentGlyph() scaleToHeight = dest.font.info.xHeight bounds = source.bounds if bounds: minx, miny, maxx, maxy = bounds h = maxy - miny source.moveBy((-minx, -miny)) scale = scaleToHeight / h source.scaleBy(scale) dest.clear() dest.appendGlyph(source)
ryan last edited by gferreira
Great thanks you two!
I've combined these things into one script that does pretty much what I was looking to do. Here it is:
# menuTitle : Paste to Baseline (Pasteline?) # shortCut : shift+command+v from lib.contrib.aicbTools import readAICBFromPasteboard, drawAICBOutlines g = CurrentGlyph() data = readAICBFromPasteboard() source = RGlyph() drawAICBOutlines(data, source.getPen()) bounds = source.bounds if bounds: L = bounds B = bounds source.moveBy((-L, -B)) g.appendGlyph(source)