Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include and use new fonts in iPhone SDK?

I want to use font "MgOpen Modata" in my iphone App. But I dont see it in the font list in Property inspector.

How do I include that font so that I can use it?

like image 535
meetpd Avatar asked Feb 11 '11 13:02

meetpd


People also ask

How do you import fonts to iPhone?

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.

How do you add TTF file in iOS?

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 use custom fonts in Xcode 13?

Add the font file to your Xcode projectSelect File menu > Add Files to "Your Project Name"... from the menu bar, select all the fonts you need to add, then click the Add button. Or drag the file from Finder and drop it into your Xcode project. Drag the font files from Finder and drop it into your Xcode project.


1 Answers

  1. Add the font files to your resource files
  2. Edit your Info.plist: Add a new entry with the key Fonts provided by application.
  3. For each of your files, add the file name to this array

On the example below, I've added the font "DejaVu Sans Mono":

Info.plist: adding custom fonts

In your application you can the use [UIFont fontWithName:@"DejaVuSansMono-Bold" size:14.f].

Or if you want to use it in html/css, just use font-family:DejaVu Sans Mono;

Note: this is available in iOS 3.2 and later.

like image 156
Jilouc Avatar answered Oct 06 '22 18:10

Jilouc