Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Font in Xcode 6

I have a custom font that I have imported into xcode that I want to use as a UIFont. When I try to create a UIFont with the fonts name it doesn't work. I've tried looking thru all of the fonts in each font family and I don't see the font. But when I go to my storyboard I am able to use the font. Can anyone point me in the right direction?

Heres the code for printing the fonts. The font is called Nexa Light and Nexa Bold (Apple says the real name is the same without a space):

for family in UIFont.familyNames() as [String] {
    println("    ---" + family + "---")
    for font in UIFont.fontNamesForFamilyName(family) {
        println("        " + (font as String))
    }
}

Heres the output from all the fonts:

---Marion---
    Marion-Italic
    Marion-Bold
    Marion-Regular
---Copperplate---
    Copperplate-Light
    Copperplate
    Copperplate-Bold
---Heiti SC---
    STHeitiSC-Medium
    STHeitiSC-Light
---Iowan Old Style---
    IowanOldStyle-Italic
    IowanOldStyle-Roman
    IowanOldStyle-BoldItalic
    IowanOldStyle-Bold
---Courier New---
    CourierNewPS-BoldMT
    CourierNewPS-ItalicMT
    CourierNewPSMT
    CourierNewPS-BoldItalicMT
---Apple SD Gothic Neo---
    AppleSDGothicNeo-Bold
    AppleSDGothicNeo-Thin
    AppleSDGothicNeo-UltraLight
    AppleSDGothicNeo-Regular
    AppleSDGothicNeo-Light
    AppleSDGothicNeo-Medium
    AppleSDGothicNeo-SemiBold
---Heiti TC---
    STHeitiTC-Medium
    STHeitiTC-Light
---Gill Sans---
    GillSans-Italic
    GillSans-Bold
    GillSans-BoldItalic
    GillSans-LightItalic
    GillSans
    GillSans-Light
---Marker Felt---
    MarkerFelt-Thin
    MarkerFelt-Wide
---Thonburi---
    Thonburi
    Thonburi-Bold
    Thonburi-Light
---Avenir Next Condensed---
    AvenirNextCondensed-BoldItalic
    AvenirNextCondensed-Heavy
    AvenirNextCondensed-Medium
    AvenirNextCondensed-Regular
    AvenirNextCondensed-HeavyItalic
    AvenirNextCondensed-MediumItalic
    AvenirNextCondensed-Italic
    AvenirNextCondensed-UltraLightItalic
    AvenirNextCondensed-UltraLight
    AvenirNextCondensed-DemiBold
    AvenirNextCondensed-Bold
    AvenirNextCondensed-DemiBoldItalic
---Tamil Sangam MN---
    TamilSangamMN
    TamilSangamMN-Bold
---Helvetica Neue---
    HelveticaNeue-Italic
    HelveticaNeue-Bold
    HelveticaNeue-UltraLight
    HelveticaNeue-CondensedBlack
    HelveticaNeue-BoldItalic
    HelveticaNeue-CondensedBold
    HelveticaNeue-Medium
    HelveticaNeue-Light
    HelveticaNeue-Thin
    HelveticaNeue-ThinItalic
    HelveticaNeue-LightItalic
    HelveticaNeue-UltraLightItalic
    HelveticaNeue-MediumItalic
    HelveticaNeue
---Gurmukhi MN---
    GurmukhiMN-Bold
    GurmukhiMN
---Times New Roman---
    TimesNewRomanPSMT
    TimesNewRomanPS-BoldItalicMT
    TimesNewRomanPS-ItalicMT
    TimesNewRomanPS-BoldMT
---Georgia---
    Georgia-BoldItalic
    Georgia
    Georgia-Italic
    Georgia-Bold
---Apple Color Emoji---
    AppleColorEmoji
---Arial Rounded MT Bold---
    ArialRoundedMTBold
---Kailasa---
    Kailasa-Bold
    Kailasa
---Kohinoor Devanagari---
    KohinoorDevanagari-Light
    KohinoorDevanagari-Medium
    KohinoorDevanagari-Book
---Sinhala Sangam MN---
    SinhalaSangamMN-Bold
    SinhalaSangamMN
---Chalkboard SE---
    ChalkboardSE-Bold
    ChalkboardSE-Light
    ChalkboardSE-Regular
---Superclarendon---
    Superclarendon-Italic
    Superclarendon-Black
    Superclarendon-LightItalic
    Superclarendon-BlackItalic
    Superclarendon-BoldItalic
    Superclarendon-Light
    Superclarendon-Regular
    Superclarendon-Bold
---Gujarati Sangam MN---
    GujaratiSangamMN-Bold
    GujaratiSangamMN
---Damascus---
    DamascusLight
    DamascusBold
    DamascusSemiBold
    DamascusMedium
    Damascus
---Noteworthy---
    Noteworthy-Light
    Noteworthy-Bold
---Geeza Pro---
    GeezaPro
    GeezaPro-Bold
---Avenir---
    Avenir-Medium
    Avenir-HeavyOblique
    Avenir-Book
    Avenir-Light
    Avenir-Roman
    Avenir-BookOblique
    Avenir-Black
    Avenir-MediumOblique
    Avenir-BlackOblique
    Avenir-Heavy
    Avenir-LightOblique
    Avenir-Oblique
---Academy Engraved LET---
    AcademyEngravedLetPlain
---Mishafi---
    DiwanMishafi
---Futura---
    Futura-CondensedMedium
    Futura-CondensedExtraBold
    Futura-Medium
    Futura-MediumItalic
---Farah---
    Farah
---Kannada Sangam MN---
    KannadaSangamMN
    KannadaSangamMN-Bold
---Arial Hebrew---
    ArialHebrew-Bold
    ArialHebrew-Light
    ArialHebrew
---Arial---
    ArialMT
    Arial-BoldItalicMT
    Arial-BoldMT
    Arial-ItalicMT
---Party LET---
    PartyLetPlain
---Chalkduster---
    Chalkduster
---Hiragino Kaku Gothic ProN---
    HiraKakuProN-W6
    HiraKakuProN-W3
---Hoefler Text---
    HoeflerText-Italic
    HoeflerText-Regular
    HoeflerText-Black
    HoeflerText-BlackItalic
---Optima---
    Optima-Regular
    Optima-ExtraBlack
    Optima-BoldItalic
    Optima-Italic
    Optima-Bold
---Palatino---
    Palatino-Bold
    Palatino-Roman
    Palatino-BoldItalic
    Palatino-Italic
---Malayalam Sangam MN---
    MalayalamSangamMN-Bold
    MalayalamSangamMN
---Lao Sangam MN---
    LaoSangamMN
---Al Nile---
    AlNile-Bold
    AlNile
---Bradley Hand---
    BradleyHandITCTT-Bold
---Hiragino Mincho ProN---
    HiraMinProN-W6
    HiraMinProN-W3
---Trebuchet MS---
    Trebuchet-BoldItalic
    TrebuchetMS
    TrebuchetMS-Bold
    TrebuchetMS-Italic
---Helvetica---
    Helvetica-Bold
    Helvetica
    Helvetica-LightOblique
    Helvetica-Oblique
    Helvetica-BoldOblique
    Helvetica-Light
---Courier---
    Courier-BoldOblique
    Courier
    Courier-Bold
    Courier-Oblique
---Cochin---
    Cochin-Bold
    Cochin
    Cochin-Italic
    Cochin-BoldItalic
---Devanagari Sangam MN---
    DevanagariSangamMN
    DevanagariSangamMN-Bold
---Oriya Sangam MN---
    OriyaSangamMN
    OriyaSangamMN-Bold
---Snell Roundhand---
    SnellRoundhand-Bold
    SnellRoundhand
    SnellRoundhand-Black
---Zapf Dingbats---
    ZapfDingbatsITC
---Bodoni 72---
    BodoniSvtyTwoITCTT-Bold
    BodoniSvtyTwoITCTT-Book
    BodoniSvtyTwoITCTT-BookIta
---Verdana---
    Verdana-Italic
    Verdana-BoldItalic
    Verdana
    Verdana-Bold
---American Typewriter---
    AmericanTypewriter-CondensedLight
    AmericanTypewriter
    AmericanTypewriter-CondensedBold
    AmericanTypewriter-Light
    AmericanTypewriter-Bold
    AmericanTypewriter-Condensed
---Avenir Next---
    AvenirNext-UltraLight
    AvenirNext-UltraLightItalic
    AvenirNext-Bold
    AvenirNext-BoldItalic
    AvenirNext-DemiBold
    AvenirNext-DemiBoldItalic
    AvenirNext-Medium
    AvenirNext-HeavyItalic
    AvenirNext-Heavy
    AvenirNext-Italic
    AvenirNext-Regular
    AvenirNext-MediumItalic
---Baskerville---
    Baskerville-Italic
    Baskerville-SemiBold
    Baskerville-BoldItalic
    Baskerville-SemiBoldItalic
    Baskerville-Bold
    Baskerville
---Khmer Sangam MN---
    KhmerSangamMN
---Didot---
    Didot-Italic
    Didot-Bold
    Didot
---Savoye LET---
    SavoyeLetPlain
---Bodoni Ornaments---
    BodoniOrnamentsITCTT
---Symbol---
    Symbol
---Menlo---
    Menlo-Italic
    Menlo-Bold
    Menlo-Regular
    Menlo-BoldItalic
---Bodoni 72 Smallcaps---
    BodoniSvtyTwoSCITCTT-Book
---DIN Alternate---
    DINAlternate-Bold
---Papyrus---
    Papyrus
    Papyrus-Condensed
---Euphemia UCAS---
    EuphemiaUCAS-Italic
    EuphemiaUCAS
    EuphemiaUCAS-Bold
---Telugu Sangam MN---
    TeluguSangamMN
    TeluguSangamMN-Bold
---Bangla Sangam MN---
    BanglaSangamMN-Bold
    BanglaSangamMN
---Zapfino---
    Zapfino
---Bodoni 72 Oldstyle---
    BodoniSvtyTwoOSITCTT-Book
    BodoniSvtyTwoOSITCTT-Bold
    BodoniSvtyTwoOSITCTT-BookIt
---DIN Condensed---
    DINCondensed-Bold

Both fonts are added to the plist and added to the build phases.

like image 708
GnarGnar Avatar asked Sep 19 '14 21:09

GnarGnar


People also ask

How do I add custom fonts to Xcode?

To add a font file to your Xcode project, select File > Add Files to “Your Project Name” from the menu bar, or drag the file from Finder and drop it into your Xcode project. You can add True Type Font (. ttf) and Open Type Font (. otf) files.

How do I create a custom font for iOS?

You can download fonts from the App Store app , then use them in documents you create on iPhone. After you download an app containing fonts from the App Store, open the app to install the fonts. To manage installed fonts, go to Settings > General, then tap Fonts.


1 Answers

Have you added the fonts to your Info.plist. For example:

Fonts in plist file

like image 175
Austen Chongpison Avatar answered Nov 04 '22 05:11

Austen Chongpison