![]() |
libdragon
|
Functions | |
void | rdpq_text_register_font (uint8_t font_id, const rdpq_font_t *font) |
Register a new font into the text engine. | |
void | rdpq_text_unregister_font (uint8_t font_id) |
Unregister a font from the text engine. | |
const rdpq_font_t * | rdpq_text_get_font (uint8_t font_id) |
Get a registered font by its ID. | |
rdpq_paragraph_t * | __rdpq_paragraph_build (const rdpq_textparms_t *parms, uint8_t initial_font_id, const char *utf8_text, int *nbytes, rdpq_paragraph_t *layout, bool optimize) |
Inner implementation of rdpq_text_printn, with explicit memory handling. | |
rdpq_textmetrics_t | rdpq_text_printn (const rdpq_textparms_t *parms, uint8_t initial_font_id, float x0, float y0, const char *utf8_text, int nbytes) |
Layout and render a text in a single call. | |
rdpq_textmetrics_t | rdpq_text_vprintf (const rdpq_textparms_t *parms, uint8_t font_id, float x0, float y0, const char *utf8_fmt, va_list va) |
Layout and render a formatted text in a single call. | |
rdpq_textmetrics_t | rdpq_text_printf (const rdpq_textparms_t *parms, uint8_t font_id, float x0, float y0, const char *utf8_fmt,...) |
Layout and render a formatted text in a single call. | |
rdpq_textmetrics_t | rdpq_text_print (const rdpq_textparms_t *parms, uint8_t font_id, float x0, float y0, const char *utf8_text) |
Layout and render a text in a single call. | |
void rdpq_text_register_font | ( | uint8_t | font_id, |
const rdpq_font_t * | font | ||
) |
Register a new font into the text engine.
After this call, the font is available to be used by the text engine for layout and render. If font_id
is already registered, this function will fail by asserting.
font_id | Font ID |
font | Font to register |
void rdpq_text_unregister_font | ( | uint8_t | font_id | ) |
Unregister a font from the text engine.
This call will remove the font that was previously registered with font_id
from the text engine. Afterwards, font_id
can be used again to register other fonts. If font_id
is not registered, this function will fail by asserting.
font_id | Font ID |
const rdpq_font_t * rdpq_text_get_font | ( | uint8_t | font_id | ) |
Get a registered font by its ID.
font_id | Font ID |
rdpq_textmetrics_t rdpq_text_printn | ( | const rdpq_textparms_t * | parms, |
uint8_t | font_id, | ||
float | x0, | ||
float | y0, | ||
const char * | utf8_text, | ||
int | nbytes | ||
) |
Layout and render a text in a single call.
This function accepts UTF-8 encoded text. It will layout the text according to the parameters provided in rdpq_textparms_t, and then render it at the specified coordinates.
The text is layout and rendered using the specified font by default (using its default style 0), but it can contain special escape codes to change the font or its style.
Escape codes are sequences of the form:
$xx Select font "xx", where "xx" is the hexadecimal ID of the font For instance, $04 will switch to font 4. The current style is reset to 0. ^xx Switch to style "xx" of the current font, where "xx" is the hexadecimal ID of the style. For instance, ^02 will switch to style 2. A "style" is an font-dependent rendering style, which can be anything (a color, a faux-italic variant, etc.). It is up the the font to define what styles are available.
To use a stray "$" or "^" character in the text, you can escape it by repeating them twice: "$$" or "^^".
The specified position refers to the "baseline" of the text. This is the line upon which the various glyphs are laid out (just like the line on a handwriting paper); each glyph will extend above or even below the baseline, depending on how the font has been designed.
The return value is the number of bytes printed, and can be useful to provide a pagination system (as the caller will be able to know where the next page would start). Notice that if you ask for horizontal line truncation (via WRAP_NONE or WRAP_ELLIPSES), those lines will be counted as fully printed anyway (so that pagination works as expected).
parms | Layout parameters (see rdpq_textparms_t) |
font_id | Font ID to use to render the text (at least initially; it can modified via escape codes). The initial style will be style 0. |
x0 | X coordinate where to start rendering the text (baseline) |
y0 | Y coordinate where to start rendering the text (baseline) |
utf8_text | Text to render, in UTF-8 encoding. Does not need to be NULL terminated. |
nbytes | Number of bytes in the text to render |
rdpq_textmetrics_t rdpq_text_vprintf | ( | const rdpq_textparms_t * | parms, |
uint8_t | font_id, | ||
float | x0, | ||
float | y0, | ||
const char * | utf8_fmt, | ||
va_list | va | ||
) |
Layout and render a formatted text in a single call.
This function is similar to rdpq_text_printf, but it accepts a va_list argument list, similar to vsprintf. The format string is expected to be UTF-8 encoded.
parms | Layout parameters |
font_id | Font ID to use to render the text (at least initially; it can modified via escape codes). The initial style will be style 0. |
x0 | X coordinate where to start rendering the text |
y0 | Y coordinate where to start rendering the text |
utf8_fmt | Format string, in UTF-8 encoding |
va | Argument list |
rdpq_textmetrics_t rdpq_text_printf | ( | const rdpq_textparms_t * | parms, |
uint8_t | font_id, | ||
float | x0, | ||
float | y0, | ||
const char * | utf8_fmt, | ||
... | |||
) |
Layout and render a formatted text in a single call.
This function is similar to rdpq_text_print, but it accepts a printf-like format string. The format string is expected to be UTF-8 encoded.
parms | Layout parameters |
font_id | Font ID to use to render the text (at least initially; it can modified via escape codes). The initial style will be style 0. |
x0 | X coordinate where to start rendering the text |
y0 | Y coordinate where to start rendering the text |
utf8_fmt | Format string, in UTF-8 encoding |
|
externinline |
Layout and render a text in a single call.
This function is similar to rdpq_text_print, but it accepts a UTF-8 encoded, NULL-terminated string.
parms | Layout parameters |
font_id | Font ID to use to render the text (at least initially; it can modified via escape codes). The initial style will be style 0. |
x0 | X coordinate where to start rendering the text |
y0 | Y coordinate where to start rendering the text |
utf8_text | Text to render, in UTF-8 encoding, NULL terminated. |