On iOS, you can easily get all the available Fonts via [UIFont familyNames]. The method returns an array, so it would sure be easy to create a little App that displayed all the available fonts in a UITableView and would show which fonts every "family" has in a DetailViewController.
Before I go ahead and code something like this I wanted to ask whether anyone knew if Apple or anybody else provides such a font demo app?
Yes, there is - it's called Fonts.
iFonts displays the fonts in a table view. You can also use it to email the list of fonts to yourself or someone else on your team.
Disclaimer: I developed it.
Related
Is it possible to load a font from disk and use it during run-time?
If so, how/where do you store the fonts on the iphone/ipod/ipad for your app to use?
(To be clear, I'm not talking about adding the font as a resource at design-time. I'm asking about a way to allow a user to select a font file during run-time, loading it, and making it available for use.)
You should put them (.ttf, .otf) into your info-plist under UIAppFonts then you can "use" them with setFont: withSize:
You add your font as a resource, add it to your info.plist under Fonts provided by application (UIAppFonts) array, then use it as any embedded one.
Ok, in that case take a look at FontLabel project.
One thing though, looking through it's code - you can only get CGFontRef and with kind of voodoo work with it, no conversion between CGFontRef and UIFont really exists. See this question
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 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
Just wondering what is the best way to display a barcode given a string on the iPhone. I have looked over stackoverflow and google and a few people have different ways each requiring a decent amount of work (I think) and also slightly old so I wanted to get it right first time.
One way I've read is using a custom font that you can now use in iOS4, using this font Someone else has written a class to import custom fonts, though this apparently isn't needed for iPads.
I have also found a Library but not much further details on it.
If using the font is the best way is the font linked above good or are there better ones?
Cheers for any help.
Well I went ahead and checked it out anyway. Fonts work extremely well and are very easy to implement. Basically copy this barcode font into your project. Then in your App info.plist type this in:
<key>UIAppFonts</key>
<array>
<string>3OF9_NEW.TTF</string>
</array>
For the above linked font.
Then in where you want to place the barcode just use a UILabel and then for the font use :
label.font = [UIFont fontWithName:#"3 of 9 Barcode" size:40];
Note that the font name is not 30F9_NEW.TTF. If you are using another barcode font or other font in general just open the ttf file in font book and it will say the name up the top of the window. Also you need to have a * at the beginning and end of the string you are using. If you navigated here looking at how to implement a custom font you can do it the same way, just not the font name isn't the file name.
Fonts are like a coin lost in the forrest: You're never sure where to look first. Had to say that ;-)
Ok, so the problem: I come from the web dev world and my mind is screwed up completely regarding fonts. There is a UIFont class that can be used to specify how text in a label should look like. Unfortunately it seems I have to know a lot of font secrets to use it properly. Does anyone know which kind of fonts I can specify and which are "safe to use"?
With safe to use I mean: Which ones are not dependent a lot on the language of the user, i.e. completely inavailable if the user has Chinese language active. Nor sure if that would be a different font, all those funny symbols and stuff. I want to use the font in a "tight graphical environment" where I have a design that's made to match that font. That would look like crap if in japan the font is italic style and in greece they see huge chunky and bold letters.
So which fonts would be best to use to avoid most of uglyness-problems arount internationalization and different devices?
Here are a list of available fonts for the iPhone OS.
Also, you can use the UIFont APIs systemFontOfSize:, boldSystemFontOfSize: and italicSystemFontOfSize: - any of which I would imagine will handle localization reasonably.
More UIFont documentation can be found here.