font in iphone sdk? - iphone

is it possible to bring another language font in iphone sdk and to insert that font value (for example,chinese) in UILabel value? any help please?

You can include the font as a resource in the project, then load the font using CoreText but it's not trivial.
The main step is to create a CTFontDescriptor that will load the font. There is sample code in the iPhone SDK documentation that I can't quote, the name of the section I found useful is...
CoreText Listing 2-9 "Creating a font from serialized data"

Related

iPhone muliti laanguage support application

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…

Custom font in iphone not being displayed properly

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

Custom font doesn't work in interface builder!

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.

String with different font

I am having a string message i need first word of that as bold font and rest normal.
Making different label can be create problems,(need to find the size of first the make other and then make other,text is in 4 line).
How can i use NSAttributedString here. I could found How do you use NSAttributedString?
but using this shows undeclared NSForegrou... (present in app kit framework).But could not found app kit framework on sdk 4.2
Need help for making such kind of string(bold + normal text).
Go through the below blog tutorial with code, they have different font with NSAttributedString.
http://www.cocoanetics.com/2011/01/rich-text-editing-on-ios/
https://github.com/Cocoanetics/NSAttributedString-Additions-for-HTML
https://github.com/omnigroup/OmniGroup/tree/master/Frameworks/OmniUI/iPad/Examples/TextEditor
May I point you to the CoreText Framework and Befriending Core Text on cocoanetics.com. This will show you how to format text.

Using custom fonts in Cocos2d

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!