Changing the font for labels in my project - ios

My client wants me to change the label font to "Interstate-bold". I have installed the font. I dragged the font to the resource folder in Xcode and added it to the Info.plist but it is not supported yet. What else do I need to do?

I think you followed correct steps to apply this fonts in app.
You can check exact name of font supported, by following way:
NSArray *fonts = [UIFont fontNamesForFamilyName:#"interstate"];
NSLog this fonts array and give that exact name in the fontName parameter llike this
[UIFont fontWithName:#"Interstate-Bold" size:14.0];
I am getting this, plz check at ur end.

So as you say you have:
added asset
in plist: Fonts provided by application, then name of the font FSAlbert.otf [*.otf]
placing the used name to your label:
the name of the font is not the same as the name you put on your label is different,
self.myLabel.font = [UIFont fontWithName:#"FS Albert" size:14];
look what is the name of that font for example in photo shop [or font book], and that would be the name for your label.font

Check in font book the name of the font.
Most probably the font name in the file name doesn't matches what is required to be given in iOS app.
So check what is the font name in font book and put it the app.

Related

Embedding font in ios?

I have embedded font in ios, like the normal version italics and all by following methodes.
1.Added font to project folder.
2.Added font names "MuseoSans_100.otf" inside "Fonts provided by application" in info.plist.
3. created UIFont in viewdidload method
UIFont *newfont = [UIFont fontWithName:#"MuseoSans_100" size:13.0];
[labelname setFont:newfont];
but when i run this in simulator, i can see the font and size are not changing.
Please help.
You can use the fontNamesForFamilyName: method to retrieve the specific font names for a given font family.
Check the font family
NSLog(#"%#",[UIFont fontNamesForFamilyName:#"MuseoSans_100"]);

How to Import the Font in xcode for Iphone Application [duplicate]

This question already has answers here:
Can I embed a custom font in an iPhone application?
(32 answers)
How to include and use new fonts in iPhone SDK?
(9 answers)
Closed 8 years ago.
I am import the font in my app folder.
Then i added font in info.plist file.
Like..... Fonts provided by application--->add two font.
Then set the font to title.After create the UILabel to set the font. Like this
self.title = #"Home";
CGRect frame = CGRectMake(0, 0,100, 44);
label = [[UILabel alloc] initWithFrame:frame];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont fontWithName:#"Benguiat Gothic" size:9];
label.textAlignment = UITextAlignmentCenter;
self.navigationItem.titleView = label;
label.text =self.title;
This code written in viewdidload method.
But the font is not changed.its appear only default font for that label.
1 Add your custom font into your project , i.e. Dragged the font file(CALIBRIZ_0.TTF) into XCode project.
2 Edit 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
4.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];
First download your relevant font
Add your custom font into your project , i.e. Dragged the font file(Berlin Sans FB.TTF) into XCode project.
Add a new entry with the key "Fonts provided by application".
Now use this font in your textview
txtview.font = [UIFont fontWithName:#"Berlin Sans FB" size:15];
i used Berlin Sans FB you use your teleugu font
for more detail check this link
Using a custom font in iOS requires a few steps:
Have access to the TTF or OTF file for the desired font.
Drag the TTF or OTF font file into your Xcode project.
Located the application's Plist file and add a new row with the key "Fonts provided by the application.
Make sure that the associated value in the Plist perfectly matches the naming of the dragged in font file.
In your code, you can now assign the custom font to be used with your label, textfield or any other control that has the font property.
[myLabel setFont:[UIFont fontWithName:#"Benguiat Gothic" size:12.0f]];
Or, if you prefer dot notation syntax
myLabel.font = [UIFont fontWithName:#"Benguiat Gothic" size: 12.0f];
There's a few things to take into consideration. The actual naming of the Font File may not always be what you have to pass in as a string literal. Some custom fonts may have different weights associated with it (Light, Regular, Medium, Bold, Italic Bold etc). If the font isn't displaying as you would expect and all steps above have been explicitly followed then it could be down to the string you're using in your code.
You can get the list of font family names in debug by logging out as so:
NSLog (#"Font families: %#", [UIFont familyNames]);
That should give you a decent indication of what to actually use in your code when defining the custom font for use with the label.

Issue with adding custom fonts

Okay, so I'm trying to a custom font into an iOS 7 application
I've added the .ttf file into the "Supporting Files" Folder, I've added a new key which has the .ttf file specified, the .ttf file is in the "Copy Bundle Resources" area under "Build Phases" and in my *.m file I have this code... [UIFont fontWithName:#"Minecrafter_3" size:12]; By the way the "Minecrafter_3" bit is the name before the .ttf of my font.
Then I go into my main.storyboard, highlight the text in my label that I want to be that certain font, I go into the "Fonts" drop down menu and the font is not there, all that is there is the default fonts, with the "Custom" font. I tried using the "Custom" font but all it is, is "Helvetica Neue", which is not my font. I know that this is really long but I've been stuck on this for around 1 week now. Please help me!!!
first You can check your font added to your project or not by using the below code.
- (void)viewDidLoad{
[super viewDidLoad];
for (NSString* family in [UIFont familyNames])
{
NSLog(#"%#", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])
{
NSLog(#" Sub names: %#", name);
}
}
}
for example CourierNew is our font. I declared like this
[UIFont fontWithName:#"CourierNew" size:40.0f];
but actually this is not a font name.
Courier New // this one cannot use like font name
//below are font names
CourierNewPSMT
CourierNewPS-BoldMT
CourierNewPS-ItalicMT
CourierNewPS-BoldItalicMT
we have to give sub names like this
[UIFont fontWithName:#"CourierNewPSMT" size:40.0f];
Now it should work.
Sounds like you forgot to add the font file to the plist under "Fonts provided by application"
Check out this step by step tutorial:
http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/
The previous comments where correct about opening the font file to find the name of the font family, not the file name to use here:
[UIFont fontWithName:#"Minecrafter_3" size:12];

Non-System fonts not working on iOS6

I've never had this problem before. But I can't get any font to show up besides the system font. I wanted to use helvetica, but that wasn't working, I have tried setting my UILabel's to Farah just to see if it would work and it doesn't. However, if I run in the simulator (with iOS7) then it seems to work fine. I've tried setting fonts on the storyboard. Then tried setting it programatically,
self.titleLabel.font = [UIFont fontWithName:#"Farah" size:25];
Has anything changed with the new Xcode that won't allow non-system fonts?
Add all non-system fonts to your application and include to .plist file in 'Fonts provided by application' section.
After you can use fonts in your application : [UIFont fontWithName: #"TitilliumText25L-400wt" size:14];(replacing "TitilliumText25L-400wt" to corresponding font name).
P.S. If you have a problems with detection of real font name use FontBook application or
the code snippet bellow which show you all available fonts for your application.
for(NSString* family in [UIFont familyNames]) {
NSLog(#"%#", family);
for(NSString* name in [UIFont fontNamesForFamilyName: family]) {
NSLog(#" %#", name);
}
}
The parameter of fontWithName must be the real name of the font, not the name of the file.
If you open your ttf file with the Mac Font Book, you will directly see its name on top of the window.
For more, check this out.
Getting font names right is not easy. Run this code to learn the available names:
for (NSString* s in [UIFont familyNames])
NSLog(#"%#: %#", s, [UIFont fontNamesForFamilyName:s]);
Of course, if setting a feature of self.titleLabel does not work, you should also make sure that self.titleLabel is not nil.

custom font too small

I'm trying to set a custom font and, following the last answer to this question, I seem to have the font working in the project.
The only trick is that it's always the same size - too small. I'm trying to set it rather large but it's always small, no matter the size. Here's the line of code I'm using, as per the instructions in the above link.
self.timeLabel.font = [UIFont fontWithName:#"DistProTh" size:48];
I know the line works because I can change the font name (DistProTh) to something another font (say, Didot) and everything's fine. It therefore seems to me to be an issue with the font (which is freely available) but the font works ok in other applications (Stickies for example). Sadly, I'm no font expert..
The fontName parameter of the fontWithName: method is the full name of the font, not its file name. DistProTh is the file name; the full name of that font is District Pro Thin.
This should fix the problem:
self.timeLabel.font = [UIFont fontWithName:#"District Pro Thin" size:48];
Font name and file name are often the same, but that's not always the case. To look up the name of the font, locate your font in the Font Book application, and press Command+I to view font's information.
Turns out it needed what Font Book calls the "PostScript name" which, in the case of District Pro Thin is DistrictPro-Thin.
Incidentally, either the "PostScript name" or the "full name" (as per Font Book) worked for the font called "Code Light" but not for "District Pro Thin".

Resources