std1.0.0-beta-7 SafeC docs

Module gui::gui_font

#include <std/gui/gui_font.h> source

GUI: loadable/serializable bitmap fonts.

GuiWindow::draw_text() (gui.h) always uses the single built-in 8x8 font baked into the binary. This header adds a real font asset: a generic bit-packed glyph bitmap (any glyph size, not just 8x8) that can be built programmatically, saved to disk, and reloaded — and a drawing API on the font itself (font.draw_text(&win, ...)), for UIs that want a custom look instead of (or alongside) the built-in font.

On-disk format ("SCXF", version 1) — little-endian, no external dependency (not TTF/OTF — a font must already be rasterized to a GuiFont, e.g. via GuiFont::new()+font.set_bit(), before it can be saved):

offset 0  (4 bytes)  magic "SCXF"
offset 4  (1 byte)   version = 1
offset 5  (1 byte)   glyphW (pixels, 1-255)
offset 6  (1 byte)   glyphH (pixels, 1-255)
offset 7  (1 byte)   reserved = 0
offset 8  (4 bytes)  first codepoint (uint32 LE)
offset 12 (4 bytes)  glyph count (uint32 LE)
offset 16 ...        count * ceil(glyphW*glyphH/8) bytes: each glyph's
                     pixels, row-major, MSB-first-per-byte, packed
                     with no padding between rows or glyphs.

Structs

GuiFont