Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues with setting some different font for UILabel

Tags:

xcode

ios

iphone

I would like to set the font size and familyname to the titleLabel. //Helvetica Neue UltraLight

 [titleLabel setFont:[UIFont fontWithName:@"Helvetica Neue UltraLight" size:25.0f]];

This is not working.

Kindly tell me what could be wrong?

Any help will be appreciated?

like image 208
pie Avatar asked Mar 28 '12 12:03

pie


2 Answers

the correct fontName is @"HelveticaNeue-UltraLight".

use something like this to get a nicely formatted list of available font names:

NSMutableString *str = [NSMutableString stringWithCapacity:1000];
for (NSString *familyName in [UIFont familyNames]) {
    [str appendFormat:@"%@\n", familyName];
    for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
        [str appendFormat:@"    %@\n", fontName];
    }
    [str appendString:@"\n"];
}
NSLog(@"%@", str);

this is the current list for iOS5.1:

Thonburi
    Thonburi-Bold
    Thonburi

Snell Roundhand
    SnellRoundhand-Bold
    SnellRoundhand-Black
    SnellRoundhand

Academy Engraved LET
    AcademyEngravedLetPlain

Marker Felt
    MarkerFelt-Wide
    MarkerFelt-Thin

Geeza Pro
    GeezaPro-Bold
    GeezaPro

Arial Rounded MT Bold
    ArialRoundedMTBold

Trebuchet MS
    TrebuchetMS
    TrebuchetMS-Bold
    TrebuchetMS-Italic
    Trebuchet-BoldItalic

Arial
    Arial-BoldMT
    ArialMT
    Arial-ItalicMT
    Arial-BoldItalicMT

Marion
    Marion-Regular
    Marion-Bold
    Marion-Italic

Gurmukhi MN
    GurmukhiMN
    GurmukhiMN-Bold

Malayalam Sangam MN
    MalayalamSangamMN-Bold
    MalayalamSangamMN

Bradley Hand
    BradleyHandITCTT-Bold

Kannada Sangam MN
    KannadaSangamMN
    KannadaSangamMN-Bold

Bodoni 72 Oldstyle
    BodoniSvtyTwoOSITCTT-Book
    BodoniSvtyTwoOSITCTT-Bold
    BodoniSvtyTwoOSITCTT-BookIt

Cochin
    Cochin
    Cochin-BoldItalic
    Cochin-Italic
    Cochin-Bold

Sinhala Sangam MN
    SinhalaSangamMN
    SinhalaSangamMN-Bold

Hiragino Kaku Gothic ProN
    HiraKakuProN-W6
    HiraKakuProN-W3

Papyrus
    Papyrus-Condensed
    Papyrus

Verdana
    Verdana
    Verdana-Bold
    Verdana-BoldItalic
    Verdana-Italic

Zapf Dingbats
    ZapfDingbatsITC

Courier
    Courier-Bold
    Courier
    Courier-BoldOblique
    Courier-Oblique

Hoefler Text
    HoeflerText-Black
    HoeflerText-Italic
    HoeflerText-Regular
    HoeflerText-BlackItalic

Euphemia UCAS
    EuphemiaUCAS-Bold
    EuphemiaUCAS
    EuphemiaUCAS-Italic

Helvetica
    Helvetica-LightOblique
    Helvetica
    Helvetica-Oblique
    Helvetica-BoldOblique
    Helvetica-Bold
    Helvetica-Light

Hiragino Mincho ProN
    HiraMinProN-W3
    HiraMinProN-W6

Bodoni Ornaments
    BodoniOrnamentsITCTT

Apple Color Emoji
    AppleColorEmoji

Optima
    Optima-ExtraBlack
    Optima-Italic
    Optima-Regular
    Optima-BoldItalic
    Optima-Bold

Gujarati Sangam MN
    GujaratiSangamMN
    GujaratiSangamMN-Bold

Devanagari Sangam MN
    DevanagariSangamMN
    DevanagariSangamMN-Bold

Times New Roman
    TimesNewRomanPS-ItalicMT
    TimesNewRomanPS-BoldMT
    TimesNewRomanPSMT
    TimesNewRomanPS-BoldItalicMT

Kailasa
    Kailasa
    Kailasa-Bold

Telugu Sangam MN
    TeluguSangamMN-Bold
    TeluguSangamMN

Heiti SC
    STHeitiSC-Medium
    STHeitiSC-Light

Apple SD Gothic Neo
    AppleSDGothicNeo-Bold
    AppleSDGothicNeo-Medium

Futura
    Futura-Medium
    Futura-CondensedExtraBold
    Futura-CondensedMedium
    Futura-MediumItalic

Bodoni 72
    BodoniSvtyTwoITCTT-BookIta
    BodoniSvtyTwoITCTT-Book
    BodoniSvtyTwoITCTT-Bold

Baskerville
    Baskerville-SemiBoldItalic
    Baskerville-Bold
    Baskerville-Italic
    Baskerville-BoldItalic
    Baskerville-SemiBold
    Baskerville

Chalkboard SE
    ChalkboardSE-Regular
    ChalkboardSE-Bold
    ChalkboardSE-Light

Heiti TC
    STHeitiTC-Medium
    STHeitiTC-Light

Copperplate
    Copperplate
    Copperplate-Light
    Copperplate-Bold

Party LET
    PartyLetPlain

American Typewriter
    AmericanTypewriter-CondensedLight
    AmericanTypewriter-Light
    AmericanTypewriter-Bold
    AmericanTypewriter
    AmericanTypewriter-CondensedBold
    AmericanTypewriter-Condensed

Bangla Sangam MN
    BanglaSangamMN-Bold
    BanglaSangamMN

Noteworthy
    Noteworthy-Light
    Noteworthy-Bold

Zapfino
    Zapfino

Tamil Sangam MN
    TamilSangamMN
    TamilSangamMN-Bold

DB LCD Temp
    DBLCDTempBlack

Arial Hebrew
    ArialHebrew
    ArialHebrew-Bold

Chalkduster
    Chalkduster

Georgia
    Georgia-Italic
    Georgia-BoldItalic
    Georgia-Bold
    Georgia

Helvetica Neue
    HelveticaNeue-Bold
    HelveticaNeue-CondensedBlack
    HelveticaNeue-Medium
    HelveticaNeue
    HelveticaNeue-Light
    HelveticaNeue-CondensedBold
    HelveticaNeue-LightItalic
    HelveticaNeue-UltraLightItalic
    HelveticaNeue-UltraLight
    HelveticaNeue-BoldItalic
    HelveticaNeue-Italic

Gill Sans
    GillSans-LightItalic
    GillSans-BoldItalic
    GillSans-Italic
    GillSans
    GillSans-Bold
    GillSans-Light

Palatino
    Palatino-Roman
    Palatino-Bold
    Palatino-BoldItalic
    Palatino-Italic

Courier New
    CourierNewPSMT
    CourierNewPS-BoldMT
    CourierNewPS-BoldItalicMT
    CourierNewPS-ItalicMT

Oriya Sangam MN
    OriyaSangamMN-Bold
    OriyaSangamMN

Didot
    Didot-Italic
    Didot
    Didot-Bold

Bodoni 72 Smallcaps
    BodoniSvtyTwoSCITCTT-Book
like image 189
Matthias Bauch Avatar answered Oct 06 '22 00:10

Matthias Bauch


You use wrong font name, correct one will be:

[titleLabel setFont:[UIFont fontWithName:@"HelveticaNeue-UltraLight" size:25.0f]]; 

You can see the list of all available font names for a given font family using +fontNamesForFamilyName: method in UIFont, e.g.:

[UIFont fontNamesForFamilyName:@"Helvetica Neue"]

Edit: Also mind that some fonts may not be present on all versions of iOS as Apple gradually adds (and sometimes probably removes) fonts from standard OS set.

It appears that "HelveticaNeue-UltraLight" font present in OS starting 5.0 version. If you want to use it in older OS versions you'll need to embed it to you application - check for example this answer for details how to do that

like image 34
Vladimir Avatar answered Oct 05 '22 23:10

Vladimir