98

What is the name of the default system font on the iPhone?

I would like to retrieve this for customizing a UIView.

Hussein El Feky
  • 6,627
  • 5
  • 44
  • 57
Ken
  • 30,811
  • 34
  • 116
  • 155

12 Answers12

110

To the delight of font purists everywhere, the iPhone system interface uses Helvetica or a variant thereof.

The original iPhone, iPhone 3G and iPhone 3GS system interface uses Helvetica. As first noted by the always excellent DaringFireball, the iPhone 4 uses a subtly revised font called "Helvetica Neue." DaringFireball also notes that this change is related to the iPhone 4 display rather than the iOS 4 operating system and older iPhone models running iOS 4 still use Helvetica as the system font.

iPod models released prior to the iPhone use either Chicago, Espy Sans, or Myriad and use Helvetica after the release of the iPhone.

From http://www.everyipod.com/iphone-faq/iphone-who-designed-iphone-font-used-iphone-ringtones.html

For iOS9 it has changed to San Francisco. See http://developer.apple.com/fonts for more info.

Alain Bianchini
  • 3,883
  • 1
  • 7
  • 27
Gary Willoughby
  • 50,926
  • 41
  • 133
  • 199
104

If you're doing programatic customisation, don't hard code the system font. Use UIFont systemFontOfSize:, UIFont boldSystemFontOfSize: and UIFont italicSystemFontOfSize (Apple documentation).

This has become especially relevant since iOS 7, which changed the system font to Helvetica Neue.

This has become super especially relevant since iOS 9, which changed the system font again to San Francisco.

Adam Wright
  • 48,938
  • 12
  • 131
  • 152
  • 1
    I'm not going to change the system font, that's a bad idea. But I want it for some html in UIWebView. – Ken Oct 01 '10 at 11:56
  • This doesn't change the system font - it just gives you `UIFont` instances of the system font using the given sizes, and will always return the system fonts regardless of future iOS updates. – Adam Wright Oct 01 '10 at 12:02
  • The font I'm seeing in my UIWebView doesn't looking like Helvetica to me. I might be wrong but setting the font for my view takes away my doubt. – Ken Oct 01 '10 at 12:31
  • "don't hard code the system font" is good advice, or really bad advice, depending on the situation. Personally, I wish I had hardcoded `Helvetica`... doing that now. – Dan Rosenstark Aug 22 '13 at 00:06
  • Totally agree, don't hardcode, please. This should be the right answer to this question – Esteve Mar 06 '14 at 12:47
16

afaik iPhone uses "Helvetica" by default < iOS 10

szuniverse
  • 1,076
  • 4
  • 17
  • 32
Vladimir
  • 170,431
  • 36
  • 387
  • 313
14

Swift

Specific font

Setting a specific font in Swift is done like this:

let myFont = UIFont(name: "Helvetica", size: 17)

If you don't know the name, you can get a list of the available font names like this:

print(UIFont.familyNames())

Or an even more detailed list like this:

for familyName in UIFont.familyNames() {
    print(UIFont.fontNamesForFamilyName(familyName))
}

But the system font changes from version to version of iOS. So it would be better to get the system font dynamically.

System font

let myFont = UIFont.systemFontOfSize(17)

But we have the size hard-coded in. What if the user's eyes are bad and they want to make the font larger? Of course, you could make a setting in your app for the user to change the font size, but this would be annoying if the user had to do this separately for every single app on their phone. It would be easier to just make one change in the general settings...

Dynamic font

let myFont = UIFont.preferredFont(forTextStyle: .body)

Ah, now we have the system font at the user's chosen size for the Text Style we are working with. This is the recommended way of setting the font. See Supporting Dynamic Type for more info on this.

Related

Community
  • 1
  • 1
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
12

You can always use

UIFont *systemFont = [UIFont systemFontOfSize:12];
NSLog(@"what is it? %@ %@", systemFont.familyName, systemFont.fontName);

The answer is:

Up to iOS 6

 Helvetica Helvetica

iOS 7

.Helvetica Neue Interface .HelveticaNeueInterface-M3

but you can just use Helvetica Neue

Dan Rosenstark
  • 68,471
  • 58
  • 283
  • 421
8

I'm not sure there is an api to get the default system font name. So I just get the name like this :

    //get system default font
    UILabel *label = [[UILabel alloc] init];        
    fontname = label.font.fontName;
    [label release];

Looks stupid but it works.

perkin tang
  • 113
  • 2
  • 1
3

Here is some update for supporting iOS 7. It has Dynamic Font Size now.

For any and all apps that support “Dynamic Type,” users can select a font size in iOS 7 that works system wide, simply by visiting the "General" section under "Settings" and selecting "Font Size."

UIFont *dynamicFont  = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];

And constants list, detailed explanation is here

NSString *const UIFontTextStyleHeadline;
NSString *const UIFontTextStyleSubheadline;
NSString *const UIFontTextStyleBody;
NSString *const UIFontTextStyleFootnote;
NSString *const UIFontTextStyleCaption1;
NSString *const UIFontTextStyleCaption2;
B.S.
  • 21,660
  • 14
  • 87
  • 109
3

Category UIFontSystemFonts for UIFont (UIInterface.h) provides several convenient predefined sizes.

@interface UIFont (UIFontSystemFonts)
 + (CGFloat)labelFontSize;
 + (CGFloat)buttonFontSize;
 + (CGFloat)smallSystemFontSize;
 + (CGFloat)systemFontSize;
@end 

I use it for chat messages (labels) and it work well when I need to get size of text blocks.

 [UIFont systemFontOfSize:[UIFont labelFontSize]];

Happy coding!

Anton Gaenko
  • 8,929
  • 6
  • 44
  • 39
3
UIFont *systemFont = [UIFont systemFontOfSize:[UIFont systemFontSize]];

This will give you the system font with the default system font size applied for the label texts by default.

Rohit saraf
  • 491
  • 1
  • 6
  • 17
2

Swift

You should always use the system defaults and not hard coding the font name because the default font could be changed by Apple at any time.

There are a couple of system default fonts(normal, bold, italic) with different sizes(label, button, others):

let font = UIFont.systemFont(ofSize: UIFont.systemFontSize)
let font2 = UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)
let font3 = UIFont.italicSystemFont(ofSize: UIFont.systemFontSize)

beaware that the default font size depends on the target view (label, button, others)

Examples:

let labelFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
let buttonFont = UIFont.systemFont(ofSize: UIFont.buttonFontSize)
let textFieldFont = UIFont.systemFont(ofSize: UIFont.systemFontSize)
Musa almatri
  • 5,596
  • 2
  • 34
  • 33
0
  1. download required .ttf file

  2. add the .ttf file under copy bundle resource, double check whether the ttf file is added under resource

  3. In info.pllist add the ttf file name as it is.

  4. now open the font book add the .ttf file in the font book, select information icon there you find the postscript name.

  5. now give the postscript name in the place of font name

Jobin
  • 5,610
  • 5
  • 38
  • 53
0

The default font for iOS is San Francisco . You can refer the link for further details

Sateesh Pasala
  • 772
  • 8
  • 15