summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2017-11-07 11:22:09 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-11-07 11:34:53 +0900
commitb038d7df25f9cecaa4f0d8c1c7355e4852e5348a (patch)
tree595da7d0114056e147d4a40fedc72d5b71b3927a /src/lib/evas/common
parenta75b3dcdfbe0760972c8b4d55a90dc6250bd1e45 (diff)
Remove evas internal dependency from the evas_font module
Summary: dev branch : devs/subhransu/font The Final goal is to move the evas_font module to ector so that both ector and evas can reuse the code. make the api simple so that sam eapi can be used by evas_textblock and ector text. This is the 1st stage to achive that gola, first remove the evas internal dependancy as much as possible before moving to ector library. Reviewers: jpeg, raster, herdsman, cedric, id213sin Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D5419
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_font.h354
-rw-r--r--src/lib/evas/common/evas_font_compress.c173
-rw-r--r--src/lib/evas/common/evas_font_draw.c154
-rw-r--r--src/lib/evas/common/evas_font_draw.h18
-rw-r--r--src/lib/evas/common/evas_font_load.c50
-rw-r--r--src/lib/evas/common/evas_font_main.c28
-rw-r--r--src/lib/evas/common/evas_font_ot.c4
-rw-r--r--src/lib/evas/common/evas_font_ot.h11
-rw-r--r--src/lib/evas/common/evas_font_private.h44
-rw-r--r--src/lib/evas/common/evas_font_query.c3
-rw-r--r--src/lib/evas/common/evas_text_utils.c8
-rw-r--r--src/lib/evas/common/evas_text_utils.h5
12 files changed, 613 insertions, 239 deletions
diff --git a/src/lib/evas/common/evas_font.h b/src/lib/evas/common/evas_font.h
index 132b474e2f..8d57476953 100644
--- a/src/lib/evas/common/evas_font.h
+++ b/src/lib/evas/common/evas_font.h
@@ -1,9 +1,329 @@
1#ifndef _EVAS_FONT_H 1#ifndef _EVAS_FONT_H
2#define _EVAS_FONT_H 2#define _EVAS_FONT_H
3
4typedef unsigned char DATA8;
5typedef unsigned long long DATA64;
6
7#include <ft2build.h>
8#include FT_FREETYPE_H
9#include FT_GLYPH_H
10#include FT_SIZES_H
11#include FT_MODULE_H
12
13#ifndef FT_HAS_COLOR
14# define FT_HAS_COLOR(face) 0
15#endif
16
17#ifndef FT_LOAD_COLOR
18# define FT_LOAD_COLOR FT_LOAD_DEFAULT
19#endif
20
21#ifdef EAPI
22# undef EAPI
23#endif
24
25#ifdef _WIN32
26# ifdef EFL_EVAS_BUILD
27# ifdef DLL_EXPORT
28# define EAPI __declspec(dllexport)
29# else
30# define EAPI
31# endif /* ! DLL_EXPORT */
32# else
33# define EAPI __declspec(dllimport)
34# endif /* ! EFL_EVAS_BUILD */
35#else
36# ifdef __GNUC__
37# if __GNUC__ >= 4
38# define EAPI __attribute__ ((visibility("default")))
39# else
40# define EAPI
41# endif
42# else
43# define EAPI
44# endif
45#endif /* ! _WIN32 */
46
47#include <Eina.h>
48
49#define LK(x) Eina_Lock x
50#define LKU(x) eina_lock_release(&(x))
51#define LKL(x) eina_lock_take(&(x))
52#define LKD(x) eina_lock_free(&(x))
53
3#include "evas_text_utils.h" 54#include "evas_text_utils.h"
4 55
56
57enum _Evas_Font_Style
58{
59 EVAS_FONT_STYLE_SLANT,
60 EVAS_FONT_STYLE_WEIGHT,
61 EVAS_FONT_STYLE_WIDTH
62};
63
64enum _Evas_Font_Slant
65{
66 EVAS_FONT_SLANT_NORMAL,
67 EVAS_FONT_SLANT_OBLIQUE,
68 EVAS_FONT_SLANT_ITALIC
69};
70
71enum _Evas_Font_Weight
72{
73 EVAS_FONT_WEIGHT_NORMAL,
74 EVAS_FONT_WEIGHT_THIN,
75 EVAS_FONT_WEIGHT_ULTRALIGHT,
76 EVAS_FONT_WEIGHT_EXTRALIGHT,
77 EVAS_FONT_WEIGHT_LIGHT,
78 EVAS_FONT_WEIGHT_BOOK,
79 EVAS_FONT_WEIGHT_MEDIUM,
80 EVAS_FONT_WEIGHT_SEMIBOLD,
81 EVAS_FONT_WEIGHT_BOLD,
82 EVAS_FONT_WEIGHT_ULTRABOLD,
83 EVAS_FONT_WEIGHT_EXTRABOLD,
84 EVAS_FONT_WEIGHT_BLACK,
85 EVAS_FONT_WEIGHT_EXTRABLACK
86};
87
88enum _Evas_Font_Width
89{
90 EVAS_FONT_WIDTH_NORMAL,
91 EVAS_FONT_WIDTH_ULTRACONDENSED,
92 EVAS_FONT_WIDTH_EXTRACONDENSED,
93 EVAS_FONT_WIDTH_CONDENSED,
94 EVAS_FONT_WIDTH_SEMICONDENSED,
95 EVAS_FONT_WIDTH_SEMIEXPANDED,
96 EVAS_FONT_WIDTH_EXPANDED,
97 EVAS_FONT_WIDTH_EXTRAEXPANDED,
98 EVAS_FONT_WIDTH_ULTRAEXPANDED
99};
100
101enum _Evas_Font_Spacing
102{
103 EVAS_FONT_SPACING_PROPORTIONAL,
104 EVAS_FONT_SPACING_DUAL,
105 EVAS_FONT_SPACING_MONO,
106 EVAS_FONT_SPACING_CHARCELL
107};
108
109typedef enum _Evas_Font_Style Evas_Font_Style;
110typedef enum _Evas_Font_Slant Evas_Font_Slant;
111typedef enum _Evas_Font_Weight Evas_Font_Weight;
112typedef enum _Evas_Font_Width Evas_Font_Width;
113typedef enum _Evas_Font_Spacing Evas_Font_Spacing;
114
115typedef struct _Evas_Font_Dir Evas_Font_Dir;
116typedef struct _Evas_Font Evas_Font;
117typedef struct _Evas_Font_Alias Evas_Font_Alias;
118typedef struct _Evas_Font_Description Evas_Font_Description;
119
120
121typedef struct _RGBA_Font RGBA_Font;
122typedef struct _RGBA_Font_Int RGBA_Font_Int;
123typedef struct _RGBA_Font_Source RGBA_Font_Source;
124typedef struct _RGBA_Font_Glyph RGBA_Font_Glyph;
125typedef struct _RGBA_Font_Glyph_Out RGBA_Font_Glyph_Out;
126
127typedef struct _Fash_Item_Index_Map Fash_Item_Index_Map;
128typedef struct _Fash_Int_Map Fash_Int_Map;
129typedef struct _Fash_Int_Map2 Fash_Int_Map2;
130typedef struct _Fash_Int Fash_Int;
131
132
133struct _Fash_Item_Index_Map
134{
135 RGBA_Font_Int *fint;
136 int index;
137};
138struct _Fash_Int_Map
139{
140 Fash_Item_Index_Map item[256];
141};
142struct _Fash_Int_Map2
143{
144 Fash_Int_Map *bucket[256];
145};
146struct _Fash_Int
147{
148 Fash_Int_Map2 *bucket[256];
149 void (*freeme) (Fash_Int *fash);
150};
151
152typedef struct _Fash_Glyph_Map Fash_Glyph_Map;
153typedef struct _Fash_Glyph_Map2 Fash_Glyph_Map2;
154typedef struct _Fash_Glyph Fash_Glyph;
155struct _Fash_Glyph_Map
156{
157 RGBA_Font_Glyph *item[256];
158};
159struct _Fash_Glyph_Map2
160{
161 Fash_Glyph_Map *bucket[256];
162};
163struct _Fash_Glyph
164{
165 Fash_Glyph_Map2 *bucket[256];
166 void (*freeme) (Fash_Glyph *fash);
167};
168
169
170typedef enum _Font_Hint_Flags
171{
172 FONT_NO_HINT,
173 FONT_AUTO_HINT,
174 FONT_BYTECODE_HINT
175} Font_Hint_Flags;
176
177typedef enum _Font_Rend_Flags
178{
179 FONT_REND_REGULAR = 0,
180 FONT_REND_SLANT = (1 << 0),
181 FONT_REND_WEIGHT = (1 << 1),
182} Font_Rend_Flags;
183
184struct _RGBA_Font
185{
186 Eina_List *fonts;
187 Fash_Int *fash;
188 Font_Hint_Flags hinting;
189 int references;
190 LK(lock);
191 unsigned char sizeok : 1;
192};
193
194
195struct _Evas_Font_Dir
196{
197 Eina_Hash *lookup;
198 Eina_List *fonts;
199 Eina_List *aliases;
200 DATA64 dir_mod_time;
201 DATA64 fonts_dir_mod_time;
202 DATA64 fonts_alias_mod_time;
203};
204
205struct _Evas_Font
206{
207 struct {
208 const char *prop[14];
209 } x;
210 struct {
211 const char *name;
212 } simple;
213 const char *path;
214 char type;
215};
216
217struct _Evas_Font_Alias
218{
219 const char *alias;
220 Evas_Font *fn;
221};
222
223struct _Evas_Font_Description
224{
225 int ref;
226 Eina_Stringshare *name;
227 Eina_Stringshare *fallbacks;
228 Eina_Stringshare *lang;
229 Eina_Stringshare *style;
230
231 Evas_Font_Slant slant;
232 Evas_Font_Weight weight;
233 Evas_Font_Width width;
234 Evas_Font_Spacing spacing;
235
236 Eina_Bool is_new : 1;
237};
238
239struct _RGBA_Font_Int
240{
241 EINA_INLIST;
242 RGBA_Font_Source *src;
243 Eina_Hash *kerning;
244 Fash_Glyph *fash;
245 unsigned int size;
246 float scale_factor;
247 int real_size;
248 int max_h;
249 int references;
250 int usage;
251 struct {
252 FT_Size size;
253#ifdef USE_HARFBUZZ
254 void *hb_font;
255#endif
256 } ft;
257 LK(ft_mutex);
258 Font_Hint_Flags hinting;
259 Font_Rend_Flags wanted_rend; /* The wanted rendering style */
260 Font_Rend_Flags runtime_rend; /* The rendering we need to do on runtime
261 in order to comply with the wanted_rend. */
262
263 Eina_List *task;
264#ifdef EVAS_CSERVE2
265 void *cs2_handler;
266#endif
267
268 int generation;
269
270 Efl_Text_Font_Bitmap_Scalable bitmap_scalable;
271
272 unsigned char sizeok : 1;
273 unsigned char inuse : 1;
274};
275
276struct _RGBA_Font_Source
277{
278 const char *name;
279 const char *file;
280 void *data;
281 unsigned int current_size;
282 int data_size;
283 int references;
284 struct {
285 int orig_upem;
286 FT_Face face;
287 } ft;
288};
289
290/*
291 * laziness wins for now. The parts used from the freetpye struct are
292 * kept intact to avoid changing the code using it until we know exactly
293 * what needs to be changed
294 */
295struct _RGBA_Font_Glyph_Out
296{
297 unsigned char *rle;
298 struct {
299 unsigned char *buffer;
300 unsigned short rows;
301 unsigned short width;
302 unsigned short pitch;
303 unsigned short rle_alloc : 1;
304 unsigned short no_free_glout : 1;
305 } bitmap;
306 int rle_size;
307};
308
309struct _RGBA_Font_Glyph
310{
311 FT_UInt index;
312 Evas_Coord width;
313 Evas_Coord x_bear;
314 Evas_Coord y_bear;
315 FT_Glyph glyph;
316 RGBA_Font_Glyph_Out *glyph_out;
317 /* this is a problem - only 1 engine at a time can extend such a font... grrr */
318 void *ext_dat;
319 void (*ext_dat_free) (void *ext_dat);
320 RGBA_Font_Int *fi;
321};
322
323
5/* The tangent of the slant angle we do on runtime. */ 324/* The tangent of the slant angle we do on runtime. */
6#define _EVAS_FONT_SLANT_TAN 0.221694663 325#define _EVAS_FONT_SLANT_TAN 0.221694663
326
7/* main */ 327/* main */
8 328
9EAPI void evas_common_font_init (void); 329EAPI void evas_common_font_init (void);
@@ -23,20 +343,9 @@ EAPI int evas_common_font_instance_underline_thickness_get (R
23EAPI int evas_common_font_get_line_advance (RGBA_Font *fn); 343EAPI int evas_common_font_get_line_advance (RGBA_Font *fn);
24void *evas_common_font_freetype_face_get(RGBA_Font *font); /* XXX: Not EAPI on purpose. Not ment to be used in modules. */ 344void *evas_common_font_freetype_face_get(RGBA_Font *font); /* XXX: Not EAPI on purpose. Not ment to be used in modules. */
25 345
26/* draw */
27typedef Eina_Bool (*Evas_Common_Font_Draw_Cb)(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, RGBA_Gfx_Func func, int ext_x, int ext_y, int ext_w, int ext_h, int im_w, int im_h);
28
29EAPI Eina_Bool evas_common_font_draw_cb (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, Evas_Common_Font_Draw_Cb cb);
30EAPI void evas_common_font_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs);
31EAPI Eina_Bool evas_common_font_rgba_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, RGBA_Gfx_Func func, int ext_x, int ext_y, int ext_w, int ext_h, int im_w, int im_h);
32EAPI int evas_common_font_glyph_search (RGBA_Font *fn, RGBA_Font_Int **fi_ret, Eina_Unicode gl);
33EAPI RGBA_Font_Glyph *evas_common_font_int_cache_glyph_get (RGBA_Font_Int *fi, FT_UInt index); 346EAPI RGBA_Font_Glyph *evas_common_font_int_cache_glyph_get (RGBA_Font_Int *fi, FT_UInt index);
34EAPI Eina_Bool evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg); 347EAPI Eina_Bool evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg);
35EAPI FT_UInt evas_common_get_char_index (RGBA_Font_Int* fi, Eina_Unicode gl); 348EAPI FT_UInt evas_common_get_char_index (RGBA_Font_Int* fi, Eina_Unicode gl);
36EAPI void evas_common_font_draw_init (void);
37EAPI void evas_common_font_draw_prepare (Evas_Text_Props *text_props);
38EAPI void evas_common_font_draw_do(const Cutout_Rects *reuse, const Eina_Rectangle *clip, RGBA_Gfx_Func func, RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, const Evas_Text_Props *text_props);
39EAPI Eina_Bool evas_common_font_draw_prepare_cutout(Cutout_Rects **reuse, RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Gfx_Func *func);
40 349
41/* load */ 350/* load */
42EAPI void evas_common_font_dpi_set (int dpi_h, int dpi_v); 351EAPI void evas_common_font_dpi_set (int dpi_h, int dpi_v);
@@ -85,10 +394,31 @@ 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); 394EAPI void evas_common_font_ascent_descent_get(RGBA_Font *fn, const Evas_Text_Props *text_props, int *ascent, int *descent);
86 395
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); 396EAPI 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 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); 397EAPI DATA8 *evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret);
398EAPI int evas_common_font_glyph_search (RGBA_Font *fn, RGBA_Font_Int **fi_ret, Eina_Unicode gl);
90 399
91void evas_common_font_load_init(void); 400void evas_common_font_load_init(void);
92void evas_common_font_load_shutdown(void); 401void evas_common_font_load_shutdown(void);
93 402
403void evas_font_dir_cache_free(void);
404const char *evas_font_dir_cache_find(char *dir, char *font);
405Eina_List *evas_font_dir_available_list(const Eina_List *font_paths);
406void evas_font_dir_available_list_free(Eina_List *available);
407void evas_font_free(void *font);
408void evas_fonts_zero_free();
409void evas_fonts_zero_pressure();
410void evas_font_name_parse(Evas_Font_Description *fdesc, const char *name);
411int evas_font_style_find(const char *start, const char *end, Evas_Font_Style style);
412Evas_Font_Description *evas_font_desc_new(void);
413Evas_Font_Description *evas_font_desc_dup(const Evas_Font_Description *fdesc);
414void evas_font_desc_unref(Evas_Font_Description *fdesc);
415int evas_font_desc_cmp(const Evas_Font_Description *a, const Evas_Font_Description *b);
416Evas_Font_Description *evas_font_desc_ref(Evas_Font_Description *fdesc);
417const char *evas_font_lang_normalize(const char *lang);
418void * evas_font_load(const Eina_List *font_paths, int hinting, Evas_Font_Description *fdesc, const char *source, Evas_Font_Size size, Efl_Text_Font_Bitmap_Scalable bitmap_scalable);
419void evas_font_load_hinting_set(void *font, int hinting);
420
421#undef EAPI
422#define EAPI
423
94#endif /* _EVAS_FONT_H */ 424#endif /* _EVAS_FONT_H */
diff --git a/src/lib/evas/common/evas_font_compress.c b/src/lib/evas/common/evas_font_compress.c
index 5e7658caf8..6843c97880 100644
--- a/src/lib/evas/common/evas_font_compress.c
+++ b/src/lib/evas/common/evas_font_compress.c
@@ -1,23 +1,9 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <assert.h>
6
7#include "evas_common_private.h"
8#include "evas_private.h"
9
10#include "evas_font_private.h" 1#include "evas_font_private.h"
11#include "evas_blend_private.h"
12#include "draw.h"
13 2
14#ifdef EVAS_CSERVE2 3#ifdef EVAS_CSERVE2
15# include "../cserve2/evas_cs2_private.h" 4# include "../cserve2/evas_cs2_private.h"
16#endif 5#endif
17 6
18#include FT_OUTLINE_H
19#include FT_SYNTHESIS_H
20
21// XXX: 7// XXX:
22// XXX: adapt cserve2 to this! 8// XXX: adapt cserve2 to this!
23// XXX: 9// XXX:
@@ -128,7 +114,7 @@ alpha8to4(int a8)
128// [char] second byte of RLE data 114// [char] second byte of RLE data
129// ... 115// ...
130// [char] last byte of RLE data 116// [char] last byte of RLE data
131// 117//
132static DATA8 * 118static DATA8 *
133compress_rle4(DATA8 *src, int pitch, int w, int h, int *size_ret) 119compress_rle4(DATA8 *src, int pitch, int w, int h, int *size_ret)
134{ 120{
@@ -247,7 +233,7 @@ static void
247decompress_full_row(DATA8 *src, int start, int end, DATA8 *dst) 233decompress_full_row(DATA8 *src, int start, int end, DATA8 *dst)
248{ 234{
249 DATA8 *p = src + start, *e = src + end, *d = dst, len, val; 235 DATA8 *p = src + start, *e = src + end, *d = dst, len, val;
250 236
251 while (p < e) 237 while (p < e)
252 { 238 {
253 // length is upper 4 bits + 1 239 // length is upper 4 bits + 1
@@ -377,7 +363,7 @@ decompress_bpp4(DATA8 *src, DATA8 *dst, int pitch, int w, int h)
377{ 363{
378 int pitch2, x, y; 364 int pitch2, x, y;
379 DATA8 *d, *s, val; 365 DATA8 *d, *s, val;
380 366
381 // deal with source pixel to round up for odd length rows 367 // deal with source pixel to round up for odd length rows
382 pitch2 = (w + 1) / 2; 368 pitch2 = (w + 1) / 2;
383 // skip header int 369 // skip header int
@@ -462,7 +448,7 @@ evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret)
462 RGBA_Font_Glyph_Out *fgo = fg->glyph_out; 448 RGBA_Font_Glyph_Out *fgo = fg->glyph_out;
463 DATA8 *buf = calloc(1, fgo->bitmap.width * fgo->bitmap.rows); 449 DATA8 *buf = calloc(1, fgo->bitmap.width * fgo->bitmap.rows);
464 int *iptr; 450 int *iptr;
465 451
466 if (!buf) return NULL; 452 if (!buf) return NULL;
467 if (wret) *wret = fgo->bitmap.width; 453 if (wret) *wret = fgo->bitmap.width;
468 if (hret) *hret = fgo->bitmap.rows; 454 if (hret) *hret = fgo->bitmap.rows;
@@ -475,154 +461,3 @@ evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret)
475 fgo->bitmap.width, fgo->bitmap.rows); 461 fgo->bitmap.width, fgo->bitmap.rows);
476 return buf; 462 return buf;
477} 463}
478
479// this draws a compressed font glyph and decompresses on the fly as it
480// draws, saving memory bandwidth and providing speedups
481EAPI void
482evas_common_font_glyph_draw(RGBA_Font_Glyph *fg,
483 RGBA_Draw_Context *dc,
484 RGBA_Image *dst_image, int dst_pitch,
485 int dx, int dy, int dw, int dh, int cx, int cy, int cw, int ch)
486{
487 RGBA_Font_Glyph_Out *fgo = fg->glyph_out;
488 int x, y, w, h, x1, x2, y1, y2, i, *iptr;
489 DATA32 *dst = dst_image->image.data;
490 DATA32 coltab[16], col;
491 DATA16 mtab[16], v;
492
493 // FIXME: Use dw, dh for scaling glyphs...
494 (void) dw;
495 (void) dh;
496 x = dx;
497 y = dy;
498 w = fgo->bitmap.width; h = fgo->bitmap.rows;
499 // skip if totally clipped out
500 if ((y >= (cy + ch)) || ((y + h) <= cy) ||
501 (x >= (cx + cw)) || ((x + w) <= cx)) return;
502 // figure y1/y2 limit range
503 y1 = 0; y2 = h;
504 if ((y + y1) < cy) y1 = cy - y;
505 if ((y + y2) > (cy + ch)) y2 = cy + ch - y;
506 // figure x1/x2 limit range
507 x1 = 0; x2 = w;
508 if ((x + x1) < cx) x1 = cx - x;
509 if ((x + x2) > (cx + cw)) x2 = cx + cw - x;
510 col = dc->col.col;
511 if (dst_image->cache_entry.space == EVAS_COLORSPACE_GRY8)
512 {
513 // FIXME: Font draw not optimized for Alpha targets! SLOW!
514 // This is not pretty :)
515
516 DATA8 *src8, *dst8;
517 Draw_Func_Alpha func;
518 int row;
519
520 if (EINA_UNLIKELY(x < 0))
521 {
522 x1 += (-x);
523 x = 0;
524 if ((x2 - x1) <= 0) return;
525 }
526 if (EINA_UNLIKELY(y < 0))
527 {
528 y1 += (-y);
529 y = 0;
530 if ((y2 - y1) <= 0) return;
531 }
532
533 dst8 = dst_image->image.data8 + x + (y * dst_pitch);
534 func = efl_draw_alpha_func_get(dc->render_op, EINA_FALSE);
535 src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL);
536 if (!src8) return;
537
538 for (row = y1; row < y2; row++)
539 {
540 DATA8 *d = dst8 + ((row - y1) * dst_pitch);
541 DATA8 *s = src8 + (row * w) + x1;
542 func(d, s, x2 - x1);
543 }
544 free(src8);
545 }
546 else if (dc->clip.mask)
547 {
548 RGBA_Gfx_Func func;
549 DATA8 *src8, *mask;
550 DATA32 *buf, *ptr, *buf_ptr;
551 RGBA_Image *im = dc->clip.mask;
552 int row;
553
554 buf = alloca(sizeof(DATA32) * w * h);
555
556 // Adjust clipping info
557 if (EINA_UNLIKELY((x + x1) < dc->clip.mask_x))
558 x1 = dc->clip.mask_x - x;
559 if (EINA_UNLIKELY((y + y1) < dc->clip.mask_y))
560 y1 = dc->clip.mask_y - y;
561 if (EINA_UNLIKELY((x + x2) > (int)(x + x1 + im->cache_entry.w)))
562 x2 = x1 + im->cache_entry.w;
563 if (EINA_UNLIKELY((y + y2) > (int)(y + y1 + im->cache_entry.h)))
564 y2 = y1 + im->cache_entry.h;
565
566 // Step 1: alpha glyph drawing
567 src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL);
568 if (!src8) return;
569
570 // Step 2: color blending to buffer
571 func = evas_common_gfx_func_composite_mask_color_span_get(col, dst_image->cache_entry.flags.alpha, 1, EVAS_RENDER_COPY);
572 for (row = y1; row < y2; row++)
573 {
574 buf_ptr = buf + (row * w) + x1;
575 DATA8 *s = src8 + (row * w) + x1;
576 func(NULL, s, col, buf_ptr, x2 - x1);
577 }
578 free(src8);
579
580 // Step 3: masking to destination
581 func = evas_common_gfx_func_composite_pixel_mask_span_get(im->cache_entry.flags.alpha, im->cache_entry.flags.alpha_sparse, dst_image->cache_entry.flags.alpha, dst_pitch, dc->render_op);
582 for (row = y1; row < y2; row++)
583 {
584 mask = im->image.data8
585 + (y + row - dc->clip.mask_y) * im->cache_entry.w
586 + (x + x1 - dc->clip.mask_x);
587
588 ptr = dst + (x + x1) + ((y + row) * dst_pitch);
589 buf_ptr = buf + (row * w) + x1;
590 func(buf_ptr, mask, 0, ptr, w);
591 }
592 }
593 else
594 {
595 // build fast multiply + mask color tables to avoid compute. this works
596 // because of our very limited 4bit range of alpha values
597 for (i = 0; i <= 0xf; i++)
598 {
599 v = (i << 4) | i;
600 coltab[i] = MUL_SYM(v, col);
601 mtab[i] = 256 - (coltab[i] >> 24);
602 }
603#ifdef BUILD_MMX
604 if (evas_common_cpu_has_feature(CPU_FEATURE_MMX))
605 {
606#define MMX 1
607#include "evas_font_compress_draw.c"
608#undef MMX
609 }
610 else
611#endif
612
613#ifdef BUILD_NEON
614 if (evas_common_cpu_has_feature(CPU_FEATURE_NEON))
615 {
616#define NEON 1
617#include "evas_font_compress_draw.c"
618#undef NEON
619 }
620 else
621#endif
622
623 // Plain C
624 {
625#include "evas_font_compress_draw.c"
626 }
627 }
628}
diff --git a/src/lib/evas/common/evas_font_draw.c b/src/lib/evas/common/evas_font_draw.c
index 4bdecddafe..f40e9b50c8 100644
--- a/src/lib/evas/common/evas_font_draw.c
+++ b/src/lib/evas/common/evas_font_draw.c
@@ -1,4 +1,4 @@
1#include "evas_common_private.h" 1#include "evas_font_draw.h"
2#include "evas_private.h" 2#include "evas_private.h"
3#include "evas_blend_private.h" 3#include "evas_blend_private.h"
4 4
@@ -6,6 +6,7 @@
6#include "evas_font_private.h" /* for Frame-Queuing support */ 6#include "evas_font_private.h" /* for Frame-Queuing support */
7 7
8#include "evas_font_ot.h" 8#include "evas_font_ot.h"
9#include "draw.h"
9 10
10#ifdef EVAS_CSERVE2 11#ifdef EVAS_CSERVE2
11#include "../cserve2/evas_cs2_private.h" 12#include "../cserve2/evas_cs2_private.h"
@@ -507,3 +508,154 @@ evas_common_font_draw_prepare_cutout(Cutout_Rects **reuse, RGBA_Image *dst, RGBA
507 return EINA_TRUE; 508 return EINA_TRUE;
508} 509}
509 510
511// this draws a compressed font glyph and decompresses on the fly as it
512// draws, saving memory bandwidth and providing speedups
513EAPI void
514evas_common_font_glyph_draw(RGBA_Font_Glyph *fg,
515 RGBA_Draw_Context *dc,
516 RGBA_Image *dst_image, int dst_pitch,
517 int dx, int dy, int dw, int dh, int cx, int cy, int cw, int ch)
518{
519 RGBA_Font_Glyph_Out *fgo = fg->glyph_out;
520 int x, y, w, h, x1, x2, y1, y2, i, *iptr;
521 DATA32 *dst = dst_image->image.data;
522 DATA32 coltab[16], col;
523 DATA16 mtab[16], v;
524
525 // FIXME: Use dw, dh for scaling glyphs...
526 (void) dw;
527 (void) dh;
528 x = dx;
529 y = dy;
530 w = fgo->bitmap.width; h = fgo->bitmap.rows;
531 // skip if totally clipped out
532 if ((y >= (cy + ch)) || ((y + h) <= cy) ||
533 (x >= (cx + cw)) || ((x + w) <= cx)) return;
534 // figure y1/y2 limit range
535 y1 = 0; y2 = h;
536 if ((y + y1) < cy) y1 = cy - y;
537 if ((y + y2) > (cy + ch)) y2 = cy + ch - y;
538 // figure x1/x2 limit range
539 x1 = 0; x2 = w;
540 if ((x + x1) < cx) x1 = cx - x;
541 if ((x + x2) > (cx + cw)) x2 = cx + cw - x;
542 col = dc->col.col;
543 if (dst_image->cache_entry.space == EVAS_COLORSPACE_GRY8)
544 {
545 // FIXME: Font draw not optimized for Alpha targets! SLOW!
546 // This is not pretty :)
547
548 DATA8 *src8, *dst8;
549 Draw_Func_Alpha func;
550 int row;
551
552 if (EINA_UNLIKELY(x < 0))
553 {
554 x1 += (-x);
555 x = 0;
556 if ((x2 - x1) <= 0) return;
557 }
558 if (EINA_UNLIKELY(y < 0))
559 {
560 y1 += (-y);
561 y = 0;
562 if ((y2 - y1) <= 0) return;
563 }
564
565 dst8 = dst_image->image.data8 + x + (y * dst_pitch);
566 func = efl_draw_alpha_func_get(dc->render_op, EINA_FALSE);
567 src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL);
568 if (!src8) return;
569
570 for (row = y1; row < y2; row++)
571 {
572 DATA8 *d = dst8 + ((row - y1) * dst_pitch);
573 DATA8 *s = src8 + (row * w) + x1;
574 func(d, s, x2 - x1);
575 }
576 free(src8);
577 }
578 else if (dc->clip.mask)
579 {
580 RGBA_Gfx_Func func;
581 DATA8 *src8, *mask;
582 DATA32 *buf, *ptr, *buf_ptr;
583 RGBA_Image *im = dc->clip.mask;
584 int row;
585
586 buf = alloca(sizeof(DATA32) * w * h);
587
588 // Adjust clipping info
589 if (EINA_UNLIKELY((x + x1) < dc->clip.mask_x))
590 x1 = dc->clip.mask_x - x;
591 if (EINA_UNLIKELY((y + y1) < dc->clip.mask_y))
592 y1 = dc->clip.mask_y - y;
593 if (EINA_UNLIKELY((x + x2) > (int)(x + x1 + im->cache_entry.w)))
594 x2 = x1 + im->cache_entry.w;
595 if (EINA_UNLIKELY((y + y2) > (int)(y + y1 + im->cache_entry.h)))
596 y2 = y1 + im->cache_entry.h;
597
598 // Step 1: alpha glyph drawing
599 src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL);
600 if (!src8) return;
601
602 // Step 2: color blending to buffer
603 func = evas_common_gfx_func_composite_mask_color_span_get(col, dst_image->cache_entry.flags.alpha, 1, EVAS_RENDER_COPY);
604 for (row = y1; row < y2; row++)
605 {
606 buf_ptr = buf + (row * w) + x1;
607 DATA8 *s = src8 + (row * w) + x1;
608 func(NULL, s, col, buf_ptr, x2 - x1);
609 }
610 free(src8);
611
612 // Step 3: masking to destination
613 func = evas_common_gfx_func_composite_pixel_mask_span_get(im->cache_entry.flags.alpha, im->cache_entry.flags.alpha_sparse, dst_image->cache_entry.flags.alpha, dst_pitch, dc->render_op);
614 for (row = y1; row < y2; row++)
615 {
616 mask = im->image.data8
617 + (y + row - dc->clip.mask_y) * im->cache_entry.w
618 + (x + x1 - dc->clip.mask_x);
619
620 ptr = dst + (x + x1) + ((y + row) * dst_pitch);
621 buf_ptr = buf + (row * w) + x1;
622 func(buf_ptr, mask, 0, ptr, w);
623 }
624 }
625 else
626 {
627 // build fast multiply + mask color tables to avoid compute. this works
628 // because of our very limited 4bit range of alpha values
629 for (i = 0; i <= 0xf; i++)
630 {
631 v = (i << 4) | i;
632 coltab[i] = MUL_SYM(v, col);
633 mtab[i] = 256 - (coltab[i] >> 24);
634 }
635#ifdef BUILD_MMX
636 if (evas_common_cpu_has_feature(CPU_FEATURE_MMX))
637 {
638#define MMX 1
639#include "evas_font_compress_draw.c"
640#undef MMX
641 }
642 else
643#endif
644
645#ifdef BUILD_NEON
646 if (evas_common_cpu_has_feature(CPU_FEATURE_NEON))
647 {
648#define NEON 1
649#include "evas_font_compress_draw.c"
650#undef NEON
651 }
652 else
653#endif
654
655 // Plain C
656 {
657#include "evas_font_compress_draw.c"
658 }
659 }
660}
661
diff --git a/src/lib/evas/common/evas_font_draw.h b/src/lib/evas/common/evas_font_draw.h
new file mode 100644
index 0000000000..c0b5e8edae
--- /dev/null
+++ b/src/lib/evas/common/evas_font_draw.h
@@ -0,0 +1,18 @@
1#ifndef _EVAS_FONT_DRAW_H
2#define _EVAS_FONT_DRAW_
3
4#include "evas_common_private.h"
5
6/* draw */
7typedef Eina_Bool (*Evas_Common_Font_Draw_Cb)(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, RGBA_Gfx_Func func, int ext_x, int ext_y, int ext_w, int ext_h, int im_w, int im_h);
8
9EAPI Eina_Bool evas_common_font_draw_cb (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, Evas_Common_Font_Draw_Cb cb);
10EAPI void evas_common_font_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs);
11EAPI Eina_Bool evas_common_font_rgba_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, RGBA_Gfx_Func func, int ext_x, int ext_y, int ext_w, int ext_h, int im_w, int im_h);
12EAPI void evas_common_font_draw_init (void);
13EAPI void evas_common_font_draw_prepare (Evas_Text_Props *text_props);
14EAPI void evas_common_font_draw_do (const Cutout_Rects *reuse, const Eina_Rectangle *clip, RGBA_Gfx_Func func, RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, const Evas_Text_Props *text_props);
15EAPI Eina_Bool evas_common_font_draw_prepare_cutout (Cutout_Rects **reuse, RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Gfx_Func *func);
16EAPI 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);
17
18#endif /* _EVAS_FONT_DRAW_H */ \ No newline at end of file
diff --git a/src/lib/evas/common/evas_font_load.c b/src/lib/evas/common/evas_font_load.c
index dfe94e9fb1..19baadc46f 100644
--- a/src/lib/evas/common/evas_font_load.c
+++ b/src/lib/evas/common/evas_font_load.c
@@ -3,9 +3,7 @@
3#endif 3#endif
4 4
5#include <assert.h> 5#include <assert.h>
6 6#include "evas_font_ot.h"
7#include "evas_common_private.h"
8#include "evas_private.h"
9 7
10#ifdef USE_HARFBUZZ 8#ifdef USE_HARFBUZZ
11# include <hb.h> 9# include <hb.h>
@@ -13,7 +11,7 @@
13 11
14#include "evas_font_private.h" /* for Frame-Queuing support */ 12#include "evas_font_private.h" /* for Frame-Queuing support */
15 13
16#include <ft2build.h> 14#include <ft2build.h>
17#include FT_TRUETYPE_TABLES_H /* Freetype2 OS/2 font table. */ 15#include FT_TRUETYPE_TABLES_H /* Freetype2 OS/2 font table. */
18 16
19#ifdef EVAS_CSERVE2 17#ifdef EVAS_CSERVE2
@@ -142,7 +140,7 @@ evas_common_font_dpi_set(int dpi_h, int dpi_v)
142EAPI RGBA_Font_Source * 140EAPI RGBA_Font_Source *
143evas_common_font_source_memory_load(const char *name, const void *data, int data_size) 141evas_common_font_source_memory_load(const char *name, const void *data, int data_size)
144{ 142{
145 int error; 143 int error;
146 RGBA_Font_Source *fs; 144 RGBA_Font_Source *fs;
147 145
148 assert(name != NULL); 146 assert(name != NULL);
@@ -218,7 +216,7 @@ evas_common_font_source_reload(RGBA_Font_Source *fs)
218 if (fs->data) 216 if (fs->data)
219 { 217 {
220 int error; 218 int error;
221 219
222 FTLOCK(); 220 FTLOCK();
223 error = FT_New_Memory_Face(evas_ft_lib, fs->data, fs->data_size, 0, &(fs->ft.face)); 221 error = FT_New_Memory_Face(evas_ft_lib, fs->data, fs->data_size, 0, &(fs->ft.face));
224 FTUNLOCK(); 222 FTUNLOCK();
@@ -316,8 +314,8 @@ _evas_common_font_double_int_cmp(const int *key1, EINA_UNUSED int key1_length,
316static int 314static int
317_evas_common_font_double_int_hash(const unsigned int key[2], int key_length) 315_evas_common_font_double_int_hash(const unsigned int key[2], int key_length)
318{ 316{
319 return 317 return
320 eina_hash_int32(&key[0], key_length) ^ 318 eina_hash_int32(&key[0], key_length) ^
321 eina_hash_int32(&key[1], key_length); 319 eina_hash_int32(&key[1], key_length);
322} 320}
323 321
@@ -336,19 +334,17 @@ EAPI RGBA_Font_Int *
336evas_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) 334evas_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)
337{ 335{
338 RGBA_Font_Int *fi; 336 RGBA_Font_Int *fi;
339 char *fake_name; 337 char fake_name[PATH_MAX];
340 338
341 fake_name = evas_file_path_join(source, name); 339 eina_file_path_join(fake_name, sizeof(fake_name), source, name);
342 fi = evas_common_font_int_find(fake_name, size, wanted_rend, bitmap_scalable); 340 fi = evas_common_font_int_find(fake_name, size, wanted_rend, bitmap_scalable);
343 if (fi) 341 if (fi)
344 { 342 {
345 free(fake_name);
346 return fi; 343 return fi;
347 } 344 }
348 fi = calloc(1, sizeof(RGBA_Font_Int)); 345 fi = calloc(1, sizeof(RGBA_Font_Int));
349 if (!fi) 346 if (!fi)
350 { 347 {
351 free(fake_name);
352 return NULL; 348 return NULL;
353 } 349 }
354 fi->src = evas_common_font_source_find(fake_name); 350 fi->src = evas_common_font_source_find(fake_name);
@@ -356,9 +352,8 @@ evas_common_font_int_memory_load(const char *source, const char *name, int size,
356 fi->src = evas_common_font_source_memory_load(fake_name, data, data_size); 352 fi->src = evas_common_font_source_memory_load(fake_name, data, data_size);
357 if (!fi->src) 353 if (!fi->src)
358 { 354 {
359 free(fi); 355 free(fi);
360 free(fake_name); 356 return NULL;
361 return NULL;
362 } 357 }
363 fi->size = size; 358 fi->size = size;
364 fi->bitmap_scalable = bitmap_scalable; 359 fi->bitmap_scalable = bitmap_scalable;
@@ -380,10 +375,19 @@ evas_common_font_int_memory_load(const char *source, const char *name, int size,
380 } 375 }
381 } 376 }
382#endif 377#endif
383 free(fake_name);
384 return fi; 378 return fi;
385} 379}
386 380
381static int
382_file_path_is_file_helper(const char *path)
383{
384 struct stat st;
385
386 if (stat(path, &st) == -1) return 0;
387 if (S_ISREG(st.st_mode)) return 1;
388 return 0;
389}
390
387EAPI RGBA_Font_Int * 391EAPI RGBA_Font_Int *
388evas_common_font_int_load(const char *name, int size, 392evas_common_font_int_load(const char *name, int size,
389 Font_Rend_Flags wanted_rend, 393 Font_Rend_Flags wanted_rend,
@@ -396,7 +400,7 @@ evas_common_font_int_load(const char *name, int size,
396 fi = calloc(1, sizeof(RGBA_Font_Int)); 400 fi = calloc(1, sizeof(RGBA_Font_Int));
397 if (!fi) return NULL; 401 if (!fi) return NULL;
398 fi->src = evas_common_font_source_find(name); 402 fi->src = evas_common_font_source_find(name);
399 if (!fi->src && evas_file_path_is_file(name)) 403 if (!fi->src && _file_path_is_file_helper(name))
400 fi->src = evas_common_font_source_load(name); 404 fi->src = evas_common_font_source_load(name);
401 405
402 if (!fi->src) 406 if (!fi->src)
@@ -466,7 +470,7 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi)
466 for (i = 0; i < fi->src->ft.face->num_fixed_sizes; i++) 470 for (i = 0; i < fi->src->ft.face->num_fixed_sizes; i++)
467 { 471 {
468 int s, cd; 472 int s, cd;
469 473
470 s = fi->src->ft.face->available_sizes[i].size; 474 s = fi->src->ft.face->available_sizes[i].size;
471 cd = chosen_size - fi->real_size; 475 cd = chosen_size - fi->real_size;
472 if (cd < 0) cd = -cd; 476 if (cd < 0) cd = -cd;
@@ -853,7 +857,7 @@ void
853evas_common_font_int_promote(RGBA_Font_Int *fi EINA_UNUSED) 857evas_common_font_int_promote(RGBA_Font_Int *fi EINA_UNUSED)
854{ 858{
855 return; 859 return;
856/* unused - keep for reference 860/* unused - keep for reference
857 if (fonts_use_lru == (Eina_Inlist *)fi) return; 861 if (fonts_use_lru == (Eina_Inlist *)fi) return;
858 if (!fi->inuse) return; 862 if (!fi->inuse) return;
859 fonts_use_lru = eina_inlist_remove(fonts_use_lru, EINA_INLIST_GET(fi)); 863 fonts_use_lru = eina_inlist_remove(fonts_use_lru, EINA_INLIST_GET(fi));
@@ -871,7 +875,7 @@ void
871evas_common_font_int_use_trim(void) 875evas_common_font_int_use_trim(void)
872{ 876{
873 return; 877 return;
874/* unused - keep for reference 878/* unused - keep for reference
875 Eina_Inlist *l; 879 Eina_Inlist *l;
876 880
877 if (fonts_use_usage <= (font_cache << 1)) return; 881 if (fonts_use_usage <= (font_cache << 1)) return;
@@ -894,7 +898,7 @@ void
894evas_common_font_int_unload(RGBA_Font_Int *fi EINA_UNUSED) 898evas_common_font_int_unload(RGBA_Font_Int *fi EINA_UNUSED)
895{ 899{
896 return; 900 return;
897/* unused - keep for reference 901/* unused - keep for reference
898 if (!fi->src->ft.face) return; 902 if (!fi->src->ft.face) return;
899 _evas_common_font_int_clear(fi); 903 _evas_common_font_int_clear(fi);
900 FT_Done_Size(fi->ft.size); 904 FT_Done_Size(fi->ft.size);
@@ -909,7 +913,7 @@ evas_common_font_int_reload(RGBA_Font_Int *fi)
909 if (fi->src->ft.face) return; 913 if (fi->src->ft.face) return;
910 evas_common_font_source_load_complete(fi->src); 914 evas_common_font_source_load_complete(fi->src);
911 return; 915 return;
912/* unused - keep for reference 916/* unused - keep for reference
913 evas_common_font_source_reload(fi->src); 917 evas_common_font_source_reload(fi->src);
914 evas_common_font_int_load_complete(fi); 918 evas_common_font_int_load_complete(fi);
915 */ 919 */
@@ -947,7 +951,7 @@ evas_common_font_flush(void)
947 while (font_cache_usage > font_cache) 951 while (font_cache_usage > font_cache)
948 { 952 {
949 int pfont_cache_usage; 953 int pfont_cache_usage;
950 954
951 pfont_cache_usage = font_cache_usage; 955 pfont_cache_usage = font_cache_usage;
952 evas_common_font_flush_last(); 956 evas_common_font_flush_last();
953 if (pfont_cache_usage == font_cache_usage) break; 957 if (pfont_cache_usage == font_cache_usage) break;
diff --git a/src/lib/evas/common/evas_font_main.c b/src/lib/evas/common/evas_font_main.c
index c156bd7477..ef2c588668 100644
--- a/src/lib/evas/common/evas_font_main.c
+++ b/src/lib/evas/common/evas_font_main.c
@@ -1,12 +1,3 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <assert.h>
6
7#include "evas_common_private.h"
8#include "evas_private.h"
9
10#include "evas_font_private.h" 1#include "evas_font_private.h"
11 2
12#ifdef EVAS_CSERVE2 3#ifdef EVAS_CSERVE2
@@ -25,6 +16,8 @@ LK(lock_font_draw); // for freetype2 API calls
25LK(lock_bidi); // for evas bidi internal usage. 16LK(lock_bidi); // for evas bidi internal usage.
26LK(lock_ot); // for evas bidi internal usage. 17LK(lock_ot); // for evas bidi internal usage.
27 18
19int _evas_font_log_dom_global = -1;
20
28EAPI void 21EAPI void
29evas_common_font_init(void) 22evas_common_font_init(void)
30{ 23{
@@ -36,6 +29,12 @@ evas_common_font_init(void)
36#else 29#else
37 35; 30 35;
38#endif 31#endif
32 _evas_font_log_dom_global = eina_log_domain_register
33 ("evas_font_main", EVAS_FONT_DEFAULT_LOG_COLOR);
34 if (_evas_font_log_dom_global < 0)
35 {
36 EINA_LOG_ERR("Can not create a module log domain.");
37 }
39 38
40 initialised++; 39 initialised++;
41 if (initialised != 1) return; 40 if (initialised != 1) return;
@@ -77,6 +76,7 @@ evas_common_font_shutdown(void)
77 LKD(lock_font_draw); 76 LKD(lock_font_draw);
78 LKD(lock_bidi); 77 LKD(lock_bidi);
79 LKD(lock_ot); 78 LKD(lock_ot);
79 eina_log_domain_unregister(_evas_font_log_dom_global);
80} 80}
81 81
82EAPI void 82EAPI void
@@ -681,7 +681,7 @@ evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg)
681 fg->glyph_out->bitmap.pitch = fbg->bitmap.pitch; 681 fg->glyph_out->bitmap.pitch = fbg->bitmap.pitch;
682 fg->glyph_out->bitmap.buffer = fbg->bitmap.buffer; 682 fg->glyph_out->bitmap.buffer = fbg->bitmap.buffer;
683 fg->glyph_out->bitmap.rle_alloc = EINA_TRUE; 683 fg->glyph_out->bitmap.rle_alloc = EINA_TRUE;
684 684
685 /* This '+ 100' is just an estimation of how much memory freetype will use 685 /* This '+ 100' is just an estimation of how much memory freetype will use
686 * on it's size. This value is not really used anywhere in code - it's 686 * on it's size. This value is not really used anywhere in code - it's
687 * only for statistics. */ 687 * only for statistics. */
@@ -709,7 +709,7 @@ evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg)
709 fg->glyph_out->rle = NULL; 709 fg->glyph_out->rle = NULL;
710 fg->glyph_out->bitmap.rle_alloc = EINA_FALSE; 710 fg->glyph_out->bitmap.rle_alloc = EINA_FALSE;
711 } 711 }
712 712
713 return EINA_TRUE; 713 return EINA_TRUE;
714} 714}
715 715
@@ -805,11 +805,11 @@ evas_common_get_char_index(RGBA_Font_Int* fi, Eina_Unicode gl)
805 // codepoints with a guess that bitmap font is playing the old 805 // codepoints with a guess that bitmap font is playing the old
806 // game of putting line drawing chars in specific ranges 806 // game of putting line drawing chars in specific ranges
807 max = sizeof(mapfix) / (sizeof(mapfix[0]) * 2); 807 max = sizeof(mapfix) / (sizeof(mapfix[0]) * 2);
808 i = (min + max) / 2; 808 i = (min + max) / 2;
809 for (;;) 809 for (;;)
810 { 810 {
811 unsigned short v; 811 unsigned short v;
812 812
813 v = mapfix[i << 1]; 813 v = mapfix[i << 1];
814 if (gl == v) 814 if (gl == v)
815 { 815 {
@@ -867,7 +867,7 @@ evas_common_font_glyph_search(RGBA_Font *fn, RGBA_Font_Int **fi_ret, Eina_Unicod
867 fi = l->data; 867 fi = l->data;
868 868
869#if 0 /* FIXME: charmap user is disabled and use a deprecated data type. */ 869#if 0 /* FIXME: charmap user is disabled and use a deprecated data type. */
870/* 870/*
871 if (fi->src->charmap) // Charmap loaded, FI/FS blank 871 if (fi->src->charmap) // Charmap loaded, FI/FS blank
872 { 872 {
873 idx = evas_array_hash_search(fi->src->charmap, gl); 873 idx = evas_array_hash_search(fi->src->charmap, gl);
diff --git a/src/lib/evas/common/evas_font_ot.c b/src/lib/evas/common/evas_font_ot.c
index 230abd68eb..47c624c99a 100644
--- a/src/lib/evas/common/evas_font_ot.c
+++ b/src/lib/evas/common/evas_font_ot.c
@@ -1,12 +1,10 @@
1#include "evas_common_private.h" 1#include "evas_font_private.h"
2 2
3#ifdef USE_HARFBUZZ 3#ifdef USE_HARFBUZZ
4# include <hb.h> 4# include <hb.h>
5# include <hb-ft.h> 5# include <hb-ft.h>
6#endif 6#endif
7 7
8#include "evas_font_private.h"
9
10#ifdef USE_HARFBUZZ 8#ifdef USE_HARFBUZZ
11static const hb_script_t 9static const hb_script_t
12_evas_script_to_harfbuzz[] = 10_evas_script_to_harfbuzz[] =
diff --git a/src/lib/evas/common/evas_font_ot.h b/src/lib/evas/common/evas_font_ot.h
index fe263db759..e38e758b00 100644
--- a/src/lib/evas/common/evas_font_ot.h
+++ b/src/lib/evas/common/evas_font_ot.h
@@ -1,6 +1,10 @@
1#ifndef _EVAS_FONT_OT_H 1#ifndef _EVAS_FONT_OT_H
2# define _EVAS_FONT_OT_H 2# define _EVAS_FONT_OT_H
3 3
4#ifdef HAVE_CONFIG_H
5# include "config.h"
6#endif
7
4# ifdef HAVE_HARFBUZZ 8# ifdef HAVE_HARFBUZZ
5# define OT_SUPPORT 9# define OT_SUPPORT
6# define USE_HARFBUZZ 10# define USE_HARFBUZZ
@@ -17,8 +21,8 @@ typedef void *Evas_Font_OT_Info;
17struct _Evas_Font_OT_Info 21struct _Evas_Font_OT_Info
18{ 22{
19 size_t source_cluster; 23 size_t source_cluster;
20 Evas_Coord x_offset; 24 int x_offset;
21 Evas_Coord y_offset; 25 int y_offset;
22}; 26};
23# endif 27# endif
24 28
@@ -28,7 +32,8 @@ struct _Evas_Font_OT_Info
28# define EVAS_FONT_OT_POS_GET(a) ((a).source_cluster) 32# define EVAS_FONT_OT_POS_GET(a) ((a).source_cluster)
29# endif 33# endif
30 34
31# include "evas_text_utils.h" 35#include "evas_font.h"
36
32EAPI int 37EAPI int
33evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_index); 38evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_index);
34 39
diff --git a/src/lib/evas/common/evas_font_private.h b/src/lib/evas/common/evas_font_private.h
index 904a01e4bf..213ef7f96f 100644
--- a/src/lib/evas/common/evas_font_private.h
+++ b/src/lib/evas/common/evas_font_private.h
@@ -1,10 +1,50 @@
1#ifndef _EVAS_FONT_PRIVATE_H 1#ifndef _EVAS_FONT_PRIVATE_H
2# define _EVAS_FONT_PRIVATE_H 2#define _EVAS_FONT_PRIVATE_H
3#include "evas_font_ot.h" 3
4#include "evas_font.h"
5
6/* macros needed to log message through eina_log */
7extern EAPI int _evas_font_log_dom_global;
8#ifdef _EVAS_FONT_DEFAULT_LOG_DOM
9# undef _EVAS_FONT_DEFAULT_LOG_DOM
10#endif
11#define _EVAS_FONT_DEFAULT_LOG_DOM _evas_font_log_dom_global
12
13#ifdef EVAS_FONT_DEFAULT_LOG_COLOR
14# undef EVAS_FONT_DEFAULT_LOG_COLOR
15#endif
16#define EVAS_FONT_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
17
18#ifdef ERR
19# undef ERR
20#endif
21#define ERR(...) EINA_LOG_DOM_ERR(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__)
22
23#ifdef DBG
24# undef DBG
25#endif
26#define DBG(...) EINA_LOG_DOM_DBG(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__)
27
28#ifdef INF
29# undef INF
30#endif
31#define INF(...) EINA_LOG_DOM_INFO(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__)
32
33#ifdef WRN
34# undef WRN
35#endif
36#define WRN(...) EINA_LOG_DOM_WARN(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__)
37
38#ifdef CRI
39# undef CRI
40#endif
41#define CRI(...) EINA_LOG_DOM_CRIT(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__)
42
4 43
5extern LK(lock_font_draw); // for freetype2 API calls 44extern LK(lock_font_draw); // for freetype2 API calls
6extern LK(lock_bidi); // for fribidi API calls 45extern LK(lock_bidi); // for fribidi API calls
7extern LK(lock_ot); // for harfbuzz calls 46extern LK(lock_ot); // for harfbuzz calls
47
8# define FTLOCK() LKL(lock_font_draw) 48# define FTLOCK() LKL(lock_font_draw)
9# define FTUNLOCK() LKU(lock_font_draw) 49# define FTUNLOCK() LKU(lock_font_draw)
10 50
diff --git a/src/lib/evas/common/evas_font_query.c b/src/lib/evas/common/evas_font_query.c
index 0fd5bc1360..1ff0447963 100644
--- a/src/lib/evas/common/evas_font_query.c
+++ b/src/lib/evas/common/evas_font_query.c
@@ -1,7 +1,4 @@
1#include "evas_common_private.h"
2#include "language/evas_bidi_utils.h" /*defines BIDI_SUPPORT if possible */
3#include "evas_font_private.h" /* for Frame-Queuing support */ 1#include "evas_font_private.h" /* for Frame-Queuing support */
4#include "evas_font_ot.h"
5 2
6 3
7/* FIXME: Check coverage according to the font and not by actually loading */ 4/* FIXME: Check coverage according to the font and not by actually loading */
diff --git a/src/lib/evas/common/evas_text_utils.c b/src/lib/evas/common/evas_text_utils.c
index 5c00c7fb54..93e5694609 100644
--- a/src/lib/evas/common/evas_text_utils.c
+++ b/src/lib/evas/common/evas_text_utils.c
@@ -1,8 +1,4 @@
1#include "evas_common_private.h"
2#include "evas_font_private.h" 1#include "evas_font_private.h"
3#include "evas_text_utils.h"
4#include "language/evas_bidi_utils.h"
5#include "language/evas_language_utils.h"
6 2
7#define PROPS_CHANGE(Props) Props->changed = EINA_TRUE; 3#define PROPS_CHANGE(Props) Props->changed = EINA_TRUE;
8 4
@@ -47,7 +43,7 @@ evas_common_text_props_content_ref(Evas_Text_Props *props)
47 return; 43 return;
48 44
49 props->info->refcount++; 45 props->info->refcount++;
50 if (props->font_instance) 46 if (props->font_instance)
51 ((RGBA_Font_Int *)props->font_instance)->references++; 47 ((RGBA_Font_Int *)props->font_instance)->references++;
52} 48}
53 49
@@ -541,7 +537,7 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text,
541 text_props->font_instance = fi; 537 text_props->font_instance = fi;
542 fi->references++; 538 fi->references++;
543 } 539 }
544 540
545 evas_common_font_int_reload(fi); 541 evas_common_font_int_reload(fi);
546 if (fi->src->current_size != fi->size) 542 if (fi->src->current_size != fi->size)
547 { 543 {
diff --git a/src/lib/evas/common/evas_text_utils.h b/src/lib/evas/common/evas_text_utils.h
index 2c49dcb73a..36039568fa 100644
--- a/src/lib/evas/common/evas_text_utils.h
+++ b/src/lib/evas/common/evas_text_utils.h
@@ -17,7 +17,6 @@ typedef enum
17} Evas_Text_Props_Mode; 17} Evas_Text_Props_Mode;
18 18
19# include "evas_font_ot.h" 19# include "evas_font_ot.h"
20# include "language/evas_bidi_utils.h"
21# include "language/evas_language_utils.h" 20# include "language/evas_language_utils.h"
22 21
23/* Used for showing "malformed" or missing chars */ 22/* Used for showing "malformed" or missing chars */
@@ -126,7 +125,7 @@ struct _Evas_Font_Glyph_Info
126 // relative layout info... worry then. 125 // relative layout info... worry then.
127 Evas_Coord pen_after; // 4 126 Evas_Coord pen_after; // 4
128 short x_bear, y_bear, width; // 6 127 short x_bear, y_bear, width; // 6
129#else 128#else
130 Evas_Coord x_bear; // 4 129 Evas_Coord x_bear; // 4
131 /* This one is rarely used, only in draw, in which we already get the glyph 130 /* This one is rarely used, only in draw, in which we already get the glyph
132 * so it doesn't really save time. Leaving it here just so no one will 131 * so it doesn't really save time. Leaving it here just so no one will
@@ -134,7 +133,7 @@ struct _Evas_Font_Glyph_Info
134 Evas_Coord y_bear; // 4 133 Evas_Coord y_bear; // 4
135 Evas_Coord width; // 4 134 Evas_Coord width; // 4
136 Evas_Coord pen_after; // 4 135 Evas_Coord pen_after; // 4
137#endif 136#endif
138}; 137};
139 138
140void 139void