evas font: do floating point division for calculating more accurately
authorYoungbok Shin <youngb.shin@samsung.com>
Wed, 30 Aug 2017 18:40:26 +0000 (11:40 -0700)
committerCedric Bail <cedric@osg.samsung.com>
Wed, 30 Aug 2017 19:06:01 +0000 (12:06 -0700)
Summary:
Assigning a result of integral division to a double type variable is
not useful for next division calculation. For more accurate calculation,
it needs to be casted to double before doing division.
It does not fix some bugs. It was reported by a code quality advisor.

Test Plan: N/A

Reviewers: raster, cedric, jpeg, herdsman, eunue

Reviewed By: cedric

Differential Revision: https://phab.enlightenment.org/D5069

Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
src/lib/evas/common/evas_font_query.c

index c52486b..081f9a5 100644 (file)
@@ -755,13 +755,13 @@ evas_common_font_query_char_at_coords(RGBA_Font *fn, const Evas_Text_Props *text
         if (text_props->bidi_dir == EVAS_BIDI_DIRECTION_LTR)
           {
              double part;
-             part = cluster_adv / items;
+             part = (double) cluster_adv / items;
              item_pos = (int) ((x - cluster_start) / part);
           }
         else
           {
              double part;
-             part = cluster_adv / items;
+             part = (double) cluster_adv / items;
              item_pos = items - ((int) ((x - cluster_start) / part)) - 1;
           }