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:
Notice how the selected rect has the same height as the insertion point.
Now for behavior from Pages:
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:
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.
精彩评论