copy paste - Cocoa NSAttributedString Pasting Changes Font -


i have nsattributedstring has nsattachment , text. have copied pasteboard. have made sure string has no font attributes. when paste it, changes font helvetica. there way prevent behavior?

let wrapper = nsfilewrapper() wrapper.preferredfilename = "image"  let attachment = nstextattachment(filewrapper: wrapper) if let im = nsimage(data: data) { attachment.image = im }  let image = nsattributedstring(attachment: attachment) let str = nsmutableattributedstring(attributedstring: image) str.appendattributedstring(nsattributedstring(string: "hello world"))  let range = nsmakerange(0, str.length)  //remove font attributes str.removeattribute(nsfontattributename, range: range) str.removeattribute(nsfontsizeattribute, range: range)  swift.print(str.attributes) //prints empty array 

at point copy data clipboard

if let d = str.rtfdfromrange(range, documentattributes: [nsdocumenttypedocumentattribute: nsrtfdtextdocumenttype]) {     let pboard = nspasteboard.generalpasteboard()     pboard.clearcontents()     pboard.declaretypes([nspasteboardtypertfd], owner: self)     pboard.setdata(d, fortype: nspasteboardtypertfd) } 


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -