字体大小(像素) [英] Font size in pixels

查看:397
本文介绍了字体大小(像素)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iPhone上如何计算给定点尺寸的字符大小(以像素为单位)?

On an iPhone how do I calculate the size of a character in pixels for a given point size?

推荐答案

定义为1/72英寸。也就是说,72点字体从最低下降到最高上升大约1英寸。因此,72pt字体中字形的最大高度约为1英寸。

Point sizes are defined as 1/72 of an inch. That is, a 72-point font is approximately 1 inch from the lowest descent to the highest ascent. So the maximum height of a glyph in a 72pt font is about 1 inch.

Apple的iphone技术规格页面声称iPhone 当前的分辨率为每英寸163像素。所以72点是163像素,或每点约2.2639像素。只要记住每个字形在高度和宽度上都是不同的,所以这是一个非常粗略的尺寸估计。一般来说,基准之间的距离将大于字体的点大小,

Apple's iphone tech specs page claims that the iPhone currently has a resolution of 163 pixels per inch. So 72 points is 163 pixels, or about 2.2639 pixels per point. Just remember that every glyph varies in height and width, so this is a very rough estimate of size. Generally, the distance between baselines will be a bit larger than the font's point size so that lines of text don't crash into each other.

如果你需要精确的测量(你可能会做),那么你需要实际测量字体字形字体度量信息。您可以使用 NSString的UIKit添加,这将让您在屏幕上呈现时测量特定字符串的大小。

If you need exact measurements (and you probably do) then you'll need to actually measure the font glyphs using the font metric information. You can do this by using NSString's UIKit additions, which will let you measure the size of a particular string when rendered on screen.

这篇关于字体大小(像素)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆