NSTextView .... Strange Display

Has anyone played with NSTextView in Swift or ObjC?
I have one where I insert data, and its fine…
but if I do the process again (activated by a button), the same text appears (as it should), but the character spacing is all wonky…

And if I cut the text and paste it into another app to examine it… its perfectly fine, no zombies or other strange stuff…

AHHHHHHH… I think i may have found it…
The text represents error messages… and the first character is a :beetle:
if I remove that… the text part remains correct

is it mishandling the emoji ?
or possibly not set up to handle attributed text right ?

I don’t know :frowning:
I’m just inserting \u{1F41E} at the head of the msg text…
if I substitude a non Unicode value like “*”… .it works fine

it seems to make all the spaces extra wide,

Solved… not sure this is the “best” way… but it does work.

originally I was using

textView.string=myString // where myString may contain  :beetle: 

but needed to use this instead

textView.textStorage?.setAttributedString(NSAttributedString(string:myString, attributes: attributes))

where attributes redefined the display font to use

interesting … if you set the original nstextview to use that same font do you still have that issue ?

seems odd

the original TV was the same font, but it was treated as “plain text”… I guess adding that glyph needed to be treated as attributed… But unless I apply the font attribute, it used changed it to a default font… Apple does seemed to have learned alot with iOS, as macOS is convulted in doing some things where iOS is not


iOS probably had the benefit of looking at what NeXT had done for the previous 20 years and throwing out the complicated crap where macOS was a more descendent that retained all that from the macOS X 1.0 days

And now some of that is being pushed back into macOS
The Text System on macOS is quite complicated