How to insert emoji into NSTextView without shifting the line down?

与世无争的帅哥 提交于 2019-12-22 10:31:35

问题


How do I insert emoji into an NSTextView without moving the line down?

If I insert an emoji character into an NSTextView, the whole line will shift down a couple pixels. If I remove the emoji character, it will move back up to its original position.

On the other hand, if I insert an emoji into an NSTextField, the line doesn't move at all, even when the text in the line is the same font and size as it was in the NSTextView.

You can see this behavior in TextEdit. When you are typing in the main editor area (an NSTextView), emoji make the lines move down. When you are typing in the Find search bar (NSTextField) emoji don't affect the line position.

I've tried setting typingAttributes with various NSParagraphStyle settings (lineHeight, lineSpacing, lineHeightMultiple, max/minLineHeight) and also raising or lowering the baseline to no avail. In fact, some of these settings don't help the emoji behavior, but they do mess up the vertical alignment of the spelling error indicators.

来源:https://stackoverflow.com/questions/39460470/how-to-insert-emoji-into-nstextview-without-shifting-the-line-down

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!