سؤال

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

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top