cocoa - NSPasteboard with RTF/RTFD Changing Font -
i'm working on utility pastes images text. far best way i've found using nspasteboard
, encapsulating images , text in rtfd data stream. problem i'm having though have no font attributes (i have checked) every time paste copied code document changes font 'helvetica size 12'. possible force paste text , images without changing font?
void copydata() { let pboard = nspasteboard.generalpasteboard() pboard.clearcontents() let str = nsmutableattributedstring() im in images { let = nstextattachment() a.image = im let s = nsattributedstring(attachment: a) str.appendattributedstring(s) } //now have rtf whole bunch of images let range = nsmakerange(0, str.length) if let d = str.rtfdfromrange(range, documentattributes: [nsdocumenttypedocumentattribute: nsplaintextdocumenttype]) { pboard.setdata(d, fortype: nspasteboardtypertfd) } pboard.writeobjects(images) }
Comments
Post a Comment