summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
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
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 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_draw.h2
-rw-r--r--src/lib/evas/common/evas_draw_main.c2
-rw-r--r--src/lib/evas/common/evas_font.h22
-rw-r--r--src/lib/evas/common/evas_font_compress.c11
-rw-r--r--src/lib/evas/common/evas_font_draw.c60
-rw-r--r--src/lib/evas/common/evas_font_load.c75
-rw-r--r--src/lib/evas/common/evas_font_main.c53
7 files changed, 165 insertions, 60 deletions
diff --git a/src/lib/evas/common/evas_draw.h b/src/lib/evas/common/evas_draw.h
index 28b7c9429f..e045a186ce 100644
--- a/src/lib/evas/common/evas_draw.h
+++ b/src/lib/evas/common/evas_draw.h
@@ -11,7 +11,7 @@ EAPI void evas_common_draw_context_font_ext_set (RGBA_D
11 void *data, 11 void *data,
12 void *(*gl_new) (void *data, RGBA_Font_Glyph *fg), 12 void *(*gl_new) (void *data, RGBA_Font_Glyph *fg),
13 void (*gl_free) (void *ext_dat), 13 void (*gl_free) (void *ext_dat),
14 void (*gl_draw) (void *data, void *dest, void *context, RGBA_Font_Glyph *fg, int x, int y), 14 void (*gl_draw) (void *data, void *dest, void *context, RGBA_Font_Glyph *fg, int x, int y, int w, int h),
15 void *(*gl_image_new) (void *gc, RGBA_Font_Glyph *fg, int alpha, Evas_Colorspace cspace), 15 void *(*gl_image_new) (void *gc, RGBA_Font_Glyph *fg, int alpha, Evas_Colorspace cspace),
16 void (*gl_image_free) (void *image), 16 void (*gl_image_free) (void *image),
17 void (*gl_image_draw) (void *gc, void *im, int dx, int dy, int dw, int dh, int smooth)); 17 void (*gl_image_draw) (void *gc, void *im, int dx, int dy, int dw, int dh, int smooth));
diff --git a/src/lib/evas/common/evas_draw_main.c b/src/lib/evas/common/evas_draw_main.c
index d6b0a8942b..2f3fa949de 100644
--- a/src/lib/evas/common/evas_draw_main.c
+++ b/src/lib/evas/common/evas_draw_main.c
@@ -215,7 +215,7 @@ evas_common_draw_context_font_ext_set(RGBA_Draw_Context *dc,
215 void *data, 215 void *data,
216 void *(*gl_new) (void *data, RGBA_Font_Glyph *fg), 216 void *(*gl_new) (void *data, RGBA_Font_Glyph *fg),
217 void (*gl_free) (void *ext_dat), 217 void (*gl_free) (void *ext_dat),
218 void (*gl_draw) (void *data, void *dest, void *context, RGBA_Font_Glyph *fg, int x, int y), 218 void (*gl_draw) (void *data, void *dest, void *context, RGBA_Font_Glyph *fg, int x, int y, int w, int h),
219 void *(*gl_image_new) (void *gc, RGBA_Font_Glyph *fg, int alpha, Evas_Colorspace cspace), 219 void *(*gl_image_new) (void *gc, RGBA_Font_Glyph *fg, int alpha, Evas_Colorspace cspace),
220 void (*gl_image_free) (void *image), 220 void (*gl_image_free) (void *image),
221 void (*gl_image_draw) (void *gc, void *im, int dx, int dy, int dw, int dh, int smooth)) 221 void (*gl_image_draw) (void *gc, void *im, int dx, int dy, int dw, int dh, int smooth))
diff --git a/src/lib/evas/common/evas_font.h b/src/lib/evas/common/evas_font.h
index f9f8026c85..b50b68d530 100644
--- a/src/lib/evas/common/evas_font.h
+++ b/src/lib/evas/common/evas_font.h
@@ -46,27 +46,27 @@ EAPI int evas_common_font_source_load_complete (RGBA_Font_Source *
46EAPI RGBA_Font_Source *evas_common_font_source_find (const char *name); 46EAPI RGBA_Font_Source *evas_common_font_source_find (const char *name);
47EAPI void evas_common_font_source_free (RGBA_Font_Source *fs); 47EAPI void evas_common_font_source_free (RGBA_Font_Source *fs);
48EAPI void evas_common_font_size_use (RGBA_Font *fn); 48EAPI void evas_common_font_size_use (RGBA_Font *fn);
49EAPI RGBA_Font_Int *evas_common_font_int_load (const char *name, int size, Font_Rend_Flags wanted_rend); 49EAPI RGBA_Font_Int *evas_common_font_int_load (const char *name, int size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable);
50EAPI RGBA_Font_Int *evas_common_font_int_load_init (RGBA_Font_Int *fn); 50EAPI RGBA_Font_Int *evas_common_font_int_load_init (RGBA_Font_Int *fn);
51EAPI RGBA_Font_Int *evas_common_font_int_load_complete (RGBA_Font_Int *fi); 51EAPI RGBA_Font_Int *evas_common_font_int_load_complete (RGBA_Font_Int *fi);
52EAPI RGBA_Font *evas_common_font_memory_load (const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend); 52EAPI RGBA_Font *evas_common_font_memory_load (const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable);
53EAPI RGBA_Font *evas_common_font_load (const char *name, int size, Font_Rend_Flags wanted_rend); 53EAPI RGBA_Font *evas_common_font_load (const char *name, int size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable);
54EAPI RGBA_Font *evas_common_font_add (RGBA_Font *fn, const char *name, int size, Font_Rend_Flags wanted_rend); 54EAPI RGBA_Font *evas_common_font_add (RGBA_Font *fn, const char *name, int size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable);
55EAPI RGBA_Font *evas_common_font_memory_add (RGBA_Font *fn, const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend); 55EAPI RGBA_Font *evas_common_font_memory_add (RGBA_Font *fn, const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable);
56EAPI void evas_common_font_free (RGBA_Font *fn); 56EAPI void evas_common_font_free (RGBA_Font *fn);
57EAPI void evas_common_font_int_unref (RGBA_Font_Int *fi); 57EAPI void evas_common_font_int_unref (RGBA_Font_Int *fi);
58EAPI void evas_common_font_hinting_set (RGBA_Font *fn, Font_Hint_Flags hinting); 58EAPI void evas_common_font_hinting_set (RGBA_Font *fn, Font_Hint_Flags hinting);
59EAPI Eina_Bool evas_common_hinting_available (Font_Hint_Flags hinting); 59EAPI Eina_Bool evas_common_hinting_available (Font_Hint_Flags hinting);
60EAPI RGBA_Font *evas_common_font_memory_hinting_load (const char *source, const char *name, int size, const void *data, int data_size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend); 60EAPI RGBA_Font *evas_common_font_memory_hinting_load (const char *source, const char *name, int size, const void *data, int data_size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable);
61EAPI RGBA_Font *evas_common_font_hinting_load (const char *name, int size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend); 61EAPI RGBA_Font *evas_common_font_hinting_load (const char *name, int size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable);
62EAPI RGBA_Font *evas_common_font_hinting_add (RGBA_Font *fn, const char *name, int size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend); 62EAPI RGBA_Font *evas_common_font_hinting_add (RGBA_Font *fn, const char *name, int size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable);
63EAPI RGBA_Font *evas_common_font_memory_hinting_add (RGBA_Font *fn, const char *source, const char *name, int size, const void *data, int data_size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend); 63EAPI RGBA_Font *evas_common_font_memory_hinting_add (RGBA_Font *fn, const char *source, const char *name, int size, const void *data, int data_size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable);
64EAPI void evas_common_font_int_modify_cache_by (RGBA_Font_Int *fi, int dir); 64EAPI void evas_common_font_int_modify_cache_by (RGBA_Font_Int *fi, int dir);
65EAPI int evas_common_font_cache_get (void); 65EAPI int evas_common_font_cache_get (void);
66EAPI void evas_common_font_cache_set (int size); 66EAPI void evas_common_font_cache_set (int size);
67EAPI void evas_common_font_flush (void); 67EAPI void evas_common_font_flush (void);
68EAPI void evas_common_font_flush_last (void); 68EAPI void evas_common_font_flush_last (void);
69EAPI RGBA_Font_Int *evas_common_font_int_find (const char *name, int size, Font_Rend_Flags wanted_rend); 69EAPI RGBA_Font_Int *evas_common_font_int_find (const char *name, int size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable);
70EAPI void evas_common_font_all_clear (void); 70EAPI void evas_common_font_all_clear (void);
71EAPI void evas_common_font_ext_clear (void); 71EAPI void evas_common_font_ext_clear (void);
72 72
@@ -85,7 +85,7 @@ EAPI int evas_common_font_query_run_font_end_get(RGBA_Font *fn, RG
85EAPI void evas_common_font_ascent_descent_get(RGBA_Font *fn, const Evas_Text_Props *text_props, int *ascent, int *descent); 85EAPI void evas_common_font_ascent_descent_get(RGBA_Font *fn, const Evas_Text_Props *text_props, int *ascent, int *descent);
86 86
87EAPI void *evas_common_font_glyph_compress(void *data, int num_grays, int pixel_mode, int pitch_data, int w, int h, int *size_ret); 87EAPI void *evas_common_font_glyph_compress(void *data, int num_grays, int pixel_mode, int pitch_data, int w, int h, int *size_ret);
88EAPI void evas_common_font_glyph_draw(RGBA_Font_Glyph *fg, RGBA_Draw_Context *dc, RGBA_Image *dst, int dst_pitch, int x, int y, int cx, int cy, int cw, int ch); 88EAPI void evas_common_font_glyph_draw(RGBA_Font_Glyph *fg, RGBA_Draw_Context *dc, RGBA_Image *dst, int dst_pitch, int dx, int dy, int dw, int dh, int cx, int cy, int cw, int ch);
89EAPI DATA8 *evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret); 89EAPI DATA8 *evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret);
90 90
91void evas_common_font_load_init(void); 91void evas_common_font_load_init(void);
diff --git a/src/lib/evas/common/evas_font_compress.c b/src/lib/evas/common/evas_font_compress.c
index 3a0e90c64f..5e7658caf8 100644
--- a/src/lib/evas/common/evas_font_compress.c
+++ b/src/lib/evas/common/evas_font_compress.c
@@ -482,14 +482,19 @@ EAPI void
482evas_common_font_glyph_draw(RGBA_Font_Glyph *fg, 482evas_common_font_glyph_draw(RGBA_Font_Glyph *fg,
483 RGBA_Draw_Context *dc, 483 RGBA_Draw_Context *dc,
484 RGBA_Image *dst_image, int dst_pitch, 484 RGBA_Image *dst_image, int dst_pitch,
485 int x, int y, int cx, int cy, int cw, int ch) 485 int dx, int dy, int dw, int dh, int cx, int cy, int cw, int ch)
486{ 486{
487 RGBA_Font_Glyph_Out *fgo = fg->glyph_out; 487 RGBA_Font_Glyph_Out *fgo = fg->glyph_out;
488 int w, h, x1, x2, y1, y2, i, *iptr; 488 int x, y, w, h, x1, x2, y1, y2, i, *iptr;
489 DATA32 *dst = dst_image->image.data; 489 DATA32 *dst = dst_image->image.data;
490 DATA32 coltab[16], col; 490 DATA32 coltab[16], col;
491 DATA16 mtab[16], v; 491 DATA16 mtab[16], v;
492 492
493 // FIXME: Use dw, dh for scaling glyphs...
494 (void) dw;
495 (void) dh;
496 x = dx;
497 y = dy;
493 w = fgo->bitmap.width; h = fgo->bitmap.rows; 498 w = fgo->bitmap.width; h = fgo->bitmap.rows;
494 // skip if totally clipped out 499 // skip if totally clipped out
495 if ((y >= (cy + ch)) || ((y + h) <= cy) || 500 if ((y >= (cy + ch)) || ((y + h) <= cy) ||
@@ -582,7 +587,7 @@ evas_common_font_glyph_draw(RGBA_Font_Glyph *fg,
582 587
583 ptr = dst + (x + x1) + ((y + row) * dst_pitch); 588 ptr = dst + (x + x1) + ((y + row) * dst_pitch);
584 buf_ptr = buf + (row * w) + x1; 589 buf_ptr = buf + (row * w) + x1;
585 func(buf_ptr, mask, 0, ptr, x2 - x1); 590 func(buf_ptr, mask, 0, ptr, w);
586 } 591 }
587 } 592 }
588 else 593 else
diff --git a/src/lib/evas/common/evas_font_draw.c b/src/lib/evas/common/evas_font_draw.c
index f7fcb13bd8..4bdecddafe 100644
--- a/src/lib/evas/common/evas_font_draw.c
+++ b/src/lib/evas/common/evas_font_draw.c
@@ -24,16 +24,25 @@ evas_common_font_draw_init(void)
24} 24}
25 25
26static void * 26static void *
27_evas_font_image_new_from_data(int w, int h, DATA32 *image_data, int alpha, Evas_Colorspace cspace) 27_evas_font_image_new(RGBA_Font_Glyph *fg, int alpha, Evas_Colorspace cspace)
28{ 28{
29 DATA32 *image_data;
30 int src_w, src_h;
31
32 if (!fg) return NULL;
33
34 image_data = (DATA32 *)fg->glyph_out->bitmap.buffer;
35 src_w = fg->glyph_out->bitmap.width;
36 src_h = fg->glyph_out->bitmap.rows;
37
29#ifdef EVAS_CSERVE2 38#ifdef EVAS_CSERVE2
30 if (evas_cserve2_use_get()) 39 if (evas_cserve2_use_get())
31 { 40 {
32 Evas_Cache2 *cache = evas_common_image_cache2_get(); 41 Evas_Cache2 *cache = evas_common_image_cache2_get();
33 return evas_cache2_image_data(cache, w, h, image_data, alpha, cspace); 42 return evas_cache2_image_data(cache, src_w, src_h, image_data, alpha, cspace);
34 } 43 }
35#endif 44#endif
36 return evas_cache_image_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace); 45 return evas_cache_image_data(evas_common_image_cache_get(), src_w, src_h, image_data, alpha, cspace);
37} 46}
38 47
39static void 48static void
@@ -50,12 +59,15 @@ _evas_font_image_free(void *image)
50} 59}
51 60
52static void 61static void
53_evas_font_image_draw(void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth) 62_evas_font_image_draw(void *context, void *surface, void *image, RGBA_Font_Glyph *fg, int x, int y, int w, int h, int smooth)
54{ 63{
55 RGBA_Image *im; 64 RGBA_Image *im;
65 int src_w, src_h;
56 66
57 if (!image) return; 67 if (!image || !fg) return;
58 im = image; 68 im = image;
69 src_w = fg->glyph_out->bitmap.width;
70 src_h = fg->glyph_out->bitmap.rows;
59 71
60#ifdef BUILD_PIPE_RENDER 72#ifdef BUILD_PIPE_RENDER
61 if ((eina_cpu_count() > 1)) 73 if ((eina_cpu_count() > 1))
@@ -66,24 +78,24 @@ _evas_font_image_draw(void *context, void *surface, void *image, int src_x, int
66#endif 78#endif
67 evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im), 79 evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im),
68 surface, context, smooth, 80 surface, context, smooth,
69 src_x, src_y, src_w, src_h, 81 0, 0, src_w, src_h,
70 dst_x, dst_y, dst_w, dst_h); 82 x, y, w, h);
71 83
72 evas_common_pipe_image_draw(im, surface, context, smooth, 84 evas_common_pipe_image_draw(im, surface, context, smooth,
73 src_x, src_y, src_w, src_h, 85 0, 0, src_w, src_h,
74 dst_x, dst_y, dst_w, dst_h); 86 x, y, w, h);
75 } 87 }
76 else 88 else
77#endif 89#endif
78 { 90 {
79 evas_common_rgba_image_scalecache_prepare 91 evas_common_rgba_image_scalecache_prepare
80 (&im->cache_entry, surface, context, smooth, 92 (&im->cache_entry, surface, context, smooth,
81 src_x, src_y, src_w, src_h, 93 0, 0, src_w, src_h,
82 dst_x, dst_y, dst_w, dst_h); 94 x, y, w, h);
83 evas_common_rgba_image_scalecache_do 95 evas_common_rgba_image_scalecache_do
84 (&im->cache_entry, surface, context, smooth, 96 (&im->cache_entry, surface, context, smooth,
85 src_x, src_y, src_w, src_h, 97 0, 0, src_w, src_h,
86 dst_x, dst_y, dst_w, dst_h); 98 x, y, w, h);
87 99
88 evas_common_cpu_end_opt(); 100 evas_common_cpu_end_opt();
89 } 101 }
@@ -111,9 +123,20 @@ evas_common_font_rgba_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y,
111 int chr_x, chr_y, w, h; 123 int chr_x, chr_y, w, h;
112 124
113 fg = glyph->fg; 125 fg = glyph->fg;
126
114 w = fg->glyph_out->bitmap.width; 127 w = fg->glyph_out->bitmap.width;
115 h = fg->glyph_out->bitmap.rows; 128 h = fg->glyph_out->bitmap.rows;
116 129
130 if (FT_HAS_FIXED_SIZES(fg->fi->src->ft.face))
131 {
132 if ((fg->fi->bitmap_scalable & EFL_TEXT_FONT_BITMAP_SCALABLE_COLOR) &&
133 FT_HAS_COLOR(fg->fi->src->ft.face))
134 {
135 w *= fg->fi->scale_factor;
136 h *= fg->fi->scale_factor;
137 }
138 }
139
117 if ((!fg->ext_dat) && (dc->font_ext.func.gl_new)) 140 if ((!fg->ext_dat) && (dc->font_ext.func.gl_new))
118 { 141 {
119 /* extension calls */ 142 /* extension calls */
@@ -132,9 +155,7 @@ evas_common_font_rgba_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y,
132 } 155 }
133 else 156 else
134 { 157 {
135 fg->ext_dat = _evas_font_image_new_from_data 158 fg->ext_dat = _evas_font_image_new(fg, EINA_TRUE, EVAS_COLORSPACE_ARGB8888);
136 (w, h, (DATA32 *)fg->glyph_out->bitmap.buffer,
137 EINA_TRUE, EVAS_COLORSPACE_ARGB8888);
138 fg->ext_dat_free = _evas_font_image_free; 159 fg->ext_dat_free = _evas_font_image_free;
139 } 160 }
140 } 161 }
@@ -150,10 +171,11 @@ evas_common_font_rgba_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y,
150 if ((fg->ext_dat) && (dc->font_ext.func.gl_draw)) 171 if ((fg->ext_dat) && (dc->font_ext.func.gl_draw))
151 dc->font_ext.func.gl_draw(dc->font_ext.data, dst, 172 dc->font_ext.func.gl_draw(dc->font_ext.data, dst,
152 dc, fg, 173 dc, fg,
153 chr_x, y - (chr_y - y)); 174 chr_x, y - (chr_y - y), w, h);
154 else 175 else
176 // TODO: scale with evas_font_compress_draw.c...
155 evas_common_font_glyph_draw(fg, dc, dst, im_w, 177 evas_common_font_glyph_draw(fg, dc, dst, im_w,
156 chr_x, y - (chr_y - y), 178 chr_x, y - (chr_y - y), w, h,
157 ext_x, ext_y, 179 ext_x, ext_y,
158 ext_w, ext_h); 180 ext_w, ext_h);
159 } 181 }
@@ -165,7 +187,7 @@ evas_common_font_rgba_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y,
165 chr_x, y - (chr_y - y), w, h, EINA_TRUE); 187 chr_x, y - (chr_y - y), w, h, EINA_TRUE);
166 else 188 else
167 _evas_font_image_draw 189 _evas_font_image_draw
168 (dc, dst, fg->ext_dat, 0, 0, w, h, 190 (dc, dst, fg->ext_dat, fg,
169 chr_x, y - (chr_y - y), w, h, EINA_TRUE); 191 chr_x, y - (chr_y - y), w, h, EINA_TRUE);
170 } 192 }
171 } 193 }
diff --git a/src/lib/evas/common/evas_font_load.c b/src/lib/evas/common/evas_font_load.c
index 2afd124941..6bf1e34a08 100644
--- a/src/lib/evas/common/evas_font_load.c
+++ b/src/lib/evas/common/evas_font_load.c
@@ -42,9 +42,16 @@ _evas_font_cache_int_cmp(const RGBA_Font_Int *k1, int k1_length EINA_UNUSED,
42 if (k1->src->name == k2->src->name) 42 if (k1->src->name == k2->src->name)
43 { 43 {
44 if (k1->size == k2->size) 44 if (k1->size == k2->size)
45 return k1->wanted_rend - k2->wanted_rend; 45 {
46 if (k1->wanted_rend == k2->wanted_rend)
47 return k1->bitmap_scalable - k2->bitmap_scalable;
48 else
49 return k1->wanted_rend - k2->wanted_rend;
50 }
46 else 51 else
47 return k1->size - k2->size; 52 {
53 return k1->size - k2->size;
54 }
48 } 55 }
49 return strcmp(k1->src->name, k2->src->name); 56 return strcmp(k1->src->name, k2->src->name);
50} 57}
@@ -57,6 +64,7 @@ _evas_font_cache_int_hash(const RGBA_Font_Int *key, int key_length EINA_UNUSED)
57 hash = eina_hash_djb2(key->src->name, eina_stringshare_strlen(key->src->name) + 1); 64 hash = eina_hash_djb2(key->src->name, eina_stringshare_strlen(key->src->name) + 1);
58 hash ^= eina_hash_int32(&key->size, sizeof (int)); 65 hash ^= eina_hash_int32(&key->size, sizeof (int));
59 hash ^= eina_hash_int32(&wanted_rend, sizeof (int)); 66 hash ^= eina_hash_int32(&wanted_rend, sizeof (int));
67 hash ^= eina_hash_int32(&key->bitmap_scalable, sizeof (int));
60 return hash; 68 return hash;
61} 69}
62 70
@@ -322,13 +330,13 @@ _evas_common_font_int_cache_init(RGBA_Font_Int *fi)
322} 330}
323 331
324EAPI RGBA_Font_Int * 332EAPI RGBA_Font_Int *
325evas_common_font_int_memory_load(const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend) 333evas_common_font_int_memory_load(const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
326{ 334{
327 RGBA_Font_Int *fi; 335 RGBA_Font_Int *fi;
328 char *fake_name; 336 char *fake_name;
329 337
330 fake_name = evas_file_path_join(source, name); 338 fake_name = evas_file_path_join(source, name);
331 fi = evas_common_font_int_find(fake_name, size, wanted_rend); 339 fi = evas_common_font_int_find(fake_name, size, wanted_rend, bitmap_scalable);
332 if (fi) 340 if (fi)
333 { 341 {
334 free(fake_name); 342 free(fake_name);
@@ -350,6 +358,7 @@ evas_common_font_int_memory_load(const char *source, const char *name, int size,
350 return NULL; 358 return NULL;
351 } 359 }
352 fi->size = size; 360 fi->size = size;
361 fi->bitmap_scalable = bitmap_scalable;
353 _evas_common_font_int_cache_init(fi); 362 _evas_common_font_int_cache_init(fi);
354 fi = evas_common_font_int_load_init(fi); 363 fi = evas_common_font_int_load_init(fi);
355 evas_common_font_int_load_complete(fi); 364 evas_common_font_int_load_complete(fi);
@@ -374,11 +383,12 @@ evas_common_font_int_memory_load(const char *source, const char *name, int size,
374 383
375EAPI RGBA_Font_Int * 384EAPI RGBA_Font_Int *
376evas_common_font_int_load(const char *name, int size, 385evas_common_font_int_load(const char *name, int size,
377 Font_Rend_Flags wanted_rend) 386 Font_Rend_Flags wanted_rend,
387 Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
378{ 388{
379 RGBA_Font_Int *fi; 389 RGBA_Font_Int *fi;
380 390
381 fi = evas_common_font_int_find(name, size, wanted_rend); 391 fi = evas_common_font_int_find(name, size, wanted_rend, bitmap_scalable);
382 if (fi) return fi; 392 if (fi) return fi;
383 fi = calloc(1, sizeof(RGBA_Font_Int)); 393 fi = calloc(1, sizeof(RGBA_Font_Int));
384 if (!fi) return NULL; 394 if (!fi) return NULL;
@@ -393,6 +403,7 @@ evas_common_font_int_load(const char *name, int size,
393 } 403 }
394 fi->size = size; 404 fi->size = size;
395 fi->wanted_rend = wanted_rend; 405 fi->wanted_rend = wanted_rend;
406 fi->bitmap_scalable = bitmap_scalable;
396 _evas_common_font_int_cache_init(fi); 407 _evas_common_font_int_cache_init(fi);
397 fi = evas_common_font_int_load_init(fi); 408 fi = evas_common_font_int_load_init(fi);
398#ifdef EVAS_CSERVE2 409#ifdef EVAS_CSERVE2
@@ -437,6 +448,7 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi)
437 FT_Activate_Size(fi->ft.size); 448 FT_Activate_Size(fi->ft.size);
438 } 449 }
439 fi->real_size = fi->size * 64; 450 fi->real_size = fi->size * 64;
451 fi->scale_factor = 1.0;
440 error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi, font_dpi); 452 error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi, font_dpi);
441 if (error) 453 if (error)
442 error = FT_Set_Pixel_Sizes(fi->src->ft.face, 0, fi->real_size); 454 error = FT_Set_Pixel_Sizes(fi->src->ft.face, 0, fi->real_size);
@@ -468,9 +480,20 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi)
468 FTLOCK(); 480 FTLOCK();
469 481
470 if (FT_HAS_FIXED_SIZES(fi->src->ft.face)) 482 if (FT_HAS_FIXED_SIZES(fi->src->ft.face))
471 error = FT_Select_Size(fi->src->ft.face, strike_index); 483 {
484 error = FT_Select_Size(fi->src->ft.face, strike_index);
485
486 if (!error)
487 {
488 if (FT_HAS_COLOR(fi->src->ft.face) &&
489 fi->bitmap_scalable & EFL_TEXT_FONT_BITMAP_SCALABLE_COLOR)
490 fi->scale_factor = (float)fi->size * 64.0 / (float)fi->real_size;
491 }
492 }
472 else 493 else
473 error = FT_Set_Pixel_Sizes(fi->src->ft.face, 0, fi->real_size); 494 {
495 error = FT_Set_Pixel_Sizes(fi->src->ft.face, 0, fi->real_size);
496 }
474 497
475 FTUNLOCK(); 498 FTUNLOCK();
476 if (error) 499 if (error)
@@ -543,13 +566,13 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi)
543} 566}
544 567
545EAPI RGBA_Font * 568EAPI RGBA_Font *
546evas_common_font_memory_load(const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend) 569evas_common_font_memory_load(const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
547{ 570{
548 RGBA_Font *fn; 571 RGBA_Font *fn;
549 RGBA_Font_Int *fi; 572 RGBA_Font_Int *fi;
550 573
551 fi = evas_common_font_int_memory_load(source, name, size, data, data_size, 574 fi = evas_common_font_int_memory_load(source, name, size, data, data_size,
552 wanted_rend); 575 wanted_rend, bitmap_scalable);
553 if (!fi) return NULL; 576 if (!fi) return NULL;
554 fn = calloc(1, sizeof(RGBA_Font)); 577 fn = calloc(1, sizeof(RGBA_Font));
555 if (!fn) 578 if (!fn)
@@ -577,12 +600,12 @@ evas_common_font_memory_load(const char *source, const char *name, int size, con
577// fi->fs 600// fi->fs
578 601
579EAPI RGBA_Font * 602EAPI RGBA_Font *
580evas_common_font_load(const char *name, int size, Font_Rend_Flags wanted_rend) 603evas_common_font_load(const char *name, int size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
581{ 604{
582 RGBA_Font *fn; 605 RGBA_Font *fn;
583 RGBA_Font_Int *fi; 606 RGBA_Font_Int *fi;
584 607
585 fi = evas_common_font_int_load(name, size, wanted_rend); 608 fi = evas_common_font_int_load(name, size, wanted_rend, bitmap_scalable);
586 if (!fi) return NULL; 609 if (!fi) return NULL;
587 /* First font, complete load */ 610 /* First font, complete load */
588 if (!fi->ft.size) 611 if (!fi->ft.size)
@@ -619,12 +642,12 @@ evas_common_font_load(const char *name, int size, Font_Rend_Flags wanted_rend)
619} 642}
620 643
621EAPI RGBA_Font * 644EAPI RGBA_Font *
622evas_common_font_add(RGBA_Font *fn, const char *name, int size, Font_Rend_Flags wanted_rend) 645evas_common_font_add(RGBA_Font *fn, const char *name, int size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
623{ 646{
624 RGBA_Font_Int *fi; 647 RGBA_Font_Int *fi;
625 648
626 if (!fn) return NULL; 649 if (!fn) return NULL;
627 fi = evas_common_font_int_load(name, size, wanted_rend); 650 fi = evas_common_font_int_load(name, size, wanted_rend, bitmap_scalable);
628 if (fi) 651 if (fi)
629 { 652 {
630 fn->fonts = eina_list_append(fn->fonts, fi); 653 fn->fonts = eina_list_append(fn->fonts, fi);
@@ -641,13 +664,13 @@ evas_common_font_add(RGBA_Font *fn, const char *name, int size, Font_Rend_Flags
641} 664}
642 665
643EAPI RGBA_Font * 666EAPI RGBA_Font *
644evas_common_font_memory_add(RGBA_Font *fn, const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend) 667evas_common_font_memory_add(RGBA_Font *fn, const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
645{ 668{
646 RGBA_Font_Int *fi; 669 RGBA_Font_Int *fi;
647 670
648 if (!fn) 671 if (!fn)
649 return NULL; 672 return NULL;
650 fi = evas_common_font_int_memory_load(source, name, size, data, data_size, wanted_rend); 673 fi = evas_common_font_int_memory_load(source, name, size, data, data_size, wanted_rend, bitmap_scalable);
651 if (fi) 674 if (fi)
652 { 675 {
653 fn->fonts = eina_list_append(fn->fonts, fi); 676 fn->fonts = eina_list_append(fn->fonts, fi);
@@ -744,38 +767,38 @@ evas_common_hinting_available(Font_Hint_Flags hinting)
744} 767}
745 768
746EAPI RGBA_Font * 769EAPI RGBA_Font *
747evas_common_font_memory_hinting_load(const char *source, const char *name, int size, const void *data, int data_size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend) 770evas_common_font_memory_hinting_load(const char *source, const char *name, int size, const void *data, int data_size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
748{ 771{
749 RGBA_Font *fn; 772 RGBA_Font *fn;
750 773
751 fn = evas_common_font_memory_load(source, name, size, data, data_size, wanted_rend); 774 fn = evas_common_font_memory_load(source, name, size, data, data_size, wanted_rend, bitmap_scalable);
752 if (fn) evas_common_font_hinting_set(fn, hinting); 775 if (fn) evas_common_font_hinting_set(fn, hinting);
753 return fn; 776 return fn;
754} 777}
755 778
756EAPI RGBA_Font * 779EAPI RGBA_Font *
757evas_common_font_hinting_load(const char *name, int size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend) 780evas_common_font_hinting_load(const char *name, int size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
758{ 781{
759 RGBA_Font *fn; 782 RGBA_Font *fn;
760 783
761 fn = evas_common_font_load(name, size, wanted_rend); 784 fn = evas_common_font_load(name, size, wanted_rend, bitmap_scalable);
762 if (fn) evas_common_font_hinting_set(fn, hinting); 785 if (fn) evas_common_font_hinting_set(fn, hinting);
763 return fn; 786 return fn;
764} 787}
765 788
766EAPI RGBA_Font * 789EAPI RGBA_Font *
767evas_common_font_hinting_add(RGBA_Font *fn, const char *name, int size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend) 790evas_common_font_hinting_add(RGBA_Font *fn, const char *name, int size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
768{ 791{
769 fn = evas_common_font_add(fn, name, size, wanted_rend); 792 fn = evas_common_font_add(fn, name, size, wanted_rend, bitmap_scalable);
770 if (fn) evas_common_font_hinting_set(fn, hinting); 793 if (fn) evas_common_font_hinting_set(fn, hinting);
771 return fn; 794 return fn;
772} 795}
773 796
774EAPI RGBA_Font * 797EAPI RGBA_Font *
775evas_common_font_memory_hinting_add(RGBA_Font *fn, const char *source, const char *name, int size, const void *data, int data_size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend) 798evas_common_font_memory_hinting_add(RGBA_Font *fn, const char *source, const char *name, int size, const void *data, int data_size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
776{ 799{
777 fn = evas_common_font_memory_add(fn, source, name, size, data, data_size, 800 fn = evas_common_font_memory_add(fn, source, name, size, data, data_size,
778 wanted_rend); 801 wanted_rend, bitmap_scalable);
779 if (fn) evas_common_font_hinting_set(fn, hinting); 802 if (fn) evas_common_font_hinting_set(fn, hinting);
780 return fn; 803 return fn;
781} 804}
@@ -939,7 +962,8 @@ evas_common_font_flush_last(void)
939 962
940EAPI RGBA_Font_Int * 963EAPI RGBA_Font_Int *
941evas_common_font_int_find(const char *name, int size, 964evas_common_font_int_find(const char *name, int size,
942 Font_Rend_Flags wanted_rend) 965 Font_Rend_Flags wanted_rend,
966 Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
943{ 967{
944 RGBA_Font_Int tmp_fi; 968 RGBA_Font_Int tmp_fi;
945 RGBA_Font_Source tmp_fn; 969 RGBA_Font_Source tmp_fn;
@@ -949,6 +973,7 @@ evas_common_font_int_find(const char *name, int size,
949 tmp_fi.src = &tmp_fn; 973 tmp_fi.src = &tmp_fn;
950 tmp_fi.size = size; 974 tmp_fi.size = size;
951 tmp_fi.wanted_rend = wanted_rend; 975 tmp_fi.wanted_rend = wanted_rend;
976 tmp_fi.bitmap_scalable = bitmap_scalable;
952 fi = eina_hash_find(fonts, &tmp_fi); 977 fi = eina_hash_find(fonts, &tmp_fi);
953 if (fi) 978 if (fi)
954 { 979 {
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;