Created
October 11, 2014 07:51
-
-
Save wudi/22e49abb830b1fb0a0cc to your computer and use it in GitHub Desktop.
iOS程序字体与ps设计字体换算
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
一,ps和pt转换px:相对长度单位。像素(Pixel)。(PS字体) | |
pt:绝对长度单位。点(Point)。(iOS字体)公式如下:pt=(px/96)*72。二,字体间转换1in = 2.54cm = 25.4 mm = 72pt = 6pc | |
具体换算是: | |
Points Pixels Ems Percent | |
6pt 8px 0.5em 50% | |
7pt 9px 0.55em 55% | |
7.5pt 10px 0.625em 62.5% | |
8pt 11px 0.7em 70% | |
9pt 12px 0.75em 75% | |
10pt 13px 0.8em 80% | |
10.5pt 14px 0.875em 87.5% | |
11pt 15px 0.95em 95% | |
12pt 16px 1em 100% | |
13pt 17px 1.05em 105% | |
13.5pt 18px 1.125em 112.5% | |
14pt 19px 1.2em 120% | |
14.5pt 20px 1.25em 125% | |
15pt 21px 1.3em 130% | |
16pt 22px 1.4em 140% | |
17pt 23px 1.45em 145% | |
18pt 24px 1.5em 150% | |
20pt 26px 1.6em 160% | |
22pt 29px 1.8em 180% | |
24pt 32px 2em 200% | |
26pt 35px 2.2em 220% | |
27pt 36px 2.25em 225% | |
28pt 37px 2.3em 230% | |
29pt 38px 2.35em 235% | |
30pt 40px 2.45em 245% | |
32pt 42px 2.55em 255% | |
34pt 45px 2.75em 275% | |
36pt 48px 3em 300% | |
像素与毫米的转换 | |
转换还需要知道另一个参数:DPI(每英寸多少点) | |
象素数 / DPI = 英寸数 | |
英寸数 * 25.4 = 毫米数 | |
对于显示设备,不管是打印机还是屏幕,都有一种通用的方法 | |
先用GetDeviceCaps(设备句柄,LOGPIXELSX) | |
或者 | |
GetDeviceCaps(设备句柄,LOGPIXELSY)获得设备每英寸的像素数 | |
分别记为:px 和 py | |
一英寸等于25.4mm | |
那么毫米换算成像素的公式为 | |
水平方向的换算: x * px /25.4 | |
垂直方向的换算: y * py /25.4 | |
像素换算为毫米 x * 25.4 / px | |
在程序中这么写 | |
MyControl.Height := 10{mm} * PixelsPerInch * 10 div 254; | |
分子和分母同乘以10,将浮点数运算转化为整数运算,效率更高 | |
常用的1024x768或800x600等标准的分辨率计算出来的dpi是一个常数:96,因此计算出来的毫米与像素的关系也约等于一个常数: | |
基本上 1毫米 约等于 3.78像素 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment