3.2 Data Structures
/* Character glyph metrics */
typedef struct {
uint16_t width; /* Character width in pixels */
uint16_t height; /* Character height in pixels */
int16_t bearing_x; /* X offset of glyph origin */
int16_t bearing_y; /* Y offset of glyph origin */
uint16_t advance; /* Advance to next character */
uint16_t tex_x; /* Texture X coordinate */
uint16_t tex_y; /* Texture Y coordinate */
uint16_t tex_w; /* Texture width */
uint16_t tex_h; /* Texture height */
} d3tui_glyph_t;
/* Font face */
typedef struct {
char name[32]; /* Font name */
uint16_t size; /* Font size in points */
uint16_t line_height; /* Line height in pixels */
pvr_ptr_t texture; /* PVR2 texture pointer */
d3tui_glyph_t *glyphs; /* Array of glyphs (256 for ASCII) */
uint16_t tex_width; /* Texture atlas width */
uint16_t tex_height; /* Texture atlas height */
} d3tui_font_t;
/* Render context */
typedef struct {
d3tui_font_t *font; /* Current font */
uint32_t fg_color; /* Current foreground color */
uint32_t bg_color; /* Current background color */
uint16_t cursor_x; /* Cursor X position in pixels */
uint16_t cursor_y; /* Cursor Y position in pixels */
uint16_t cell_w; /* Cell width in pixels */
uint16_t cell_h; /* Cell height in pixels */
uint16_t screen_w; /* Screen width in pixels */
uint16_t screen_h; /* Screen height in pixels */
bool dirty; /* Screen needs redraw */
} d3tui_render_ctx_t;