summaryrefslogtreecommitdiffstats
path: root/minuitwrp
diff options
context:
space:
mode:
authorVojtech Bocek <vbocek@gmail.com>2015-03-15 17:03:50 +0100
committerDees Troy <dees_troy@teamw.in>2015-03-19 16:46:13 +0100
commita482f253453a50fc8c12d03205e12b577ef803d6 (patch)
tree994a701035d21eeffdb6e258d372e4d8cc2d4563 /minuitwrp
parentFix GUIPatternPassword when the pattern crosses already visited dots (diff)
downloadandroid_bootable_recovery-a482f253453a50fc8c12d03205e12b577ef803d6.tar
android_bootable_recovery-a482f253453a50fc8c12d03205e12b577ef803d6.tar.gz
android_bootable_recovery-a482f253453a50fc8c12d03205e12b577ef803d6.tar.bz2
android_bootable_recovery-a482f253453a50fc8c12d03205e12b577ef803d6.tar.lz
android_bootable_recovery-a482f253453a50fc8c12d03205e12b577ef803d6.tar.xz
android_bootable_recovery-a482f253453a50fc8c12d03205e12b577ef803d6.tar.zst
android_bootable_recovery-a482f253453a50fc8c12d03205e12b577ef803d6.zip
Diffstat (limited to 'minuitwrp')
-rw-r--r--minuitwrp/truetype.c106
1 files changed, 54 insertions, 52 deletions
diff --git a/minuitwrp/truetype.c b/minuitwrp/truetype.c
index db70236a4..e8a162945 100644
--- a/minuitwrp/truetype.c
+++ b/minuitwrp/truetype.c
@@ -378,6 +378,58 @@ static int gr_ttf_copy_glyph_to_surface(GGLSurface *dest, FT_BitmapGlyph glyph,
return 0;
}
+static void gr_ttf_calcMaxFontHeight(TrueTypeFont *f)
+{
+ char c;
+ int char_idx;
+ int error;
+ FT_Glyph glyph;
+ FT_BBox bbox;
+ FT_BBox bbox_glyph;
+ TrueTypeCacheEntry *ent;
+
+ bbox.yMin = bbox_glyph.yMin = LONG_MAX;
+ bbox.yMax = bbox_glyph.yMax = LONG_MIN;
+
+ for(c = '!'; c <= '~'; ++c)
+ {
+ char_idx = FT_Get_Char_Index(f->face, c);
+ ent = gr_ttf_glyph_cache_peek(f, char_idx);
+ if(ent)
+ {
+ bbox.yMin = MIN(bbox.yMin, ent->bbox.yMin);
+ bbox.yMax = MAX(bbox.yMax, ent->bbox.yMax);
+ }
+ else
+ {
+ error = FT_Load_Glyph(f->face, char_idx, 0);
+ if(error)
+ continue;
+
+ error = FT_Get_Glyph(f->face->glyph, &glyph);
+ if(error)
+ continue;
+
+ FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_PIXELS, &bbox_glyph);
+ bbox.yMin = MIN(bbox.yMin, bbox_glyph.yMin);
+ bbox.yMax = MAX(bbox.yMax, bbox_glyph.yMax);
+
+ FT_Done_Glyph(glyph);
+ }
+ }
+
+ if(bbox.yMin > bbox.yMax)
+ bbox.yMin = bbox.yMax = 0;
+
+ f->max_height = bbox.yMax - bbox.yMin;
+ f->base = bbox.yMax;
+
+ // FIXME: twrp fonts have some padding on top, I'll add it here
+ // Should be fixed in the themes
+ f->max_height += f->size / 4;
+ f->base += f->size / 4;
+}
+
// returns number of bytes from const char *text rendered to fit max_width, not number of UTF8 characters!
static int gr_ttf_render_text(TrueTypeFont *font, GGLSurface *surface, const char *text, int max_width)
{
@@ -426,7 +478,7 @@ static int gr_ttf_render_text(TrueTypeFont *font, GGLSurface *surface, const cha
}
if(font->max_height == -1)
- gr_ttf_getMaxFontHeight(font);
+ gr_ttf_calcMaxFontHeight(font);
if(font->max_height == -1)
{
@@ -681,57 +733,7 @@ int gr_ttf_getMaxFontHeight(void *font)
pthread_mutex_lock(&f->mutex);
if(f->max_height == -1)
- {
- char c;
- int char_idx;
- int error;
- FT_Glyph glyph;
- FT_BBox bbox;
- FT_BBox bbox_glyph;
- TrueTypeCacheEntry *ent;
-
- bbox.yMin = bbox_glyph.yMin = LONG_MAX;
- bbox.yMax = bbox_glyph.yMax = LONG_MIN;
-
- for(c = '!'; c <= '~'; ++c)
- {
- char_idx = FT_Get_Char_Index(f->face, c);
- ent = gr_ttf_glyph_cache_peek(f, char_idx);
- if(ent)
- {
- bbox.yMin = MIN(bbox.yMin, ent->bbox.yMin);
- bbox.yMax = MAX(bbox.yMax, ent->bbox.yMax);
- }
- else
- {
- error = FT_Load_Glyph(f->face, char_idx, 0);
- if(error)
- continue;
-
- error = FT_Get_Glyph(f->face->glyph, &glyph);
- if(error)
- continue;
-
- FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_PIXELS, &bbox_glyph);
- bbox.yMin = MIN(bbox.yMin, bbox_glyph.yMin);
- bbox.yMax = MAX(bbox.yMax, bbox_glyph.yMax);
-
- FT_Done_Glyph(glyph);
- }
- }
-
- if(bbox.yMin > bbox.yMax)
- bbox.yMin = bbox.yMax = 0;
-
- f->max_height = bbox.yMax - bbox.yMin;
- f->base = bbox.yMax;
-
- // FIXME: twrp fonts have some padding on top, I'll add it here
- // Should be fixed in the themes
- f->max_height += f->size / 4;
- f->base += f->size / 4;
- }
-
+ gr_ttf_calcMaxFontHeight(f);
res = f->max_height;
pthread_mutex_unlock(&f->mutex);