forked from enlightenment/efl
1. Started feeding Evas_Text_Props to the font engine instead of Evas_BiDi_Props because no we have more general text properties as well - i.e, OpenType stuff. 2. Full Harfbuzz integration which gets compiled in by default (if harfbuzz is present) but only works if the environment variable EVAS_USE_OT is set to 1 (because OT is way slower than regular text rendering). 3. Cleaned the font querying/drawing functions. 4. Added font_shaped function to all of the engines, which by default calls teh harfbuzz stuff (default on linux that is). 5. Moved some source files around a bit to make more sense. SVN revision: 56455devs/devilhorns/wayland_egl
parent
836b16f085
commit
ff18fa8399
37 changed files with 1891 additions and 577 deletions
@ -0,0 +1,203 @@ |
||||
#ifndef _EVAS_FONT_DEFAULT_WALK_X |
||||
#define _EVAS_FONT_DEFAULT_WALK_X |
||||
/* Macros for text walking */ |
||||
|
||||
/** |
||||
* @def EVAS_FONT_UPDATE_KERN() |
||||
* @internal |
||||
* This macro updates pen_x and kern according to kerning. |
||||
* This macro assumes the following variables exist: |
||||
* intl_props, char_index, adv, fi, kern, pen_x |
||||
*/ |
||||
#ifdef BIDI_SUPPORT |
||||
#define EVAS_FONT_UPDATE_KERN(is_visual) \ |
||||
do \ |
||||
{ \ |
||||
/* if it's rtl, the kerning matching should be reversed, */ \ |
||||
/* i.e prev index is now the index and the other way */ \ |
||||
/* around. There is a slight exception when there are */ \ |
||||
/* compositing chars involved.*/ \ |
||||
if (intl_props && (intl_props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) && \ |
||||
visible && !is_visual) \ |
||||
{ \ |
||||
if (evas_common_font_query_kerning(fi, index, prev_index, &kern)) \ |
||||
pen_x += kern; \ |
||||
} \ |
||||
else \ |
||||
{ \ |
||||
if (evas_common_font_query_kerning(fi, prev_index, index, &kern)) \ |
||||
pen_x += kern; \ |
||||
} \ |
||||
} \ |
||||
while (0) |
||||
#else |
||||
#define EVAS_FONT_UPDATE_KERN(is_visual) \ |
||||
do \ |
||||
{ \ |
||||
(void) is_visual; \ |
||||
if (evas_common_font_query_kerning(fi, prev_index, index, &kern)) \ |
||||
pen_x += kern; \ |
||||
} \ |
||||
while (0) |
||||
#endif |
||||
|
||||
/** |
||||
* @def EVAS_FONT_WALK_DEFAULT_TEXT_VISUAL_START |
||||
* @internal |
||||
* This runs through the variable text while updating char_index, |
||||
* which is the current index in the text. This macro exposes (inside |
||||
* the loop) the following vars: |
||||
* adv - advancement |
||||
* gl - the current unicode code point |
||||
* bear_x, bear_y, width - info about the bitmap |
||||
* pen_x, pen_y - (also available outside of the loop, but updated here) |
||||
* fg - the font glyph. |
||||
* index, prev_index - font indexes. |
||||
* Does not end with a ; |
||||
* @see EVAS_FONT_WALK_DEFAULT_TEXT_INIT |
||||
* @see EVAS_FONT_WALK_DEFAULT_TEXT_WORK |
||||
* @see EVAS_FONT_WALK_DEFAULT_TEXT_END |
||||
*/ |
||||
#define EVAS_FONT_WALK_DEFAULT_TEXT_VISUAL_START() \ |
||||
do \ |
||||
{ \ |
||||
const Eina_Unicode *_base_text; \ |
||||
int _char_index_d, _i; \ |
||||
int visible; \ |
||||
prev_index = 0; \ |
||||
_base_text = text; \ |
||||
for ( ; *text ; text++); \ |
||||
_i = text - _base_text; \ |
||||
if (intl_props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) \ |
||||
{ \ |
||||
char_index = text - _base_text - 1; \ |
||||
text--; \ |
||||
_char_index_d = -1; \ |
||||
} \ |
||||
else \ |
||||
{ \ |
||||
char_index = 0; \ |
||||
text = _base_text; \ |
||||
_char_index_d = 1; \ |
||||
} \ |
||||
for ( ; _i > 0 ; char_index += _char_index_d, text += _char_index_d, _i--) \ |
||||
{ \ |
||||
FT_UInt index; \ |
||||
RGBA_Font_Glyph *fg; \ |
||||
int gl, kern; \ |
||||
gl = *text; \ |
||||
if (gl == 0) break; |
||||
/** |
||||
* @def EVAS_FONT_WALK_DEFAULT_TEXT_LOGICAL_START |
||||
* @internal |
||||
* FIXME: update |
||||
* This runs through the variable text while updating char_index, |
||||
* which is the current index in the text. This macro exposes (inside |
||||
* the loop) the following vars: |
||||
* adv - advancement |
||||
* gl - the current unicode code point |
||||
* bear_x, bear_y, width - info about the bitmap |
||||
* pen_x, pen_y - (also available outside of the loop, but updated here) |
||||
* fg - the font glyph. |
||||
* index, prev_index - font indexes. |
||||
* Does not end with a ; |
||||
* @see EVAS_FONT_WALK_DEFAULT_TEXT_INIT |
||||
* @see EVAS_FONT_WALK_DEFAULT_TEXT_WORK |
||||
* @see EVAS_FONT_WALK_DEFAULT_TEXT_END |
||||
*/ |
||||
#define EVAS_FONT_WALK_DEFAULT_TEXT_LOGICAL_START() \ |
||||
do \ |
||||
{ \ |
||||
int visible; \ |
||||
prev_index = 0; \ |
||||
for (char_index = 0 ; *text ; text++, char_index++) \ |
||||
{ \ |
||||
FT_UInt index; \ |
||||
RGBA_Font_Glyph *fg; \ |
||||
int gl, kern; \ |
||||
gl = *text; \ |
||||
if (gl == 0) break; |
||||
|
||||
/*FIXME: doc */ |
||||
#define EVAS_FONT_WALK_DEFAULT_X_OFF (kern) |
||||
#define EVAS_FONT_WALK_DEFAULT_Y_OFF (0) |
||||
#define EVAS_FONT_WALK_DEFAULT_X_BEAR (fg->glyph_out->left) |
||||
#define EVAS_FONT_WALK_DEFAULT_Y_BEAR (fg->glyph_out->top) |
||||
#define EVAS_FONT_WALK_DEFAULT_X_ADV (fg->glyph->advance.x >> 16) |
||||
#define EVAS_FONT_WALK_DEFAULT_Y_ADV (0) |
||||
#define EVAS_FONT_WALK_DEFAULT_WIDTH (fg->glyph_out->bitmap.width) |
||||
#define EVAS_FONT_WALK_DEFAULT_POS (char_index) |
||||
#define EVAS_FONT_WALK_DEFAULT_IS_LAST \ |
||||
(!text[char_index]) |
||||
#define EVAS_FONT_WALK_DEFAULT_IS_FIRST \ |
||||
(!char_index) |
||||
#define EVAS_FONT_WALK_DEFAULT_POS_NEXT \ |
||||
((!EVAS_FONT_WALK_DEFAULT_IS_LAST) ? \ |
||||
(char_index + 1) : \ |
||||
(char_index) \ |
||||
) |
||||
#define EVAS_FONT_WALK_DEFAULT_POS_PREV \ |
||||
((!EVAS_FONT_WALK_DEFAULT_IS_FIRST) ? \ |
||||
(char_index - 1) : \ |
||||
EVAS_FONT_WALK_DEFAULT_POS \ |
||||
) |
||||
#define EVAS_FONT_WALK_DEFAULT_LEN (EVAS_FONT_WALK_ORIG_LEN) |
||||
/** |
||||
* @def EVAS_FONT_WALK_DEFAULT_TEXT_WORK |
||||
* @internal |
||||
* This macro actually updates the values mentioned in EVAS_FONT_WALK_DEFAULT_TEXT_VISUAL_START |
||||
* according to the current positing in the walk. |
||||
* @see EVAS_FONT_WALK_DEFAULT_TEXT_VISUAL_START |
||||
* @see EVAS_FONT_WALK_DEFAULT_TEXT_INIT |
||||
* @see EVAS_FONT_WALK_DEFAULT_TEXT_END |
||||
*/ |
||||
#define EVAS_FONT_WALK_DEFAULT_TEXT_WORK(is_visual) \ |
||||
index = evas_common_font_glyph_search(fn, &fi, gl); \ |
||||
LKL(fi->ft_mutex); \ |
||||
fg = evas_common_font_int_cache_glyph_get(fi, index); \ |
||||
if (!fg) \ |
||||
{ \ |
||||
LKU(fi->ft_mutex); \ |
||||
continue; \ |
||||
} \ |
||||
kern = 0; \ |
||||
if (EVAS_FONT_CHARACTER_IS_INVISIBLE(gl)) \ |
||||
{ \ |
||||
visible = 0; \ |
||||
} \ |
||||
else \ |
||||
{ \ |
||||
visible = 1; \ |
||||
} \ |
||||
/* hmmm kerning means i can't sanely do my own cached metric */ \ |
||||
/* tables! grrr - this means font face sharing is kinda... not */ \ |
||||
/* an option if you want performance */ \ |
||||
if ((use_kerning) && (prev_index) && (index) && \ |
||||
(pface == fi->src->ft.face)) \ |
||||
{ \ |
||||
EVAS_FONT_UPDATE_KERN(is_visual); \ |
||||
} \ |
||||
\ |
||||
pface = fi->src->ft.face; \ |
||||
LKU(fi->ft_mutex); \ |
||||
|
||||
/** |
||||
* @def EVAS_FONT_WALK_DEFAULT_TEXT_END |
||||
* @internal |
||||
* Closes EVAS_FONT_WALK_DEFAULT_TEXT_VISUAL_START, needs to end with a ; |
||||
* @see EVAS_FONT_WALK_DEFAULT_TEXT_VISUAL_START |
||||
* @see EVAS_FONT_WALK_DEFAULT_TEXT_INIT |
||||
* @see EVAS_FONT_WALK_DEFAULT_TEXT_WORK |
||||
*/ |
||||
#define EVAS_FONT_WALK_DEFAULT_TEXT_END() \ |
||||
if (visible) \ |
||||
{ \ |
||||
pen_x += EVAS_FONT_WALK_DEFAULT_X_ADV; \ |
||||
} \ |
||||
prev_index = index; \ |
||||
} \ |
||||
} \ |
||||
while(0) |
||||
|
||||
|
||||
#endif |