std1.0.0-beta-7 SafeC docs

std :: gui::gui_font

Struct std::GuiFont

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

struct GuiFont {
    int glyphW;
    int glyphH;
    int first;
    int count;
    &heap unsigned char bitmap;
}

Fields

§int glyphWsource
§int glyphHsource
§int firstsource

first codepoint this font covers

§int countsource

number of glyphs (codepoints first..first+count-1)

§&heap unsigned char bitmapsource

count * bytesPerGlyph(glyphW,glyphH) bytes

Methods

§static struct GuiFont new(int glyphW, int glyphH, int first, int count)source · definition

Allocates a blank (all-zero) font of the given shape, ready for set_bit() calls to draw each glyph programmatically.

§static struct GuiFont default()source · definition

A heap-owned copy of the built-in 8x8 font (see gui_draw.sc), in the same generic GuiFont representation — e.g. as a starting point to edit with set_bit() and save a modified variant. Release it with free().

§int get_bit(int cp, int px, int py) constsource · definition

Bit accessors, (0,0) = top-left of the glyph for codepoint 'cp'. Reads return 0 for an out-of-range codepoint or pixel; writes are a no-op in that case.

§void set_bit(int cp, int px, int py, int value)source · definition
§int save(const &char path) constsource · definition

Serialization. save() writes this font as an SCXF file; load() reads one into this font in place (overwriting it without freeing — call it on a fresh 'struct GuiFont f;', or free() first). On failure load() leaves the font untouched. Both return 1 = ok.

§int load(const &char path)source · definition
§void drop()source · definition
§void free() consumesource · definition

= drop()

§int draw_text( &GuiWindow win, int x, int y, const &char text, struct GuiColor color, int scale, ) constsource · definition

Drawing with this font (mirrors GuiWindow::draw_text() and gui_draw.h's gui_text_width()/gui_text_height() for the built-in font): each glyph cell is glyphWscale by glyphHscale pixels; codepoints the font doesn't cover draw as a blank cell. draw_text() returns the total pixel width drawn.

§int text_width(const &char text, int scale) constsource · definition
§int text_height(int scale) constsource · definition