Custom fonts in Interface Builder

IosFontsInterface Builder

Ios Problem Overview


So we're in 2014, is there any way to set custom fonts within Interface Builder yet? Ie don't do it programmatically, except for "Fonts provided by application" in the app's plist.

Ios Solutions


Solution 1 - Ios

Yes, Marrius is right. In Xcode 6, you neither need to use extra software nor to set Font in Code files. Just add your font files in your project along with other files. And Interface builder will display the added fonts in the Custom Font List.

And the most amazing thing is, xcode 6 shows the applied font instantly in IB. This is the great addition by Apple.

Also make sure to add this key "Fonts provided by application" in your project's info.plist and provide your font file names to see the effect in devices.

Solution 2 - Ios

In Xcode 6, we have custom fonts available in interface builder.

No need for extra software. Thank you Apple!

Solution 3 - Ios

In Xcode 6, just add the ttf file in your project and use it in storyboard through custom fonts. If you directly want to use it in your code without using it in storyboard then you have to add key "UIAppFonts" in projectName-Info.plist.

Example:

<key>UIAppFonts</key> 
<array>
    <string>Signika-Bold.ttf</string>
    <string>Signika-Regular.ttf</string>
    <string>Signika-Light.ttf</string>
    <string>Signika-Semibold.ttf</string>
</array> 

just before the line </dict> in projectName-Info.plist.

UIFont* font  = [UIFont fontWithName:@"Signika-Regular" size:25];

Solution 4 - Ios

Looks like someone worked on it. You can have a look at MoarFonts :

> MoarFonts > > Use custom fonts for your iOS projects directly in Interface Builder, the WYSIWYG way > > by Cédric Luthi “0xced

It costs 10$, but :

> Since iOS 3.2, you can use custom fonts in your iOS apps by adding the > UIAppFonts Info.plist key. Unfortunately, custom fonts are not > available when editing your xib files in Interface Builder. MoarFonts > makes your custom fonts available right within Interface Builder. > > MoarFonts is compatible with both Xcode 4 and Xcode 5.

Solution 5 - Ios

This is my solution, nothing else worked for me

#import "UILabelEx.h"
#import "Constants.h"

@implementation UILabelEx

//- (void)layoutSubviews
//{
//    [super layoutSubviews];
//    // Implement font logic depending on screen size
//    self.font = [UIFont fontWithName:@"CustomFont" size:self.font.pointSize];
//}

- (void) traitCollectionDidChange: (UITraitCollection *) previousTraitCollection {
    [super traitCollectionDidChange: previousTraitCollection];
    
    self.font = [UIFont fontWithName:APP_FONT size:self.font.pointSize];
}
@end

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJonnyView Question on Stackoverflow
Solution 1 - IosAsif BilalView Answer on Stackoverflow
Solution 2 - IosMarius PopescuView Answer on Stackoverflow
Solution 3 - IosankurkumarView Answer on Stackoverflow
Solution 4 - IosrdurandView Answer on Stackoverflow
Solution 5 - IosJulesView Answer on Stackoverflow