UIFont的点数是多少? [英] What exactly is UIFont's point size?

查看:168
本文介绍了UIFont的点数是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很努力的去理解 UIFont 的大小。这不是像素,它似乎不是标准的定义,它是关系到1/72英寸。

我使用 - [NSString sizeWithFont:] 各种大小的字体,并得到以下内容:

  |点大小|像素大小| 
| ---------- | ---------- |
| 10.0 | 13.0 |
| 20.0 | 24.0 |
| 30.0 | 36.0 |
| 40.0 | 47.0 |
| 50.0 | 59.0 |
| 72.0 | 84.0 |
| 99.0 | 115.0 |
| 100.0 | 116.0 |

(我做了 [@AsizeWithFont:[UIFont systemFontOfSize:theSize ]]



观察 72.0 点大小,即不是1因为这是在一个设备的DPI为163,所以1英寸将是163.0像素,对不对?任何人都可以解释什么是点那么code> UIFont 是什么?即我的方法上面错了,真的如果我用了别的东西,我会看到有关字体的东西是72点的163像素?或者纯粹是从一个其他的定义点?

解决方案

一个字体有一个内部坐标系统,认为它是一个单位正方形,在这个单位正方形中,字体的矢量坐标被指定为任意大小,以容纳字体中的所有字形+ - 字体设计师选择的任何数量的页边空白。字体的单位平方是72.0分。字体 y 的字形 x 与此英寸平方相比具有任意大小。因此,字体设计者可以制作出与其他字体相比大小的字体。这是字体'字符'的一部分。

因此,在72点绘制一个A告诉你它将是A的两倍在同一字体的36个点 - 绝对没有关于实际位图大小将是什么。

即对于给定的字体唯一的方法来确定点大小和像素是衡量它。

I am struggling to understand exactly what the point size in UIFont means. It's not pixels and it doesn't appear to be the standard definition of point which is that they relate to 1/72th inch.

I worked out the pixel size using -[NSString sizeWithFont:] of fonts at various sizes and got the following:

| Point Size | Pixel Size |
| ---------- | ---------- |
| 10.0       | 13.0       |
| 20.0       | 24.0       |
| 30.0       | 36.0       |
| 40.0       | 47.0       |
| 50.0       | 59.0       |
| 72.0       | 84.0       |
| 99.0       | 115.0      |
| 100.0      | 116.0      |

(I did [@"A" sizeWithFont:[UIFont systemFontOfSize:theSize]])

And looking at the 72.0 point size, that is not 1-inch since this is on a device with a DPI of 163, so 1-inch would be 163.0 pixels, right?

Can anyone explain what a "point" in UIFont terms is then? i.e. is my method above wrong and really if I used something else I'd see something about the font is 163 pixels at 72 point? Or is it purely that a point is defined from something else?

解决方案

A font has an internal coordinate system, think of it as a unit square, within which a glyph's vector coordinates are specified at whatever arbitrary size accommodates all the glyphs in the font +- any amount of margin the font designer chooses.

At 72.0 points the font's unit square is one inch. Glyph x of font y has an arbitrary size in relation to this inch square. Thus a font designer can make a font that appears large or small in relation to other fonts. This is part of the font's 'character'.

So, drawing an 'A' at 72 points tells you that it will be twice as high as an 'A' drawn at 36 points in the same font - and absolutely nothing else about what the actual bitmap size will be.

ie For a given font the only way to determine the relationship between point size and pixels is to measure it.

这篇关于UIFont的点数是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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