FontFormat struct
#include <Jazz2/UI/FontFormat.h>
On-disk layout of a packed font.
A font is a single self-contained file: the glyph metrics and the glyph atlas together, the atlas in the same QOI-based encoding every other image asset uses, all of it deflated. It holds one palette index per pixel rather than the expanded colours the old two-file (.png + .png.font) form carried, which cost four bytes per pixel on disk and again in memory.
A font is entirely index based: every pixel either names a palette color or is index 0 and draws nothing. There is no per-pixel coverage - the shading of a glyph comes from the colors it names, not from blending it into what is behind it - so the packer resolves anything in between and says so.
Glyphs are packed tightly: every one is measured to its actual inked area rather than sitting in a fixed cell, and each keeps a bearing so it still lands where it belongs on the line. A one pixel margin is left around each - so neighbours are two pixels apart - which is what stops bilinear sampling from bleeding one glyph into the next, the same margin the sprite sheets leave around each frame.
The layout is:
- Signature,
ContentFileType::Font, CurrentVersion and a flags byte - the size of the deflated block that follows, everything below being inside it
- the atlas size, the line height, the base spacing and the character counts
- a Glyph for each ASCII character, then a codepoint and a Glyph for each Unicode one
- the atlas itself, one palette index per pixel
Public types
- struct Glyph
- Metrics of a single glyph.
Public static variables
-
static std::
uint64_t Signature constexpr - Signature shared by the game's own file formats.
-
static std::
uint8_t CurrentVersion constexpr - Version of the layout described here.
-
static std::
int32_t GlyphMargin constexpr - Margin left around every glyph, in pixels (so neighbours are two pixels apart).
-
static std::
uint32_t FallbackCodepoint constexpr - Codepoint of the glyph drawn in place of a character the font doesn't have.
-
static std::
int32_t MaxGlyphSize constexpr - Largest glyph box the record above can describe.
-
static std::
int32_t MaxGlyphBearing constexpr - Largest bearing (in absolute value) the record above can describe.