I installed a custom font called "modern no. 20" (already installed in my mac) into my iphone project .
I copied the modernno20.ttf into my resources.
Now in my app-info.plist i added this font name in "Fonts provided by application".
Then i added
cell.textLabel.font=[UIFont fontWithName:#"modernno20.ttf" size:14.0];
in my tableviewcode .
i dont know why but this font is not properly displayed.is there any thing i missed?
In order to call the font in your fontWithName call, the string should be the name of the font as it is displayed in the Mac's 'Font Book' app, and not the actual filename of the referenced font file.
There hasn’t been an easy way to add custom fonts to your iPhone applications. As of iOS 4 it has become very easy to do. there could be possibility you would have missed some of the step to get custom font work.
Here is what you need to do in order to add custom fonts,
Check How to include ttf fonts to iOS app
Related
I wanna create my iPhone app in three languages. English & Punjabi & Gujarai.
"Gujarati" & "Punjabi" is not available in locale list of languages. so i can't able to create values folder like values-fr(french) and value-rs(russia).. like dat.. How can i develop this app with "Punjabi" & "Gujarati"?
IOS 4.3 onwards these fonts are supported : http://iosfonts.com/
If don't find the fonts then you can use custom fonts. Steps listed below
Just follow these steps:
1.Add your custom font files into your project using XCode as a resource
2.Add a key to your info.plist file called UIAppFonts.
3.Make this key an array
4.For each font you have, enter the full name of your font file (including the extension) as items to the UIAppFonts array
5.Save info.plist
6.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…
In my application i need to display arabic text with different custom fonts. I follow the scenario adding ttf files to info.plist.
As per above scenario i am successfully getting display text in different font style for ENGLISH text only. I am doing same thing for arabic font styles but here i am not getting. Why is going like that?
Please any one can help me
Thanks in Advance.
#Kareem , I took hint from Stackoverflow itself to load the fonts but could not get it working in first go. May be following steps can help you .
Add the font files to your project.
Make their entries in info.plist file
such as
you can now implement some method that loads your font somewhere in
application delegate
like
-(UIFont*) CustomFontWithSize:(float)size{
UIFont* customFont = [UIFont fontWithName:#"FX_Masa" size:size];
if(customFont == nil)
customFont = [UIFont systemFontOfSize:size];
return customFont;
}
If you notice then the name I have passes here is "FX_MASA" and not FX_MasaRegular , this was the point where I was wrong. The name that we need to use while fetching the font is the INSTALL NAME (Double click on the font to install the font on system and the name that appears in Font Book is the install name).
Hope this helps your problem as well. In case you come across any good method, please update here.
There is a nice UILabel extension in GitHub called "Font Label": https://github.com/zynga/FontLabel
This allows to load any TTF file and then draw ZLabel objects (ZLabel is an extension of UILabel) with this custom font. It is based on CoreGraphics and I tested with many custom fonts and proved to work correctly. I don't know of course the effect with arabic fonts, but it's worth a try and a feedback from you (to us and also the github project admins) is welcome.
I've downloaded a font that's called "aldo the apache (.tff) " from dafont.com.
I used it with different programms like adobe illustrator and it seemed to work just fine.
Recently i tried to use it in a game that i'm making to experement. It didn't work -_-.
IB was displaying the font as a slightly bigger version of arial.
How can i solve this problem and get the font to display correctly?
If you have any suggestions, please post them down below.
-DD
You have to edit your <appname>-Info.plist file and create a new UIAppFonts key with type array, where each element is a String with the name of your font file, in this case AldotheApache.ttf. Then use the name in IB or with UIFont as it shows in the application Font Book app of your Mac, in your case Aldo the Apache. Obviously the font should also be added as a resource of your project.
I added a font file (.ttf) to my Xcode project, to resources. Also, I added it to the UIAppFonts in my info.plist.
When I want to use this font though, I don't even see it as a choice in IB.
After installing the font on my system, I started seeing it in IB, but still - changing to it doesn't change anything - some default system font is displayed in the Interface Builder as well as in iPhone emulator.
Are there any steps more I should do to be able to use my own font?
To use custom fonts with iOS you have to set them programmatically.
For example, suppose you have a font file called swellfont.ttf that you add to your project.
You then would go into your App-Info.plist file and add the full name of the file to the next index of the array keyed by UIAppFonts, as you mention.
<key>UIAppFonts</key>
<array>
<string>swellfont.ttf</string>
</array>
Then, to use the font:
label.font = [UIFont fontWithName:#"swellfont" size:12];
Assuming that label is a UILabel and that swellfont.ttf is not protected. It's important to note that UIFont's fontWithName is not referring to the filename, instead its wanting the actual name of the font. If you open the font with FontForge you can see this information by selecting Element > Font Info from the menu bar. There are probably cleverer ways to find this information out.
I use 2 fonts in an APP. The first one was automatically added to the "Copy Bundle Resources", the other was not. I had to add that one myself.
Call in code:
[labelName setFont:[UIFont fontWithName:#"OneGreatBigFont" size:40]];
How do I use custom TTF fonts in my Cocos2d iPhone apps?
I searched for this for a while and decided to post as question and answer for people wanting to implement.
The solution is quite easy.
Find the fonts you want and download them. This website has a huge collection of free fonts.
Add the font files to your project.
Add the font names to your info.plist file using the array below as an example.
Find the font's name; Double click the font file and use the font name shown in the title of the window. In this example it is "Action Man"
To use the font name the way you would normally:
CCLabel* myLabel = [CCLabel labelWithString:#"Some Text" fontName:#"Action Man" fontSize:18];
Add this to your info.plist file:
<key>UIAppFonts</key>
<array>
<string>Action Man Bold.ttf</string>
<string>AdineKirnberg-S.ttf</string>
</array>
In Cocos2D, you can include the font file with your resources and then in fontName: simply supply the filename. For example:
CCLabelTTF *label = [CCLabelTTF labelWithString:#"whatever" fontName:#"FONTNAME.ttf" fontSize:18];
This is often easier than the method Hanaan has posted.
You should use the exact same file name capitalisation as the filename.
You do not need to add fonts to your info.plist if you are only using it in Cocos2D bits.
If, like Confused, you find that the font works on the simulator but not the device, it is probably a file name capitalisation mistake. The iPhone is case-sensitive, the simulator is not.
As these answers are outdated, I'm sure my question/ answer will help all those out there.
Importing fonts for cocos2dx iOS
this is for iOS and Android platform font importing, with just a single line of code!