A Font Tool
Posted: Fri Dec 02, 2011 11:16 am
I know there are some nice font tools already created for irrlicht, none of them quite did what i needed of them. So as you do, off to the internet to look for alternatives. Came across this....
http://www.angelcode.com/products/bmfont/
fits the bill, exactly except the output *.fnt format does not work with irrlicht so, created this utility to convert the bmFont ".fnt" font file (xml setting in export options) output to an Irrlicht ".xml" font file.
http://www.mediafire.com/download.php?pad4dr799dqeduz
it takes a single argument <filename>.fnt and creates a file <filename>.xml that should work with irrlicht. It will handle multiple bitmaps too.
All well and good upto now, but hang on bmfont being very clever does a best fit on the font glyphs, to reduce the space used in the bitmaps. But Irrlicht doesn't support variable height font glyphs, Doh ! Well unless you hack the source....
CGUIFont.h
modify SFontArea struct to this
CGUIFont.cpp
add
to CGUIFont::load after
to CGUIFont::draw add the following
directly after
add
before
and finally add
just before
This code shouldn't have any effect on "traditional" irrlicht fixed height fonts as voffset is initialized to 0 and if the "v" attribute is not present it's ignored as per the "i" texture index attribute. If this code could be added to svn by someone who knows what they are doing that would be all well and dandy 
anyway use it, don't use it, have a cup tea, whatever
a quick addendum:
though both bmfont & irrlicht font tool use px to define font size the following formula will match sizes
irrlicht = bmfont * 72 / 96
the 72/96 is generalized, if you have wacky screen settings it probably won't work.
http://www.angelcode.com/products/bmfont/
fits the bill, exactly except the output *.fnt format does not work with irrlicht so, created this utility to convert the bmFont ".fnt" font file (xml setting in export options) output to an Irrlicht ".xml" font file.
http://www.mediafire.com/download.php?pad4dr799dqeduz
it takes a single argument <filename>.fnt and creates a file <filename>.xml that should work with irrlicht. It will handle multiple bitmaps too.
All well and good upto now, but hang on bmfont being very clever does a best fit on the font glyphs, to reduce the space used in the bitmaps. But Irrlicht doesn't support variable height font glyphs, Doh ! Well unless you hack the source....
CGUIFont.h
modify SFontArea struct to this
Code: Select all
struct SFontArea
{
SFontArea() : underhang(0), overhang(0), width(0), spriteno(0), voffset(0) {}
s32 underhang;
s32 overhang;
s32 width;
s32 voffset;
u32 spriteno;
};
add
Code: Select all
a.voffset = xml->getAttributeValueAsInt(L"v");
Code: Select all
a.overhang = xml->getAttributeValueAsInt(L"o");
Code: Select all
s32 saveYoffset = offset.Y;
Code: Select all
core::array<core::position2di> offsets(text.size());
Code: Select all
offset.Y = saveYoffset;
Code: Select all
wchar_t c = text[i];
Code: Select all
offset.Y += area.voffset;
Code: Select all
offset.X += area.underhang;

anyway use it, don't use it, have a cup tea, whatever

a quick addendum:
though both bmfont & irrlicht font tool use px to define font size the following formula will match sizes
irrlicht = bmfont * 72 / 96
the 72/96 is generalized, if you have wacky screen settings it probably won't work.