开发者

Crazy Font Issue with NSTextView

开发者 https://www.devze.com 2023-02-10 19:26 出处:网络
I\'m knee deep in font metrics with NSTextView at the moment.I was hoping a developer here could shed some light as to what\'s going on.

I'm knee deep in font metrics with NSTextView at the moment. I was hoping a developer here could shed some light as to what's going on.

With Myriad Pro in a default NSTextView (dragg开发者_JAVA技巧ed from IB and run in a fresh project), here's what you get:

Crazy Font Issue with NSTextView

Crazy Font Issue with NSTextView

Notice how the selected rect has the same height as the insertion point.

Now for behavior from Pages:

Crazy Font Issue with NSTextView

Crazy Font Issue with NSTextView

Notice how the selected rect is similar to the regular text view version, but the insertion point height is actually more reflective of the font (and smaller!).

Weird.

Why do I care? Here is a screen of my application with Helvetica, and then with Myriad:

Crazy Font Issue with NSTextView

Crazy Font Issue with NSTextView

Notice that in both cases, the outline symbol is perfectly centered with the insertion point height. Those symbols are actually subviews, and not in the text stream. Notice those symbols in Pages. They remain centered for Myriad. Clearly Apple realized something and fixed it. Any ideas what they did?

Thanks!


This isn't a mistake on Apple's part but rather an assumption on yours. This is a function of font metrics as well as line height.The insertion point takes the whole line height; the drawn font parts don't.

I thought it was you who I pointed to the Font Handling guide a few days ago. Either way, you need to understand this topic thoroughly so you can determine where to draw your dot.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号