2004-06-17 21:32:04 +02:00
|
|
|
Fonts consist of
|
|
|
|
fontname.fnt
|
2010-05-31 21:04:39 +02:00
|
|
|
fontname.png
|
2004-06-17 21:32:04 +02:00
|
|
|
and you load fonts by just specifying the "path/fontname" part.
|
|
|
|
|
2010-05-31 21:04:39 +02:00
|
|
|
The .png is an 8-bit greyscale image, used for alpha-blending the text.
|
2004-06-17 21:32:04 +02:00
|
|
|
(DXTC allows 0.5 bytes/pixel at best, which isn't much better than
|
2010-05-31 21:04:39 +02:00
|
|
|
PNG's 1 byte/pixel, and DXTC's lossiness is almost noticeable,
|
|
|
|
so we stick with lossless formats.)
|
|
|
|
Or it's a 32-bit RGBA image, to allow more complex text styles.
|
2004-06-17 21:32:04 +02:00
|
|
|
|
|
|
|
The .fnt file is something like:
|
|
|
|
|
2004-11-23 19:19:27 +01:00
|
|
|
101
|
2004-06-17 21:32:04 +02:00
|
|
|
512 256
|
2010-05-30 15:42:56 +02:00
|
|
|
a
|
2004-06-17 21:32:04 +02:00
|
|
|
3
|
|
|
|
16
|
2004-11-23 19:19:27 +01:00
|
|
|
12
|
2004-06-17 21:32:04 +02:00
|
|
|
32 0 0 10 10 12
|
|
|
|
33 10 0 6 10 7
|
|
|
|
3300 16 0 6 10 7
|
2010-05-31 21:04:39 +02:00
|
|
|
|
2004-06-17 21:32:04 +02:00
|
|
|
First line = version number of file, for slightly better error
|
|
|
|
detection if people leave old ones hanging around.
|
|
|
|
|
|
|
|
Second line = size of texture (width/height).
|
|
|
|
|
2010-05-30 15:42:56 +02:00
|
|
|
Third line = texture format: "a" or "rgba".
|
2004-06-17 21:32:04 +02:00
|
|
|
|
2010-05-30 15:42:56 +02:00
|
|
|
Fourth line = number of glyphs in the font.
|
2004-06-17 21:32:04 +02:00
|
|
|
|
2010-05-30 15:42:56 +02:00
|
|
|
Fifth line = line spacing (pixels between each baseline)
|
|
|
|
|
|
|
|
Sixth line = text 'height' (height of the "I" glyph, possibly manually
|
2004-11-23 19:19:27 +01:00
|
|
|
adjusted so that vertical centering works)
|
|
|
|
|
2004-06-17 21:32:04 +02:00
|
|
|
Each subsequent line is
|
|
|
|
|
|
|
|
<code point> <x> <y> <width> <height> <x offset> <y offset> <advance>
|
|
|
|
|
|
|
|
0 <= Code point < 2^16.
|
|
|
|
x, y, width, height are in pixels on the texture.
|
|
|
|
x/y offset are the position of the texture relative to the glyph's origin.
|
|
|
|
advance is the number of pixels to move along for the next character.
|