sergiocg90
sergiocg90

Reputation: 499

Font not loading in XCode

Well, I want to import a new Font to my application but without success. I have the Fonts provided by application key in my .plist , I have my font in the Item 0 as a String and the value AdelleBasic_Bold.otf, I have added that Font to my project, and I am trying to use it with:

_myTextField.font = [UIFont fontWithName:@"Adelle Basic" size:15];

Adelle Basic is the header of the Font when I open it. I have also tried without any success:

_myTextField.font = [UIFont fontWithName:@"AdelleBasic_Bold" size:15];

Any suggestion?

Upvotes: 1

Views: 7786

Answers (6)

Hasan Wazzan
Hasan Wazzan

Reputation: 18

I've seen some comments about tff and otf and I wouldn't agree, it could be that you are not using the correct font name, this doesn't mean the file name to find the fonts you have installed in xcode run the

     for family: String in UIFont.familyNames{
                print(family)
                for names: String in UIFont.fontNames(forFamilyName: family){
                    print("== \(names)")
                }
            }

Upvotes: 0

WINSergey
WINSergey

Reputation: 2005

I just add font into project, check if font will copy inside bundle. Set up it on my Mac and directly use font inside Interface Builder. If you will have any problems solve they here.

Upvotes: 0

Apart from assuring the 5 points, you could also try out the following snippet of code that prints out the installed fonts:

for (NSString* family in [UIFont familyNames])
{   
    NSLog(@"%@", family)       
    for (NSString* name in [UIFont fontNamesForFamilyName: family])
    {
        NSLog(@"  %@", name);
    }
}

If the font that you want to use is not listed, then you missed in some of the 5 steps.

Upvotes: 0

i--
i--

Reputation: 4359

Below is the proper way to add fonts to your XCODE app (.otf fonts work fine):

  1. Include your fonts in your XCode project
  2. Make sure that they’re included in the target
  3. Double check that your fonts are included as Resources in your bundle
  4. Include your iOS custom fonts in your application plist
  5. Find the name of the font

Credits and better explaination with images here

Upvotes: 3

Charan
Charan

Reputation: 4946

you can use only the third party fonts which have extension as ttf and the fonts which have otf extension will not work effectively and mostly doesn't work

Upvotes: 1

SomaMan
SomaMan

Reputation: 4164

This may well not true for all fonts, but in my experience, Xcode can be fussy, & I've never been able to get it to use otf fonts (anyone who has please post!), so I've always converted my fonts using this really excellent website - Online Font Converter

I convert them to ttf fonts, and they always seem to work fine - make sure you use the exact name (changing the filename of the font seems to stop it working too).

Hope this helps.

Upvotes: 15

Related Questions