libdragon
Loading...
Searching...
No Matches
rdpq_text.h
Go to the documentation of this file.
1
171#ifndef LIBDRAGON_RDPQ_TEXT_H
172#define LIBDRAGON_RDPQ_TEXT_H
173
174#include <stdint.h>
175#include <stdbool.h>
176#include <stdarg.h>
177#include <string.h>
178
179#ifdef __cplusplus
180extern "C" {
181#endif
182
184struct rdpq_font_s;
185typedef struct rdpq_font_s rdpq_font_t;
187
201
210
219
236
244
257void rdpq_text_register_font(uint8_t font_id, const rdpq_font_t *font);
258
270void rdpq_text_unregister_font(uint8_t font_id);
271
278const rdpq_font_t *rdpq_text_get_font(uint8_t font_id);
279
331rdpq_textmetrics_t rdpq_text_printn(const rdpq_textparms_t *parms, uint8_t font_id, float x0, float y0,
332 const char *utf8_text, int nbytes);
333
349__attribute__((format(printf, 5, 6)))
350rdpq_textmetrics_t rdpq_text_printf(const rdpq_textparms_t *parms, uint8_t font_id, float x0, float y0,
351 const char *utf8_fmt, ...);
352
353
371rdpq_textmetrics_t rdpq_text_vprintf(const rdpq_textparms_t *parms, uint8_t font_id, float x0, float y0,
372 const char *utf8_fmt, va_list va);
373
389inline rdpq_textmetrics_t rdpq_text_print(const rdpq_textparms_t *parms, uint8_t font_id, float x0, float y0,
390 const char *utf8_text)
391{
392 return rdpq_text_printn(parms, font_id, x0, y0, utf8_text, strlen(utf8_text));
393}
394
395#ifdef __cplusplus
396}
397#endif
398
399#endif
A font64 file containing a font.
Definition rdpq_font_internal.h:106
int16_t line_spacing
Extra spacing between lines (in addition to font height)
Definition rdpq_text.h:230
rdpq_align_t
Print formatting parameters: horizontal alignment.
Definition rdpq_text.h:205
@ ALIGN_CENTER
Center alignment.
Definition rdpq_text.h:207
@ ALIGN_LEFT
Left alignment.
Definition rdpq_text.h:206
@ ALIGN_RIGHT
Right alignment.
Definition rdpq_text.h:208
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.
Definition rdpq_text.c:54
float advance_x
X pen advance after rendering the text.
Definition rdpq_text.h:239
rdpq_valign_t
Print formatting parameters: horizontal alignment.
Definition rdpq_text.h:214
@ VALIGN_TOP
Top alignment.
Definition rdpq_text.h:215
@ VALIGN_BOTTOM
Vertical alignment.
Definition rdpq_text.h:217
@ VALIGN_CENTER
Center alignment.
Definition rdpq_text.h:216
int nlines
Number of lines rendered (including wrapped lines)
Definition rdpq_text.h:242
int16_t height
Maximum vertical height of the paragraph, in pixels (0 if unbounded)
Definition rdpq_text.h:224
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.
Definition rdpq_text.c:69
void rdpq_text_unregister_font(uint8_t font_id)
Unregister a font from the text engine.
Definition rdpq_text.c:23
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.
Definition rdpq_text.h:389
const rdpq_font_t * rdpq_text_get_font(uint8_t font_id)
Get a registered font by its ID.
Definition rdpq_text.c:30
void rdpq_text_register_font(uint8_t font_id, const rdpq_font_t *font)
Register a new font into the text engine.
Definition rdpq_text.c:16
rdpq_textwrap_t
Print formatting parameters: wrapping modes.
Definition rdpq_text.h:195
@ WRAP_ELLIPSES
Truncate the text adding ellipsis (if any)
Definition rdpq_text.h:197
@ WRAP_CHAR
Wrap at character boundaries.
Definition rdpq_text.h:198
@ WRAP_WORD
Wrap at word boundaries.
Definition rdpq_text.h:199
@ WRAP_NONE
Truncate the text (if any)
Definition rdpq_text.h:196
rdpq_valign_t valign
Vertical alignment (0=top, 1=center, 2=bottom)
Definition rdpq_text.h:226
rdpq_align_t align
Horizontal alignment (0=left, 1=center, 2=right)
Definition rdpq_text.h:225
float advance_y
Y pen advance after rendering the text.
Definition rdpq_text.h:240
bool disable_aa_fix
Obtain a small rendering speedup by disabling the anti-aliasing fix. Can be enabled when anti-alias i...
Definition rdpq_text.h:233
int16_t max_chars
Maximum number of characters to print (0 if unbounded), useful for typewriting effect.
Definition rdpq_text.h:228
int utf8_text_advance
Number of bytes rendered in the UTF-8 text.
Definition rdpq_text.h:241
int16_t style_id
Initial style ID for the text.
Definition rdpq_text.h:222
int16_t * tabstops
Array of tab stops, in pixels (0-terminated). If NULL, tab stops are every 32 pixels.
Definition rdpq_text.h:232
int16_t indent
Indentation of the first line, in pixels (only valid for left alignment)
Definition rdpq_text.h:227
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.
Definition rdpq_text.c:37
int16_t char_spacing
Extra spacing between chars (in addition to glyph width and kerning)
Definition rdpq_text.h:229
int16_t width
Maximum horizontal width of the paragraph, in pixels (0 if unbounded)
Definition rdpq_text.h:223
bool preserve_overlap
Preserve overlapping glyphs when rendering. Notice that this might have a strong performance impact b...
Definition rdpq_text.h:234
rdpq_textwrap_t wrap
Wrap mode.
Definition rdpq_text.h:231
Metrics of formatted text.
Definition rdpq_text.h:238
Print formatting parameters.
Definition rdpq_text.h:221