FONT (File Format): Difference between revisions

>Aruki
>Aruki
Line 285: Line 285:
== Textures ==
== Textures ==


Starting with version 4, textures used by FONT files are encoded in a bit of an unorthodox manner. The textures are ostensibly C4, but it appears that the game probably replaces the palette colors with different ones at runtime, which means trying to decode them as-is will turn out junk. Fortunately, the correct colors are fairly intuitive to guess at, so the textures can be decoded as such: For each 4-bit palette index, each bit determines whether a given color channel should be set to 0 or 255. Bit 3 (the MSB) refers to the red channel, bit 2 refers to the green channel, bit 1 refers to the blue channel, and bit 0 (the LSB) refers to the alpha channel. This would correspond to the following RGB5A3 color palettes:
{{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:


<pre>0 (0000) - 0x8000 (none)
<pre>0 (0000) - 0x8000 (none)
Line 303: Line 305:
14 (1110) - 0xFFFF (red/green/blue)
14 (1110) - 0xFFFF (red/green/blue)
15 (1111) - 0x7FFF (red/green/blue/alpha)</pre>
15 (1111) - 0x7FFF (red/green/blue/alpha)</pre>
Note: ''Donkey Kong Country Returns'' features some font textures that use C8 instead of C4, but the palette indices still only range from 0 to 15, so the same method still applies.


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