SOLVED [Request] Paste special (i.e. from other vector apps)
-
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
Shift+Cmd+V
?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.
TIA,
Ryan
-
Pastaline?
-
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[0] B = bounds[1] source.moveBy((-L, -B)) g.appendGlyph(source)
-
RoboFont uses the old aicbTools from @tal.
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)
-
hello @ryan,
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[0] for c in g.selectedContours]) B = min([c.bounds[1] for c in g.selectedContours]) for c in g.selectedContours: c.moveBy((-L, -B)) MyCustomPaste()
cheers!
-
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?
-
hello @ryan,
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!