Can I embed a custom font in an iPhone application?
iOS 3.2 and later support this. Straight from the What's New in iPhone OS 3.2 doc:
Custom Font Support
Applications that want to use custom fonts can now include those fonts in their application bundle and register those fonts with the system by including the UIAppFonts key in their Info.plist file. The value of this key is an array of strings identifying the font files in the application’s bundle. When the system sees the key, it loads the specified fonts and makes them available to the application.
Once the fonts have been set in the Info.plist
, you can use your custom fonts as any other font in IB or programatically.
There is an ongoing thread on Apple Developer Forums:
https://devforums.apple.com/thread/37824 (login required)
And here's an excellent and simple 3 steps tutorial on how to achieve this (broken link removed)
- Add your custom font files into your project using Xcode as a resource
- Add a key to your
Info.plist
file calledUIAppFonts
. - Make this key an array
- For each font you have, enter the full name of your font file (including the extension) as items to the
UIAppFonts
array - Save
Info.plist
- Now in your application you can simply call
[UIFont fontWithName:@"CustomFontName" size:12]
to get the custom font to use with your UILabels and UITextViews, etc…
Also: Make sure the fonts are in your Copy Bundle Resources.
How do i add in a custom font into my iOS app?
From here you can download the font
http://www.free-fonts.com/heiti-tc-light..
After downloading add the folder(.ttf format) to supporting files in the project.
Then Edit info.Plist like this
Fonts provided by Application take as array
Item 0 as Heiti SC.ttf
now you can set
label.font = [UIFont fontWithName:@"Heiti SC" size:15];
Are custom fonts that I add to my iOS app available to other apps on the device?
No. As the other apps can't access your app's bundle resources, they can't use your custom font.
Since It's not possible to access other app bundle details, there is no document available since now.
But you can learn more about NSBundle
here and about Accessing a Bundle's Content here.
How to add custom fonts to an iPhone app?
To add a custom font to your application, you can add them to the XCode project. Then, modify the application-info.plist
file. Add the key Fonts provided by application
to a new row. Add one item for each font you have added.
It supports both TTF and OpenType fonts. One caveat is that it loads and parses all fonts in the startup of your app, so it will slow down the initial load time.
I believe this is only available in iOS 3.2 or later.
Can I embed a custom font in a bundle and access it from an ios framework?
This is a new method that lets you load fonts dynamically without putting them in your Info.plist: http://www.marco.org/2012/12/21/ios-dynamic-font-loading
Can I embed a custom font in an iPhone application?
iOS 3.2 and later support this. Straight from the What's New in iPhone OS 3.2 doc:
Custom Font Support
Applications that want to use custom fonts can now include those fonts in their application bundle and register those fonts with the system by including the UIAppFonts key in their Info.plist file. The value of this key is an array of strings identifying the font files in the application’s bundle. When the system sees the key, it loads the specified fonts and makes them available to the application.
Once the fonts have been set in the Info.plist
, you can use your custom fonts as any other font in IB or programatically.
There is an ongoing thread on Apple Developer Forums:
https://devforums.apple.com/thread/37824 (login required)
And here's an excellent and simple 3 steps tutorial on how to achieve this (broken link removed)
- Add your custom font files into your project using Xcode as a resource
- Add a key to your
Info.plist
file calledUIAppFonts
. - Make this key an array
- For each font you have, enter the full name of your font file (including the extension) as items to the
UIAppFonts
array - Save
Info.plist
- Now in your application you can simply call
[UIFont fontWithName:@"CustomFontName" size:12]
to get the custom font to use with your UILabels and UITextViews, etc…
Also: Make sure the fonts are in your Copy Bundle Resources.
How can we use custom font in an iOS app?
Try the steps below:
1. Make configuration in the info.plist as shown in Image
2. Now you should use that added file
UIFont *customFont = [UIFont fontWithName:@"fontName" size:size];
// further you may set That Font to any Label etc.
EDIT: Make Sure you have added that file in your resources Bundle.
How to use custom fonts in iPhone SDK?
Add your custom font into your project , i.e. Dragged the font file(
CALIBRIZ_0.TTF
) into XCode project.Edit Info.plist: Add a new entry with the key "Fonts provided by
application".For each of your files, add the file name to this array
Opened the font in font book(double click on your font in finder) to see what the real filename is and
I see this:
Now set font to your label
yourLabel.font = [UIFont fontWithName:@"Calibri" size:15];
Follow this to get more
Adding custom fonts to my iphone application
Thanks for the response, I found the error. Basically what happened was that the file I used for my font had a white space in the file name. So when I tried to load it in the plist file it gave the error of file not found, once I removed the space out of the filename everything worked perfecty.
How do I add a custom font to my app?
I just got it working!!! Thanks to JSD for steering me in the right direction. Apparently the issue is how XCode renames font variants that are in the same family.
Using the Font Book name doesn't work!!!
You actually have to see how Xcode names the fonts. In order to do that you have to run a log command:
NSLog(@"%@", [UIFont fontNamesForFamilyName:@"Source Sans Pro"]);
gave me this:
This code worked:
cellTitle.font = [UIFont fontWithName:@"SourceSansPro-Black" size:50];
Related Topics
What Are Unwind Segues For and How to Use Them
Detecting Which Uibutton Was Pressed in a Uitableview
Exc_Bad_Access Signal Received
Uiimage(Contentsoffile:) Returning Nil Despite File Existing in Caches Directory
Getting and Setting Cursor Position of Uitextfield and Uitextview in Swift
Returning Method Object from Inside Block
Swift: How to Split Up a [String] Resulting in a [[String]] With a Given Subarray Size
Get Location Updates For iOS App Even When Suspended
Xcode Command /Usr/Bin/Codesign Failed With Exit Code 1: Errsecinternalcomponent
How to Make a Uitextfield Move Up When the Keyboard Is Present - on Starting to Edit
How to Set Up a Simple Delegate to Communicate Between Two View Controllers
How to Force a Uiviewcontroller to Portrait Orientation in iOS 6
Why Is There Extra Padding At the Top of My Uitableview With Style Uitableviewstylegrouped in Ios7
How to Convert String Date to Nsdate
How to Use Background Thread in Swift
Ios :How to Get Facebook Album Photo'S Picker
Difference Between Observedobject and Stateobject in Swiftui