使用 CJK 字符时 NSTextView 行高发生变化

NSTextView line height changes when using CJK characters

我使用 NSTextView 渲染可能包含非拉丁字符的 NSAttributedStrings,似乎包含任何 CJK 字符的行 always 6像素比没有那些的线高。即使将 NSParagraphStyleminimumLineHeight 属性 设置为更高的值(例如 32 像素,当使用标准系统字体大小时)仍然存在此问题(带有 CJK 字符的行呈现为 38像素)。

此外,NSAttributedStringboundingRectWithSize 似乎报告了错误(“正确”)的尺寸(没有额外的 6 个像素)。

我错过了什么?

layoutManager.usesFontLeading 设置为 NO 解决了这个问题。