summaryrefslogtreecommitdiff
path: root/legacy/evas
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-10-10 06:07:38 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-10-10 06:07:38 +0000
commitaad2041e5522797bb850cf6bc210f0b49c47e8c6 (patch)
tree979b4b1a96e0a0591ca4136cd9ee2c872ea89fdc /legacy/evas
parentf91826870daf36209f642cf3b86362f2b8784e97 (diff)
fix font rounding in evas to round and not floor - fixes some rare
font sizing issues. SVN revision: 77688
Diffstat (limited to 'legacy/evas')
-rw-r--r--legacy/evas/ChangeLog5
-rw-r--r--legacy/evas/NEWS1
-rw-r--r--legacy/evas/src/lib/engines/common/evas_font_load.c8
-rw-r--r--legacy/evas/src/lib/engines/common/evas_font_main.c16
-rw-r--r--legacy/evas/src/lib/engines/common/evas_font_private.h15
5 files changed, 33 insertions, 12 deletions
diff --git a/legacy/evas/ChangeLog b/legacy/evas/ChangeLog
index 8ee08f965b..83c997651e 100644
--- a/legacy/evas/ChangeLog
+++ b/legacy/evas/ChangeLog
@@ -1086,3 +1086,8 @@
1086 This change adds Eo support to Evas while keeping the old API intact. 1086 This change adds Eo support to Evas while keeping the old API intact.
1087 For more information, go to Eo. 1087 For more information, go to Eo.
1088 1088
10892012-10-10 Carsten Haitzler (The Rasterman)
1090
1091 * Fix font sizing issues when size scaling happens to down down
1092 when it should round up. happens in rare sizing situations and fonts.
1093
diff --git a/legacy/evas/NEWS b/legacy/evas/NEWS
index e06cfe7e25..b0ac447717 100644
--- a/legacy/evas/NEWS
+++ b/legacy/evas/NEWS
@@ -25,6 +25,7 @@ Fixes:
25 * Fix evas_object_image_alpha_set when image data not loaded yet. 25 * Fix evas_object_image_alpha_set when image data not loaded yet.
26 * Fix map surface leak. 26 * Fix map surface leak.
27 * Fix native surface set to null crash bug in gl engine. 27 * Fix native surface set to null crash bug in gl engine.
28 * Fix font sizing issue with some rare sizes and fonts when rounding wrong.
28 29
29Removal: 30Removal:
30 * No more support s3c6410. 31 * No more support s3c6410.
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 33126ad129..11b46f9bd3 100644
--- a/legacy/evas/src/lib/engines/common/evas_font_load.c
+++ b/legacy/evas/src/lib/engines/common/evas_font_load.c
@@ -455,13 +455,13 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi)
455 if (fi->src->ft.face->units_per_EM != 0) 455 if (fi->src->ft.face->units_per_EM != 0)
456 { 456 {
457 dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM; 457 dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
458 ret = (val * fi->src->ft.face->size->metrics.y_scale) / (dv * dv); 458 ret = FONT_MERTIC_CONV(val, dv, fi->src->ft.face->size->metrics.y_scale);
459 } 459 }
460 else 460 else
461 { 461 {
462 if ((fi->src->ft.face->bbox.yMax == 0) && 462 if ((fi->src->ft.face->bbox.yMax == 0) &&
463 (fi->src->ft.face->bbox.yMin == 0)) 463 (fi->src->ft.face->bbox.yMin == 0))
464 ret = (int)fi->ft.size->metrics.ascender / 64; 464 ret = FONT_METRIC_ROUNDUP((int)fi->ft.size->metrics.ascender);
465 else 465 else
466 ret = val; 466 ret = val;
467 } 467 }
@@ -470,13 +470,13 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi)
470 if (fi->src->ft.face->units_per_EM != 0) 470 if (fi->src->ft.face->units_per_EM != 0)
471 { 471 {
472 dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM; 472 dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
473 ret = (val * fi->src->ft.face->size->metrics.y_scale) / (dv * dv); 473 ret = FONT_MERTIC_CONV(val, dv, fi->src->ft.face->size->metrics.y_scale);
474 } 474 }
475 else 475 else
476 { 476 {
477 if ((fi->src->ft.face->bbox.yMax == 0) && 477 if ((fi->src->ft.face->bbox.yMax == 0) &&
478 (fi->src->ft.face->bbox.yMin == 0)) 478 (fi->src->ft.face->bbox.yMin == 0))
479 ret = -(int)fi->ft.size->metrics.descender / 64; 479 ret = FONT_METRIC_ROUNDUP(-(int)fi->ft.size->metrics.descender);
480 else 480 else
481 ret = val; 481 ret = val;
482 } 482 }
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 ecbe263059..1154bd7e12 100644
--- a/legacy/evas/src/lib/engines/common/evas_font_main.c
+++ b/legacy/evas/src/lib/engines/common/evas_font_main.c
@@ -112,7 +112,7 @@ evas_common_font_ascent_get(RGBA_Font *fn)
112 WRN("NOT SCALABLE!"); 112 WRN("NOT SCALABLE!");
113 } 113 }
114 val = (int)fi->src->ft.face->size->metrics.ascender; 114 val = (int)fi->src->ft.face->size->metrics.ascender;
115 return val >> 6; 115 return FONT_METRIC_ROUNDUP(val);
116// printf("%i | %i\n", val, val >> 6); 116// printf("%i | %i\n", val, val >> 6);
117// if (fi->src->ft.face->units_per_EM == 0) 117// if (fi->src->ft.face->units_per_EM == 0)
118// return val; 118// return val;
@@ -138,7 +138,7 @@ evas_common_font_descent_get(RGBA_Font *fn)
138 fi->src->current_size = fi->size; 138 fi->src->current_size = fi->size;
139 } 139 }
140 val = -(int)fi->src->ft.face->size->metrics.descender; 140 val = -(int)fi->src->ft.face->size->metrics.descender;
141 return val >> 6; 141 return FONT_METRIC_ROUNDUP(val);
142// if (fi->src->ft.face->units_per_EM == 0) 142// if (fi->src->ft.face->units_per_EM == 0)
143// return val; 143// return val;
144// dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM; 144// dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
@@ -166,13 +166,13 @@ evas_common_font_max_ascent_get(RGBA_Font *fn)
166 if ((fi->src->ft.face->bbox.yMax == 0) && 166 if ((fi->src->ft.face->bbox.yMax == 0) &&
167 (fi->src->ft.face->bbox.yMin == 0) && 167 (fi->src->ft.face->bbox.yMin == 0) &&
168 (fi->src->ft.face->units_per_EM == 0)) 168 (fi->src->ft.face->units_per_EM == 0))
169 val = (int)fi->src->ft.face->size->metrics.ascender / 64; 169 val = FONT_METRIC_ROUNDUP((int)fi->src->ft.face->size->metrics.ascender);
170 else 170 else
171 val = (int)fi->src->ft.face->bbox.yMax; 171 val = (int)fi->src->ft.face->bbox.yMax;
172 if (fi->src->ft.face->units_per_EM == 0) 172 if (fi->src->ft.face->units_per_EM == 0)
173 return val; 173 return val;
174 dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM; 174 dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
175 ret = (val * fi->src->ft.face->size->metrics.y_scale) / (dv * dv); 175 ret = FONT_MERTIC_CONV(val, dv, fi->src->ft.face->size->metrics.y_scale);
176 return ret; 176 return ret;
177} 177}
178 178
@@ -196,13 +196,13 @@ evas_common_font_max_descent_get(RGBA_Font *fn)
196 if ((fi->src->ft.face->bbox.yMax == 0) && 196 if ((fi->src->ft.face->bbox.yMax == 0) &&
197 (fi->src->ft.face->bbox.yMin == 0) && 197 (fi->src->ft.face->bbox.yMin == 0) &&
198 (fi->src->ft.face->units_per_EM == 0)) 198 (fi->src->ft.face->units_per_EM == 0))
199 val = -(int)fi->src->ft.face->size->metrics.descender / 64; 199 val = FONT_METRIC_ROUNDUP(-(int)fi->src->ft.face->size->metrics.descender);
200 else 200 else
201 val = -(int)fi->src->ft.face->bbox.yMin; 201 val = -(int)fi->src->ft.face->bbox.yMin;
202 if (fi->src->ft.face->units_per_EM == 0) 202 if (fi->src->ft.face->units_per_EM == 0)
203 return val; 203 return val;
204 dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM; 204 dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
205 ret = (val * fi->src->ft.face->size->metrics.y_scale) / (dv * dv); 205 ret = FONT_MERTIC_CONV(val, dv, fi->src->ft.face->size->metrics.y_scale);
206 return ret; 206 return ret;
207} 207}
208 208
@@ -226,10 +226,10 @@ evas_common_font_get_line_advance(RGBA_Font *fn)
226 if ((fi->src->ft.face->bbox.yMax == 0) && 226 if ((fi->src->ft.face->bbox.yMax == 0) &&
227 (fi->src->ft.face->bbox.yMin == 0) && 227 (fi->src->ft.face->bbox.yMin == 0) &&
228 (fi->src->ft.face->units_per_EM == 0)) 228 (fi->src->ft.face->units_per_EM == 0))
229 return val >> 6; 229 return FONT_METRIC_ROUNDUP(val);
230 else if (fi->src->ft.face->units_per_EM == 0) 230 else if (fi->src->ft.face->units_per_EM == 0)
231 return val; 231 return val;
232 return val >> 6; 232 return FONT_METRIC_ROUNDUP(val);
233// dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM; 233// dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
234// ret = (val * fi->src->ft.face->size->metrics.y_scale) / (dv * dv); 234// ret = (val * fi->src->ft.face->size->metrics.y_scale) / (dv * dv);
235// return ret; 235// return ret;
diff --git a/legacy/evas/src/lib/engines/common/evas_font_private.h b/legacy/evas/src/lib/engines/common/evas_font_private.h
index 2a2a382f89..c50cbb0c46 100644
--- a/legacy/evas/src/lib/engines/common/evas_font_private.h
+++ b/legacy/evas/src/lib/engines/common/evas_font_private.h
@@ -46,5 +46,20 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi);
46 ((0x202A <= (x)) && ((x) <= 0x202E)) /* BIDI stuff */ \ 46 ((0x202A <= (x)) && ((x) <= 0x202E)) /* BIDI stuff */ \
47 ) 47 )
48 48
49# if 1
50// do proper round (up or down like 1.4 -> 1 and 1.6 -> 2 etc
51# define FONT_MERTIC_CONV(val, dv, scale) \
52 (((long long)((val) * (scale)) + (long long)((dv) * (dv) / 2LL)) \
53 / (long long)((dv) * (dv)))
54# define FONT_METRIC_ROUNDUP(val) \
55 (((val) + 31) >> 6)
56# else
57// truncate/round down
58# define FONT_MERTIC_CONV(val, dv, scale) \
59 (((val) * (scale)) / ((dv) * (dv)))
60# define FONT_METRIC_ROUNDUP(val) \
61 ((val) >> 6)
62# endif
63
49# include "evas_font_default_walk.x" 64# include "evas_font_default_walk.x"
50#endif /* !_EVAS_FONT_PRIVATE_H */ 65#endif /* !_EVAS_FONT_PRIVATE_H */