iPhone设备字体详解

做iPhone开发的同学一定对:UIFont systemFontOfSize、boldSystemFontOfSize、italicSystemFontOfSize很熟悉,但你们知道它们都是什么字体吗?这篇文章将会带大家认识一下iPhone的字体。

一、默认字体

首先我们用如下代码看看,我们的默认字体是什么:

NSLog(@%@
, [UIFont systemFontOfSize:10]);
NSLog(@"%@
", [UIFont boldSystemFontOfSize:10]);
NSLog(@"%@
", [UIFont italicSystemFontOfSize:10]);
<UICTFont: 0x8ca7700> font-family: ".HelveticaNeueInterface-M3"; font-weight: normal; font-style: normal; font-size: 10.00pt
    <UICTFont: 0x8b81b20> font-family: ".HelveticaNeueInterface-MediumP4"; font-weight: bold; font-style: normal; font-size: 10.00pt
    <UICTFont: 0x8ca9eb0> font-family: ".HelveticaNeueInterface-ItalicM3"; font-weight: normal; font-style: italic; font-size: 10.00pt

我们能看到这样的字符串:".HelveticaNeueInterface"

我们再用下面这个代码看看系统到底支持哪些字体:

复制代码
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indexFamily, indexFont;
 for (indexFamily = 0; indexFamily < [familyNames count]; ++indexFamily)
 {
    NSLog(@"Family name: %@", [familyNames objectAtIndex:indexFamily]);
    fontNames = [[NSArray alloc] initWithArray:
    [UIFont fontNamesForFamilyName:[familyNames objectAtIndex:indexFamily]]];
     for (indexFont = 0; indexFont < [fontNames count]; ++indexFont)
    {
        NSLog(@"    Font name: %@", [fontNames objectAtIndex:indexFont]);
    }
}
复制代码
复制代码
Family name: Thonburi
       Font name: Thonburi-Bold
       Font name: Thonburi
       Font name: Thonburi-Light
  Family name: Snell Roundhand
       Font name: SnellRoundhand-Black
       Font name: SnellRoundhand-Bold
       Font name: SnellRoundhand
  Family name: Academy Engraved LET
       Font name: AcademyEngravedLetPlain
  Family name: Marker Felt
       Font name: MarkerFelt-Thin
       Font name: MarkerFelt-Wide

  ……

  ……

  Family name: Helvetica Neue
       Font name: HelveticaNeue-BoldItalic
       Font name: HelveticaNeue-Light
       Font name: HelveticaNeue-Italic
       Font name: HelveticaNeue-UltraLightItalic
       Font name: HelveticaNeue-CondensedBold
       Font name: HelveticaNeue-MediumItalic
       Font name: HelveticaNeue-Thin
       Font name: HelveticaNeue-Medium
       Font name: HelveticaNeue-Thin_Italic
       Font name: HelveticaNeue-LightItalic
       Font name: HelveticaNeue-UltraLight
       Font name: HelveticaNeue-Bold
       Font name: HelveticaNeue
       Font name: HelveticaNeue-CondensedBlack

  ……

  ……
复制代码

二、Helvetica字体详解

Helvetica是一种被广泛使用的的西文字体,于1957年由瑞士字体设计师爱德华德·霍夫曼(Eduard Hoffmann)和马克斯·米耶丁格(MaxMiedinger)设计。

Helvetica是由米耶丁格和爱德华德·霍夫曼在瑞士哈斯铸造所作为排版铅字制作的。当时人们熟悉的是“国际字体风格”(也称为“瑞士风格”),比如 Josef Muller-Brockmann 在1896年推广的 Akzidenz Grotesk 这类无衬线字体,而哈斯希望能设计一套新的无衬线字体能够与 Akzidenz Grotesk 在瑞士市场上竞争。最初的名称是“Neue Haas Grotesk”,意为“哈斯的新无衬线铅字”,后来曾考虑改为Helvetia(源自拉丁文的“瑞士”一词),不过最终改为 Helvetica,在拉丁文中意为“瑞士的”。

Helvetica被广泛用于全世界使用拉丁字母和西里尔字母的国家。同样的风格也被移植到希腊字母希伯来字母和汉字。

历史

Helvetica是由米耶丁格和爱德华德·霍夫曼(Eduard Hoffmann)在瑞士哈斯铸造所(Haas’sche Schriftgie&szlig;erei)作为排版铅字制作的。当时人们熟悉的是“国际字体风格”(也称为“瑞士风格”),比如 Josef Muller-Brockmann 在1896年推广 Akzidenz Grotesk 这类在50多年前制作的无衬线字体,并由德国铸造所 Berthold 持续进行市场推广。因此哈斯希望能设计一套新的无衬线字体能够与 Akzidenz Grotesk 在瑞士市场上竞争。最初的名称是“Neue Haas Grotesk”,意为“哈斯的新无衬线铅字”,后来哈斯的德国母公司斯滕佩尔(Stempel)在1960年曾考虑将名字改为Helvetia(源自拉丁文的“瑞士”一词),不过最终改为 Helvetica,在拉丁文中意为“瑞士的”,以使其更具有国际市场竞争力。现在,Helvetica由Linotype公司所拥有,Stempel是它的子公司。

应用

Helvetica被广泛用于全世界使用拉丁字母和西里尔字母的国家。同样的风格也被移植到希腊字母希伯来字母和汉字。加拿大政府的联邦认证制度(corporate identity program)也使用了这个字体及其各种版本。Helvetica被大量使用在标志、电视、新闻标题以及无数的商标。 如3M、爱克发、BASF、美国航空、American Apparel、BMW、Crate & Barrel、Epson、德国汉莎航空公司、Fendi、J. C. Penney、Jeep、川崎重工业、Knoll、英特尔无印良品雀巢松下、Microsoft、三菱电机、摩托罗拉、丰田、Parmalat、SAAB(Helvetica 83 粗体)、三星、渣打银行、Staples、Target、Texaco等数百间主要企业的标志都是使用Helvetica字体。

Helvetica是Mac OS系统的默认字体。Mac OS X系统中也包含Helvetica和Helvetica Neue字体。Nimbus Sans字体(GNU/Linux系统中的默认字体)也是基于Helvetica的,Bitstream公司的Swiss 721 BT字体也是一样(从这个字体名字就可以看出)。Helvetica在政府部门和公共机构中也获得广泛使用,例如美国华盛顿和波士顿的地铁和大众交通系统采用了该字体。新的纽约地铁也将标志字体从Akzidenz Grotesk体转为Helvetica字体。

Helvetica是苹果电脑的默认字体,微软常用的Arial字体也来自于它。2007年是helvetica诞生50年,作为在平面设计和商业上非常普及和成功的一款字体,英国导演Gary Hustwit专门为她拍摄了一部纪录片《Helvetica》。

三、添加自己的字体

1、要添加方正兰亭字体,首先需要一个ttf的字体库。

     2、然后把这个文件添加到工程里面 

3、在plist里面添加

添加成功后就可以使用啦!

参考:

http://baike.baidu.com/view/1649051.htm

http://www.cocoachina.com/bbs/simple/?t10620.html

http://www.cocoachina.com/bbs/read.php?tid-71703.html

原文地址:https://www.cnblogs.com/lingzhao/p/3512033.html