#define EVAS_FONT_WALK_TEXT_INIT() \
int pen_x = 0, pen_y = 0; \
int char_index; \
- int last_adv; \
FT_UInt prev_index; \
FT_Face pface = NULL; \
(void) pen_y; /* Sometimes it won't be used */
int adv; \
int visible; \
prev_index = 0; \
- last_adv = 0; \
for (char_index = 0 ; *text ; text++, char_index++) \
{ \
FT_UInt index; \
\
pface = fi->src->ft.face; \
LKU(fi->ft_mutex); \
- /* If the current one is not a compositing char, do the */ \
- /* previous advance and set the current advance as the next */ \
- /* advance to do. If it's an invisible char (i.e one that shouldn't
- * be printed anyhow, we want to advance everything as if it's
- * a visible char. FIXME: use a proper way to detect diacritic
- * instead. */ \
- if ((adv > 0) || !visible) \
- { \
- pen_x += last_adv; \
- last_adv = adv; \
- } \
/**
* @def EVAS_FONT_WALK_TEXT_END
* @see EVAS_FONT_WALK_TEXT_WORK
*/
#define EVAS_FONT_WALK_TEXT_END() \
+ if (visible) \
+ { \
+ pen_x += adv; \
+ } \
prev_index = index; \
} \
} \
evas_common_font_query_size(RGBA_Font *fn, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props __UNUSED__, int *w, int *h)
{
int keep_width = 0;
+ int prev_pen_x = 0;
int use_kerning;
RGBA_Font_Int *fi;
EVAS_FONT_WALK_TEXT_INIT();
EVAS_FONT_WALK_TEXT_WORK();
/* Keep the width because we'll need it for the last char */
keep_width = width + bear_x;
+ /* Keep the previous pen_x, before it's advanced in TEXT_END */
+ prev_pen_x = pen_x;
}
EVAS_FONT_WALK_TEXT_END();
- if (w) *w = pen_x + keep_width;
+ if (w) *w = prev_pen_x + keep_width;
if (h) *h = evas_common_font_max_ascent_get(fn) + evas_common_font_max_descent_get(fn);
evas_common_font_int_use_trim();
}
EAPI void
evas_common_font_query_advance(RGBA_Font *fn, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int *h_adv, int *v_adv)
{
- int keep_adv = 0;
int use_kerning;
RGBA_Font_Int *fi;
EVAS_FONT_WALK_TEXT_INIT();
EVAS_FONT_WALK_TEXT_START()
{
EVAS_FONT_WALK_TEXT_WORK();
- /* Keep the advancement because we want to also do the last
- * advancement */
- keep_adv = adv;
}
EVAS_FONT_WALK_TEXT_END();
if (v_adv) *v_adv = evas_common_font_get_line_advance(fn);
- if (h_adv) *h_adv = pen_x + keep_adv;
+ if (h_adv) *h_adv = pen_x;
evas_common_font_int_use_trim();
}