API
API
C++
API reference (Font Generation) — Alpha (1.14.1)

Defold Learn logo


Font generation

Asynchronously generates glyphs and hands them to a caller-owned cache. The callbacks are invoked on the main thread. The caller context must remain valid until the completion callback has run or the job has been cancelled.

Namespace: FontGeneration
Include: #include <engine/font/src/fontgen.h>
TYPES
FFontGenAddGlyph Inserts a generated glyph into the caller-owned cache.
FFontGenComplete Reports completion of a glyph generation batch.
FFontGenIsGlyphCached Looks up a glyph in the caller-owned cache.
STRUCTS
struct FontGenParams Runtime glyph generation parameters.
FUNCTIONS
FontGenJobData* FontGenCreateJobData (FontGenParams* params, uint32_t num_glyphs) Allocates scratch data for one generation batch.
bool FontGenIsSupported () Tests whether runtime glyph generation is linked into the engine.

Functions

FontGenCreateJobData

FontGenJobData* FontGenCreateJobData(FontGenParams* params, uint32_t num_glyphs)

Allocates scratch data for one generation batch.

PARAMETERS

FontGenParams* params Generation settings and callbacks. The values are copied.
uint32_t num_glyphs Maximum number of glyphs in the batch.

RETURNS

FontGenJobData* Job data, or null when unsupported.

FontGenIsSupported

bool FontGenIsSupported()

Tests whether runtime glyph generation is linked into the engine.

PARAMETERS

RETURNS

bool True when the full font_gen library is linked.

Structs

FontGenParams

TYPE

struct FontGenParams

Runtime glyph generation parameters.

MEMBERS

void* m_UserContext Opaque context passed to all callbacks.
FFontGenIsGlyphCached m_IsGlyphCached Cache lookup callback.
FFontGenAddGlyph m_AddGlyph Glyph insertion callback.
FFontGenComplete m_Complete Batch completion callback.
HJobContext m_Jobs Job system used for asynchronous generation.
float m_Size Glyph generation size in pixels.
float m_OutlineWidth Outline width in pixels.
float m_ShadowBlur Shadow blur spread in pixels.
uint8_t m_IsSdf Non-zero when SDF output is requested.
uint8_t m_IsVector Non-zero when Vector glyph output is requested.
uint8_t m_BitmapEffects Generate RGB vector effect bitmaps on the CPU.
uint8_t m_HasOutline Include the authored outline in the effect bitmaps.
uint8_t m_HasShadow Generate the authored shadow bitmap.


Types

FFontGenAddGlyph

void FFontGenAddGlyph()

Returning FONT_RESULT_OK transfers ownership of the glyph to the callback. For every other result, font_gen retains ownership and frees the glyph.

PARAMETERS



FFontGenComplete

void FFontGenComplete()

Reports completion of a glyph generation batch.

PARAMETERS



FFontGenIsGlyphCached

void FFontGenIsGlyphCached()

Looks up a glyph in the caller-owned cache.

PARAMETERS