|
|
View previous topic - View next topic |
Author |
Message |
Mattias Gustavsson Mage
Joined: 10 Nov 2007 Posts: 457 Location: Royal Leamington Spa, UK
|
Posted: Thu Jul 16, 2009 1:46 pm Post subject: Font generation tool - PixieFGT |
[quote] |
|
As I couldn't find an existing tool which met my requirements, I've written by own utility to generate a bitmap font from a true-type font, which is quite useful for when you want to use a font in a game but don't want to buy the full distribution rights to it...
It can be downloaded here (source code included):
PixieFGT_1_0.zip
And the syntax is:
PixieFGT fontname size [spacing] [-antialias] [-texture]
The optional parameter spacing gives you that many empty pixels around each character, so there's room to add things like dropshadow or glow in your image editing software.
The optional flag -texture will give you the characters arranged on a bitmap of power-of-two size, and if the flag is not specified, they will be placed on one long horizontal strip instead (which is what I most often use for fonts in Pixie, as it makes it easier to apply gradients to the font in photoshop).
If you specify -antialias, the font will be generated at 16 times the requested size, and then downsampled, for high quality antialias.
Here's an example of how a generated font bitmap might look:
And along with it you also get an XML file which specifies which character can be found in which area of the bitmap.
The XML file also contains kerning information, which you could make use of if you want. What it basically tells you is that if a character with the ascii value matching the "first"-value was rendered, followed immediately by one matching the "second"-value, the second character should be moved horizontally by the specified amount, so that, for example, "A" and "V" are placed closer together than "A" and "L"...
The source code is public domain as usual. _________________ www.mattiasgustavsson.com - My blog
www.rivtind.com - My Fantasy world and isometric RPG engine
www.pixieuniversity.com - Software 2D Game Engine
|
|
Back to top |
|
|
RedSlash Mage
Joined: 12 May 2005 Posts: 331
|
Posted: Thu Jul 16, 2009 2:42 pm Post subject: |
[quote] |
|
This is something I need! awesome. Though I'm not that hot on the XML based format.
|
|
Back to top |
|
|
Mattias Gustavsson Mage
Joined: 10 Nov 2007 Posts: 457 Location: Royal Leamington Spa, UK
|
Posted: Thu Jul 16, 2009 3:10 pm Post subject: |
[quote] |
|
I'm only using the XML as an intermediate format myself (and a custom binary one for the release).
However, I intentionally kept the bit which writes the XML very simple, so it should be very straightforward to replace it with something which suits your needs better - The whole XML writing thing is just this bit (with > and < replaced with ] and [ just to be able to post it here):
Code: |
fprintf(fp,"[PixieFont version=\"0\" name=\"%s\" size=\"%d\" glyphCount=\"%d\" glyphHeight=\"%d\" baseline=\"%d\"]\n",fontname.GetString(),fontsize,glyphCount,lineSpacing,baseline);
fprintf(fp,"[Layer filename=\"%s.tga\"/]\n",filename);
for (int i=0; i<glyphs>ascii);
fprintf(fp," width=\"%d\"",glyph->width);
fprintf(fp," x1=\"%d\"",glyph->x1);
fprintf(fp," y1=\"%d\"",glyph->y1);
fprintf(fp," x2=\"%d\"",glyph->x2);
fprintf(fp," y2=\"%d\"",glyph->y2);
fprintf(fp," xoffset=\"%d\"",glyph->xoffset);
fprintf(fp," yoffset=\"%d\"",glyph->yoffset);
fprintf(fp,"/]\n");
}
for (int i=0; i<kerning.GetItemCount(); i++)
{
fprintf(fp,"[Kerning");
fprintf(fp," first=\"%d\"",(unsigned char)kerning.Get(i).first);
fprintf(fp," second=\"%d\"",(unsigned char)kerning.Get(i).second);
fprintf(fp," amount=\"%d\"",kerning.Get(i).amount);
fprintf(fp,"/]\n");
}
fprintf(fp,"[/PixieFont]\n");
|
_________________ www.mattiasgustavsson.com - My blog
www.rivtind.com - My Fantasy world and isometric RPG engine
www.pixieuniversity.com - Software 2D Game Engine
|
|
Back to top |
|
|
RampantCoyote Demon Hunter
Joined: 16 May 2006 Posts: 546 Location: Salt Lake City, Utah
|
Posted: Thu Jul 16, 2009 5:27 pm Post subject: |
[quote] |
|
Now THAT is an awesome, useful, general-purpose tool. I'm sure there are others like it (I think I used to have one a long time ago), but I don't remember seeing one that is so flexible. _________________ Tales of the Rampant Coyote - Old-School Game Developer talks Indie Games, RPGs, and the Games Biz
|
|
Back to top |
|
|
Mattias Gustavsson Mage
Joined: 10 Nov 2007 Posts: 457 Location: Royal Leamington Spa, UK
|
Posted: Thu Jul 16, 2009 5:48 pm Post subject: |
[quote] |
|
Thanks :-)
Yeah, there's a few similar tools out there (bmfont is one), but most of them doesn't give out the source code (and definitely not public domain), and I haven't found one which puts all the characters on a single horizontal strip, which is what I needed... also, quite often tools like this have poor, if any, antialias, or doesn't support kerning, or something else I don't like about it :P _________________ www.mattiasgustavsson.com - My blog
www.rivtind.com - My Fantasy world and isometric RPG engine
www.pixieuniversity.com - Software 2D Game Engine
|
|
Back to top |
|
|
DeveloperX 202192397
Joined: 04 May 2003 Posts: 1626 Location: Decatur, IL, USA
|
|
Back to top |
|
|
RampantCoyote Demon Hunter
Joined: 16 May 2006 Posts: 546 Location: Salt Lake City, Utah
|
Posted: Thu Jul 16, 2009 8:07 pm Post subject: |
[quote] |
|
Maybe it was bmfont that I used before.
Well, whatevah.
You rock. _________________ Tales of the Rampant Coyote - Old-School Game Developer talks Indie Games, RPGs, and the Games Biz
|
|
Back to top |
|
|
Hajo Demon Hunter
Joined: 30 Sep 2003 Posts: 779 Location: Between chair and keyboard.
|
Posted: Tue Jul 21, 2009 9:36 am Post subject: |
[quote] |
|
Cool tool :) This is definitely very useful. Thank you for making this!
|
|
Back to top |
|
|
df Pretty, Pretty Fairy Princess
Joined: 13 Apr 2009 Posts: 5
|
Posted: Wed Jul 22, 2009 5:20 pm Post subject: |
[quote] |
|
If you had asked, I could have supplied ;) I have one for my roguelike, It uses SDL_TTF and dumps to a png file the first 256 characters as a 16x16 grid.
|
|
Back to top |
|
|
|
Page 1 of 1 |
All times are GMT
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|