Skip to content

font

FreeBodyEngine.graphics.text.font #

Runtime representation of a loaded .fbfont (an MSDF atlas + its per-glyph metrics/UVs) - see font/atlasgen.py for how these are generated and core/files/loaders/font.py for how this gets constructed from a loaded file. This replaces the previous version of this file, which targeted pygame+moderngl (dead code, imported nowhere) and parsed a JSON schema the engine's own generator never actually produced.

Font(texture, glyphs, distance_range, atlas_em_size, ascender, descender, line_height) #

A ready-to-render MSDF font: an atlas Texture plus, per Unicode codepoint, the Glyph describing where in it and how to draw that character.

Stores the given atlas/glyphs/metrics directly - see the attribute comments below for what each metric means.

ascender = ascender instance-attribute #

atlas_em_size = atlas_em_size instance-attribute #

descender = descender instance-attribute #

distance_range = distance_range instance-attribute #

glyphs = glyphs instance-attribute #

line_height = line_height instance-attribute #

texture = texture instance-attribute #

get_glyph(codepoint) #

Returns the Glyph for codepoint (a Unicode code point, e.g. ord(ch)), or None if this font has no glyph for it.

Glyph(advance, plane_bounds, uv_bounds) #

One character's metrics and atlas location within a Font.

Stores this glyph's advance width plus its already-computed plane/UV bounds - see the attribute comments below for exactly what each represents.

advance = advance instance-attribute #

plane_bounds = plane_bounds instance-attribute #

uv_bounds = uv_bounds instance-attribute #