Bffnt: Difference between revisions
Jump to navigation
Jump to search
(Early bffnt.) |
(No difference)
|
Latest revision as of 03:46, 27 December 2023
Binary Cafe Font. nn::font in addition to supporting Open Type Fonts supports this custom bitmap font file format.
Header
There are 5 section types, Font Information (FINF), Texture Glyph (TGLP), Character Width (CWDH), Code Map (CMAP), and Kerning (KRNG).
Font Information
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x8 | Ui2d Section Header | Magic: "FINF" |
| 0x8 | 0x1 | u8 | Font Type |
| 0x9 | 0x1 | u8 | Height |
| 0xa | 0x1 | u8 | Width |
| 0xb | 0x1 | u8 | Ascent |
| 0xc | 0x2 | u16 | Line Feed |
| 0xe | 0x2 | u16 | Alternate Character Index |
| 0x10 | 0x3 | CharacterWidthData | Default Character Widths |
| 0x13 | 0x1 | u8 | Character Encoding |
| 0x14 | 0x4 | u32 | Texture Glyph Offset (TGLP) |
| 0x18 | 0x4 | u32 | Character Width Offset (CWDH) |
| 0x1c | 0x4 | u32 | Code Map Offset (CMAP) |
Font Type
| Name | Enum Value | Description |
|---|---|---|
| Glyph | 0x0 | |
| Texture | 0x1 | Not witnessed by author |
| PackedTexture | 0x2 | Not witnessed by author |
Character Encoding
| Name | Enum Value | Description |
|---|---|---|
| Utf16 | 0x0 | |
| ShiftJis | 0x1 | |
| CP1252 | 0x2 |
Character Width Data
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x1 | s8 | Left Width |
| 0x1 | 0x1 | u8 | Glyph Width |
| 0x2 | 0x1 | u8 | Character Width |
Texture Glyph
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x8 | Ui2d Section Header | Magic: "TGLP" |
| 0x8 | 0x1 | u8 | Cell Width |
| 0x9 | 0x1 | u8 | Cell Height |
| 0xa | 0x1 | u8 | Texture Count |
| 0xb | 0x1 | u8 | Max Character Width |
| 0xc | 0x4 | u32 | Per Texture Size |
| 0x10 | 0x2 | u16 | Baseline Position |
| 0x12 | 0x2 | u16 | Image Format |
| 0x14 | 0x2 | u16 | Cells Per Row |
| 0x16 | 0x2 | u16 | Cells Per Column |
| 0x18 | 0x2 | u16 | Image Width |
| 0x1a | 0x2 | u16 | Image Height |
| 0x1c | 0x4 | u32 | Image Data Offset (Bntx) |
Image Format
| Name | Enum Value | Description |
|---|---|---|
| R8G8B8A8_Unorm | 0x0 | |
| R8G8B8_Unorm | 0x1 | |
| R5G5B5A1_Unorm | 0x2 | |
| R5G6B5_Unorm | 0x3 | |
| R4G4B4A4_Unorm | 0x4 | |
| LA8_Unorm | 0x5 | |
| LA4_Unorm | 0x6 | |
| A4_Unorm | 0x7 | |
| A8_Unorm | 0x8 | |
| BC1_Unorm | 0x9 | |
| BC2_Unorm | 0xa | |
| BC3_Unorm | 0xb | |
| BC4_Unorm | 0xc | |
| BC5_Unorm | 0xd | |
| R8G8B8A8_SRGB | 0xe | |
| BC1_SRGB | 0xf | |
| BC2_SRGB | 0x10 | |
| BC3_SRGB | 0x11 | |
| BC7_Unorm | 0x12 | |
| BC7_SRGB | 0x13 |
Character Width
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x8 | Ui2d Section Header | Magic: "CWDH" |
| 0x8 | 0x2 | u16 | First Entry Index |
| 0xa | 0x2 | u16 | Last Entry Index |
| 0xc | 0x4 | u32 | Next Character Width Offset (CWDH) |
| 0x10 | 0x3 | CharacterWidthData | Character Width Array |
Code Map
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x8 | Ui2d Section Header | Magic: "CMAP" |
| 0x8 | 0x4 | u32 | Code Range Begin |
| 0xc | 0x4 | u32 | Code Range End |
| 0x10 | 0x2 | u16 | Map Method |
| 0x12 | 0x2 | u16 | Unknown/Reserved |
| 0x14 | 0x4 | u32 | Next Code Map Offset (CMAP) |
| 0x18 | 0x2
0x2 * Range 0x4 + 0x4 * Range |
Direct
Table Scan |
See below |
Code Map Method
| Name | Enum Value | Description |
|---|---|---|
| Direct | 0x0 | |
| Table | 0x1 | |
| Scan | 0x2 |
Direct
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x2 | u16 | Base Character |
Table
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x2 * Range | u16 | Character |
Scan
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x2 | u16 | Scan Half Count |
| 0x2 | 0x2 | u16 | Unknown/Reserved |
| 0x4 | 0x4 * Range | ScanEntry | Scan Entry Array (sorted) |
Scan Entry
| Offset | Size | Type | Description |
|---|---|---|---|
| 0x0 | 0x2 | u16 | Key |
| 0x2 | 0x2 | u16 | Code |
Kerning (TODO)
This section has not yet been witnessed by author.