Question

When ever I set the pointSize for a NSFont the output text does not reach the exact height of point size, for instance when I set it to 20.0 the output text for a capital B is 17.0 pixels tall. Since I'm using it to draw text on a NSView it's causing some measuring problems for me. Is there any accurate methods to measure the maximum height of text?

I'm drawing the strings with this method: [stringValue drawInRect:stringRect withAttributes:stringAttributes];

Regards

Was it helpful?

Solution

See Font Handling in the Cocoa documentation. Scroll down to 'Querying Font Metrics': this clearly shows how the different metrics such as descender, ascender and leading are used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top