Abcd Efg
Abcd Efg

Reputation: 2146

NSFont Height For Drawing

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

Upvotes: 2

Views: 3946

Answers (1)

Frederik Slijkerman
Frederik Slijkerman

Reputation: 6529

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.

Upvotes: 4

Related Questions