How do I include a font with my iPhone application?

后端 未结 2 2017
醉话见心
醉话见心 2020-12-28 10:49

I\'ve already seen this post:

Can I embed a custom font in an iPhone application?

which is helpful, but I\'d love to simply load the font via:



        
相关标签:
2条回答
  • 2020-12-28 11:01

    There are several steps you need to take:

    1) Make sure you have the rights to distribute the font. Most fonts -- even free ones -- do not allow you to distribute them. Putting them in your app most likely consitutes 'distribution' and would be considered illegal.

    2) Copy the font to your Resources folder in your app. Make sure it's in your Copy Files build phase.

    3) Add a "Fonts provided by application" key to the plist file, and add the complete file name of the font (including extension)

    4) Get the 'name' of the font by putting in a temporary line of code:

    NSLog(@"%@",[UIFont familyNames]);
    

    Build and run the app. This will print to the Console the family names of all the fonts on the device. Find the one that matches your font.

    You can then use that font name in the fontWithName: method.

    0 讨论(0)
  • 2020-12-28 11:20

    To add onto August's answer above, you need to add a "Fonts provided by application" key to the plist file, and add the complete file name of the font (including extension). Then the font will appear in the family printout and you can use that name to set the font.

    0 讨论(0)
提交回复
热议问题