summaryrefslogtreecommitdiff
path: root/src/lib/evas/common/evas_font_main.c
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2017-09-25 18:34:22 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-09-26 11:31:31 +0900
commit17504106501cec1a0a85eb380c5dea7e0ca3729c (patch)
tree942944734aa98b84c791206bdc6c5db1e084c3ae /src/lib/evas/common/evas_font_main.c
parentbb887f9869c3dd9eca72c8e65f335d148f9dbdd3 (diff)
evas: Add scale feature for embedded bitmap fonts.
Summary: When evas selects a strike of embedded bitmap font, calculate ratio and use it for scaling embedded bitmap. @feature Reviewers: jpeg, tasn, woohyun, raster, herdsman Reviewed By: raster Subscribers: charlesmilette, Francesco149, cedric Differential Revision: https://phab.enlightenment.org/D2713
Diffstat (limited to '')
-rw-r--r--src/lib/evas/common/evas_font_main.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/lib/evas/common/evas_font_main.c b/src/lib/evas/common/evas_font_main.c
index 91db4d52ec..0b25e31868 100644
--- a/src/lib/evas/common/evas_font_main.c
+++ b/src/lib/evas/common/evas_font_main.c
@@ -115,6 +115,14 @@ evas_common_font_instance_ascent_get(RGBA_Font_Int *fi)
115 WRN("NOT SCALABLE!"); 115 WRN("NOT SCALABLE!");
116 } 116 }
117 val = (int)fi->src->ft.face->size->metrics.ascender; 117 val = (int)fi->src->ft.face->size->metrics.ascender;
118
119 if (FT_HAS_FIXED_SIZES(fi->src->ft.face))
120 {
121 if (FT_HAS_COLOR(fi->src->ft.face) &&
122 fi->bitmap_scalable & EFL_TEXT_FONT_BITMAP_SCALABLE_COLOR)
123 val *= fi->scale_factor;
124 }
125
118 return FONT_METRIC_ROUNDUP(val); 126 return FONT_METRIC_ROUNDUP(val);
119// printf("%i | %i\n", val, val >> 6); 127// printf("%i | %i\n", val, val >> 6);
120// if (fi->src->ft.face->units_per_EM == 0) 128// if (fi->src->ft.face->units_per_EM == 0)
@@ -137,6 +145,14 @@ evas_common_font_instance_descent_get(RGBA_Font_Int *fi)
137 fi->src->current_size = fi->size; 145 fi->src->current_size = fi->size;
138 } 146 }
139 val = -(int)fi->src->ft.face->size->metrics.descender; 147 val = -(int)fi->src->ft.face->size->metrics.descender;
148
149 if (FT_HAS_FIXED_SIZES(fi->src->ft.face))
150 {
151 if (FT_HAS_COLOR(fi->src->ft.face) &&
152 fi->bitmap_scalable & EFL_TEXT_FONT_BITMAP_SCALABLE_COLOR)
153 val *= fi->scale_factor;
154 }
155
140 return FONT_METRIC_ROUNDUP(val); 156 return FONT_METRIC_ROUNDUP(val);
141// if (fi->src->ft.face->units_per_EM == 0) 157// if (fi->src->ft.face->units_per_EM == 0)
142// return val; 158// return val;
@@ -165,6 +181,14 @@ evas_common_font_instance_max_ascent_get(RGBA_Font_Int *fi)
165 val = FONT_METRIC_ROUNDUP((int)fi->src->ft.face->size->metrics.ascender); 181 val = FONT_METRIC_ROUNDUP((int)fi->src->ft.face->size->metrics.ascender);
166 else 182 else
167 val = (int)fi->src->ft.face->bbox.yMax; 183 val = (int)fi->src->ft.face->bbox.yMax;
184
185 if (FT_HAS_FIXED_SIZES(fi->src->ft.face))
186 {
187 if (FT_HAS_COLOR(fi->src->ft.face) &&
188 fi->bitmap_scalable & EFL_TEXT_FONT_BITMAP_SCALABLE_COLOR)
189 val *= fi->scale_factor;
190 }
191
168 if (fi->src->ft.face->units_per_EM == 0) 192 if (fi->src->ft.face->units_per_EM == 0)
169 return val; 193 return val;
170 dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM; 194 dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
@@ -192,6 +216,14 @@ evas_common_font_instance_max_descent_get(RGBA_Font_Int *fi)
192 val = FONT_METRIC_ROUNDUP(-(int)fi->src->ft.face->size->metrics.descender); 216 val = FONT_METRIC_ROUNDUP(-(int)fi->src->ft.face->size->metrics.descender);
193 else 217 else
194 val = -(int)fi->src->ft.face->bbox.yMin; 218 val = -(int)fi->src->ft.face->bbox.yMin;
219
220 if (FT_HAS_FIXED_SIZES(fi->src->ft.face))
221 {
222 if (FT_HAS_COLOR(fi->src->ft.face) &&
223 fi->bitmap_scalable & EFL_TEXT_FONT_BITMAP_SCALABLE_COLOR)
224 val *= fi->scale_factor;
225 }
226
195 if (fi->src->ft.face->units_per_EM == 0) 227 if (fi->src->ft.face->units_per_EM == 0)
196 return val; 228 return val;
197 dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM; 229 dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
@@ -244,6 +276,14 @@ evas_common_font_get_line_advance(RGBA_Font *fn)
244 fi->src->current_size = fi->size; 276 fi->src->current_size = fi->size;
245 } 277 }
246 val = (int)fi->src->ft.face->size->metrics.height; 278 val = (int)fi->src->ft.face->size->metrics.height;
279
280 if (FT_HAS_FIXED_SIZES(fi->src->ft.face))
281 {
282 if ((fi->bitmap_scalable & EFL_TEXT_FONT_BITMAP_SCALABLE_COLOR) &&
283 FT_HAS_COLOR(fi->src->ft.face))
284 val *= fi->scale_factor;
285 }
286
247 if ((fi->src->ft.face->bbox.yMax == 0) && 287 if ((fi->src->ft.face->bbox.yMax == 0) &&
248 (fi->src->ft.face->bbox.yMin == 0) && 288 (fi->src->ft.face->bbox.yMin == 0) &&
249 (fi->src->ft.face->units_per_EM == 0)) 289 (fi->src->ft.face->units_per_EM == 0))
@@ -558,6 +598,19 @@ evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt idx)
558 fg->width = EVAS_FONT_ROUND_26_6_TO_INT(outbox.xMax - outbox.xMin); 598 fg->width = EVAS_FONT_ROUND_26_6_TO_INT(outbox.xMax - outbox.xMin);
559 fg->x_bear = EVAS_FONT_ROUND_26_6_TO_INT(outbox.xMin); 599 fg->x_bear = EVAS_FONT_ROUND_26_6_TO_INT(outbox.xMin);
560 fg->y_bear = EVAS_FONT_ROUND_26_6_TO_INT(outbox.yMax); 600 fg->y_bear = EVAS_FONT_ROUND_26_6_TO_INT(outbox.yMax);
601
602 if (FT_HAS_FIXED_SIZES(fi->src->ft.face))
603 {
604 if (FT_HAS_COLOR(fi->src->ft.face) &&
605 fi->bitmap_scalable & EFL_TEXT_FONT_BITMAP_SCALABLE_COLOR)
606 {
607 fg->glyph->advance.x *= fi->scale_factor;
608 fg->glyph->advance.y *= fi->scale_factor;
609 fg->width *= fi->scale_factor;
610 fg->x_bear *= fi->scale_factor;
611 fg->y_bear *= fi->scale_factor;
612 }
613 }
561 } 614 }
562 615
563 fg->index = idx; 616 fg->index = idx;