mk_font_atlasfunction
mk_texture_t mk_font_atlas(mk_font_t font)Get a font's first atlas page.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
Returns The resulting handle or value.
#include <modkit/font.h>55 functions · 21 structs · 13 enums · 37 typedefs · 12 macros
Retained atlas-backed text rendering with FreeType and MTSDF.
Provides simple text rendering independent of NanoVG. Supports hinted grayscale coverage and multi-channel signed distance fields for scalable, stylized text. Usage: mk_font_t font = mk_font_load("fonts/Roboto.ttf", 24.0f, MK_FONT_BITMAP); mk_text_begin(encoder, view, width, height); mk_text_draw(font, 10, 30, "Hello World", 0, 0xFFFFFFFF, MK_TEXT_ALIGN_LEFT); mk_text_end(); mk_font_destroy(font);
mk_font_atlasfunctionmk_texture_t mk_font_atlas(mk_font_t font)Get a font's first atlas page.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
Returns The resulting handle or value.
mk_font_atlas_pagefunctionbool mk_font_atlas_page(mk_font_t font, uint16_t page_index, mk_font_atlas_page_t *page)Query one generation-checked atlas page.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
page_index | uint16_t | Value for page index. |
page | mk_font_atlas_page_t * | Value for page. |
Returns True when the operation succeeds.
mk_font_atlas_page_countfunctionuint16_t mk_font_atlas_page_count(mk_font_t font)Number of live atlas pages owned by a font.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
Returns The resulting value.
mk_font_cache_get_statsfunctionvoid mk_font_cache_get_stats(mk_font_cache_stats_t *stats)Query aggregate atlas/raster/upload counters.
| Parameter | Type | Description |
|---|---|---|
stats | mk_font_cache_stats_t * | Value for stats. |
mk_font_cache_set_gpu_budgetfunctionvoid mk_font_cache_set_gpu_budget(uint64_t bytes)Override the shared font-atlas GPU budget in bytes.
| Parameter | Type | Description |
|---|---|---|
bytes | uint64_t | Value for bytes. |
mk_font_destroyfunctionvoid mk_font_destroy(mk_font_t font)Destroy font and release resources.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
mk_font_get_metricsfunctionvoid mk_font_get_metrics(mk_font_t font, float size_px, mk_font_metrics_t *metrics)Get font metrics at specified size.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Font handle |
size_px | float | Pixel size (0 = use default size from mk_font_load) |
metrics | mk_font_metrics_t * | Output metrics (can be NULL) |
mk_font_get_typefunctionmk_font_type_t mk_font_get_type(mk_font_t font)Get font type (bitmap or SDF).
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
Returns The resulting handle or value.
mk_font_initfunctionbool mk_font_init(void)Initialize font rendering system.
Called automatically by mk_init().
Returns True when the operation succeeds.
mk_font_is_validfunctionbool mk_font_is_valid(mk_font_t font)Check if font handle is valid.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
Returns True when the condition holds.
mk_font_loadfunctionmk_font_t mk_font_load(const char *path, float size_px, mk_font_type_t type)Load font from file.
Supports TTF/OTF (TrueType/OpenType), BDF (Bitmap Distribution Format), and PSF (PC Screen Font) files. BDF/PSF fonts are loaded as MK_FONT_BITMAP regardless of the type parameter, with all 256 glyphs pre-populated.
| Parameter | Type | Description |
|---|---|---|
path | const char * | Path to .ttf, .otf, .bdf, or .psf file |
size_px | float | Default pixel size for rendering (0 = native height for BDF/PSF) |
type | mk_font_type_t | MK_FONT_BITMAP for crisp text, MK_FONT_SDF for scalable text |
Returns Font handle or MK_FONT_INVALID on failure
mk_font_load_exfunctionmk_font_t mk_font_load_ex(const mk_font_load_desc_t *desc)Load raw OpenType or cooked .mkfont input with explicit face/render options.
| Parameter | Type | Description |
|---|---|---|
desc | const mk_font_load_desc_t * | Configuration descriptor. |
Returns The resulting handle or value.
mk_font_load_memfunctionmk_font_t mk_font_load_mem(const void *data, uint32_t size, float size_px, mk_font_type_t type)Load font from memory.
Data is copied internally. Supports TTF/OTF, BDF, and PSF formats.
| Parameter | Type | Description |
|---|---|---|
data | const void * | Font file data (TTF/OTF/BDF/PSF) |
size | uint32_t | Size of font data in bytes |
size_px | float | Default pixel size for rendering (0 = native height for BDF/PSF) |
type | mk_font_type_t | MK_FONT_BITMAP or MK_FONT_SDF |
Returns Font handle or MK_FONT_INVALID on failure
mk_font_prewarmfunctionbool mk_font_prewarm(mk_font_t font, const char *text, float size_px, mk_font_render_policy_t policy)Blocking glyph prewarm.
The UTF-8 text is shaped when shaping is enabled. GPU uploads are issued on the calling API thread before this function returns.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
text | const char * | Value for text. |
size_px | float | Value for size px. |
policy | mk_font_render_policy_t | Value for policy. |
Returns True when the operation succeeds.
mk_font_probefunctionmk_result mk_font_probe(const char *path, uint32_t face_index, mk_font_metadata_t *metadata)Read basic metadata from one face without creating a renderable font.
| Parameter | Type | Description |
|---|---|---|
path | const char * | Value for path. |
face_index | uint32_t | Value for face index. |
metadata | mk_font_metadata_t * | Value for metadata. |
Returns MK_SUCCESS or an error result.
mk_font_probe_memfunctionmk_result mk_font_probe_mem(const void *data, uint32_t size, uint32_t face_index, mk_font_metadata_t *metadata)Read basic metadata from an in-memory font or collection.
| Parameter | Type | Description |
|---|---|---|
data | const void * | Data buffer. |
size | uint32_t | Size in bytes. |
face_index | uint32_t | Value for face index. |
metadata | mk_font_metadata_t * | Value for metadata. |
Returns MK_SUCCESS or an error result.
mk_font_shutdownfunctionvoid mk_font_shutdown(void)Shutdown font rendering system and free all fonts.
Called automatically by mk_shutdown().
mk_system_font_catalog_generationfunctionuint64_t mk_system_font_catalog_generation(void)Generation of the latest successful catalog snapshot.
Returns The resulting value.
mk_system_font_countfunctionuint32_t mk_system_font_count(void)Query the latest successful installed-font snapshot.
Query the latest successful installed-font snapshot.
Returns The resulting value.
mk_system_font_face_atfunctionmk_system_font_face_t * mk_system_font_face_at(uint32_t index)Return an owned face from the current snapshot.
| Parameter | Type | Description |
|---|---|---|
index | uint32_t | Zero-based index. |
Returns A borrowed pointer, or NULL when unavailable.
mk_system_font_face_findfunctionmk_system_font_face_t * mk_system_font_face_find(const char *name)Find system font face.
| Parameter | Type | Description |
|---|---|---|
name | const char * | Stable name. |
Returns A borrowed pointer, or NULL when unavailable.
mk_system_font_face_get_infofunctionmk_result mk_system_font_face_get_info(const mk_system_font_face_t *face, mk_system_font_face_info_t *info)Get info from the system font face.
| Parameter | Type | Description |
|---|---|---|
face | const mk_system_font_face_t * | Value for face. |
info | mk_system_font_face_info_t * | Value for info. |
Returns MK_SUCCESS or an error result.
mk_system_font_face_has_codepointfunctionbool mk_system_font_face_has_codepoint(const mk_system_font_face_t *face, uint32_t codepoint)Test whether the system font face has codepoint.
| Parameter | Type | Description |
|---|---|---|
face | const mk_system_font_face_t * | Value for face. |
codepoint | uint32_t | Value for codepoint. |
Returns True when the condition holds.
mk_system_font_face_info_initfunctionvoid mk_system_font_face_info_init(mk_system_font_face_info_t *info)Initialize the system font face info.
| Parameter | Type | Description |
|---|---|---|
info | mk_system_font_face_info_t * | Value for info. |
mk_system_font_face_is_validfunctionbool mk_system_font_face_is_valid(const mk_system_font_face_t *face)Test whether the system font face is valid.
| Parameter | Type | Description |
|---|---|---|
face | const mk_system_font_face_t * | Value for face. |
Returns True when the condition holds.
mk_system_font_face_load_asyncfunctionmk_result mk_system_font_face_load_async(mk_system_font_face_t *face, float size_px, mk_font_type_t type, mk_system_font_face_load_fn callback, void *user_data)Load async for the system font face.
| Parameter | Type | Description |
|---|---|---|
face | mk_system_font_face_t * | Value for face. |
size_px | float | Value for size px. |
type | mk_font_type_t | Value for type. |
callback | mk_system_font_face_load_fn | Completion callback. |
user_data | void * | Caller-provided context. |
Returns MK_SUCCESS or an error result.
mk_system_font_face_queryfunctionuint32_t mk_system_font_face_query(const char *text, mk_system_font_face_t **matches, uint32_t capacity)Query system font face.
| Parameter | Type | Description |
|---|---|---|
text | const char * | Value for text. |
matches | mk_system_font_face_t ** | Value for matches. |
capacity | uint32_t | Value for capacity. |
Returns The resulting value.
mk_system_font_face_releasefunctionvoid mk_system_font_face_release(mk_system_font_face_t *face)Release system font face.
| Parameter | Type | Description |
|---|---|---|
face | mk_system_font_face_t * | Value for face. |
mk_system_font_face_retainfunctionmk_system_font_face_t * mk_system_font_face_retain(mk_system_font_face_t *face)Retain system font face.
| Parameter | Type | Description |
|---|---|---|
face | mk_system_font_face_t * | Value for face. |
Returns A borrowed pointer, or NULL when unavailable.
mk_system_font_fallback_desc_initfunctionvoid mk_system_font_fallback_desc_init(mk_system_font_fallback_desc_t *desc)Initialize the system font fallback desc.
| Parameter | Type | Description |
|---|---|---|
desc | mk_system_font_fallback_desc_t * | Configuration descriptor. |
mk_system_font_fallbacksfunctionuint32_t mk_system_font_fallbacks(const mk_system_font_fallback_desc_t *desc, mk_system_font_face_t **faces, uint32_t capacity)Perform the system font fallbacks operation.
| Parameter | Type | Description |
|---|---|---|
desc | const mk_system_font_fallback_desc_t * | Configuration descriptor. |
faces | mk_system_font_face_t ** | Value for faces. |
capacity | uint32_t | Value for capacity. |
Returns The resulting value.
mk_system_font_findfunctionint32_t mk_system_font_find(const char *family_or_postscript_name)Find a face by PostScript/full name, or the closest regular face in a family.
Returns -1 when no face matches. Find a face by PostScript/full name, or the closest regular face in a family.
| Parameter | Type | Description |
|---|---|---|
family_or_postscript_name | const char * | Value for family or postscript name. |
Returns The resulting value.
mk_system_font_infofunctionmk_result mk_system_font_info(uint32_t index, mk_font_metadata_t *metadata)Perform the system font info operation.
| Parameter | Type | Description |
|---|---|---|
index | uint32_t | Zero-based index. |
metadata | mk_font_metadata_t * | Value for metadata. |
Returns MK_SUCCESS or an error result.
mk_system_font_load_asyncfunctionmk_result mk_system_font_load_async(uint32_t index, float size_px, mk_font_type_t type, mk_system_font_load_fn callback, void *user_data)Load one face from the current snapshot, completing on a later frame.
Load one face from the current snapshot, completing on a later frame.
| Parameter | Type | Description |
|---|---|---|
index | uint32_t | Zero-based index. |
size_px | float | Value for size px. |
type | mk_font_type_t | Value for type. |
callback | mk_system_font_load_fn | Completion callback. |
user_data | void * | Caller-provided context. |
Returns MK_SUCCESS or an error result.
mk_system_font_matchfunctionmk_result mk_system_font_match(const mk_system_font_match_desc_t *desc, mk_system_font_face_t **face)Perform the system font match operation.
| Parameter | Type | Description |
|---|---|---|
desc | const mk_system_font_match_desc_t * | Configuration descriptor. |
face | mk_system_font_face_t ** | Value for face. |
Returns MK_SUCCESS or an error result.
mk_system_font_match_desc_initfunctionvoid mk_system_font_match_desc_init(mk_system_font_match_desc_t *desc)Initialize the system font match desc.
| Parameter | Type | Description |
|---|---|---|
desc | mk_system_font_match_desc_t * | Configuration descriptor. |
mk_system_font_queryfunctionuint32_t mk_system_font_query(const char *text, uint32_t *matches, uint32_t capacity)Query faces whose family, style, full name, or PostScript name contains text.
Matching is case-insensitive. Writes up to capacity catalog indices to matches and returns the total match count; matches may be NULL to count only. Query faces whose family, style, full name, or PostScript name contains text.
| Parameter | Type | Description |
|---|---|---|
text | const char * | Value for text. |
matches | uint32_t * | Value for matches. |
capacity | uint32_t | Value for capacity. |
Returns The resulting value.
mk_system_fonts_refreshfunctionmk_result mk_system_fonts_refresh(mk_system_fonts_fn callback, void *user_data)Refresh the installed-font snapshot.
Completion runs on a later main-loop frame. Only one refresh may be in flight at a time.
| Parameter | Type | Description |
|---|---|---|
callback | mk_system_fonts_fn | Completion callback. |
user_data | void * | Caller-provided context. |
Returns MK_SUCCESS or an error result.
mk_system_fonts_supportedfunctionbool mk_system_fonts_supported(void)True when this platform can expose locally installed fonts.
Returns True when the condition holds.
mk_textfunctionfloat mk_text(mk_font_t font, float x, float y, const char *text, uint32_t color)Draw text at position with default alignment (left, baseline).
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
x | float | Value for x. |
y | float | Value for y. |
text | const char * | Value for text. |
color | uint32_t | Value for color. |
Returns The resulting value.
mk_text_beginfunctionvoid mk_text_begin(mk_encoder_t encoder, mk_view_id_t view, uint16_t width, uint16_t height)Begin text drawing mode.
Sets up orthographic projection for 2D text rendering. Must be called before mk_text_draw(). This compatibility entry point assumes a 1:1 logical-to-framebuffer scale. Use mk_text_begin_ex() for HiDPI windows and other scaled targets.
| Parameter | Type | Description |
|---|---|---|
encoder | mk_encoder_t | Encoder to submit draw calls to |
view | mk_view_id_t | View ID to render to |
width | uint16_t | Logical viewport width in pixels |
height | uint16_t | Logical viewport height in pixels |
mk_text_begin_exfunctionbool mk_text_begin_ex(const mk_text_begin_desc *desc)Begin text drawing with independent logical and framebuffer dimensions.
Text positions remain in logical pixels while raster selection and effects use the projected framebuffer density.
| Parameter | Type | Description |
|---|---|---|
desc | const mk_text_begin_desc * | Configuration descriptor. |
Returns true when the context was begun, false for invalid parameters
mk_text_buildfunctionuint32_t mk_text_build(mk_font_t font, const char *text, float size_px, mk_glyph_quad *out_quads, uint32_t max_quads, mk_text_geometry *out_geom)Lay out a string into glyph quads (does not draw anything).
Walks the UTF-8 string, rasterizing/caching glyphs into the font atlas, and writes one mk_glyph_quad per visible glyph into the caller-provided buffer. The quads are in layout space with the pen origin at (0,0); apply your own model/ortho transform when you submit them. Bitmap/SDF fonts only (the NanoVG path has no exposed geometry — use mk_text_draw_styled for that). Newly rasterized glyphs are uploaded before the frame's draw submissions and can be used immediately.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Font (MK_FONT_BITMAP or MK_FONT_SDF) |
text | const char * | UTF-8 string |
size_px | float | Pixel size to lay out at |
out_quads | mk_glyph_quad * | Caller buffer to fill |
max_quads | uint32_t | Capacity of out_quads |
out_geom | mk_text_geometry * | Filled with {quads=out_quads, count, atlas, width, height} |
Returns Number of glyph quads written (== out_geom->count)
mk_text_build_batchesfunctionmk_text_build_error_t mk_text_build_batches(mk_font_t font, const char *text, float size_px, mk_glyph_quad *out_quads, uint32_t max_quads, mk_text_geometry_batch_t *out_batches, uint16_t max_batches, mk_text_batch_geometry_t *out_geom)Batch-aware geometry builder for text spanning multiple atlas pages.
Batches reference consecutive ranges in out_quads and expose page metadata.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
text | const char * | Value for text. |
size_px | float | Value for size px. |
out_quads | mk_glyph_quad * | Receives the quads. |
max_quads | uint32_t | Value for max quads. |
out_batches | mk_text_geometry_batch_t * | Receives the batches. |
max_batches | uint16_t | Value for max batches. |
out_geom | mk_text_batch_geometry_t * | Receives the geom. |
Returns The resulting handle or value.
mk_text_drawfunctionfloat mk_text_draw(mk_font_t font, float x, float y, const char *text, float size_px, uint32_t color, int align)Draw text with simple parameters.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Font handle |
x | float | X position |
y | float | Y position |
text | const char * | UTF-8 text string |
size_px | float | Pixel size (0 = use font default) |
color | uint32_t | Text color (0xRRGGBBAA) |
align | int | Alignment flags (MK_TEXT_ALIGN_*) |
Returns Horizontal advance to next text position
mk_text_draw_boxfunctionfloat mk_text_draw_box(mk_font_t font, float x, float y, float max_width, float max_height, const char *text, float size_px, const mk_text_style_t *style, int align)Draw text within a bounding box with automatic word wrap.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Font handle |
x | float | X position of box left edge |
y | float | Y position of box top edge |
max_width | float | Maximum box width (0 = no limit) |
max_height | float | Maximum box height (0 = no limit, text may be clipped) |
text | const char * | UTF-8 text string |
size_px | float | Pixel size (0 = use font default) |
style | const mk_text_style_t * | Text style with color and effects |
align | int | Alignment flags (horizontal alignment applies within box) |
Returns Total height of rendered text
mk_text_draw_nfunctionfloat mk_text_draw_n(mk_font_t font, float x, float y, const char *text, size_t len, float size_px, uint32_t color, int align)Draw text with length limit.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Font handle |
x | float | X position |
y | float | Y position |
text | const char * | UTF-8 text string |
len | size_t | Maximum bytes to render (or 0 for entire string) |
size_px | float | Pixel size (0 = use font default) |
color | uint32_t | Text color (0xRRGGBBAA) |
align | int | Alignment flags |
Returns Horizontal advance
mk_text_draw_styledfunctionfloat mk_text_draw_styled(mk_font_t font, float x, float y, const char *text, float size_px, const mk_text_style_t *style, int align)Draw text with full styling (for SDF effects).
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Font handle |
x | float | X position |
y | float | Y position |
text | const char * | UTF-8 text string |
size_px | float | Pixel size (0 = use font default) |
style | const mk_text_style_t * | Text style with color and effects |
align | int | Alignment flags |
Returns Horizontal advance
mk_text_draw_styled_nfunctionfloat mk_text_draw_styled_n(mk_font_t font, float x, float y, const char *text, size_t len, float size_px, const mk_text_style_t *style, int align)Draw a length-delimited styled UTF-8 slice.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
x | float | Value for x. |
y | float | Value for y. |
text | const char * | Value for text. |
len | size_t | Value for len. |
size_px | float | Value for size px. |
style | const mk_text_style_t * | Value for style. |
align | int | Value for align. |
Returns The resulting value.
mk_text_endfunctionvoid mk_text_end(void)End text drawing mode and flush all pending text.
mk_text_measurefunctionfloat mk_text_measure(mk_font_t font, const char *text, float size_px, mk_text_bounds_t *bounds)Measure text bounds without rendering.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Font handle |
text | const char * | UTF-8 text string |
size_px | float | Pixel size (0 = use default) |
bounds | mk_text_bounds_t * | Output bounding box (can be NULL) |
Returns Horizontal advance (width of text)
mk_text_measure_boxfunctionfloat mk_text_measure_box(mk_font_t font, const char *text, float size_px, float max_width, float line_height_scale, mk_text_bounds_t *bounds)Measure text box dimensions with word wrap.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Font handle |
text | const char * | UTF-8 text string |
size_px | float | Pixel size (0 = use font default) |
max_width | float | Maximum width for wrapping (0 = no limit) |
line_height_scale | float | Line height multiplier (1.0 = default) |
bounds | mk_text_bounds_t * | Output bounding box (can be NULL) |
Returns Total height of text box
mk_text_measure_nfunctionfloat mk_text_measure_n(mk_font_t font, const char *text, size_t len, float size_px, mk_text_bounds_t *bounds)Measure text bounds with length limit.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Font handle |
text | const char * | UTF-8 text string |
len | size_t | Maximum bytes to measure (or 0 for entire string) |
size_px | float | Pixel size (0 = use default) |
bounds | mk_text_bounds_t * | Output bounding box (can be NULL) |
Returns Horizontal advance
mk_text_measure_styled_nfunctionfloat mk_text_measure_styled_n(mk_font_t font, const char *text, size_t len, float size_px, const mk_text_style_t *style, mk_text_bounds_t *bounds)Measure a length-delimited styled UTF-8 slice.
Letter spacing from style is included in the returned advance.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
text | const char * | Value for text. |
len | size_t | Value for len. |
size_px | float | Value for size px. |
style | const mk_text_style_t * | Value for style. |
bounds | mk_text_bounds_t * | Value for bounds. |
Returns The resulting value.
mk_text_sizefunctionfloat mk_text_size(mk_font_t font, float x, float y, const char *text, float size_px, uint32_t color)Draw text at position with specified size.
| Parameter | Type | Description |
|---|---|---|
font | mk_font_t | Value for font. |
x | float | Value for x. |
y | float | Value for y. |
text | const char * | Value for text. |
size_px | float | Value for size px. |
color | uint32_t | Value for color. |
Returns The resulting value.
mk_font_atlas_pagestructData for font atlas page.
| Field | Type | Description |
|---|---|---|
texture | mk_texture_t | The texture. |
format | mk_texture_format_t | The format. |
raster_kind | mk_font_raster_kind_t | The raster kind. |
distance_range | float | The distance range. |
generation | uint32_t | The generation. |
width | uint16_t | The width. |
height | uint16_t | The height. |
mk_font_axis_valuestructData for font axis value.
| Field | Type | Description |
|---|---|---|
tag | uint32_t | Four-byte OpenType tag in big-endian byte order. |
value | float | Design-space axis coordinate. |
mk_font_cache_statsstructData for font cache stats.
| Field | Type | Description |
|---|---|---|
rasterizations | uint32_t | The rasterizations. |
uploads | uint32_t | The uploads. |
pages | uint32_t | The pages. |
evictions | uint32_t | The evictions. |
gpu_bytes | uint64_t | The GPU bytes. |
gpu_budget | uint64_t | The GPU budget. |
mk_font_load_descstructExtended font load descriptor.
Set either path or data/data_size. Raw OpenType and cooked .mkfont input are detected from content magic.
| Field | Type | Description |
|---|---|---|
path | const char * | The path. |
data | const void * | The data. |
data_size | uint32_t | The data size. |
size_px | float | The size px. |
type | mk_font_type_t | The type. |
face_index | uint32_t | The face index. |
palette | uint16_t | The palette. |
color_mode | mk_font_color_mode_t | The color mode. |
render_policy | mk_font_render_policy_t | The render policy. |
hinting | mk_font_hinting_t | The hinting. |
axes | const mk_font_axis_value_t * | The axes. |
axis_count | uint16_t | The axis count. |
mk_font_metadatastructPortable metadata for one face in an outline-font file or system catalog.
| Field | Type | Description |
|---|---|---|
family | char | The family. |
style | char | The style. |
full_name | char | The full name. |
postscript_name | char | The postscript name. |
weight | uint16_t | OpenType weight, 1..1000; zero if unknown. |
width_class | uint8_t | OpenType width class, 1..9; zero if unknown. |
face_index | uint32_t | The face index. |
flags | uint32_t | mk_font_metadata_flags_t bits. |
mk_font_metricsstructFont vertical metrics.
| Field | Type | Description |
|---|---|---|
ascender | float | Distance from baseline to top of tallest glyph. |
descender | float | Distance from baseline to bottom (negative). |
line_height | float | Recommended line spacing. |
underline_position | float | Stroke center from baseline; below is negative. |
underline_thickness | float | Recommended underline thickness. |
strikethrough_position | float | Stroke center from baseline; above is positive. |
strikethrough_thickness | float | Recommended strikethrough thickness. |
mk_font_tstructData for font.
| Field | Type | Description |
|---|---|---|
idx | uint16_t | The idx. |
mk_glyph_quadstructOne laid-out glyph: a position rect (layout space, pen origin at 0,0, +x right, +y down) and its atlas UV rect (normalized).
| Field | Type | Description |
|---|---|---|
x0 | float | Left edge in layout space. |
y0 | float | Top edge in layout space. |
x1 | float | Right edge in layout space. |
y1 | float | Bottom edge in layout space. |
u0 | float | Left atlas coordinate, normalized to 0..1. |
v0 | float | Top atlas coordinate, normalized to 0..1. |
u1 | float | Right atlas coordinate, normalized to 0..1. |
v1 | float | Bottom atlas coordinate, normalized to 0..1. |
mk_system_font_face_infostructData for system font face info.
| Field | Type | Description |
|---|---|---|
struct_size | uint32_t | The struct size. |
struct_version | uint32_t | The struct version. |
metadata | mk_font_metadata_t | The metadata. |
local_path | const char * | The local path. |
catalog_generation | uint64_t | The catalog generation. |
mk_system_font_fallback_descstructData for system font fallback desc.
| Field | Type | Description |
|---|---|---|
struct_size | uint32_t | The struct size. |
struct_version | uint32_t | The struct version. |
text | const char * | The text. |
text_length | size_t | The text length. |
style | mk_system_font_match_desc_t | The style. |
mk_system_font_match_descstructData for system font match desc.
| Field | Type | Description |
|---|---|---|
struct_size | uint32_t | The struct size. |
struct_version | uint32_t | The struct version. |
family | const char * | The family. |
generic_family | mk_system_font_generic_family_t | The generic family. |
weight | uint16_t | The weight. |
width_class | uint8_t | The width class. |
italic | bool | The italic. |
italic_set | bool | The italic set. |
locale | const char * | The locale. |
mk_text_batch_geometrystructData for text batch geometry.
| Field | Type | Description |
|---|---|---|
quads | mk_glyph_quad * | The quads. |
count | uint32_t | The count. |
batches | mk_text_geometry_batch_t * | The batches. |
batch_count | uint16_t | The batch count. |
width | float | The width. |
height | float | The height. |
error | mk_text_build_error_t | The error. |
mk_text_begin_descstructExtended begin parameters with independent logical and physical sizes.
| Field | Type | Description |
|---|---|---|
encoder | mk_encoder_t | The encoder. |
view | mk_view_id_t | The view. |
logical_width | uint16_t | The logical width. |
logical_height | uint16_t | The logical height. |
framebuffer_width | uint16_t | The framebuffer width. |
framebuffer_height | uint16_t | The framebuffer height. |
mk_text_boundsstructText bounding box.
| Field | Type | Description |
|---|---|---|
min_x | float | Left edge of the bounding box. |
min_y | float | Top edge of the bounding box. |
max_x | float | Right edge of the bounding box. |
max_y | float | Bottom edge of the bounding box. |
mk_text_effectsstructTagged rasterizer-specific effects.
Zero-init means "no effects".
| Field | Type | Description |
|---|---|---|
kind | mk_text_effects_kind_t | The kind. |
u | union mk_text_effects::@133072235115173253031100010240227140303205024371 | The u. |
u.mtsdf | mk_text_effects_mtsdf_t | Valid iff kind == MK_TEXT_EFFECTS_MTSDF. |
u.slug | mk_text_effects_slug_t | Valid iff kind == MK_TEXT_EFFECTS_SLUG. |
mk_text_effects_mtsdfstructDistance-field effects.
Require MTSDF rendering: they work with MK_FONT_SDF and cause MK_FONT_AUTO fonts to select MTSDF.
| Field | Type | Description |
|---|---|---|
outline_width | float | Outline width in pixels (0 = no outline). |
outline_color | uint32_t | Outline color (0xRRGGBBAA). |
shadow_offset_x | float | Drop shadow X offset in pixels. |
shadow_offset_y | float | Drop shadow Y offset in pixels. |
shadow_color | uint32_t | Shadow color (0xRRGGBBAA). |
shadow_softness | float | Shadow blur amount (0 = sharp, 1 = very soft). |
glow_size | float | Glow radius in pixels (0 = no glow). |
glow_color | uint32_t | Glow color (0xRRGGBBAA). |
mk_text_effects_slugstructAnalytical effects for MK_FONT_SLUG.
Dimensions are logical pixels.
| Field | Type | Description |
|---|---|---|
optical_weight | float | 0 = original, 1 = strongest edge-coverage boost |
outline_width | float | The outline width. |
outline_color | uint32_t | The outline color. |
outline_mode | mk_slug_outline_mode_t | The outline mode. |
shadow_offset_x | float | The shadow offset x. |
shadow_offset_y | float | The shadow offset y. |
shadow_color | uint32_t | The shadow color. |
shadow_softness | float | Clamped to [0,1]. |
glow_size | float | The glow size. |
glow_color | uint32_t | The glow color. |
mk_text_fillstructText fill.
Linear endpoints are normalized against the untransformed run bounds, so (0,0) is its top-left and (1,1) is its bottom-right.
| Field | Type | Description |
|---|---|---|
kind | mk_text_fill_kind_t | The kind. |
linear | struct mk_text_fill::@075220143346001235335115226143361043130366304364 | The linear. |
linear.x0 | float | Normalized start X coordinate. |
linear.y0 | float | Normalized start Y coordinate. |
linear.x1 | float | Normalized end X coordinate. |
linear.y1 | float | Normalized end Y coordinate. |
linear.color0 | uint32_t | The color0. |
linear.color1 | uint32_t | The color1. |
mk_text_geometrystructResult of mk_text_build: the quads + the atlas to sample + measured bounds.
| Field | Type | Description |
|---|---|---|
quads | mk_glyph_quad * | Points at the caller's buffer. |
count | uint32_t | Number of visible glyph quads written. |
atlas | mk_texture_t | One R8 coverage or RGBA8 MTSDF/color page. |
page_index | uint16_t | The page index. |
page_generation | uint32_t | The page generation. |
raster_kind | mk_font_raster_kind_t | The raster kind. |
distance_range | float | The distance range. |
width | float | Total advance width (size_px units). |
height | float | Line height (size_px units). |
error | int32_t | mk_text_build_error_t |
mk_text_geometry_batchstructData for text geometry batch.
| Field | Type | Description |
|---|---|---|
first_quad | uint32_t | The first quad. |
quad_count | uint32_t | The quad count. |
page | mk_font_atlas_page_t | The page. |
mk_text_stylestructText style: colour and formatting shared by every rasterizer, plus optional rasterizer-specific effects.
| Field | Type | Description |
|---|---|---|
color | uint32_t | Text color (0xRRGGBBAA). |
letter_spacing | float | Additional space between shaped clusters (pixels). |
line_height_scale | float | Line height multiplier (1.0 = default). |
background_color | uint32_t | Background highlight color (0 = none). |
horizontal_scale | float | Horizontal text scale. |
vertical_scale | float | Baseline-relative vertical glyph scale. |
baseline_shift | float | Positive values raise the baseline in logical pixels. |
skew_x | float | Baseline-relative horizontal shear. |
decorations | uint32_t | Bitwise mk_text_decoration_flags values. |
fill | mk_text_fill_t | The fill. |
effects | mk_text_effects_t | Rasterizer-specific effects; ignored by rasterizers that cannot apply them (a mismatch is logged once, and the text draws unstyled). |
mk_font_color_modeenumColor-glyph selection is fixed per font handle because it participates in atlas and Slug glyph residency.
| Value | Description |
|---|---|
MK_FONT_COLOR_AUTO | Use color tables when the font has them. |
MK_FONT_COLOR_MONOCHROME | Render a tintable monochrome glyph. |
mk_font_hintingenumValues for font hinting.
| Value | Description |
|---|---|
MK_FONT_HINTING_DEFAULT | Selects default. |
MK_FONT_HINTING_NONE | Selects none. |
MK_FONT_HINTING_LIGHT | Selects light. |
MK_FONT_HINTING_FULL | Selects full. |
mk_font_metadata_flagsenumValues for font metadata flags.
| Value | Description |
|---|---|
MK_FONT_METADATA_ITALIC | Selects italic. |
MK_FONT_METADATA_MONOSPACE | Selects monospace. |
MK_FONT_METADATA_VARIABLE | Selects variable. |
MK_FONT_METADATA_COLOR | Selects color. |
mk_font_raster_kindenumValues for font raster kind.
| Value | Description |
|---|---|
MK_FONT_RASTER_COVERAGE | Selects coverage. |
MK_FONT_RASTER_MTSDF | Selects mtsdf. |
MK_FONT_RASTER_COLOR | Selects color. |
mk_font_render_policyenumRaster policy precedence for outline fonts: prebuilt/MK_FONT_BITMAP fonts use coverage, an explicit render policy comes next, MK_FONT_SDF uses MTSDF, and MK_FONT_AUTO selects by device size.
| Value | Description |
|---|---|
MK_FONT_RENDER_DEFAULT | Use the default implied by the font type. |
MK_FONT_RENDER_COVERAGE | Force coverage for scalable outline fonts. |
MK_FONT_RENDER_MTSDF | Force MTSDF for scalable outline fonts. |
MK_FONT_RENDER_AUTO | Choose from projected device-pixel size. |
mk_font_typeenumFont rendering type.
| Value | Description |
|---|---|
MK_FONT_BITMAP | Standard bitmap rendering (crisp at target size). |
MK_FONT_SDF | MTSDF RGBA8 (scalable, supports effects). |
MK_FONT_NANOVG | NanoVG vector rendering (anti-aliased, good quality). |
MK_FONT_AUTO | Coverage for small screen text, MTSDF otherwise. |
MK_FONT_SLUG | Curve-based, resolution-independent (modkit/slug.h). |
mk_slug_outline_modeenumValues for slug outline mode.
| Value | Description |
|---|---|
MK_SLUG_OUTLINE_SAMPLED | Selects sampled. |
MK_SLUG_OUTLINE_GEOMETRIC | Selects geometric. |
mk_system_font_generic_familyenumValues for system font generic family.
| Value | Description |
|---|---|
MK_SYSTEM_FONT_GENERIC_NONE | Selects none. |
MK_SYSTEM_FONT_GENERIC_SYSTEM_UI | Selects system UI. |
MK_SYSTEM_FONT_GENERIC_SANS | Selects sans. |
MK_SYSTEM_FONT_GENERIC_SERIF | Selects serif. |
MK_SYSTEM_FONT_GENERIC_MONOSPACE | Selects monospace. |
MK_SYSTEM_FONT_GENERIC_EMOJI | Selects emoji. |
mk_text_alignenumText alignment flags.
Combine one horizontal and one vertical flag.
| Value | Description |
|---|---|
MK_TEXT_ALIGN_LEFT | Align text to the left. |
MK_TEXT_ALIGN_CENTER | Center text horizontally. |
MK_TEXT_ALIGN_RIGHT | Align text to the right. |
MK_TEXT_ALIGN_TOP | Align text to the top. |
MK_TEXT_ALIGN_MIDDLE | Center text vertically. |
MK_TEXT_ALIGN_BOTTOM | Align text to the bottom. |
MK_TEXT_ALIGN_BASELINE | Align text to the baseline (default). |
mk_text_build_errorenumValues for text build error.
| Value | Description |
|---|---|
MK_TEXT_BUILD_OK | Selects ok. |
MK_TEXT_BUILD_INVALID_ARGUMENT | Selects invalid argument. |
MK_TEXT_BUILD_MULTIPLE_PAGES | Selects multiple pages. |
MK_TEXT_BUILD_CAPACITY | Selects capacity. |
mk_text_decoration_flagsenumValues for text decoration flags.
| Value | Description |
|---|---|
MK_TEXT_DECORATION_NONE | Selects none. |
MK_TEXT_DECORATION_UNDERLINE | Selects underline. |
MK_TEXT_DECORATION_STRIKETHROUGH | Selects strikethrough. |
mk_text_effects_kindenumWhich rasterizer's effects an mk_text_effects_t carries.
Effects are rasterizer-specific: MTSDF uses signed-distance thresholds, while Slug resamples analytical coverage. Tagging them keeps a mismatch detectable instead of silently rendering the wrong thing.
| Value | Description |
|---|---|
MK_TEXT_EFFECTS_NONE | No effects; colour and formatting only. |
MK_TEXT_EFFECTS_MTSDF | Distance-field effects; needs MTSDF raster. |
MK_TEXT_EFFECTS_SLUG | Analytical Slug coverage effects. |
mk_text_fill_kindenumValues for text fill kind.
| Value | Description |
|---|---|
MK_TEXT_FILL_SOLID | Selects solid. |
MK_TEXT_FILL_LINEAR | Selects linear. |
mk_font_atlas_page_ttypedeftypedef struct mk_font_atlas_page mk_font_atlas_page_tData for font atlas page.
mk_font_axis_value_ttypedeftypedef struct mk_font_axis_value mk_font_axis_value_tData for font axis value.
mk_font_cache_stats_ttypedeftypedef struct mk_font_cache_stats mk_font_cache_stats_tData for font cache stats.
mk_font_color_mode_ttypedeftypedef enum mk_font_color_mode mk_font_color_mode_tColor-glyph selection is fixed per font handle because it participates in atlas and Slug glyph residency.
mk_font_hinting_ttypedeftypedef enum mk_font_hinting mk_font_hinting_tValues for font hinting.
mk_font_load_desc_ttypedeftypedef struct mk_font_load_desc mk_font_load_desc_tExtended font load descriptor.
Set either path or data/data_size. Raw OpenType and cooked .mkfont input are detected from content magic.
mk_font_metadata_flags_ttypedeftypedef enum mk_font_metadata_flags mk_font_metadata_flags_tValues for font metadata flags.
mk_font_metadata_ttypedeftypedef struct mk_font_metadata mk_font_metadata_tPortable metadata for one face in an outline-font file or system catalog.
mk_font_metrics_ttypedeftypedef struct mk_font_metrics mk_font_metrics_tFont vertical metrics.
mk_font_raster_kind_ttypedeftypedef enum mk_font_raster_kind mk_font_raster_kind_tValues for font raster kind.
mk_font_render_policy_ttypedeftypedef enum mk_font_render_policy mk_font_render_policy_tRaster policy precedence for outline fonts: prebuilt/MK_FONT_BITMAP fonts use coverage, an explicit render policy comes next, MK_FONT_SDF uses MTSDF, and MK_FONT_AUTO selects by device size.
mk_font_type_ttypedeftypedef enum mk_font_type mk_font_type_tFont rendering type.
mk_glyph_quadtypedeftypedef struct mk_glyph_quad mk_glyph_quadOne laid-out glyph: a position rect (layout space, pen origin at 0,0, +x right, +y down) and its atlas UV rect (normalized).
mk_slug_outline_mode_ttypedeftypedef enum mk_slug_outline_mode mk_slug_outline_mode_tValues for slug outline mode.
mk_system_font_face_info_ttypedeftypedef struct mk_system_font_face_info mk_system_font_face_info_tData for system font face info.
mk_system_font_face_load_fntypedeftypedef void(*) mk_system_font_face_load_fn(mk_result result, mk_font_t font, void *user_data)Callback used for system font face load.
mk_system_font_face_ttypedeftypedef struct mk_system_font_face_s mk_system_font_face_tType used for system font face.
mk_system_font_fallback_desc_ttypedeftypedef struct mk_system_font_fallback_desc mk_system_font_fallback_desc_tData for system font fallback desc.
mk_system_font_generic_family_ttypedeftypedef enum mk_system_font_generic_family mk_system_font_generic_family_tValues for system font generic family.
mk_system_font_load_fntypedeftypedef void(*) mk_system_font_load_fn(mk_result result, mk_font_t font, void *user_data)Callback used for system font load.
mk_system_font_match_desc_ttypedeftypedef struct mk_system_font_match_desc mk_system_font_match_desc_tData for system font match desc.
mk_system_fonts_fntypedeftypedef void(*) mk_system_fonts_fn(mk_result result, uint32_t count, void *user_data)Callback used for system fonts.
mk_text_align_ttypedeftypedef enum mk_text_align mk_text_align_tText alignment flags.
Combine one horizontal and one vertical flag.
mk_text_batch_geometry_ttypedeftypedef struct mk_text_batch_geometry mk_text_batch_geometry_tData for text batch geometry.
mk_text_begin_desctypedeftypedef struct mk_text_begin_desc mk_text_begin_descExtended begin parameters with independent logical and physical sizes.
mk_text_bounds_ttypedeftypedef struct mk_text_bounds mk_text_bounds_tText bounding box.
mk_text_build_error_ttypedeftypedef enum mk_text_build_error mk_text_build_error_tValues for text build error.
mk_text_decoration_flags_ttypedeftypedef enum mk_text_decoration_flags mk_text_decoration_flags_tValues for text decoration flags.
mk_text_effects_kind_ttypedeftypedef enum mk_text_effects_kind mk_text_effects_kind_tWhich rasterizer's effects an mk_text_effects_t carries.
Effects are rasterizer-specific: MTSDF uses signed-distance thresholds, while Slug resamples analytical coverage. Tagging them keeps a mismatch detectable instead of silently rendering the wrong thing.
mk_text_effects_mtsdf_ttypedeftypedef struct mk_text_effects_mtsdf mk_text_effects_mtsdf_tDistance-field effects.
Require MTSDF rendering: they work with MK_FONT_SDF and cause MK_FONT_AUTO fonts to select MTSDF.
mk_text_effects_slug_ttypedeftypedef struct mk_text_effects_slug mk_text_effects_slug_tAnalytical effects for MK_FONT_SLUG.
Dimensions are logical pixels.
mk_text_effects_ttypedeftypedef struct mk_text_effects mk_text_effects_tTagged rasterizer-specific effects.
Zero-init means "no effects".
mk_text_fill_kind_ttypedeftypedef enum mk_text_fill_kind mk_text_fill_kind_tValues for text fill kind.
mk_text_fill_ttypedeftypedef struct mk_text_fill mk_text_fill_tText fill.
Linear endpoints are normalized against the untransformed run bounds, so (0,0) is its top-left and (1,1) is its bottom-right.
mk_text_geometrytypedeftypedef struct mk_text_geometry mk_text_geometryResult of mk_text_build: the quads + the atlas to sample + measured bounds.
mk_text_geometry_batch_ttypedeftypedef struct mk_text_geometry_batch mk_text_geometry_batch_tData for text geometry batch.
mk_text_style_ttypedeftypedef struct mk_text_style mk_text_style_tText style: colour and formatting shared by every rasterizer, plus optional rasterizer-specific effects.
MK_FONT_FAMILY_NAME_MAXdefineMK_FONT_FAMILY_NAME_MAXMaximum supported font family name max.
MK_FONT_FULL_NAME_MAXdefineMK_FONT_FULL_NAME_MAXMaximum supported font full name max.
MK_FONT_INVALIDdefineMK_FONT_INVALIDInvalid sentinel for font.
MK_FONT_POSTSCRIPT_NAME_MAXdefineMK_FONT_POSTSCRIPT_NAME_MAXMaximum supported font postscript name max.
MK_FONT_STYLE_NAME_MAXdefineMK_FONT_STYLE_NAME_MAXMaximum supported font style name max.
MK_SYSTEM_FONT_FACE_INFO_VERSIONdefineMK_SYSTEM_FONT_FACE_INFO_VERSIONABI or format version for system font face info.
MK_SYSTEM_FONT_FALLBACK_DESC_VERSIONdefineMK_SYSTEM_FONT_FALLBACK_DESC_VERSIONABI or format version for system font fallback desc.
MK_SYSTEM_FONT_MATCH_DESC_VERSIONdefineMK_SYSTEM_FONT_MATCH_DESC_VERSIONABI or format version for system font match desc.
MK_TEXT_ALIGN_DEFAULTdefineMK_TEXT_ALIGN_DEFAULTConstant for text align default.
MK_TEXT_EFFECTS_MTSDF_DEFAULTdefineMK_TEXT_EFFECTS_MTSDF_DEFAULTMTSDF effects preset: sensible colours, all effects switched off.
Enable one by setting its width/size, e.g.
mk_text_style_t style = MK_TEXT_STYLE_DEFAULT;
style.effects = MK_TEXT_EFFECTS_MTSDF_DEFAULT;
style.effects.u.mtsdf.outline_width = 2.0f;MK_TEXT_EFFECTS_SLUG_DEFAULTdefineMK_TEXT_EFFECTS_SLUG_DEFAULTSlug effects preset with every effect switched off.
MK_TEXT_STYLE_DEFAULTdefineMK_TEXT_STYLE_DEFAULTDefault text style: white text with no effects.