From 66bfd09ec2e4a9fa4918f812a631f50c40b9dc54 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 26 Mar 2013 01:19:22 +0900 Subject: [PATCH] Modified to auto-resize texts when the calculated height is taller than the bounding box --- scl/gwes/efl/sclgraphics-efl.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scl/gwes/efl/sclgraphics-efl.cpp b/scl/gwes/efl/sclgraphics-efl.cpp index d73013e..40aff7c 100644 --- a/scl/gwes/efl/sclgraphics-efl.cpp +++ b/scl/gwes/efl/sclgraphics-efl.cpp @@ -660,11 +660,18 @@ CSCLGraphicsImplEfl::draw_text(sclwindow window, const scldrawctx draw_ctx, cons sclint hardcoded_width = find_hardcoded_width(str, font_info.font_size); if (hardcoded_width != 0) calwidth = hardcoded_width; - if (calwidth > width) { + if (calwidth > width || calheight > height) { + sclfloat width_rate = (sclfloat)width / (sclfloat)calwidth; + sclfloat height_rate = (sclfloat)height / (sclfloat)calheight; + sclfloat resize_rate = height_rate; + if (width_rate < height_rate) { + resize_rate = width_rate; + } + snprintf(strStyle, 128, "DEFAULT='font=%s font_size=%d align=%s color=#%02X%02X%02X%02X wrap=word left_margin=%d right_margin=%d'", font_info.font_name, - (int)(SCL_LABEL_OVERLENGTH_TEXT_RESIZE_RATE * font_info.font_size * ((float)width / (float)calwidth)), + (int)(SCL_LABEL_OVERLENGTH_TEXT_RESIZE_RATE * font_info.font_size * resize_rate), (((int)align % 3) == 1 ) ? "center" : ((((int)align % 3) == 2 ) ? "right" : "left"), color.r, color.g, color.b, color.a, padding_x, padding_x); evas_textblock_style_set(st, strStyle); -- 2.7.4