2002-11-08 00:02:15 -08:00
|
|
|
#include "evas_common.h"
|
|
|
|
|
2009-02-10 07:53:17 -08:00
|
|
|
EAPI int
|
|
|
|
evas_common_font_query_kerning(RGBA_Font_Int* fi,
|
|
|
|
FT_UInt prev, FT_UInt index,
|
|
|
|
int* kerning)
|
|
|
|
{
|
|
|
|
int *result;
|
|
|
|
FT_Vector delta;
|
|
|
|
int key[2];
|
|
|
|
int error = 1;
|
|
|
|
|
|
|
|
key[0] = prev;
|
|
|
|
key[1] = index;
|
|
|
|
|
|
|
|
#ifdef HAVE_PTHREAD
|
|
|
|
pthread_mutex_lock(&fi->ft_mutex);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
result = eina_hash_find(fi->kerning, key);
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
*kerning = result[2];
|
|
|
|
goto on_correct;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTE: ft2 seems to have a bug. and sometimes returns bizarre
|
|
|
|
* values to kern by - given same font, same size and same
|
|
|
|
* prev_index and index. auto/bytecode or none hinting doesnt
|
|
|
|
* matter */
|
|
|
|
if (FT_Get_Kerning(fi->src->ft.face,
|
|
|
|
key[0], key[1],
|
|
|
|
ft_kerning_default, &delta) == 0)
|
|
|
|
{
|
|
|
|
int *push;
|
|
|
|
|
|
|
|
*kerning = delta.x >> 6;
|
|
|
|
|
|
|
|
push = malloc(sizeof (int) * 3);
|
|
|
|
if (!push) return 1;
|
|
|
|
|
|
|
|
push[0] = key[0];
|
|
|
|
push[1] = key[1];
|
|
|
|
push[2] = *kerning;
|
|
|
|
|
|
|
|
eina_hash_direct_add(fi->kerning, push, push);
|
|
|
|
|
|
|
|
goto on_correct;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
|
|
|
|
on_correct:
|
|
|
|
#ifdef HAVE_PTHREAD
|
|
|
|
pthread_mutex_unlock(&fi->ft_mutex);
|
|
|
|
#endif
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2009-05-22 14:12:32 -07:00
|
|
|
/* string extents */
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_font_query_size(RGBA_Font *fn, const char *text, int *w, int *h)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int use_kerning;
|
|
|
|
int pen_x, pen_y;
|
|
|
|
int start_x, end_x;
|
|
|
|
int chr;
|
|
|
|
FT_UInt prev_index;
|
2005-03-20 07:57:55 -08:00
|
|
|
RGBA_Font_Int *fi;
|
2005-04-27 21:57:12 -07:00
|
|
|
FT_Face pface = NULL;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-03-20 07:57:55 -08:00
|
|
|
fi = fn->fonts->data;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
start_x = 0;
|
|
|
|
end_x = 0;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
pen_x = 0;
|
|
|
|
pen_y = 0;
|
2004-01-22 18:14:45 -08:00
|
|
|
evas_common_font_size_use(fn);
|
2005-03-20 07:57:55 -08:00
|
|
|
use_kerning = FT_HAS_KERNING(fi->src->ft.face);
|
2002-11-08 00:02:15 -08:00
|
|
|
prev_index = 0;
|
|
|
|
for (chr = 0; text[chr];)
|
|
|
|
{
|
|
|
|
FT_UInt index;
|
|
|
|
RGBA_Font_Glyph *fg;
|
|
|
|
int chr_x, chr_y, chr_w;
|
2005-09-09 07:19:06 -07:00
|
|
|
int gl, kern;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-13 21:38:10 -08:00
|
|
|
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (gl == 0) break;
|
2005-03-20 07:57:55 -08:00
|
|
|
index = evas_common_font_glyph_search(fn, &fi, gl);
|
2005-04-27 21:57:12 -07:00
|
|
|
/* 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 */
|
2005-09-09 07:19:06 -07:00
|
|
|
kern = 0;
|
2005-04-27 21:57:12 -07:00
|
|
|
if ((use_kerning) && (prev_index) && (index) &&
|
|
|
|
(pface == fi->src->ft.face))
|
2009-02-10 07:53:17 -08:00
|
|
|
if (evas_common_font_query_kerning(fi, prev_index, index, &kern))
|
|
|
|
pen_x += kern;
|
|
|
|
|
2005-04-27 21:57:12 -07:00
|
|
|
pface = fi->src->ft.face;
|
2005-03-20 07:57:55 -08:00
|
|
|
fg = evas_common_font_int_cache_glyph_get(fi, index);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!fg) continue;
|
|
|
|
|
2007-06-18 09:47:20 -07:00
|
|
|
if (kern < 0) kern = 0;
|
|
|
|
chr_x = ((pen_x - kern) + (fg->glyph_out->left));
|
2006-10-08 05:43:31 -07:00
|
|
|
chr_y = (pen_y + (fg->glyph_out->top));
|
2005-09-09 07:19:06 -07:00
|
|
|
// chr_w = fg->glyph_out->bitmap.width;
|
2006-10-08 05:43:31 -07:00
|
|
|
chr_w = fg->glyph_out->bitmap.width + kern;
|
2005-09-09 07:19:06 -07:00
|
|
|
{
|
|
|
|
int advw;
|
|
|
|
|
2006-10-08 05:43:31 -07:00
|
|
|
advw = ((fg->glyph->advance.x + (kern << 16)) >> 16);
|
2005-09-09 07:19:06 -07:00
|
|
|
if (chr_w < advw) chr_w = advw;
|
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-04-27 21:57:12 -07:00
|
|
|
if ((!prev_index) && (chr_x < 0))
|
|
|
|
start_x = chr_x;
|
|
|
|
if ((chr_x + chr_w) > end_x)
|
|
|
|
end_x = chr_x + chr_w;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2006-10-08 05:43:31 -07:00
|
|
|
pen_x += fg->glyph->advance.x >> 16;
|
2003-06-06 19:32:30 -07:00
|
|
|
prev_index = index;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
if (w) *w = end_x - start_x;
|
2002-11-13 21:38:10 -08:00
|
|
|
if (h) *h = evas_common_font_max_ascent_get(fn) + evas_common_font_max_descent_get(fn);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* text x inset */
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI int
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_font_query_inset(RGBA_Font *fn, const char *text)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
FT_UInt index;
|
|
|
|
RGBA_Font_Glyph *fg;
|
|
|
|
int chr;
|
|
|
|
int gl;
|
2005-03-20 07:57:55 -08:00
|
|
|
RGBA_Font_Int *fi;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-03-20 07:57:55 -08:00
|
|
|
fi = fn->fonts->data;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
chr = 0;
|
|
|
|
if (!text[0]) return 0;
|
2005-05-21 19:49:50 -07:00
|
|
|
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (gl == 0) return 0;
|
2004-01-22 18:14:45 -08:00
|
|
|
evas_common_font_size_use(fn);
|
2005-03-20 07:57:55 -08:00
|
|
|
index = evas_common_font_glyph_search(fn, &fi, gl);
|
|
|
|
fg = evas_common_font_int_cache_glyph_get(fi, index);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!fg) return 0;
|
2009-04-23 21:35:52 -07:00
|
|
|
/*
|
2009-09-21 09:08:51 -07:00
|
|
|
INFO("fg->glyph_out->left = %i\n"
|
2007-08-25 04:54:17 -07:00
|
|
|
"fi->src->ft.face->glyph->bitmap_left = %i\n"
|
|
|
|
"fi->src->ft.face->glyph->metrics.horiBearingX = %i\n"
|
|
|
|
"fi->src->ft.face->glyph->metrics.horiBearingY = %i\n"
|
2009-09-21 09:08:51 -07:00
|
|
|
"fi->src->ft.face->glyph->metrics.horiAdvance = %i"
|
2007-08-25 04:54:17 -07:00
|
|
|
,
|
2009-04-23 21:35:52 -07:00
|
|
|
(int)fg->glyph_out->left,
|
2007-08-25 04:54:17 -07:00
|
|
|
(int)fi->src->ft.face->glyph->bitmap_left,
|
|
|
|
(int)fi->src->ft.face->glyph->metrics.horiBearingX >> 6,
|
|
|
|
(int)fi->src->ft.face->glyph->metrics.horiBearingY >> 6,
|
|
|
|
(int)fi->src->ft.face->glyph->metrics.horiAdvance >> 6
|
|
|
|
);
|
|
|
|
*/
|
2002-11-08 00:02:15 -08:00
|
|
|
return fg->glyph_out->left;
|
|
|
|
}
|
|
|
|
|
2009-05-22 14:12:32 -07:00
|
|
|
/* h & v advance */
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_font_query_advance(RGBA_Font *fn, const char *text, int *h_adv, int *v_adv)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int use_kerning;
|
|
|
|
int pen_x, pen_y;
|
|
|
|
int start_x;
|
|
|
|
int chr;
|
|
|
|
FT_UInt prev_index;
|
2005-03-20 07:57:55 -08:00
|
|
|
RGBA_Font_Int *fi;
|
2005-04-27 21:57:12 -07:00
|
|
|
FT_Face pface = NULL;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-03-20 07:57:55 -08:00
|
|
|
fi = fn->fonts->data;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
start_x = 0;
|
|
|
|
pen_x = 0;
|
|
|
|
pen_y = 0;
|
2004-01-22 18:14:45 -08:00
|
|
|
evas_common_font_size_use(fn);
|
2005-03-20 07:57:55 -08:00
|
|
|
use_kerning = FT_HAS_KERNING(fi->src->ft.face);
|
2002-11-08 00:02:15 -08:00
|
|
|
prev_index = 0;
|
2005-05-21 19:49:50 -07:00
|
|
|
for (chr = 0; text[chr];)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
FT_UInt index;
|
|
|
|
RGBA_Font_Glyph *fg;
|
|
|
|
int chr_x, chr_y, chr_w;
|
2009-02-10 07:53:17 -08:00
|
|
|
int gl, kern;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-13 21:38:10 -08:00
|
|
|
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (gl == 0) break;
|
2005-03-20 07:57:55 -08:00
|
|
|
index = evas_common_font_glyph_search(fn, &fi, gl);
|
2005-04-27 21:57:12 -07:00
|
|
|
/* 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))
|
2009-02-10 07:53:17 -08:00
|
|
|
if (evas_common_font_query_kerning(fi, prev_index, index, &kern))
|
|
|
|
pen_x += kern;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-04-27 21:57:12 -07:00
|
|
|
pface = fi->src->ft.face;
|
2005-03-20 07:57:55 -08:00
|
|
|
fg = evas_common_font_int_cache_glyph_get(fi, index);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!fg) continue;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2006-10-08 05:43:31 -07:00
|
|
|
chr_x = (pen_x + (fg->glyph_out->left));
|
|
|
|
chr_y = (pen_y + (fg->glyph_out->top));
|
2002-11-08 00:02:15 -08:00
|
|
|
chr_w = fg->glyph_out->bitmap.width;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2006-10-08 05:43:31 -07:00
|
|
|
pen_x += fg->glyph->advance.x >> 16;
|
2002-11-08 00:02:15 -08:00
|
|
|
prev_index = index;
|
|
|
|
}
|
2002-11-13 21:38:10 -08:00
|
|
|
if (v_adv) *v_adv = evas_common_font_get_line_advance(fn);
|
2006-10-08 05:43:31 -07:00
|
|
|
if (h_adv) *h_adv = pen_x - start_x;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* x y w h for char at char pos */
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI int
|
2009-05-22 14:12:32 -07:00
|
|
|
evas_common_font_query_char_coords(RGBA_Font *fn, const char *text, int pos, int *cx, int *cy, int *cw, int *ch)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int use_kerning;
|
|
|
|
int pen_x, pen_y;
|
2003-06-06 19:32:30 -07:00
|
|
|
int prev_chr_end;
|
2002-11-08 00:02:15 -08:00
|
|
|
int chr;
|
2003-06-06 19:32:30 -07:00
|
|
|
int asc, desc;
|
2002-11-08 00:02:15 -08:00
|
|
|
FT_UInt prev_index;
|
2005-03-20 07:57:55 -08:00
|
|
|
RGBA_Font_Int *fi;
|
2005-04-27 21:57:12 -07:00
|
|
|
FT_Face pface = NULL;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-03-20 07:57:55 -08:00
|
|
|
fi = fn->fonts->data;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
pen_x = 0;
|
|
|
|
pen_y = 0;
|
2004-01-22 18:14:45 -08:00
|
|
|
evas_common_font_size_use(fn);
|
2005-03-20 07:57:55 -08:00
|
|
|
use_kerning = FT_HAS_KERNING(fi->src->ft.face);
|
2002-11-08 00:02:15 -08:00
|
|
|
prev_index = 0;
|
2003-06-06 19:32:30 -07:00
|
|
|
prev_chr_end = 0;
|
|
|
|
asc = evas_common_font_max_ascent_get(fn);
|
|
|
|
desc = evas_common_font_max_descent_get(fn);
|
2009-05-22 14:12:32 -07:00
|
|
|
for (chr = 0; text[chr];)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2002-12-29 09:57:37 -08:00
|
|
|
int pchr;
|
2002-11-08 00:02:15 -08:00
|
|
|
FT_UInt index;
|
|
|
|
RGBA_Font_Glyph *fg;
|
2003-06-06 19:32:30 -07:00
|
|
|
int chr_x, chr_y, chr_w;
|
|
|
|
int gl, kern;
|
|
|
|
|
2002-12-29 09:57:37 -08:00
|
|
|
pchr = chr;
|
2002-11-13 21:38:10 -08:00
|
|
|
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (gl == 0) break;
|
2005-03-20 07:57:55 -08:00
|
|
|
index = evas_common_font_glyph_search(fn, &fi, gl);
|
2003-06-06 19:32:30 -07:00
|
|
|
kern = 0;
|
2005-04-27 21:57:12 -07:00
|
|
|
/* 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) &&
|
2009-05-22 14:12:32 -07:00
|
|
|
(pface == fi->src->ft.face))
|
|
|
|
if (evas_common_font_query_kerning(fi, prev_index, index, &kern))
|
|
|
|
pen_x += kern;
|
2009-02-10 07:53:17 -08:00
|
|
|
|
2005-04-27 21:57:12 -07:00
|
|
|
pface = fi->src->ft.face;
|
2005-03-20 07:57:55 -08:00
|
|
|
fg = evas_common_font_int_cache_glyph_get(fi, index);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!fg) continue;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
|
|
|
if (kern < 0) kern = 0;
|
2006-10-08 05:43:31 -07:00
|
|
|
chr_x = ((pen_x - kern) + (fg->glyph_out->left));
|
|
|
|
chr_y = (pen_y + (fg->glyph_out->top));
|
|
|
|
chr_w = fg->glyph_out->bitmap.width + (kern);
|
2005-02-09 08:10:56 -08:00
|
|
|
/* if (text[chr]) */
|
2003-01-07 22:39:38 -08:00
|
|
|
{
|
2003-06-06 19:32:30 -07:00
|
|
|
int advw;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2006-10-08 05:43:31 -07:00
|
|
|
advw = ((fg->glyph->advance.x + (kern << 16)) >> 16);
|
2003-06-06 19:32:30 -07:00
|
|
|
if (chr_w < advw) chr_w = advw;
|
|
|
|
}
|
|
|
|
if (chr_x > prev_chr_end)
|
|
|
|
{
|
|
|
|
chr_w += (chr_x - prev_chr_end);
|
|
|
|
chr_x = prev_chr_end;
|
2003-01-07 22:39:38 -08:00
|
|
|
}
|
2009-05-22 14:12:32 -07:00
|
|
|
if (pchr == pos)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
if (cx) *cx = chr_x;
|
2003-06-06 19:32:30 -07:00
|
|
|
if (cy) *cy = -asc;
|
2002-11-08 00:02:15 -08:00
|
|
|
if (cw) *cw = chr_w;
|
2003-06-06 19:32:30 -07:00
|
|
|
if (ch) *ch = asc + desc;
|
2009-05-22 14:12:32 -07:00
|
|
|
return 1;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2003-06-06 19:32:30 -07:00
|
|
|
prev_chr_end = chr_x + chr_w;
|
2006-10-08 05:43:31 -07:00
|
|
|
pen_x += fg->glyph->advance.x >> 16;
|
2002-11-08 00:02:15 -08:00
|
|
|
prev_index = index;
|
|
|
|
}
|
2009-05-22 14:12:32 -07:00
|
|
|
return 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* char pos of text at xy pos */
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI int
|
2009-05-22 14:12:32 -07:00
|
|
|
evas_common_font_query_text_at_pos(RGBA_Font *fn, const char *text, int x, int y, int *cx, int *cy, int *cw, int *ch)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int use_kerning;
|
|
|
|
int pen_x, pen_y;
|
2003-06-06 19:32:30 -07:00
|
|
|
int prev_chr_end;
|
2002-11-08 00:02:15 -08:00
|
|
|
int chr;
|
2003-06-06 19:32:30 -07:00
|
|
|
int asc, desc;
|
2002-11-08 00:02:15 -08:00
|
|
|
FT_UInt prev_index;
|
2005-03-20 07:57:55 -08:00
|
|
|
RGBA_Font_Int *fi;
|
2005-04-27 21:57:12 -07:00
|
|
|
FT_Face pface = NULL;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-03-20 07:57:55 -08:00
|
|
|
fi = fn->fonts->data;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
pen_x = 0;
|
|
|
|
pen_y = 0;
|
2004-01-22 18:14:45 -08:00
|
|
|
evas_common_font_size_use(fn);
|
2005-03-20 07:57:55 -08:00
|
|
|
use_kerning = FT_HAS_KERNING(fi->src->ft.face);
|
2002-11-08 00:02:15 -08:00
|
|
|
prev_index = 0;
|
2003-06-06 19:32:30 -07:00
|
|
|
prev_chr_end = 0;
|
|
|
|
asc = evas_common_font_max_ascent_get(fn);
|
|
|
|
desc = evas_common_font_max_descent_get(fn);
|
2002-11-08 00:02:15 -08:00
|
|
|
for (chr = 0; text[chr];)
|
|
|
|
{
|
2002-12-28 17:49:07 -08:00
|
|
|
int pchr;
|
2002-11-08 00:02:15 -08:00
|
|
|
FT_UInt index;
|
|
|
|
RGBA_Font_Glyph *fg;
|
|
|
|
int chr_x, chr_y, chr_w;
|
2003-05-29 22:05:52 -07:00
|
|
|
int gl, kern;
|
2002-12-28 17:49:07 -08:00
|
|
|
|
|
|
|
pchr = chr;
|
2002-11-13 21:38:10 -08:00
|
|
|
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (gl == 0) break;
|
2005-03-20 07:57:55 -08:00
|
|
|
index = evas_common_font_glyph_search(fn, &fi, gl);
|
2003-05-29 22:05:52 -07:00
|
|
|
kern = 0;
|
2005-04-27 21:57:12 -07:00
|
|
|
/* 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))
|
2009-02-10 07:53:17 -08:00
|
|
|
if (evas_common_font_query_kerning(fi, prev_index, index, &kern))
|
|
|
|
pen_x += kern;
|
|
|
|
|
2005-04-27 21:57:12 -07:00
|
|
|
pface = fi->src->ft.face;
|
2005-03-20 07:57:55 -08:00
|
|
|
fg = evas_common_font_int_cache_glyph_get(fi, index);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!fg) continue;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
|
|
|
if (kern < 0) kern = 0;
|
2006-10-08 05:43:31 -07:00
|
|
|
chr_x = ((pen_x - kern) + (fg->glyph_out->left));
|
|
|
|
chr_y = (pen_y + (fg->glyph_out->top));
|
|
|
|
chr_w = fg->glyph_out->bitmap.width + kern;
|
2005-02-09 08:10:56 -08:00
|
|
|
/* if (text[chr]) */
|
2003-01-07 22:39:38 -08:00
|
|
|
{
|
2003-06-06 19:32:30 -07:00
|
|
|
int advw;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2006-10-08 05:43:31 -07:00
|
|
|
advw = ((fg->glyph->advance.x + (kern << 16)) >> 16);
|
2003-06-06 19:32:30 -07:00
|
|
|
if (chr_w < advw) chr_w = advw;
|
|
|
|
}
|
|
|
|
if (chr_x > prev_chr_end)
|
|
|
|
{
|
|
|
|
chr_w += (chr_x - prev_chr_end);
|
|
|
|
chr_x = prev_chr_end;
|
2003-01-07 22:39:38 -08:00
|
|
|
}
|
2004-05-20 00:38:43 -07:00
|
|
|
if ((x >= chr_x) && (x <= (chr_x + chr_w)) &&
|
|
|
|
(y >= -asc) && (y <= desc))
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2009-05-22 14:12:32 -07:00
|
|
|
if (cx) *cx = chr_x;
|
|
|
|
if (cy) *cy = -asc;
|
|
|
|
if (cw) *cw = chr_w;
|
|
|
|
if (ch) *ch = asc + desc;
|
2002-12-28 17:49:07 -08:00
|
|
|
return pchr;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2003-06-06 19:32:30 -07:00
|
|
|
prev_chr_end = chr_x + chr_w;
|
2006-10-08 05:43:31 -07:00
|
|
|
pen_x += fg->glyph->advance.x >> 16;
|
2002-11-08 00:02:15 -08:00
|
|
|
prev_index = index;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|