Find center of characters in NSTextView

212 Views Asked by At

For each line fragment in an NSTextView, I'm placing a subview next to it for collapsing. The problem is, different fonts throw off the baselines and I can never position the view in the exact center of the text.

I've tried getting the baseline offset, but it doesn't quite seem to do the trick.

Here's the meat of the question: Assuming the "•" character is it's own view, how can I do this:

•Text

for ANY font in ANY language?

1

There are 1 best solutions below

0
On BEST ANSWER

See Getting Font Metrics of the Font Handling guide. Additionally the Getting Glyph Layout and related sections give a more complete answer.