Custom Fonts are not showing properly? - iphone

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.

Related

Custom font - Can't select 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].

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?
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)")
}
}

Custom Fonts Xcode 4.3

I'm trying to use this font in my project but it won't work.
I added the .ttf file in my project and added its name in the MyApp-Info.plist under the key: Fonts provided by application. Then I tried this:
[_titleLabel setFont:[UIFont fontWithName:#"chalkboard" size:_titleLabel.font.pointSize]];
I also checked if the name of the font is really "chalkboard" and it is. The displayed font is still Helvetica, only smaller. Where could the problem be?
Thanks in advance.
You need to use font name, not filename. Font name is inside the ttf file.
You can find font names for iOS here: http://iosfonts.com/
This code will list all your font names in your app, put it somewhere in viewDidLoad on main controller, run app and then in console found the right name for the font.
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(#"Family name: %#", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:
[UIFont fontNamesForFamilyName:
[familyNames objectAtIndex:indFamily]]];
for (indFont=0; indFont<[fontNames count]; ++indFont)
{
NSLog(#" Font name: %#", [fontNames objectAtIndex:indFont]);
}
}
Upd.
You can also right click on font file in Finder, get Info and copy full name. But it is not always 100%.
Flinks answer is a handy tool to check if your fonts are loaded properly.
Do the following:
[_titleLabel setFont:[UIFont fontWithName:#"chalkboard" size:_titleLabel.font.pointSize]];
Make sure your fonts are included in your bundle:
Click your project
Go to build phases
Under 'Copy Bundle Resources',
make sure your fonts are included
Worked for me :)
Xcode 4.3.1 Custom Font have problem. Because when i create new project and try to add custom fonts in Xcode 4.2.1 there is no problem.
I did several times.
Interesting...
Its my experience that not "all" fonts are compatible. Most work, but you will run into a few fonts that just for some reason will not be recognized through code no matter how hard you try... Just a heads up for anyone having issues, just try another font!
Include your fonts in your XCode project
Make sure that they’re included in the Target Membership in File Inspector tab
Include you font in Project Name > Build Phase > Copy Bundle Resources
Include your iOS custom fonts in your application plist. Add a new row called “Fonts provided by application” and put your font name and extension as parameter.
Find the name of the font.
Use UIFont and specify the name of the font.
UILabel *headingLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 290, 300, 30)];
headingLabel.text = #"WELCOME";
headingLabel.font = [UIFont fontWithName:#"Arvo" size:14.0];
Source: http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/
Not All Font's you imported are working. Just try to test into another font. If it works then it is not recognized by Xcode. Just remember that it must be in your project plist file and it has to be a extension name like ".otf" or ".ttf" in plist. And also add it in "Copy Bundle Resources" under target

Missing fonts on device

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

Adding font in iPhone application

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.