std1.0.0-beta-7 SafeC docs

std :: gui::gui_text

Struct std::GuiTypeface

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

struct GuiTypeface {
    const ?&unsigned char data;
    unsigned long size;
    int owned;
    int faceIndex;
    unsigned int tHead;
    unsigned int tHhea;
    unsigned int tHmtx;
    unsigned int tMaxp;
    unsigned int tCmap;
    unsigned int tLoca;
    unsigned int tGlyf;
    unsigned int tKern;
    unsigned int tGpos;
    unsigned int tOs2;
    unsigned int tName;
    unsigned int lenGlyf;
    unsigned int lenLoca;
    int numGlyphs;
    int unitsPerEm;
    int indexToLocFormat;
    int numHMetrics;
    int ascender;
    int descender;
    int lineGap;
    int capHeight;
    int xHeight;
    int weight;
    int italic;
    int hasOutlines;
    unsigned int cmapSub;
    int cmapFormat;
    unsigned int kernSub;
    int kernPairs;
    struct Vec<unsigned int> gposPairs;
    struct String family;
    struct Vec<struct GuiGlyphBitmap> cache;
    struct Vec<int> cacheIndex;
}

Fields

§const ?&unsigned char datasource

the font file

§unsigned long sizesource
§int ownedsource

data was copied/read by us: free() releases it

§int faceIndexsource

within a TrueType collection (.ttc)

§unsigned int tHeadsource

table offsets from the start of 'data' (0 = absent)

§unsigned int tHheasource

table offsets from the start of 'data' (0 = absent)

§unsigned int tHmtxsource

table offsets from the start of 'data' (0 = absent)

§unsigned int tMaxpsource

table offsets from the start of 'data' (0 = absent)

§unsigned int tCmapsource
§unsigned int tLocasource
§unsigned int tGlyfsource
§unsigned int tKernsource
§unsigned int tGpossource
§unsigned int tOs2source
§unsigned int tNamesource
§unsigned int lenGlyfsource
§unsigned int lenLocasource
§int numGlyphssource
§int unitsPerEmsource
§int indexToLocFormatsource
§int numHMetricssource
§int ascendersource

font units, positive up

§int descendersource

font units, negative (below the baseline)

§int lineGapsource
§int capHeightsource
§int xHeightsource
§int weightsource

OS/2 usWeightClass (400 regular, 700 bold)

§int italicsource
§int hasOutlinessource

0 for a CFF font loaded with GUI_FONT_ALLOW_NO_OUTLINES

§unsigned int cmapSubsource

chosen cmap subtable (offset from data)

§int cmapFormatsource
§unsigned int kernSubsource

'kern' format 0 subtable: pairs at kernSub+14

§int kernPairssource
§struct Vec<unsigned int> gposPairssource

GPOS PairPos subtables (offsets from data)

§struct String familysource

name table family name (UTF-8), may be empty

§struct Vec<struct GuiGlyphBitmap> cachesource

glyph cache (see GuiCanvas::fill_text): entries + open-addressed index

§struct Vec<int> cacheIndexsource

Methods

§int load_file(const &char path)source · definition

Parse a font in place ('struct GuiTypeface f; f.load_file(...)'). Return 1, or 0 for a missing/malformed/unsupported file (the face is then empty: free() is still fine). A .ttc collection loads its face 'index' with load_memory_index / load_file_index.

§int load_file_index(const &char path, int index)source · definition
§int load_memory([]const unsigned char bytes, int flags)source · definition

'flags': GUI_FONT_COPY to keep a copy (otherwise 'bytes' must outlive the face), GUI_FONT_ALLOW_NO_OUTLINES.

§int load_memory_index([]const unsigned char bytes, int index, int flags)source · definition
§static &GuiTypeface fallback()source · definition

The built-in fallback face (process lifetime; never free it).

§static ?&GuiTypeface system(const &char family)source · definition

A system font: "sans" / "serif" / "mono" or a family name such as "DejaVu Sans", "Helvetica", "Segoe UI", searched in the system font directories (and $SAFEC_GUI_FONT_DIR). Faces are loaded once and kept for the process; null when nothing matches.

§static ?&GuiTypeface system_bold(const &char family)source · definition

Like system(), but a bold variant when the family has one.

§int glyph_index(unsigned int cp) constsource · definition

The glyph for codepoint 'cp' (0 = .notdef: not in this font).

§int has_glyph(unsigned int cp) constsource · definition
§float advance(int glyph, float size) constsource · definition

In pixels at 'size' px.

§float kerning(int left, int right, float size) constsource · definition
§float ascent(float size) constsource · definition

above the baseline, positive

§float descent(float size) constsource · definition

below the baseline, positive

§float line_gap(float size) constsource · definition
§float line_height(float size) constsource · definition

ascent + descent + line gap

§int glyph_path(int glyph, &GuiPath out, float size, float x, float y) constsource · definition

Appends glyph's outline to 'out', scaled to 'size' px with the pen (baseline origin) at (x, y), y down. Returns 0 for an empty glyph (a space) or one that can't be read.

§int glyph_box(int glyph, &int x0, &int y0, &int x1, &int y1) constsource · definition

Glyph bounding box in font units (y up); 0 if it has none.

§float measure(const &char text, float size) constsource · definition

Width in pixels of one line of UTF-8 text at 'size' (kerning applied, glyphs this face lacks measured from the fallback face).

§float measure_n([]const char text, float size) constsource · definition
§?&GuiGlyphBitmap cache_find(int glyph, int sizeKey, int subpixel) constsource · definition

Takes ownership of 'b.coverage'. Returns the stored entry.

§void cache_clear()source · definition
§void drop()source · definition
§void free() consumesource · definition

= drop()