Dexter
Dexter

Reputation: 5736

Crazy Font Issue with NSTextView

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 (dragged from IB and run in a fresh project), here's what you get:

selected text unselected text

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

Now for behavior from Pages:

unselected pages text selected pages text

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:

My App Helvetica My App Myraid Pro

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!

Upvotes: 4

Views: 533

Answers (1)

Joshua Nozzi
Joshua Nozzi

Reputation: 61228

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.

Upvotes: 1

Related Questions