2014-06-17 10:10:51 sy431256wr 阅读数 1364
<h1>一,px和pt转换</h1>px:相对长度单位。像素(Pixel)。(PS字体)
pt:绝对长度单位。点(Point)。(iOS字体)
公式如下:
pt=(px/96)*72。
<h1>二,字体间转换</h1>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像素
2014-03-14 10:45:44 ys410900345 阅读数 11588
一,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像素
2014-10-24 11:13:25 meigesir 阅读数 65

UILabel的默认字体,我分别打印了出来,分别是

IOS7:font-family: ".HelveticaNeueInterface-M3"; font-weight: normal; font-style: normal; font-size: 17.00pt

IOS8:IOS8:font-family: ".HelveticaNeueInterface-Regular"; font-weight: normal; font-style: normal; font-size: 17.00pt

 

但是Helvetica Neue Interface却不在[UIFont familyNames]列表中,所以应该是某种方式的隐藏的字体。(结论参考:http://lists.apple.com/archives/cocoa-dev/2014/Jan/msg00213.html

 

查看 UIFont preferredFontForTextStyle 返回值又有下面的隐藏字体:

IOS7:

prefered font[UIFontTextStyleCaption1]: <UICTFont: 0x14ee9fc0> font-family: ".HelveticaNeueInterface-M3"; font-weight: normal; font-style: normal; font-size: 12.00pt
prefered font[UIFontTextStyleCaption2]: <UICTFont: 0x14eeb6d0> font-family: ".HelveticaNeueInterface-M3"; font-weight: normal; font-style: normal; font-size: 11.00pt
prefered font[UIFontTextStyleBody]: <UICTFont: 0x14eee680> font-family: ".HelveticaNeueInterface-M3"; font-weight: normal; font-style: normal; font-size: 17.00pt
prefered font[UIFontTextStyleFootnote]: <UICTFont: 0x14eeffb0> font-family: ".HelveticaNeueInterface-M3"; font-weight: normal; font-style: normal; font-size: 13.00pt
prefered font[UIFontTextStyleHeadline]: <UICTFont: 0x14ef1f60> font-family: ".HelveticaNeueInterface-MediumP4"; font-weight: bold; font-style: normal; font-size: 17.00pt
prefered font[UIFontTextStyleSubheadline]: <UICTFont: 0x14ef3f10> font-family: ".HelveticaNeueInterface-M3"; font-weight: normal; font-style: normal; font-size: 15.00pt

  

 

 

IOS8: 

prefered font[UIFontTextStyleCaption1]: <UICTFont: 0x165ea690> font-family: ".HelveticaNeueInterface-Regular"; font-weight: normal; font-style: normal; font-size: 12.00pt
prefered font[UIFontTextStyleCaption2]: <UICTFont: 0x1665f6c0> font-family: ".HelveticaNeueInterface-Regular"; font-weight: normal; font-style: normal; font-size: 11.00pt
prefered font[UIFontTextStyleBody]: <UICTFont: 0x165eb2d0> font-family: ".HelveticaNeueInterface-Regular"; font-weight: normal; font-style: normal; font-size: 17.00pt
prefered font[UIFontTextStyleFootnote]: <UICTFont: 0x165ecc80> font-family: ".HelveticaNeueInterface-Regular"; font-weight: normal; font-style: normal; font-size: 13.00pt
prefered font[UIFontTextStyleHeadline]: <UICTFont: 0x166b0990> font-family: ".HelveticaNeueInterface-MediumP4"; font-weight: bold; font-style: normal; font-size: 17.00pt
prefered font[UIFontTextStyleSubheadline]: <UICTFont: 0x165ee370> font-family: ".HelveticaNeueInterface-Regular"; font-weight: normal; font-style: normal; font-size: 15.00pt
 

 

很显然,UILabel的字体是[UIFont preferredFontForTextStyle:UIFontTextStyleBody]返回值

 

 

以下分别是IOS7、IOS8 的[UIFont familyNames]列表:

 

IOS7 familyNames: (

    Thonburi,

    "Snell Roundhand",

    "Academy Engraved LET",

    "Marker Felt",

    Avenir,

    "Geeza Pro",

    "Arial Rounded MT Bold",

    "Trebuchet MS",

    Arial,

    Marion,

    Menlo,

    "Malayalam Sangam MN",

    "Kannada Sangam MN",

    "Gurmukhi MN",

    "Bodoni 72 Oldstyle",

    "Bradley Hand",

    Cochin,

    "Sinhala Sangam MN",

    "Hiragino Kaku Gothic ProN",

    "Iowan Old Style",

    Damascus,

    "Al Nile",

    Farah,

    Papyrus,

    Verdana,

    "Zapf Dingbats",

    "DIN Condensed",

    "Avenir Next Condensed",

    Courier,

    "Hoefler Text",

    "Euphemia UCAS",

    Helvetica,

    "Hiragino Mincho ProN",

    "Bodoni Ornaments",

    Superclarendon,

    Mishafi,

    Optima,

    "Gujarati Sangam MN",

    "Devanagari Sangam MN",

    "Apple Color Emoji",

    "Savoye LET",

    Kailasa,

    "Times New Roman",

    "Telugu Sangam MN",

    "Heiti SC",

    "Apple SD Gothic Neo",

    Futura,

    "Bodoni 72",

    Baskerville,

    Symbol,

    "Heiti TC",

    Copperplate,

    "Party LET",

    "American Typewriter",

    "Chalkboard SE",

    "Avenir Next",

    "Bangla Sangam MN",

    Noteworthy,

    Zapfino,

    "Tamil Sangam MN",

    Chalkduster,

    "Arial Hebrew",

    Georgia,

    "Helvetica Neue",

    "Gill Sans",

    Palatino,

    "Courier New",

    "Oriya Sangam MN",

    Didot,

    "DIN Alternate",

    "Bodoni 72 Smallcaps"

)

 

 

IOS8 familyNames: (

    Thonburi,

    "Khmer Sangam MN",

    "Snell Roundhand",

    "Academy Engraved LET",

    "Marker Felt",

    Avenir,

    "Geeza Pro",

    "Arial Rounded MT Bold",

    "Trebuchet MS",

    Arial,

    Marion,

    Menlo,

    "Malayalam Sangam MN",

    "Kannada Sangam MN",

    "Gurmukhi MN",

    "Bodoni 72 Oldstyle",

    "Bradley Hand",

    Cochin,

    "Sinhala Sangam MN",

    "Hiragino Kaku Gothic ProN",

    "Iowan Old Style",

    Damascus,

    "Al Nile",

    Farah,

    Papyrus,

    Verdana,

    "Zapf Dingbats",

    "DIN Condensed",

    "Avenir Next Condensed",

    Courier,

    "Hoefler Text",

    "Euphemia UCAS",

    Helvetica,

    "Lao Sangam MN",

    "Hiragino Mincho ProN",

    "Bodoni Ornaments",

    Superclarendon,

    Mishafi,

    Optima,

    "Gujarati Sangam MN",

    "Devanagari Sangam MN",

    "Apple Color Emoji",

    "Savoye LET",

    Kailasa,

    "Times New Roman",

    "Telugu Sangam MN",

    "Heiti SC",

    "Apple SD Gothic Neo",

    Futura,

    "Bodoni 72",

    Baskerville,

    Symbol,

    "Heiti TC",

    Copperplate,

    "Party LET",

    "American Typewriter",

    "Chalkboard SE",

    "Avenir Next",

    "Bangla Sangam MN",

    Noteworthy,

    Zapfino,

    "Tamil Sangam MN",

    Chalkduster,

    "Arial Hebrew",

    Georgia,

    "Helvetica Neue",

    "Gill Sans",

    "Kohinoor Devanagari",

    Palatino,

    "Courier New",

    "Oriya Sangam MN",

    Didot,

    "DIN Alternate",

    "Bodoni 72 Smallcaps"

)

 

我使用在线文本比较工具比较了以下上述的分别,得出结论:

IOS8只是多出三种字体:Khmer Sangam MN、Lao Sangam MN、Kohinoor Devanagari

 

2012-10-29 17:46:48 lisiben 阅读数 61

UIFont
Parameters
fontSize
The size (in points) to which the font is scaled. This value must be greater than 0.0.
fontSize实际的参数是pointSize,是像素点。

windows和mac上的字号是统一的。
英文字体的1磅,相当于1/72 英寸,约等于1/2.8mm。
12PT的字打印出来约为4.2mm。网页中12px的字才相当于12像素。
虽然 四号=(14/72)*96=18.6px 更接近 19px,但是因为 18px 是点阵,所以系统还是优先显示点阵字号的。
换句话说:四号=18px
中文字号VS英文字号(磅)VS像素值的对应关系:

iOS字体对应关系

阅读数 321

iOS 字体的设置

阅读数 573

iOS字体大小

阅读数 5

没有更多推荐了,返回首页