Difference between revisions of "Font file"
(→Header) |
|||
Line 10: | Line 10: | ||
=== Header === | === Header === | ||
− | (1 byte) Fixed = 3 | + | * (1 byte) Fixed = 3 |
− | (11 bytes) Fixed: all zeroes | + | * (11 bytes) Fixed: all zeroes |
− | (1 word) Not fully understood: 1 or 2 for variable width, but has to be 1 for fixed width | + | * (1 word) Not fully understood: 1 or 2 for variable width, but has to be 1 for fixed width |
− | (1 word) Font height | + | * (1 word) Font height |
− | (1 word) Font width (if width is variable, this is zero) | + | * (1 word) Font width (if width is variable, this is zero) |
− | (1 word) Unknown: Always 8 in the three original fonts and doesn't seem to do anything if changed | + | * (1 word) Unknown: Always 8 in the three original fonts and doesn't seem to do anything if changed |
− | (1 word) Variable width flag: 1 for variable width, 0 for fixed width | + | * (1 word) Variable width flag: 1 for variable width, 0 for fixed width |
''Total: 22 bytes'' | ''Total: 22 bytes'' | ||
[[Category:Modding]] | [[Category:Modding]] | ||
[[Category:Internals]] | [[Category:Internals]] |
Revision as of 22:40, 18 March 2021
Stunts (BB 1.1) includes three font files, which have a ".FNT" extension and a very unique format. The files in question are FONTDEF.FNT, FONTN.FNT and FONTLED.FNT. FONTDEF (probably standing for "Default Font") is the thick font used for the text in menus, dialog boxes and buttons. FONTN is used for longer text, for example, car descriptions in the showroom, scoreboard rows and the high score information when viewing the complete track in 3D in the Track menu. FONTLED only contains digits and a couple of punctuation characters and is used for the lap times in the replay menu panel.
While this font format appears to be unique to Stunts, it is pretty flexible and worth considering for other projects. The three fonts included with Stunts are bitmaps of character height 8, but vary in width. As a matter of fact, FONTDEF and FONTN are variable width, that is, each character can have an individual width. Yet, Stunts allows for fonts of other characteristics to be loaded. If the files are modified, Stunts adapts to the changes very well.
Font format features
Stunts font format is strictly bitmap based, but very configurable. It allows for up to 256 characters that can be mapped to 256 code points from 0 to 255. Unused code points don't need to have their glyphs defined, which saves space. Fonts can have either fixed or variable width. For variable width, widths up to 255 are theoretically possible, although Stunts surely must have a much smaller limit. With fixed width, this could go up to 32767 or perhaps 65535 depending on how the values are interpreted. Character height can also, in theory, go up to these values. As of 18 March 2021, it is not known whether height can be made variable too.
Format structure
After an analysis made by Cas on 17 March 2021, the font format was found to have the following structure:
Header
- (1 byte) Fixed = 3
- (11 bytes) Fixed: all zeroes
- (1 word) Not fully understood: 1 or 2 for variable width, but has to be 1 for fixed width
- (1 word) Font height
- (1 word) Font width (if width is variable, this is zero)
- (1 word) Unknown: Always 8 in the three original fonts and doesn't seem to do anything if changed
- (1 word) Variable width flag: 1 for variable width, 0 for fixed width
Total: 22 bytes