edje_text: fix the fit calculation for different text size
authorVyacheslav Reutskiy <v.reutskiy@samsung.com>
Thu, 23 Jun 2016 06:10:07 +0000 (09:10 +0300)
committerVyacheslav Reutskiy <v.reutskiy@samsung.com>
Thu, 23 Jun 2016 06:13:53 +0000 (09:13 +0300)
Fixed T3569

@fix

src/lib/edje/edje_text.c

index 46ebbde..50f8e90 100644 (file)
@@ -333,28 +333,22 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
 
         if (ep->part->scale) efl_canvas_object_scale_set(ep->object, TO_DOUBLE(sc));
 
-        efl_text_properties_font_set(ep->object, font, size);
         efl_text_set(ep->object, text);
+        /* the fit shoult not depend on font size, because it give the differet
+         * size calculation. As base font size for calculate fit size I take
+         * 10 (ten), because this value used for calculate fit by Y below */
+        efl_text_properties_font_set(ep->object, font, 10);
+        part_get_geometry(ep, &tw, &th);
 
+        size = (10 * sw) / tw;
+        efl_text_properties_font_set(ep->object, font, size);
         part_get_geometry(ep, &tw, &th);
-        /* Find the wanted font size */
-        if ((tw != sw) && (size > 0) && (tw != 0))
+        while ((tw > sw) && (size > 1))
           {
-             size = (size * sw) / tw;
-
-             if (inlined_font) efl_text_properties_font_source_set(ep->object, ed->path);
-             else efl_text_properties_font_source_set(ep->object, NULL);
-
-             if (ep->part->scale) efl_canvas_object_scale_set(ep->object, TO_DOUBLE(sc));
-
+             size--;
              efl_text_properties_font_set(ep->object, font, size);
-
              part_get_geometry(ep, &tw, &th);
           }
-
-        /* FIXME: This should possibly be replaced by more proper handling,
-         * but it's still way better than what was here before. */
-        if (tw > sw) size--;
      }
    if (chosen_desc->text.fit_y && (ep->typedata.text->cache.in_str && eina_stringshare_strlen(ep->typedata.text->cache.in_str) > 0))
      {