RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
fallback.h File Reference

fallback.h — allocation-free, cluster-preserving font selection. More...

#include "font.h"
#include <stddef.h>
#include <stdint.h>

Data Structures

struct  rmgui_fallback_request_t
 rmgui_fallback_request_t.sticky More...
struct  rmgui_fallback_run_t
 rmgui_fallback_run_t.start More...

Typedefs

typedef const rmgui_font_t *(*) rmgui_fallback_resolver_fn(void *user, const uint32_t *codepoints, size_t count, int font_px)
 Return a borrowed, host-initialized font covering the complete cluster, or NULL.

Functions

int rmgui_fallback_resolve (const rmgui_fallback_request_t *request, const uint32_t *codepoints, size_t codepoint_count, const size_t *cluster_starts, size_t cluster_count, int font_px, const rmgui_font_t **out_fonts, size_t font_capacity, rmgui_fallback_run_t *runs, size_t run_capacity, size_t *out_run_count)
 cluster_starts has cluster_count + 1 entries: 0, strictly increasing boundaries, codepoint_count.

Detailed Description

fallback.h — allocation-free, cluster-preserving font selection.

Typedef Documentation

◆ rmgui_fallback_resolver_fn

typedef const rmgui_font_t *(*) rmgui_fallback_resolver_fn(void *user, const uint32_t *codepoints, size_t count, int font_px)

Return a borrowed, host-initialized font covering the complete cluster, or NULL.

Called only when the ordered fonts (and sticky font) do not cover it. No bytes are loaded or owned by this module. The callback and image coverage callbacks MUST be pure/deterministic for the whole resolve call: successful resolution visits clusters twice to keep refusal atomic without allocating scratch storage.

Function Documentation

◆ rmgui_fallback_resolve()

int rmgui_fallback_resolve ( const rmgui_fallback_request_t * request,
const uint32_t * codepoints,
size_t codepoint_count,
const size_t * cluster_starts,
size_t cluster_count,
int font_px,
const rmgui_font_t ** out_fonts,
size_t font_capacity,
rmgui_fallback_run_t * runs,
size_t run_capacity,
size_t * out_run_count )

cluster_starts has cluster_count + 1 entries: 0, strictly increasing boundaries, codepoint_count.

Each nonempty cluster chooses one font that rmgui_font_covers reports covers ALL its codepoints at font_px, including selectors/joiners if present. Missing clusters are refused, not silently substituted with tofu or split. Adjacent clusters selecting the same font merge into one run; each codepoint also receives its selected font.

Returns 0 on success. Returns -1 with ALL public outputs unchanged for invalid arguments, insufficient output capacity, invalid Unicode scalars, or no complete covering font (including an unsuitable resolver result). font_px must be positive; request and out_run_count must be non-NULL. fonts entries must be non-NULL. Empty input requires cluster_count == 0; its codepoints, cluster_starts, out_fonts and runs may be NULL, and success writes zero to out_run_count. Nonempty input requires all those arrays. Input/output arrays, request, and out_run_count must not overlap; borrowed fonts and their coverage must remain unchanged until return. No allocation, font mutation, persistent state, or fixed capacity limit is introduced.