FONT (File Format): Difference between revisions

>Aruki
>Aruki
Line 287: Line 287:
{{research|minor|Someone should look at the code to make sure the info in this section is accurate.}}
{{research|minor|Someone should look at the code to make sure the info in this section is accurate.}}


Textures used by FONT files are encoded in a bit of an unorthodox manner. The font format allows for multiple glyphs to be encoded in the same spot on the texture by splitting up the texture into multiple layers. The way this is handled on the textures is by encoding the textures with palettes (as C4), but modifying the palette indices at runtime and loading each layer one at a time as a separate layer. Each bit of the palette index corresponds to a layer, so up to four layers per font are supported. In DKCR, font texture are encoded as C8, so theoretically the game could use up to eight layers per font; however, it still never actually uses more than four. To dump out every layer into a single texture by encoding each layer on a separate RGBA channel, the following palette colors could be substituted into the texture:
Textures used by FONT files are encoded in a bit of an unorthodox manner. The font format allows for multiple glyphs to be encoded in the same spot on the texture by splitting up the texture into multiple layers. The way this is handled on the textures is by encoding the textures with palettes (as C4), but modifying the palette indices at runtime and loading each layer one at a time as a separate layer. Each bit of the palette index corresponds to a layer, so up to four layers per font are supported. In DKCR, font texture are encoded as C8, so theoretically the game could use up to eight layers per font; however, it still never actually uses more than four.


<pre>0 (0000) - 0x8000 (none)
The texture format is determined by a value in the header. These are the possible settings:
1 (0001) - 0x7000 (alpha)
 
2 (0010) - 0xFC00 (blue)
{| class="wikitable"
3 (0011) - 0x7F00 (blue/alpha)
! Value
4 (0100) - 0x83E0 (green)
! Description
5 (0101) - 0x70F0 (green/alpha)
! V1
6 (0110) - 0xFFE0 (green/blue)
! V2
7 (0111) - 0x7FF0 (green/blue/alpha)
! V4
8 (1000) - 0x801F (red)
! V5
9 (1001) - 0x700F (red/alpha)
|-
10 (1010) - 0xFC1F (red/blue)
| 0
11 (1011) - 0x7F0F (red/blue/alpha)
| One glyph layer, no outlines; fill on layer 0
12 (1100) - 0x83FF (red/green)
| {{check}}
13 (1101) - 0x70FF (red/green/alpha)
| {{check}}
14 (1110) - 0xFFFF (red/green/blue)
| {{check}}
15 (1111) - 0x7FFF (red/green/blue/alpha)</pre>
| {{check}}
|-
| 1
| One glyph layer, with outlines; fill on layer 0, outline on layer 1
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
| 2
| Four glyph layers, no outlines
| {{nocheck}}
| {{nocheck}}
| {{check}}
| {{check}}
|-
| 3
| Two glyph layers, with outlines; fill on layers 0/2, outlines on layers 1/3
| {{nocheck}}
| {{nocheck}}
| {{check}}
| {{check}}
|-
| 4
| Two glyph layers, no outlines; copies on layers 0/1, and layers 2/3
| {{nocheck}}
| {{nocheck}}
| {{check}}
| {{check}}
|-
| 8
| Two glyph layers, with outlines; fill on layers 2/3, outlines on layers 0/1
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
| {{check}}
|}
 
To dump out every layer into a single texture by encoding each layer on a separate RGBA channel, the following palette colors could be substituted into the texture:
 
{| class="wikitable"
! Index
! Binary
! Color
! Description
|-
| 0
| 0000
| 0x8000
| None
|-
| 1
| 0001
| 0x7000
| Alpha
|-
| 2
| 0010
| 0xFC00
| Blue
|-
| 3
| 0011
| 0x7F00
| Blue/Alpha
|-
| 4
| 0100
| 0x83E0
| Green
|-
| 5
| 0101
| 0x70F0
| Green/Alpha
|-
| 6
| 0110
| 0xFFE0
| Green/Blue
|-
| 7
| 0111
| 0x7FF0
| Green/Blue/Alpha
|-
| 8
| 1000
| 0x801F
| Red
|-
| 9
| 1001
| 0x700F
| Red/Alpha
|-
| 10
| 1010
| 0xFC1F
| Red/Blue
|-
| 11
| 1011
| 0x7F0F
| Red/Blue/Alpha
|-
| 12
| 1100
| 0x83FF
| Red/Green
|-
| 13
| 1101
| 0x70FF
| Red/Green/Alpha
|-
| 14
| 1110
| 0xFFFF
| Red/Green/Blue
|-
| 15
| 1111
| 0x7FFF
| Red/Green/Blue/Alpha
|}


[[Category:File Formats]]
[[Category:File Formats]]
Anonymous user