From 281043e35718b3d6c5dec81d081c7785ed40bb90 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 14 Jul 2016 16:52:01 +0100 Subject: [PATCH] Revert "Evas font: fix width query for OT" This was not done correctly. This split the code, which is essentially the same for both OT and non OT. It's the same logic with some minor additions for OT, so most of the code should be together. This reverts commit ef817f15f0eaec9704ec25d9468c2c8497a5bc13. --- src/lib/evas/common/evas_font_query.c | 93 +++++++---------------------------- 1 file changed, 17 insertions(+), 76 deletions(-) diff --git a/src/lib/evas/common/evas_font_query.c b/src/lib/evas/common/evas_font_query.c index cf977e9..f435b9b 100644 --- a/src/lib/evas/common/evas_font_query.c +++ b/src/lib/evas/common/evas_font_query.c @@ -314,81 +314,6 @@ evas_common_font_ascent_descent_get(RGBA_Font *fn, const Evas_Text_Props *text_p if (descent) *descent = (desc < max_desc) ? desc : max_desc; } -#ifdef OT_SUPPORT -static inline Evas_Coord -_evas_common_font_query_width_ot(const Evas_Text_Props *text_props) -{ - Evas_Coord ret_w = 0; - - if (text_props->len > 0) - { - size_t off = text_props->start + text_props->len - 1; - const Evas_Font_Glyph_Info *glyph = text_props->info->glyph + off; - Evas_Font_OT_Info *ot = text_props->info->ot + off; - size_t cluster = ot->source_cluster; - - do - { - Evas_Coord pen_x = (off > 0) ? glyph[-1].pen_after : 0; - Evas_Coord w = pen_x + glyph->x_bear + glyph->width + - EVAS_FONT_ROUND_26_6_TO_INT(EVAS_FONT_OT_X_OFF_GET(*ot)); - if (w > ret_w) - { - ret_w = w; - } - - glyph--; - ot--; - } while((off-- > text_props->start) && (ot->source_cluster == cluster)); - - if (text_props->start > 0) - { - ret_w -= text_props->info->glyph[text_props->start - 1].pen_after; - } - } - - return ret_w; -} -#else -static inline Evas_Coord -_evas_common_font_query_width_regular(const Evas_Text_Props *text_props) -{ - Evas_Coord ret_w = 0; - - if (text_props->len > 0) - { - const Evas_Font_Glyph_Info *last_glyph = text_props->info->glyph + - text_props->start + text_props->len - 1; - - if (text_props->len > 1) - { - const Evas_Font_Glyph_Info *glyph = text_props->info->glyph + - text_props->start; - - ret_w = last_glyph[-1].pen_after; - if (text_props->start > 0) - ret_w -= glyph[-1].pen_after; - } - - ret_w += last_glyph->width + last_glyph->x_bear; - } - - return ret_w; -} -#endif - -static inline Evas_Coord -_evas_common_font_query_width(const Evas_Text_Props *text_props) -{ - Evas_Coord ret_w; -#ifdef OT_SUPPORT - ret_w = _evas_common_font_query_width_ot(text_props); -#else - ret_w = _evas_common_font_query_width_regular(text_props); -#endif - return ret_w; -} - /** * @internal * Calculate the size of the string (width and height). @@ -408,8 +333,24 @@ evas_common_font_query_size(RGBA_Font *fn, const Evas_Text_Props *text_props, in if (text_props->len > 0) { - ret_w = _evas_common_font_query_width(text_props); + const Evas_Font_Glyph_Info *glyph = text_props->info->glyph + + text_props->start; + const Evas_Font_Glyph_Info *last_glyph = glyph; + + if (text_props->len > 1) + { + last_glyph += text_props->len - 1; + ret_w = last_glyph[-1].pen_after; + if (text_props->start > 0) + ret_w -= glyph[-1].pen_after; + } +#ifdef OT_SUPPORT + ret_w += EVAS_FONT_ROUND_26_6_TO_INT(EVAS_FONT_OT_X_OFF_GET( + text_props->info->ot[text_props->start + text_props->len - 1])); +#endif + ret_w += last_glyph->width + last_glyph->x_bear; } + if (w) *w = ret_w; if (h) *h = evas_common_font_max_ascent_get(fn) + evas_common_font_max_descent_get(fn); } -- 2.7.4