简体   繁体   English

NSFont绘图高度

[英]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. 每当我为NSFont设置pointSize时,输出文本都不会达到点大小的确切高度,例如,当我将其设置为20.0时,大写B的输出文本高度为17.0像素。 Since I'm using it to draw text on a NSView it's causing some measuring problems for me. 由于我使用它在NSView上绘制文本,因此给我造成了一些测量问题。 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]; 我使用这种方法绘制字符串:[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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM