Creating a font Texture tile with pre-created art

Posts: 31
Joined: 2004.09
Post: #1
Hi all,

I have a folder containing 128 images, each being a character from the standard ANSI character set. Each of these images has been generated in Photoshop, through Photoshop Actions, and are larger (and more detailed) than an ordinary game font.

My problem: I wish to create a Texture image, say, 512x512 (anything less is too small) with each of these images on it, like a normal font texture. However, my font is not fixed width (or monospaced) and I need to get the width information for each image.

Has anyone got a utility or some ubercunning script that can do this for me, or know of some way to simplify the process?

(I've seen Codemattic's font texture maker utility, and it's handy, but only supports existing fonts, not individual character graphics, and doesn't output coordinates.)

The trick is that doing this once, just once, isn't that bad. OK, it takes a number of hours, placing each character in the image, taking the width, writing it down, fitting it all in, plugging all those coordinates into the game code, etc.

However, this never needs to be done just once. Almost any modification to the images needs a whole lot of work to be done.

Any help greatly appreciated.
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
Why not write your own little script? Loading the images isn't hard, Patching the different images together into one shouldn't be hard, writing out a text file containing the character and four integers (x, y, w, h) for each character you pack isn't hard...

I'm sure there is a desire for this kind of tool, I'm just not sure anyone's written it yet Smile
Quote this message in a reply
Posts: 1,234
Joined: 2002.10
Post: #3
You want the metrics of each glyph in your font. From a programming standpoint this is extremely easy:

from Untima 9 source:
// using system font here, use whatever font/size you want
    NSDictionary *attribDict = [NSDictionary dictionaryWithObjectsAndKeys:
        [NSColor whiteColor],        NSForegroundColorAttributeName,
        [NSFont boldSystemFontOfSize:14],    NSFontAttributeName,
    NSMutableString *string = [[NSMutableString alloc] initWithString:@" "];
    short c;
    float metrics[256];    

    for (c = 0; c <= 255; c++){
        [string setString:[NSString stringWithFormat:@"%c", c]];
        // get floating point metrics
        metrics[c] = [string sizeWithAttributes:attribDict].width;

If you feel ambitious, and you really are only using Action-generated effects (color, emboss, etc) then you could generate the stylized font on the fly as well. If you've got hand-pixeled animals for each character or something, then you really need pre-created bitmaps.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Wings3D only creating .bmp texture files WhatMeWorry 1 4,516 Jan 18, 2006 03:51 AM
Last Post: OneSadCookie