Installing a Font

Member
Posts: 241
Joined: 2008.07
Post: #1
Hi, I've been wondering how so many games have such gorgeous and elaborate fonts in their games. I have a pretty powerful bitmap font system but bitmap fonts have limitations that really limit their utility. Pre-rendered fonts may be what other games are using, but those are only usable in non-dynamic cases.

I've been working with UITextField objects (the UIFont property) but they don't seem to have enough customization either. There's a certain font that the graphics guys have been using. They want that font to be displayed in the game but they aren't satisfied with what the bitmap font produces (neither am I really). The bitmap font just isn't the right tool for the job.

What would be perfect is if I could install any custom font.

Now, I realize that there are some obvious issues with this. Anybody who bought my app would also need to have that font on their system, so I'd need to also install that font when my game installs.

Any help would be greatly appreciated. Smile
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
You can't install a font on the iPhone, obviously.

It looks like there's no way to have UIKit load a custom font in iPhoneOS 3.1 either.

You could use FreeType, if you're making a game and want to render the text with OpenGL.
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #3
I don't know what's obvious about that but alright. I'll check out that freetype since yes, I am using OpenGL. Thanks again.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #4
You can't install anything on the iPhone that didn't come from the App Store, and the only thing that comes from the App Store is... apps.

That said, I thought I read somewhere that it would look in your app's bundle somewhere for fonts. Though I've never tried using a custom font.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Moderator
Posts: 453
Joined: 2008.04
Post: #5
There are also tools that turn fonts into bitmap fonts. I've had good luck with those sorts of tools. What do you mean when you say bitmap fonts are only good for non-dynamic cases? I've used them for text input before- although I'm not using any cocoa ui elements in my game. That seems to be what you're trying to do?

Howling Moon Software - CrayonBall for Mac and iPhone, Contract Game Dev Work
Quote this message in a reply
Member
Posts: 21
Joined: 2008.06
Post: #6
Try with Zynga's FontLabel:
http://github.com/zynga/FontLabel

we are creating OpenGL textures in cocos2d using FontLabel without problems.
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #7
AndyKorth Wrote:There are also tools that turn fonts into bitmap fonts. I've had good luck with those sorts of tools. What do you mean when you say bitmap fonts are only good for non-dynamic cases? I've used them for text input before- although I'm not using any cocoa ui elements in my game. That seems to be what you're trying to do?

I said pre-rendered fonts are non-dynamic. What I mean by that is something like "Score", which is pre-rendered just like that and drawn on a quad like a sprite as opposed to 5 quads with the letters "s-c-o-r-e". By pre-rendered, I mean typed out in PhotoShop and saved out as a bitmap.
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #8
Skorche Wrote:I thought I read somewhere that it would look in your app's bundle somewhere for fonts. Though I've never tried using a custom font.

Well, I tried copying a ttf and a ttc to my app so that it would bundle when building and then ran this code:

Code:
    NSArray* tempFonts = [UIFont familyNames];
    for(NSString* aFont in tempFonts)
        NSLog(aFont);

The font I put into the bundle didn't appear in the list of fonts. Do you know anything else about this Scorche or could you refer me to where you read about it?
Quote this message in a reply
Member
Posts: 93
Joined: 2008.11
Post: #9
Hi,

custom ttf fonts are a new feature of the 3.2 sdk.. Therefore i wouldn't expect them to work on 3.1 and prior to that.

Moderators: Sorry if i broke the nda.. I'm not aware of it Smile feel free to remove.

Alex

TapMania - iPhone StepMania // Human knowledge belongs to the world!
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #10
I'm looking at using the file exported by FontGen right now. I think that might solve my problems. Thanks again for all the help.
Quote this message in a reply
Member
Posts: 21
Joined: 2008.06
Post: #11
bmantzey Wrote:I said pre-rendered fonts are non-dynamic. What I mean by that is something like "Score", which is pre-rendered just like that and drawn on a quad like a sprite as opposed to 5 quads with the letters "s-c-o-r-e". By pre-rendered, I mean typed out in PhotoShop and saved out as a bitmap.

With FontLabel you can create something like "Score" that can be drawn using just 1 quad (not 5). FontLabel also supports custom .ttf files.

If you want to know how to render an string with FontLabel using just 1 quad, take a look at this:
http://code.google.com/p/cocos2d-iphone/...re2D.m#348
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #12
Has anyone else dealt with FontGen?
Quote this message in a reply
Member
Posts: 241
Joined: 2008.07
Post: #13
Alright, I found a solution to this problem. I wanted to share it with everyone so in case anyone else runs into the same problem.

Start off here: http://acornheroes.com/?p=44

He starts off with a windows program written by Paul Nettle, which can be found here: http://www.paulnettle.com/. It's a tool that takes any font installed on your system and writes every character as graphic information along with kerning and various other info required to display well aligned and KERNED bitmap fonts. Use this tool to generate a file that will be read in next.

George Sealy of Acorn Heroes has written an Xcode project for the iPhone that takes the output file from the above mentioned program, loads it, encapsulates it, and displays it. You'll find all the links on his blog post, posted above.

Thank you all who helped. I hope this also is helpful.
Quote this message in a reply
Post Reply