What exactly is UIFont#39;s point size?(UIFont 的磅值到底是多少?)
问题描述
我很难准确理解 UIFont
中的磅值是什么意思.它不是像素,也不是与 1/72 英寸相关的点的标准定义.
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.
我使用 -[NSString sizeWithFont:]
计算出不同大小字体的像素大小,得到以下结果:
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 |
(我做了 [@"A" sizeWithFont:[UIFont systemFontOfSize:theSize]]
)
看看 72.0
点大小,这不是 1 英寸,因为这是在 DPI 为 163 的设备上,所以 1 英寸就是 163.0 像素,对吧?
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?
谁能解释一下 UIFont
术语中的点"是什么?即我上面的方法是错误的,如果我使用其他东西,我会看到字体在 72 点处是 163 像素?还是纯粹是从其他东西定义一个点?
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.
在 72.0 点处,字体的单位正方形是一英寸.字体 y 的字形 x 相对于这个平方英寸具有任意大小.因此,字体设计者可以使字体相对于其他字体显得大或小.这是字体字符"的一部分.
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'.
因此,在 72 点处绘制A"会告诉您它将是在 36 点处以相同字体绘制的A"的两倍高 - 绝对没有其他关于实际位图大小的信息.
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 对于给定的字体,确定点大小和像素之间关系的唯一方法是测量它.
ie For a given font the only way to determine the relationship between point size and pixels is to measure it.
这篇关于UIFont 的磅值到底是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIFont 的磅值到底是多少?
基础教程推荐
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01