From 76ee903d84d5b477016fb6ed6bdee1a21e237903 Mon Sep 17 00:00:00 2001 From: Vojtech Bocek Date: Sun, 7 Sep 2014 15:01:56 +0200 Subject: Add support for TrueType fonts * Keeps original font system in place * Uses the same API as original font system: - You can render only one line at a time - You can only use one font and color for one gr_text* call * Caches all rendered text, with a string cache limited to 400 entries, then it trucates to 250, which results in memory usage hovering around 5-10MB Change-Id: I36107b9dcd8d57bae4486fce8b8f64e49ef3d906 Signed-off-by: Vojtech Bocek --- minuitwrp/minui.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'minuitwrp/minui.h') diff --git a/minuitwrp/minui.h b/minuitwrp/minui.h index f04f518b5..cb9f8a385 100644 --- a/minuitwrp/minui.h +++ b/minuitwrp/minui.h @@ -20,6 +20,12 @@ typedef void* gr_surface; typedef unsigned short gr_pixel; +#define FONT_TYPE_TWRP 0 + +#ifndef TW_DISABLE_TTF +#define FONT_TYPE_TTF 1 +#endif + int gr_init(void); void gr_exit(void); @@ -35,16 +41,25 @@ void gr_fill(int x, int y, int w, int h); int gr_textEx(int x, int y, const char *s, void* font); int gr_textExW(int x, int y, const char *s, void* font, int max_width); int gr_textExWH(int x, int y, const char *s, void* pFont, int max_width, int max_height); -int twgr_text(int x, int y, const char *s); static inline int gr_text(int x, int y, const char *s) { return gr_textEx(x, y, s, NULL); } int gr_measureEx(const char *s, void* font); static inline int gr_measure(const char *s) { return gr_measureEx(s, NULL); } int gr_maxExW(const char *s, void* font, int max_width); -int gr_getFontDetails(void* font, unsigned* cheight, unsigned* maxwidth); -static inline void gr_font_size(int *x, int *y) { gr_getFontDetails(NULL, (unsigned*) y, (unsigned*) x); } +int gr_getMaxFontHeight(void *font); void* gr_loadFont(const char* fontName); +void gr_freeFont(void *font); + +#ifndef TW_DISABLE_TTF +void *gr_ttf_loadFont(const char *filename, int size, int dpi); +void gr_ttf_freeFont(void *font); +int gr_ttf_textExWH(void *context, int x, int y, const char *s, void *pFont, int max_width, int max_height); +int gr_ttf_measureEx(const char *s, void *font); +int gr_ttf_maxExW(const char *s, void *font, int max_width); +int gr_ttf_getMaxFontHeight(void *font); +void gr_ttf_dump_stats(void); +#endif void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy); unsigned int gr_get_width(gr_surface surface); -- cgit v1.2.3