File: fileformat.txt

package info (click to toggle)
0ad 0.0.17-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 51,248 kB
  • ctags: 46,933
  • sloc: cpp: 223,208; ansic: 31,240; python: 16,343; perl: 4,083; sh: 1,011; makefile: 915; xml: 733; java: 621; ruby: 229; erlang: 53; sql: 40
file content (45 lines) | stat: -rw-r--r-- 1,308 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Fonts consist of
  fontname.fnt
  fontname.png
and you load fonts by just specifying the "path/fontname" part.

The .png is an 8-bit greyscale image, used for alpha-blending the text.
(DXTC allows 0.5 bytes/pixel at best, which isn't much better than
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.

The .fnt file is something like:

  101
  512 256
  a
  3
  16
  12
  32 0 0 10 10 12
  33 10 0 6 10 7
  3300 16 0 6 10 7

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).

Third line = texture format: "a" or "rgba".

Fourth line = number of glyphs in the font.

Fifth line = line spacing (pixels between each baseline)

Sixth line = text 'height' (height of the "I" glyph, possibly manually
                            adjusted so that vertical centering works)

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.