From b7a54a30167f211647222c0a2f90b369e0e33e32 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Mon, 5 Oct 2015 10:16:27 -0500 Subject: Allow text to scale to fit Change-Id: Iacd4bb78f551b51d092ecde09521b5541e7dadcd --- minuitwrp/truetype.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'minuitwrp/truetype.c') diff --git a/minuitwrp/truetype.c b/minuitwrp/truetype.c index 8f62ff26b..d9ed0198b 100644 --- a/minuitwrp/truetype.c +++ b/minuitwrp/truetype.c @@ -265,6 +265,21 @@ exit: return res; } +void *gr_ttf_scaleFont(void *font, int max_width, int measured_width) +{ + if (!font) + return NULL; + + TrueTypeFont *f = font; + float scale_value = (float)(max_width) / (float)(measured_width); + int new_size = ((int)((float)f->size * scale_value)) - 1; + if (new_size < 1) + new_size = 1; + const char* file = f->key->path; + int dpi = f->dpi; + return gr_ttf_loadFont(file, new_size, dpi); +} + static bool gr_ttf_freeFontCache(void *key, void *value, void *context) { TrueTypeCacheEntry *e = value; -- cgit v1.2.3