From 00d0dd777a144aa008b990ee5346149099546fdf Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Mon, 26 Jan 2004 08:21:00 +0000 Subject: [PATCH] and fix the sizing bug!!!!! all happy now! SVN revision: 8666 --- .../src/lib/engines/common/evas_font_load.c | 90 ++++++++++--------- .../src/lib/engines/common/evas_font_main.c | 24 +++-- legacy/evas/src/lib/include/evas_common.h | 1 + 3 files changed, 58 insertions(+), 57 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_font_load.c b/legacy/evas/src/lib/engines/common/evas_font_load.c index 3267e385fb..f9d14dee8c 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_load.c +++ b/legacy/evas/src/lib/engines/common/evas_font_load.c @@ -39,6 +39,10 @@ evas_common_font_source_memory_load(const char *name, const void *data, int data return NULL; } + error = FT_Select_Charmap(fs->ft.face, ft_encoding_unicode); + + fs->ft.orig_upem = fs->ft.face->units_per_EM; + fs->references = 1; fonts_src = evas_object_list_prepend(fonts_src, fs); @@ -66,6 +70,43 @@ evas_common_font_source_load(const char *name) free(fs); return NULL; } +#if 0 /* debugging to look at charmaps in a ttf */ + printf("%i\n", fs->ft.face->num_charmaps); + { + int i; + + for (i = 0; i < fs->ft.face->num_charmaps; i++) + { + printf("%i: %x, %c\n", + i, fs->ft.face->charmaps[i]->encoding, + fs->ft.face->charmaps[i]->encoding); + } + } +#endif + error = FT_Select_Charmap(fs->ft.face, ft_encoding_unicode); + if (error) + { +/* disable this for now... + error = FT_Select_Charmap(fs->ft.face, ft_encoding_latin_2); + if (error) + { + error = FT_Select_Charmap(fs->ft.face, ft_encoding_sjis); + if (error) + { + error = FT_Select_Charmap(fs->ft.face, ft_encoding_gb2312); + if (error) + { + error = FT_Select_Charmap(fs->ft.face, ft_encoding_big5); + if (error) + { + } + } + } + } + */ + } + + fs->ft.orig_upem = fs->ft.face->units_per_EM; fs->references = 1; @@ -112,9 +153,9 @@ evas_common_font_source_free(RGBA_Font_Source *fs) void evas_common_font_size_use(RGBA_Font *fn) { - if (fn->src->current_size == fn->real_size) return; + if (fn->src->current_size == fn->size) return; FT_Activate_Size(fn->ft.size); - fn->src->current_size = fn->real_size; + fn->src->current_size = fn->size; } RGBA_Font * @@ -172,11 +213,9 @@ evas_common_font_load_init(RGBA_Font *fn) { int error; - if (fn->src->references == 1) - fn->ft.size = fn->src->ft.face->size; - else + error = FT_New_Size(fn->src->ft.face, &(fn->ft.size)); + if (!error) { - error = FT_New_Size(fn->src->ft.face, &(fn->ft.size)); FT_Activate_Size(fn->ft.size); } fn->real_size = fn->size * 64; @@ -216,43 +255,8 @@ evas_common_font_load_init(RGBA_Font *fn) /* couldn't choose the size anyway... what now? */ } } - fn->src->current_size = fn->real_size; + fn->src->current_size = fn->size; -#if 0 /* debugging to look at charmaps in a ttf */ - printf("%i\n", fn->src->ft.face->num_charmaps); - { - int i; - - for (i = 0; i < fn->src->ft.face->num_charmaps; i++) - { - printf("%i: %x, %c\n", - i, fn->src->ft.face->charmaps[i]->encoding, - fn->src->ft.face->charmaps[i]->encoding); - } - } -#endif - error = FT_Select_Charmap(fn->src->ft.face, ft_encoding_unicode); - if (error) - { -/* disable this for now... - error = FT_Select_Charmap(fn->src->ft.face, ft_encoding_latin_2); - if (error) - { - error = FT_Select_Charmap(fn->src->ft.face, ft_encoding_sjis); - if (error) - { - error = FT_Select_Charmap(fn->src->ft.face, ft_encoding_gb2312); - if (error) - { - error = FT_Select_Charmap(fn->src->ft.face, ft_encoding_big5); - if (error) - { - } - } - } - } - */ - } fn->glyphs = NULL; fn->usage = 0; fn->references = 1; @@ -349,7 +353,7 @@ evas_common_font_flush_last(void) } if (!fn) return; - if (fn->src->references > 1) FT_Done_Size(fn->ft.size); + FT_Done_Size(fn->ft.size); fonts = evas_object_list_remove(fonts, fn); evas_common_font_modify_cache_by(fn, -1); diff --git a/legacy/evas/src/lib/engines/common/evas_font_main.c b/legacy/evas/src/lib/engines/common/evas_font_main.c index e835981369..e2842d1305 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_main.c +++ b/legacy/evas/src/lib/engines/common/evas_font_main.c @@ -35,10 +35,8 @@ evas_common_font_ascent_get(RGBA_Font *fn) int ret; evas_common_font_size_use(fn); - val = (int)fn->src->ft.face->ascender; - fn->src->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */ - ret = (val * fn->src->ft.face->size->metrics.y_scale) / (fn->src->ft.face->units_per_EM * fn->src->ft.face->units_per_EM); - return ret; + val = (int)fn->src->ft.face->size->metrics.ascender; + return val; } int @@ -48,35 +46,33 @@ evas_common_font_descent_get(RGBA_Font *fn) int ret; evas_common_font_size_use(fn); - val = -(int)fn->src->ft.face->descender; - fn->src->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */ - ret = (val * fn->src->ft.face->size->metrics.y_scale) / (fn->src->ft.face->units_per_EM * fn->src->ft.face->units_per_EM); - return ret; + val = -(int)fn->src->ft.face->size->metrics.descender; + return val; } int evas_common_font_max_ascent_get(RGBA_Font *fn) { - int val; + int val, dv; int ret; evas_common_font_size_use(fn); val = (int)fn->src->ft.face->bbox.yMax; - fn->src->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */ - ret = (val * fn->src->ft.face->size->metrics.y_scale) / (fn->src->ft.face->units_per_EM * fn->src->ft.face->units_per_EM); + dv = (fn->src->ft.orig_upem * 2048) / fn->src->ft.face->units_per_EM; + ret = (val * fn->src->ft.face->size->metrics.y_scale) / (dv * dv); return ret; } int evas_common_font_max_descent_get(RGBA_Font *fn) { - int val; + int val, dv; int ret; evas_common_font_size_use(fn); val = -(int)fn->src->ft.face->bbox.yMin; - fn->src->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */ - ret = (val * fn->src->ft.face->size->metrics.y_scale) / (fn->src->ft.face->units_per_EM * fn->src->ft.face->units_per_EM); + dv = (fn->src->ft.orig_upem * 2048) / fn->src->ft.face->units_per_EM; + ret = (val * fn->src->ft.face->size->metrics.y_scale) / (dv * dv); return ret; } diff --git a/legacy/evas/src/lib/include/evas_common.h b/legacy/evas/src/lib/include/evas_common.h index f6c1177098..70b54ad1a5 100644 --- a/legacy/evas/src/lib/include/evas_common.h +++ b/legacy/evas/src/lib/include/evas_common.h @@ -363,6 +363,7 @@ struct _RGBA_Font_Source int current_size; struct { + int orig_upem; FT_Face face; } ft; -- 2.34.1