I have an ios app where i add the font file to the info.plist but it still defaults to system font.Furthermore i use a font called ChalkDuster in the IBOutlet and it also refuses to show up
Interface Builder can't recognize some the fonts.
see this.. Hope it will help you Font Pro
First add your font name in plist by wrirting `Fonts provided by application and add your font name in that
then you have to include ttf or otf file for dont after that yu can see that font name by this code
NSLog(#"Available Font Families: %#", [UIFont familyNames]);
from that choose your prefable font and use as below
[lbl setFont:[UIFont fontWithName:FontName size:22] ];
-Thanx
Related
Perhaps it is the duplicate one, but I have still issues.
I have downloaded the custom fonts from the following link,
http://cooltext.com/Download-Font-Traditional+Arabic
Install it on my mac, saved in plist properly and then used as following.
lblDesc.font = [UIFont fontWithName:#"Arabic" size:10];
After downloading I have changed it's name to Arabic, it's still not showing, can any one help me?
Thanks!
Regards!
Khalid Usman
you have to use real font family name instead of file name.
lblDesc.font = [UIFont fontWithName:#"Traditional Arabic-Regular" size:10];
Alternatively you can find out all the font install and check the name of the font of your interest
for (NSString *familyName in [UIFont familyNames]) {
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(#"%#", fontName);
}
}
The following steps should do the trick:
Import the .ttf or .otf file into your Xcode project
In your info.plist file, add the field "Fonts provided by application", which should be an array where you can add the font file name. Be sure to use the exact file name there (i.e. "Arabic-font.ttf"
In your implementation, use the full name of the font as you had before and NOT the file name.
i.e. [UIFont fontWithName:#"Traditional Arabic-Regular" size:10];
Did you add the ttf / otf to the project?
Do you have the font installed on your mac using Font Book?
If so, are you using PostScript name from the Font book?
If not, try it.
I have download a ttf file for a custom font I want to use in my app.
I've added it to my supporting files, amended my .plst file so that there's a new entry called "fonts provided by application" and then set the value to the filename of my font file (copied and pasted so no typos).
I've also checked it's included in my Build phases, Copy bundle resources.
When i now select a label and then go to change the font, my custom font is not there.
Am i missing a step?
Thanks
First you have to install those particular fonts
now those fonts are like family fonts with array so you can code like this
NSArray *arrFont = [UIFont fontNamesForFamilyName:#"Your font name"];
[lbl1 setFont:[UIFont fontWithName:[arrFont objectAtIndex:0] size:16]];
[lbl2 setFont:[UIFont fontWithName:[arrFont objectAtIndex:1] size:16]];
Try This. May be it help.
Add the font files to your resource files
Edit your Info.plist: Add a new entry with the key Fonts provided by application.
if there is more than one file , For each of your files, add the file name to this array
In your application you can the use [UIFont fontWithName:#"YourFontName" size:14.f].
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?
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.
Below is the proper way to add fonts to your XCODE app (.otf fonts work fine):
Include your fonts in your XCode project
Make sure that they’re included in the target
Double check that your fonts are included as Resources in your bundle
Include your iOS custom fonts in your application plist
Find the name of the font
Credits and better explaination with images here
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
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.
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.
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)")
}
}
In my iPhone app,
I have included two custom fonts and by referring this steps by stackoverflow questions....
How to include and use new fonts in iPhone SDK?
And Coded ....
[lbl setFont:[UIFont fontWithName:#"glyphish.ttf" size:[lbl minimumFontSize]]];
I am building this app for Base SDK 5.0
The answer is,
[lbl setFont:[UIFont fontWithName:#"glyphish" size:[lbl minimumFontSize]]];
Thanks to all.
First find that font in your available fonts list:
NSLog(#"fonts: %#", [UIFont familyNames]);
Then find and input the appropriate name.
You have passed a filename (glyphish.ttf) instead of the actual font name. Most likely, the font name is Glyphish, but you need to query it somehow: either using the Mac's "Font Book.app" or via code: first, you need to query the family names via [UIFont familyNames]. Then, use [UIFont fontNamesForFamilyName:] to get the actual font names to load. For example, if your font contains a bold variant its family name would be Glyphish but font name would likely be Glyphish-Bold.
You should correct name. It should not contain ttf in glyphish.ttf. For exact reference refer following image for that. Dakota is font name in my case.
The font name is not the name of the file. Thus glyphish.ttf is not a valid font name.
you have to use the font name, not the filename. you can check the name by opening the font file on yout mac.
Most probably the actual font name to be put in the app might be something else than glyphish.ttf .. i suggest opening font book and there checking the name of the font .and using that.
You need to check the font name it may be different then the font file name...try this link
Go to your application build phases and add your font files in copy bundle resources
Double click on the font file to open it in font book. Now see the name of the font on the top bar. Use this name in your code.
I'm trying to add a custom font to my iPhone app.
The font's name is: Susa-Regular.otf
I downloaded the font, installed it, dragged it over to xCode. Then I went into info.plist and added a row called "Fonts provided by application" and typed in Susa-Regular.otf
UILabel *myLabel = [[UILabel alloc]initWithFrame:frame];
[myLabel setFont:[UIFont fontWithName:#"Susa-Regular" size: 35]];
When I run the app, the font is still the same. I don't get any error messages either.
Any idea why it doesn't work?
More than likely the "font name" is not the same as the file name.
Open the font in Font Book and see how it represents the font name and use that instead with spaces removed.
You can also use [UIFont familyNames] and [UIFont fontNamesForFamilyName:] to discover what name iOS is using for it.
I figured it out. I dropped the dash and it worked perfectly!
[myLabel setFont:[UIFont fontWithName:#"SusaRegular" size: 35]];
I use the uifont-name-grabber posted at:
http://forgecode.net/2010/08/uifont-name-grabber/
Just drop the fonts you want into the xcode project, add the file name to its plist, and run it on the device you are building for, it will email you a complete font list using the names that UIFont fontWithName: expects.