forked from enlightenment/efl
werd to my homies... this had to happen sooner or later.... evas supports
FONTSETS! so u can do Vera,Kochi,Blah ... etc. as the font name it will fall back font by font until it finds a char or finally fails. this is for internationalisation support... WHERD! SVN revision: 13804
This commit is contained in:
parent
7d7ac615c8
commit
7462681dad
|
@ -185,6 +185,7 @@ make install
|
|||
@todo (1.0) Add font listing calls
|
||||
@todo (1.0) Add ability to check image comments & disk format
|
||||
@todo (1.0) Add group objects
|
||||
@todo (1.0) Add fontset support
|
||||
@todo (1.0) Export engine rendering API cleanly to Evas API
|
||||
@todo (1.0) Add smart object ability to provide rendering callback
|
||||
@todo (1.1) Make freetype optional and put in optional graymap font engine
|
||||
|
|
|
@ -46,66 +46,171 @@ evas_font_dir_cache_find(char *dir, char *font)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static Evas_List *
|
||||
evas_font_set_get(char *name)
|
||||
{
|
||||
Evas_List *fonts = NULL;
|
||||
char *p;
|
||||
|
||||
p = strchr(name, ',');
|
||||
if (!p)
|
||||
{
|
||||
fonts = evas_list_append(fonts, strdup(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
char *nm, *pp;
|
||||
|
||||
pp = name;
|
||||
while (p)
|
||||
{
|
||||
nm = malloc(p - pp + 1);
|
||||
strncpy(nm, pp, p - pp);
|
||||
nm[p - pp] = 0;
|
||||
fonts = evas_list_append(fonts, nm);
|
||||
pp = p + 1;
|
||||
p = strchr(pp, ',');
|
||||
if (!p) fonts = evas_list_append(fonts, strdup(pp));
|
||||
}
|
||||
}
|
||||
return fonts;
|
||||
}
|
||||
|
||||
void *
|
||||
evas_font_load(Evas *evas, char *name, char *source, int size)
|
||||
{
|
||||
void *font = NULL;
|
||||
Evas_List *fonts, *l;
|
||||
|
||||
#ifdef BUILD_FONT_LOADER_EET
|
||||
if (source)
|
||||
fonts = evas_font_set_get(name);
|
||||
for (l = fonts; l; l = l->next)
|
||||
{
|
||||
Eet_File *ef;
|
||||
char *fake_name;
|
||||
char *nm;
|
||||
|
||||
fake_name = evas_file_path_join(source, name);
|
||||
if (fake_name)
|
||||
nm = l->data;
|
||||
if (l == fonts)
|
||||
{
|
||||
font = evas->engine.func->font_load(evas->engine.data.output, fake_name, size);
|
||||
#ifdef BUILD_FONT_LOADER_EET
|
||||
if (source)
|
||||
{
|
||||
Eet_File *ef;
|
||||
char *fake_name;
|
||||
|
||||
fake_name = evas_file_path_join(source, nm);
|
||||
if (fake_name)
|
||||
{
|
||||
font = evas->engine.func->font_load(evas->engine.data.output, fake_name, size);
|
||||
if (!font)
|
||||
{
|
||||
/* read original!!! */
|
||||
ef = eet_open(source, EET_FILE_MODE_READ);
|
||||
if (ef)
|
||||
{
|
||||
void *fdata;
|
||||
int fsize = 0;
|
||||
|
||||
fdata = eet_read(ef, nm, &fsize);
|
||||
if ((fdata) && (fsize > 0))
|
||||
{
|
||||
font = evas->engine.func->font_memory_load(evas->engine.data.output, fake_name, size, fdata, fsize);
|
||||
free(fdata);
|
||||
}
|
||||
eet_close(ef);
|
||||
}
|
||||
}
|
||||
free(fake_name);
|
||||
}
|
||||
}
|
||||
if (!font)
|
||||
{
|
||||
/* read original!!! */
|
||||
ef = eet_open(source, EET_FILE_MODE_READ);
|
||||
if (ef)
|
||||
{
|
||||
void *fdata;
|
||||
int fsize = 0;
|
||||
|
||||
fdata = eet_read(ef, name, &fsize);
|
||||
if ((fdata) && (fsize > 0))
|
||||
{
|
||||
font = evas->engine.func->font_memory_load(evas->engine.data.output, fake_name, size, fdata, fsize);
|
||||
free(fdata);
|
||||
}
|
||||
eet_close(ef);
|
||||
}
|
||||
}
|
||||
free(fake_name);
|
||||
}
|
||||
}
|
||||
if (!font)
|
||||
{
|
||||
#endif
|
||||
if (evas_file_path_is_full_path((char *)name))
|
||||
font = evas->engine.func->font_load(evas->engine.data.output, (char *)name, size);
|
||||
if (evas_file_path_is_full_path((char *)nm))
|
||||
font = evas->engine.func->font_load(evas->engine.data.output, (char *)nm, size);
|
||||
else
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
for (l = evas->font_path; l; l = l->next)
|
||||
{
|
||||
char *f_file;
|
||||
|
||||
f_file = evas_font_dir_cache_find(l->data, (char *)nm);
|
||||
if (f_file)
|
||||
{
|
||||
font = evas->engine.func->font_load(evas->engine.data.output, f_file, size);
|
||||
if (font) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef BUILD_FONT_LOADER_EET
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
Evas_List *l;
|
||||
int ok = 0;
|
||||
|
||||
for (l = evas->font_path; l; l = l->next)
|
||||
#ifdef BUILD_FONT_LOADER_EET
|
||||
if (source)
|
||||
{
|
||||
char *f_file;
|
||||
Eet_File *ef;
|
||||
char *fake_name;
|
||||
|
||||
f_file = evas_font_dir_cache_find(l->data, (char *)name);
|
||||
if (f_file)
|
||||
fake_name = evas_file_path_join(source, nm);
|
||||
if (fake_name)
|
||||
{
|
||||
font = evas->engine.func->font_load(evas->engine.data.output, f_file, size);
|
||||
if (font) break;
|
||||
/* FIXME: make an engine func */
|
||||
if (!evas_common_font_add(font, fake_name, size))
|
||||
{
|
||||
/* read original!!! */
|
||||
ef = eet_open(source, EET_FILE_MODE_READ);
|
||||
if (ef)
|
||||
{
|
||||
void *fdata;
|
||||
int fsize = 0;
|
||||
|
||||
fdata = eet_read(ef, nm, &fsize);
|
||||
if ((fdata) && (fsize > 0))
|
||||
{
|
||||
ok = evas_common_font_memory_add(font, fake_name, size, fdata, fsize);
|
||||
free(fdata);
|
||||
}
|
||||
eet_close(ef);
|
||||
}
|
||||
}
|
||||
else
|
||||
ok = 1;
|
||||
free(fake_name);
|
||||
}
|
||||
}
|
||||
#ifdef BUILD_FONT_LOADER_EET
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
#endif
|
||||
if (evas_file_path_is_full_path((char *)nm))
|
||||
evas_common_font_add(font, (char *)nm, size);
|
||||
else
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
for (l = evas->font_path; l; l = l->next)
|
||||
{
|
||||
char *f_file;
|
||||
|
||||
f_file = evas_font_dir_cache_find(l->data, (char *)nm);
|
||||
if (f_file)
|
||||
{
|
||||
if (evas_common_font_add(font, f_file, size))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef BUILD_FONT_LOADER_EET
|
||||
}
|
||||
#endif
|
||||
}
|
||||
free(nm);
|
||||
}
|
||||
evas_list_free(fonts);
|
||||
return font;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ static void evas_engine_buffer_image_cache_set(void *data, int bytes);
|
|||
static int evas_engine_buffer_image_cache_get(void *data);
|
||||
static void *evas_engine_buffer_font_load(void *data, char *name, int size);
|
||||
static void *evas_engine_buffer_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size);
|
||||
static void *evas_engine_buffer_font_add(void *data, void *font, char *name, int size);
|
||||
static void *evas_engine_buffer_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size);
|
||||
static void evas_engine_buffer_font_free(void *data, void *font);
|
||||
static int evas_engine_buffer_font_ascent_get(void *data, void *font);
|
||||
static int evas_engine_buffer_font_descent_get(void *data, void *font);
|
||||
|
@ -156,6 +158,8 @@ Evas_Func evas_engine_buffer_func =
|
|||
/* font draw functions */
|
||||
evas_engine_buffer_font_load,
|
||||
evas_engine_buffer_font_memory_load,
|
||||
evas_engine_buffer_font_add,
|
||||
evas_engine_buffer_font_memory_add,
|
||||
evas_engine_buffer_font_free,
|
||||
evas_engine_buffer_font_ascent_get,
|
||||
evas_engine_buffer_font_descent_get,
|
||||
|
@ -939,6 +943,24 @@ evas_engine_buffer_font_memory_load(void *data, char *name, int size, const void
|
|||
return evas_common_font_memory_load(name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void *
|
||||
evas_engine_buffer_font_add(void *data, void *font, char *name, int size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_add(font, name, size);
|
||||
}
|
||||
|
||||
static void *
|
||||
evas_engine_buffer_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void
|
||||
evas_engine_buffer_font_free(void *data, void *font)
|
||||
{
|
||||
|
@ -1054,7 +1076,7 @@ evas_engine_buffer_font_draw(void *data, void *context, void *surface, void *fon
|
|||
evas_common_font_draw(surface, context, font, x, y, text);
|
||||
else
|
||||
{
|
||||
/* create output surface size render_w x render_h, draw text in adapted size, and scale to w x h */
|
||||
/* create output surface size ow x oh and scale to w x h */
|
||||
RGBA_Draw_Context *dc, *dc_in;
|
||||
|
||||
dc_in = context;
|
||||
|
@ -1064,45 +1086,26 @@ evas_engine_buffer_font_draw(void *data, void *context, void *surface, void *fon
|
|||
RGBA_Image *im;
|
||||
int inset;
|
||||
|
||||
if ((h * ow) < (w * oh))
|
||||
{
|
||||
mult = w;
|
||||
divv = ow;
|
||||
}
|
||||
else
|
||||
{
|
||||
mult = h;
|
||||
divv = oh;
|
||||
}
|
||||
render_w = (ow * mult) / divv;
|
||||
render_h = (oh * mult) / divv;
|
||||
|
||||
newfont = evas_common_font_load( ((RGBA_Font *)font)->src->name, (((RGBA_Font *)font)->size*mult)/divv);
|
||||
|
||||
dc->col.col = dc_in->col.col;
|
||||
inset = evas_common_font_query_inset( font, text);
|
||||
im = evas_common_image_create(render_w+inset, render_h);
|
||||
im = evas_common_image_create(ow+inset, oh);
|
||||
if (im)
|
||||
{
|
||||
int max_ascent;
|
||||
int i, j;
|
||||
|
||||
im->flags |= RGBA_IMAGE_HAS_ALPHA;
|
||||
j = (render_w+inset) * render_h;
|
||||
for (i = 0; i < j; i++) im->image->data[i] = (dc->col.col & 0xffffff);
|
||||
j = (ow+inset) * oh;
|
||||
memset(im->image->data, 0, j * sizeof(DATA32));
|
||||
|
||||
if (newfont)
|
||||
{
|
||||
max_ascent = evas_common_font_max_ascent_get(newfont);
|
||||
|
||||
evas_common_font_draw(im, dc, newfont, 0, max_ascent, text);
|
||||
evas_common_cpu_end_opt();
|
||||
evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
|
||||
inset, 0, render_w, render_h,
|
||||
x + ((inset * w) / render_w), y - ((max_ascent * h) / render_h),
|
||||
w, h);
|
||||
evas_common_font_free(newfont);
|
||||
}
|
||||
max_ascent = evas_common_font_max_ascent_get(font);
|
||||
|
||||
evas_common_font_draw(im, dc, font, 0, max_ascent, text);
|
||||
evas_common_cpu_end_opt();
|
||||
evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
|
||||
inset, 0, ow, oh,
|
||||
x + ((inset * w) / ow), y - ((max_ascent * h) / oh),
|
||||
w, h);
|
||||
evas_common_image_free(im);
|
||||
}
|
||||
evas_common_draw_context_free(dc);
|
||||
|
|
|
@ -59,6 +59,8 @@ static void evas_engine_cairo_x11_image_cache_set(void *data, int bytes);
|
|||
static int evas_engine_cairo_x11_image_cache_get(void *data);
|
||||
static void *evas_engine_cairo_x11_font_load(void *data, char *name, int size);
|
||||
static void *evas_engine_cairo_x11_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size);
|
||||
static void *evas_engine_cairo_x11_font_add(void *data, void *font, char *name, int size);
|
||||
static void *evas_engine_cairo_x11_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size);
|
||||
static void evas_engine_cairo_x11_font_free(void *data, void *font);
|
||||
static int evas_engine_cairo_x11_font_ascent_get(void *data, void *font);
|
||||
static int evas_engine_cairo_x11_font_descent_get(void *data, void *font);
|
||||
|
@ -148,6 +150,8 @@ Evas_Func evas_engine_cairo_x11_func =
|
|||
/* font draw functions */
|
||||
evas_engine_cairo_x11_font_load,
|
||||
evas_engine_cairo_x11_font_memory_load,
|
||||
evas_engine_cairo_x11_font_add,
|
||||
evas_engine_cairo_x11_font_memory_add,
|
||||
evas_engine_cairo_x11_font_free,
|
||||
evas_engine_cairo_x11_font_ascent_get,
|
||||
evas_engine_cairo_x11_font_descent_get,
|
||||
|
@ -864,6 +868,24 @@ evas_engine_cairo_x11_font_memory_load(void *data, char *name, int size, const v
|
|||
return evas_common_font_memory_load(name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void *
|
||||
evas_engine_cairo_x11_font_add(void *data, void *font, char *name, int size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_add(font, name, size);
|
||||
}
|
||||
|
||||
static void *
|
||||
evas_engine_cairo_x11_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void
|
||||
evas_engine_cairo_x11_font_free(void *data, void *font)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "evas_common.h"
|
||||
|
||||
RGBA_Font_Glyph *
|
||||
evas_common_font_cache_glyph_get(RGBA_Font *fn, FT_UInt index)
|
||||
evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt index)
|
||||
{
|
||||
RGBA_Font_Glyph *fg;
|
||||
char key[6];
|
||||
|
@ -14,17 +14,17 @@ evas_common_font_cache_glyph_get(RGBA_Font *fn, FT_UInt index)
|
|||
key[4] = ((index >> 28 ) & 0x0f) + 1;
|
||||
key[5] = 0;
|
||||
|
||||
fg = evas_hash_find(fn->glyphs, key);
|
||||
fg = evas_hash_find(fi->glyphs, key);
|
||||
if (fg) return fg;
|
||||
|
||||
error = FT_Load_Glyph(fn->src->ft.face, index, FT_LOAD_NO_BITMAP);
|
||||
error = FT_Load_Glyph(fi->src->ft.face, index, FT_LOAD_NO_BITMAP);
|
||||
if (error) return NULL;
|
||||
|
||||
fg = malloc(sizeof(struct _RGBA_Font_Glyph));
|
||||
if (!fg) return NULL;
|
||||
memset(fg, 0, (sizeof(struct _RGBA_Font_Glyph)));
|
||||
|
||||
error = FT_Get_Glyph(fn->src->ft.face->glyph, &(fg->glyph));
|
||||
error = FT_Get_Glyph(fi->src->ft.face->glyph, &(fg->glyph));
|
||||
if (error)
|
||||
{
|
||||
free(fg);
|
||||
|
@ -42,10 +42,31 @@ evas_common_font_cache_glyph_get(RGBA_Font *fn, FT_UInt index)
|
|||
}
|
||||
fg->glyph_out = (FT_BitmapGlyph)fg->glyph;
|
||||
|
||||
fn->glyphs = evas_hash_add(fn->glyphs, key, fg);
|
||||
fi->glyphs = evas_hash_add(fi->glyphs, key, fg);
|
||||
return fg;
|
||||
}
|
||||
|
||||
int
|
||||
evas_common_font_glyph_search(RGBA_Font *fn, RGBA_Font_Int **fi_ret, int gl)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
for (l = fn->fonts; l; l = l->next)
|
||||
{
|
||||
RGBA_Font_Int *fi;
|
||||
int index;
|
||||
|
||||
fi = l->data;
|
||||
index = FT_Get_Char_Index(fi->src->ft.face, gl);
|
||||
if (index != 0)
|
||||
{
|
||||
*fi_ret = fi;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int x, int y, const char *text)
|
||||
{
|
||||
|
@ -58,6 +79,9 @@ evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int
|
|||
DATA32 *im;
|
||||
int im_w, im_h;
|
||||
int c;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fi = fn->fonts->data;
|
||||
|
||||
im = dst->image->data;
|
||||
im_w = dst->image->w;
|
||||
|
@ -91,7 +115,7 @@ evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int
|
|||
pen_x = x << 8;
|
||||
pen_y = y << 8;
|
||||
evas_common_font_size_use(fn);
|
||||
use_kerning = FT_HAS_KERNING(fn->src->ft.face);
|
||||
use_kerning = FT_HAS_KERNING(fi->src->ft.face);
|
||||
prev_index = 0;
|
||||
func = evas_common_draw_func_blend_alpha_get(dst);
|
||||
for (c = 0, chr = 0; text[chr];)
|
||||
|
@ -103,7 +127,7 @@ evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int
|
|||
|
||||
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
||||
if (gl == 0) break;
|
||||
index = FT_Get_Char_Index(fn->src->ft.face, gl);
|
||||
index = evas_common_font_glyph_search(fn, &fi, gl);
|
||||
/* 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 */
|
||||
|
@ -111,11 +135,11 @@ evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int
|
|||
{
|
||||
FT_Vector delta;
|
||||
|
||||
FT_Get_Kerning(fn->src->ft.face, prev_index, index,
|
||||
FT_Get_Kerning(fi->src->ft.face, prev_index, index,
|
||||
ft_kerning_default, &delta);
|
||||
pen_x += delta.x << 2;
|
||||
}
|
||||
fg = evas_common_font_cache_glyph_get(fn, index);
|
||||
fg = evas_common_font_int_cache_glyph_get(fi, index);
|
||||
if (!fg) continue;
|
||||
|
||||
if ((dc->font_ext.func.gl_new) && (!fg->ext_dat))
|
||||
|
|
|
@ -168,83 +168,91 @@ evas_common_font_source_free(RGBA_Font_Source *fs)
|
|||
void
|
||||
evas_common_font_size_use(RGBA_Font *fn)
|
||||
{
|
||||
if (fn->src->current_size == fn->size) return;
|
||||
FT_Activate_Size(fn->ft.size);
|
||||
fn->src->current_size = fn->size;
|
||||
Evas_List *l;
|
||||
|
||||
for (l = fn->fonts; l; l = l->next)
|
||||
{
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fi = l->data;
|
||||
if (fi->src->current_size == fi->size) return;
|
||||
FT_Activate_Size(fi->ft.size);
|
||||
fi->src->current_size = fi->size;
|
||||
}
|
||||
}
|
||||
|
||||
RGBA_Font *
|
||||
evas_common_font_memory_load(const char *name, int size, const void *data, int data_size)
|
||||
RGBA_Font_Int *
|
||||
evas_common_font_int_memory_load(const char *name, int size, const void *data, int data_size)
|
||||
{
|
||||
RGBA_Font *fn;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fn = evas_common_font_find(name, size);
|
||||
if (fn) return fn;
|
||||
fi = evas_common_font_int_find(name, size);
|
||||
if (fi) return fi;
|
||||
|
||||
fn = calloc(1, sizeof(RGBA_Font));
|
||||
if (!fn) return NULL;
|
||||
fi = calloc(1, sizeof(RGBA_Font_Int));
|
||||
if (!fi) return NULL;
|
||||
|
||||
fn->src = evas_common_font_source_find(name);
|
||||
if (!fn->src) fn->src = evas_common_font_source_memory_load(name, data, data_size);
|
||||
fi->src = evas_common_font_source_find(name);
|
||||
if (!fi->src) fi->src = evas_common_font_source_memory_load(name, data, data_size);
|
||||
|
||||
if (!fn->src)
|
||||
if (!fi->src)
|
||||
{
|
||||
free(fn);
|
||||
free(fi);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fn->size = size;
|
||||
fi->size = size;
|
||||
|
||||
return evas_common_font_load_init(fn);
|
||||
return evas_common_font_int_load_init(fi);
|
||||
}
|
||||
|
||||
RGBA_Font *
|
||||
evas_common_font_load(const char *name, int size)
|
||||
RGBA_Font_Int *
|
||||
evas_common_font_int_load(const char *name, int size)
|
||||
{
|
||||
RGBA_Font *fn;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fn = evas_common_font_find(name, size);
|
||||
if (fn) return fn;
|
||||
fi = evas_common_font_int_find(name, size);
|
||||
if (fi) return fi;
|
||||
|
||||
fn = calloc(1, sizeof(RGBA_Font));
|
||||
if (!fn) return NULL;
|
||||
fi = calloc(1, sizeof(RGBA_Font_Int));
|
||||
if (!fi) return NULL;
|
||||
|
||||
fn->src = evas_common_font_source_find(name);
|
||||
if (!fn->src)
|
||||
fi->src = evas_common_font_source_find(name);
|
||||
if (!fi->src)
|
||||
{
|
||||
/* printf("REAL LOAD FILE %s %i\n", name, size);*/
|
||||
fn->src = evas_common_font_source_load(name);
|
||||
fi->src = evas_common_font_source_load(name);
|
||||
}
|
||||
/* else*/
|
||||
/* printf("REAL LOAD SIZE %s %i\n", name, size);*/
|
||||
|
||||
if (!fn->src)
|
||||
if (!fi->src)
|
||||
{
|
||||
free(fn);
|
||||
free(fi);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fn->size = size;
|
||||
fi->size = size;
|
||||
|
||||
return evas_common_font_load_init(fn);
|
||||
return evas_common_font_int_load_init(fi);
|
||||
}
|
||||
|
||||
RGBA_Font *
|
||||
evas_common_font_load_init(RGBA_Font *fn)
|
||||
RGBA_Font_Int *
|
||||
evas_common_font_int_load_init(RGBA_Font_Int *fi)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = FT_New_Size(fn->src->ft.face, &(fn->ft.size));
|
||||
error = FT_New_Size(fi->src->ft.face, &(fi->ft.size));
|
||||
if (!error)
|
||||
{
|
||||
FT_Activate_Size(fn->ft.size);
|
||||
FT_Activate_Size(fi->ft.size);
|
||||
}
|
||||
fn->real_size = fn->size * 64;
|
||||
error = FT_Set_Char_Size(fn->src->ft.face, 0, fn->real_size, 75, 75);
|
||||
fi->real_size = fi->size * 64;
|
||||
error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, 75, 75);
|
||||
if (error)
|
||||
{
|
||||
fn->real_size = fn->size;
|
||||
error = FT_Set_Pixel_Sizes(fn->src->ft.face, 0, fn->real_size);
|
||||
fi->real_size = fi->size;
|
||||
error = FT_Set_Pixel_Sizes(fi->src->ft.face, 0, fi->real_size);
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
|
@ -252,48 +260,114 @@ evas_common_font_load_init(RGBA_Font *fn)
|
|||
int chosen_size = 0;
|
||||
int chosen_width = 0;
|
||||
|
||||
for (i = 0; i < fn->src->ft.face->num_fixed_sizes; i++)
|
||||
for (i = 0; i < fi->src->ft.face->num_fixed_sizes; i++)
|
||||
{
|
||||
int s;
|
||||
int d, cd;
|
||||
|
||||
s = fn->src->ft.face->available_sizes[i].height;
|
||||
cd = chosen_size - fn->size;
|
||||
s = fi->src->ft.face->available_sizes[i].height;
|
||||
cd = chosen_size - fi->size;
|
||||
if (cd < 0) cd = -cd;
|
||||
d = s - fn->size;
|
||||
d = s - fi->size;
|
||||
if (d < 0) d = -d;
|
||||
if (d < cd)
|
||||
{
|
||||
chosen_width = fn->src->ft.face->available_sizes[i].width;
|
||||
chosen_width = fi->src->ft.face->available_sizes[i].width;
|
||||
chosen_size = s;
|
||||
}
|
||||
if (d == 0) break;
|
||||
}
|
||||
fn->real_size = chosen_size;
|
||||
error = FT_Set_Pixel_Sizes(fn->src->ft.face, chosen_width, fn->real_size);
|
||||
fi->real_size = chosen_size;
|
||||
error = FT_Set_Pixel_Sizes(fi->src->ft.face, chosen_width, fi->real_size);
|
||||
if (error)
|
||||
{
|
||||
/* couldn't choose the size anyway... what now? */
|
||||
}
|
||||
}
|
||||
fn->src->current_size = fn->size;
|
||||
fi->src->current_size = fi->size;
|
||||
|
||||
fn->glyphs = NULL;
|
||||
fn->usage = 0;
|
||||
fn->references = 1;
|
||||
fonts = evas_object_list_prepend(fonts, fn);
|
||||
fi->glyphs = NULL;
|
||||
fi->usage = 0;
|
||||
fi->references = 1;
|
||||
fonts = evas_object_list_prepend(fonts, fi);
|
||||
return fi;
|
||||
}
|
||||
|
||||
RGBA_Font *
|
||||
evas_common_font_memory_load(const char *name, int size, const void *data, int data_size)
|
||||
{
|
||||
RGBA_Font *fn;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fi = evas_common_font_int_memory_load(name, size, data, data_size);
|
||||
if (!fi) return NULL;
|
||||
fn = calloc(1, sizeof(RGBA_Font));
|
||||
if (!fn) return NULL;
|
||||
fn->fonts = evas_list_append(fn->fonts, fi);
|
||||
return fn;
|
||||
}
|
||||
|
||||
RGBA_Font *
|
||||
evas_common_font_load(const char *name, int size)
|
||||
{
|
||||
RGBA_Font *fn;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fi = evas_common_font_int_load(name, size);
|
||||
if (!fi) return NULL;
|
||||
fn = calloc(1, sizeof(RGBA_Font));
|
||||
if (!fn) return NULL;
|
||||
fn->fonts = evas_list_append(fn->fonts, fi);
|
||||
return fn;
|
||||
}
|
||||
|
||||
int
|
||||
evas_common_font_add(RGBA_Font *fn, const char *name, int size)
|
||||
{
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fi = evas_common_font_int_load(name, size);
|
||||
if (fi)
|
||||
{
|
||||
fn->fonts = evas_list_append(fn->fonts, fi);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
evas_common_font_memory_add(RGBA_Font *fn, const char *name, int size, const void *data, int data_size)
|
||||
{
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fi = evas_common_font_int_memory_load(name, size, data, data_size);
|
||||
if (fi)
|
||||
{
|
||||
fn->fonts = evas_list_append(fn->fonts, fi);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
evas_common_font_free(RGBA_Font *fn)
|
||||
{
|
||||
fn->references--;
|
||||
if (fn->references == 0)
|
||||
Evas_List *l;
|
||||
|
||||
for (l = fn->fonts; l; l = l->next)
|
||||
{
|
||||
evas_common_font_modify_cache_by(fn, 1);
|
||||
evas_common_font_flush();
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fi = l->data;
|
||||
fi->references--;
|
||||
if (fi->references == 0)
|
||||
{
|
||||
evas_common_font_int_modify_cache_by(fi, 1);
|
||||
evas_common_font_flush();
|
||||
}
|
||||
}
|
||||
evas_list_free(fn->fonts);
|
||||
free(fn);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -313,12 +387,12 @@ font_modify_cache_cb(Evas_Hash *hash, const char *key, void *data, void *fdata)
|
|||
}
|
||||
|
||||
void
|
||||
evas_common_font_modify_cache_by(RGBA_Font *fn, int dir)
|
||||
evas_common_font_int_modify_cache_by(RGBA_Font_Int *fi, int dir)
|
||||
{
|
||||
int sz_hash = 0;
|
||||
|
||||
if (fn->glyphs) sz_hash = sizeof(Evas_Hash);
|
||||
evas_hash_foreach(fn->glyphs, font_modify_cache_cb, &dir);
|
||||
if (fi->glyphs) sz_hash = sizeof(Evas_Hash);
|
||||
evas_hash_foreach(fi->glyphs, font_modify_cache_cb, &dir);
|
||||
font_cache_usage += dir * (sizeof(RGBA_Font) + sz_hash +
|
||||
sizeof(FT_FaceRec) + 16384); /* fudge values */
|
||||
}
|
||||
|
@ -363,49 +437,49 @@ void
|
|||
evas_common_font_flush_last(void)
|
||||
{
|
||||
Evas_Object_List *l;
|
||||
RGBA_Font *fn = NULL;
|
||||
RGBA_Font_Int *fi = NULL;
|
||||
|
||||
for (l = fonts; l; l = l->next)
|
||||
{
|
||||
RGBA_Font *fn_tmp;
|
||||
RGBA_Font_Int *fi_tmp;
|
||||
|
||||
fn_tmp = (RGBA_Font *)l;
|
||||
if (fn_tmp->references == 0) fn = fn_tmp;
|
||||
fi_tmp = (RGBA_Font_Int *)l;
|
||||
if (fi_tmp->references == 0) fi = fi_tmp;
|
||||
}
|
||||
if (!fn) return;
|
||||
if (!fi) return;
|
||||
|
||||
FT_Done_Size(fn->ft.size);
|
||||
FT_Done_Size(fi->ft.size);
|
||||
|
||||
fonts = evas_object_list_remove(fonts, fn);
|
||||
evas_common_font_modify_cache_by(fn, -1);
|
||||
fonts = evas_object_list_remove(fonts, fi);
|
||||
evas_common_font_int_modify_cache_by(fi, -1);
|
||||
|
||||
evas_hash_foreach(fn->glyphs, font_flush_free_glyph_cb, NULL);
|
||||
evas_hash_free(fn->glyphs);
|
||||
evas_hash_foreach(fi->glyphs, font_flush_free_glyph_cb, NULL);
|
||||
evas_hash_free(fi->glyphs);
|
||||
|
||||
evas_common_font_source_free(fn->src);
|
||||
evas_common_font_source_free(fi->src);
|
||||
|
||||
free(fn);
|
||||
free(fi);
|
||||
}
|
||||
|
||||
RGBA_Font *
|
||||
evas_common_font_find(const char *name, int size)
|
||||
RGBA_Font_Int *
|
||||
evas_common_font_int_find(const char *name, int size)
|
||||
{
|
||||
Evas_Object_List *l;
|
||||
|
||||
// printf("SEARCH!\n");
|
||||
for (l = fonts; l; l = l->next)
|
||||
{
|
||||
RGBA_Font *fn;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fn = (RGBA_Font *)l;
|
||||
// printf("%s == %s, %i == %i\n", name, fn->src->name, size, fn->size);
|
||||
if ((fn->size == size) && (!strcmp(name, fn->src->name)))
|
||||
fi = (RGBA_Font_Int *)l;
|
||||
// printf("%s == %s, %i == %i\n", name, fi->src->name, size, fi->size);
|
||||
if ((fi->size == size) && (!strcmp(name, fi->src->name)))
|
||||
{
|
||||
if (fn->references == 0) evas_common_font_modify_cache_by(fn, -1);
|
||||
fn->references++;
|
||||
fonts = evas_object_list_remove(fonts, fn);
|
||||
fonts = evas_object_list_prepend(fonts, fn);
|
||||
return fn;
|
||||
if (fi->references == 0) evas_common_font_int_modify_cache_by(fi, -1);
|
||||
fi->references++;
|
||||
fonts = evas_object_list_remove(fonts, fi);
|
||||
fonts = evas_object_list_prepend(fonts, fi);
|
||||
return fi;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -33,11 +33,13 @@ evas_common_font_ascent_get(RGBA_Font *fn)
|
|||
{
|
||||
int val, dv;
|
||||
int ret;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
evas_common_font_size_use(fn);
|
||||
val = (int)fn->src->ft.face->size->metrics.ascender;
|
||||
dv = (fn->src->ft.orig_upem * 2048) / fn->src->ft.face->units_per_EM;
|
||||
ret = (val * fn->src->ft.face->size->metrics.y_scale) / (dv * dv);
|
||||
fi = fn->fonts->data;
|
||||
val = (int)fi->src->ft.face->size->metrics.ascender;
|
||||
dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
|
||||
ret = (val * fi->src->ft.face->size->metrics.y_scale) / (dv * dv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -46,11 +48,13 @@ evas_common_font_descent_get(RGBA_Font *fn)
|
|||
{
|
||||
int val, dv;
|
||||
int ret;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
evas_common_font_size_use(fn);
|
||||
val = -(int)fn->src->ft.face->size->metrics.descender;
|
||||
dv = (fn->src->ft.orig_upem * 2048) / fn->src->ft.face->units_per_EM;
|
||||
ret = (val * fn->src->ft.face->size->metrics.y_scale) / (dv * dv);
|
||||
fi = fn->fonts->data;
|
||||
val = -(int)fi->src->ft.face->size->metrics.descender;
|
||||
dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
|
||||
ret = (val * fi->src->ft.face->size->metrics.y_scale) / (dv * dv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -59,11 +63,13 @@ evas_common_font_max_ascent_get(RGBA_Font *fn)
|
|||
{
|
||||
int val, dv;
|
||||
int ret;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
evas_common_font_size_use(fn);
|
||||
val = (int)fn->src->ft.face->bbox.yMax;
|
||||
dv = (fn->src->ft.orig_upem * 2048) / fn->src->ft.face->units_per_EM;
|
||||
ret = (val * fn->src->ft.face->size->metrics.y_scale) / (dv * dv);
|
||||
fi = fn->fonts->data;
|
||||
val = (int)fi->src->ft.face->bbox.yMax;
|
||||
dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
|
||||
ret = (val * fi->src->ft.face->size->metrics.y_scale) / (dv * dv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -72,11 +78,13 @@ evas_common_font_max_descent_get(RGBA_Font *fn)
|
|||
{
|
||||
int val, dv;
|
||||
int ret;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
evas_common_font_size_use(fn);
|
||||
val = -(int)fn->src->ft.face->bbox.yMin;
|
||||
dv = (fn->src->ft.orig_upem * 2048) / fn->src->ft.face->units_per_EM;
|
||||
ret = (val * fn->src->ft.face->size->metrics.y_scale) / (dv * dv);
|
||||
fi = fn->fonts->data;
|
||||
val = -(int)fi->src->ft.face->bbox.yMin;
|
||||
dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
|
||||
ret = (val * fi->src->ft.face->size->metrics.y_scale) / (dv * dv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -85,11 +93,13 @@ evas_common_font_get_line_advance(RGBA_Font *fn)
|
|||
{
|
||||
int val, dv;
|
||||
int ret;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
evas_common_font_size_use(fn);
|
||||
val = (int)fn->src->ft.face->size->metrics.height;
|
||||
dv = (fn->src->ft.orig_upem * 2048) / fn->src->ft.face->units_per_EM;
|
||||
ret = (val * fn->src->ft.face->size->metrics.y_scale) / (dv * dv);
|
||||
fi = fn->fonts->data;
|
||||
val = (int)fi->src->ft.face->size->metrics.height;
|
||||
dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
|
||||
ret = (val * fi->src->ft.face->size->metrics.y_scale) / (dv * dv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,13 +9,16 @@ evas_common_font_query_size(RGBA_Font *fn, const char *text, int *w, int *h)
|
|||
int start_x, end_x;
|
||||
int chr;
|
||||
FT_UInt prev_index;
|
||||
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fi = fn->fonts->data;
|
||||
|
||||
start_x = 0;
|
||||
end_x = 0;
|
||||
pen_x = 0;
|
||||
pen_y = 0;
|
||||
evas_common_font_size_use(fn);
|
||||
use_kerning = FT_HAS_KERNING(fn->src->ft.face);
|
||||
use_kerning = FT_HAS_KERNING(fi->src->ft.face);
|
||||
prev_index = 0;
|
||||
for (chr = 0; text[chr];)
|
||||
{
|
||||
|
@ -26,16 +29,16 @@ evas_common_font_query_size(RGBA_Font *fn, const char *text, int *w, int *h)
|
|||
|
||||
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
||||
if (gl == 0) break;
|
||||
index = FT_Get_Char_Index(fn->src->ft.face, gl);
|
||||
index = evas_common_font_glyph_search(fn, &fi, gl);
|
||||
if ((use_kerning) && (prev_index) && (index))
|
||||
{
|
||||
FT_Vector delta;
|
||||
|
||||
FT_Get_Kerning(fn->src->ft.face, prev_index, index,
|
||||
FT_Get_Kerning(fi->src->ft.face, prev_index, index,
|
||||
ft_kerning_default, &delta);
|
||||
pen_x += delta.x << 2;
|
||||
}
|
||||
fg = evas_common_font_cache_glyph_get(fn, index);
|
||||
fg = evas_common_font_int_cache_glyph_get(fi, index);
|
||||
if (!fg) continue;
|
||||
|
||||
chr_x = (pen_x >> 8) + fg->glyph_out->left;
|
||||
|
@ -60,14 +63,17 @@ evas_common_font_query_inset(RGBA_Font *fn, const char *text)
|
|||
RGBA_Font_Glyph *fg;
|
||||
int chr;
|
||||
int gl;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fi = fn->fonts->data;
|
||||
|
||||
chr = 0;
|
||||
if (!text[0]) return 0;
|
||||
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
||||
if (gl == 0) return 0;
|
||||
evas_common_font_size_use(fn);
|
||||
index = FT_Get_Char_Index(fn->src->ft.face, gl);
|
||||
fg = evas_common_font_cache_glyph_get(fn, index);
|
||||
index = evas_common_font_glyph_search(fn, &fi, gl);
|
||||
fg = evas_common_font_int_cache_glyph_get(fi, index);
|
||||
if (!fg) return 0;
|
||||
return fg->glyph_out->left;
|
||||
}
|
||||
|
@ -81,12 +87,15 @@ evas_common_font_query_advance(RGBA_Font *fn, const char *text, int *h_adv, int
|
|||
int start_x;
|
||||
int chr;
|
||||
FT_UInt prev_index;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fi = fn->fonts->data;
|
||||
|
||||
start_x = 0;
|
||||
pen_x = 0;
|
||||
pen_y = 0;
|
||||
evas_common_font_size_use(fn);
|
||||
use_kerning = FT_HAS_KERNING(fn->src->ft.face);
|
||||
use_kerning = FT_HAS_KERNING(fi->src->ft.face);
|
||||
prev_index = 0;
|
||||
for (chr = 0; text[chr];)
|
||||
{
|
||||
|
@ -97,16 +106,16 @@ evas_common_font_query_advance(RGBA_Font *fn, const char *text, int *h_adv, int
|
|||
|
||||
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
||||
if (gl == 0) break;
|
||||
index = FT_Get_Char_Index(fn->src->ft.face, gl);
|
||||
index = evas_common_font_glyph_search(fn, &fi, gl);
|
||||
if ((use_kerning) && (prev_index) && (index))
|
||||
{
|
||||
FT_Vector delta;
|
||||
|
||||
FT_Get_Kerning(fn->src->ft.face, prev_index, index,
|
||||
FT_Get_Kerning(fi->src->ft.face, prev_index, index,
|
||||
ft_kerning_default, &delta);
|
||||
pen_x += delta.x << 2;
|
||||
}
|
||||
fg = evas_common_font_cache_glyph_get(fn, index);
|
||||
fg = evas_common_font_int_cache_glyph_get(fi, index);
|
||||
if (!fg) continue;
|
||||
|
||||
chr_x = (pen_x >> 8) + fg->glyph_out->left;
|
||||
|
@ -130,11 +139,14 @@ evas_common_font_query_char_coords(RGBA_Font *fn, const char *text, int pos, int
|
|||
int chr;
|
||||
int asc, desc;
|
||||
FT_UInt prev_index;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fi = fn->fonts->data;
|
||||
|
||||
pen_x = 0;
|
||||
pen_y = 0;
|
||||
evas_common_font_size_use(fn);
|
||||
use_kerning = FT_HAS_KERNING(fn->src->ft.face);
|
||||
use_kerning = FT_HAS_KERNING(fi->src->ft.face);
|
||||
prev_index = 0;
|
||||
prev_chr_end = 0;
|
||||
asc = evas_common_font_max_ascent_get(fn);
|
||||
|
@ -151,16 +163,16 @@ evas_common_font_query_char_coords(RGBA_Font *fn, const char *text, int pos, int
|
|||
pchr = chr;
|
||||
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
||||
if (gl == 0) break;
|
||||
index = FT_Get_Char_Index(fn->src->ft.face, gl);
|
||||
index = evas_common_font_glyph_search(fn, &fi, gl);
|
||||
kern = 0;
|
||||
if ((use_kerning) && (prev_index) && (index))
|
||||
{
|
||||
FT_Get_Kerning(fn->src->ft.face, prev_index, index,
|
||||
FT_Get_Kerning(fi->src->ft.face, prev_index, index,
|
||||
ft_kerning_default, &delta);
|
||||
kern = delta.x << 2;
|
||||
pen_x += kern;
|
||||
}
|
||||
fg = evas_common_font_cache_glyph_get(fn, index);
|
||||
fg = evas_common_font_int_cache_glyph_get(fi, index);
|
||||
if (!fg) continue;
|
||||
|
||||
if (kern < 0) kern = 0;
|
||||
|
@ -204,11 +216,14 @@ evas_common_font_query_text_at_pos(RGBA_Font *fn, const char *text, int x, int y
|
|||
int chr;
|
||||
int asc, desc;
|
||||
FT_UInt prev_index;
|
||||
RGBA_Font_Int *fi;
|
||||
|
||||
fi = fn->fonts->data;
|
||||
|
||||
pen_x = 0;
|
||||
pen_y = 0;
|
||||
evas_common_font_size_use(fn);
|
||||
use_kerning = FT_HAS_KERNING(fn->src->ft.face);
|
||||
use_kerning = FT_HAS_KERNING(fi->src->ft.face);
|
||||
prev_index = 0;
|
||||
prev_chr_end = 0;
|
||||
asc = evas_common_font_max_ascent_get(fn);
|
||||
|
@ -225,16 +240,16 @@ evas_common_font_query_text_at_pos(RGBA_Font *fn, const char *text, int x, int y
|
|||
pchr = chr;
|
||||
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
||||
if (gl == 0) break;
|
||||
index = FT_Get_Char_Index(fn->src->ft.face, gl);
|
||||
index = evas_common_font_glyph_search(fn, &fi, gl);
|
||||
kern = 0;
|
||||
if ((use_kerning) && (prev_index) && (index))
|
||||
{
|
||||
FT_Get_Kerning(fn->src->ft.face, prev_index, index,
|
||||
FT_Get_Kerning(fi->src->ft.face, prev_index, index,
|
||||
ft_kerning_default, &delta);
|
||||
kern = delta.x << 2;
|
||||
pen_x += kern;
|
||||
}
|
||||
fg = evas_common_font_cache_glyph_get(fn, index);
|
||||
fg = evas_common_font_int_cache_glyph_get(fi, index);
|
||||
if (!fg) continue;
|
||||
|
||||
if (kern < 0) kern = 0;
|
||||
|
|
|
@ -63,6 +63,8 @@ Evas_Func evas_engine_directfb_func = {
|
|||
/* more to come */
|
||||
evas_engine_directfb_font_load,
|
||||
evas_engine_directfb_font_memory_load,
|
||||
evas_engine_directfb_font_add,
|
||||
evas_engine_directfb_font_memory_add,
|
||||
evas_engine_directfb_font_free,
|
||||
evas_engine_directfb_font_ascent_get,
|
||||
evas_engine_directfb_font_descent_get,
|
||||
|
@ -769,6 +771,25 @@ evas_engine_directfb_font_memory_load(void *data, char *name, int size, const vo
|
|||
return evas_common_font_memory_load(name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
void *
|
||||
evas_engine_directfb_font_add(void *data, void *font, char *name, int size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_add(font, name, size);
|
||||
}
|
||||
|
||||
void *
|
||||
evas_engine_directfb_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
evas_engine_directfb_font_free(void *data, void *font)
|
||||
{
|
||||
|
|
|
@ -138,6 +138,8 @@ void *evas_engine_directfb_font_memory_load(void *data,
|
|||
int size,
|
||||
const void *fdata,
|
||||
int fdata_size);
|
||||
void *evas_engine_directfb_font_add(void *data, void *font, char *name, int size);
|
||||
void *evas_engine_directfb_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size);
|
||||
void evas_engine_directfb_font_free(void *data, void *font);
|
||||
int evas_engine_directfb_font_ascent_get(void *data,
|
||||
void *font);
|
||||
|
|
|
@ -58,6 +58,8 @@ static void evas_engine_fb_image_cache_set(void *data, int bytes);
|
|||
static int evas_engine_fb_image_cache_get(void *data);
|
||||
static void *evas_engine_fb_font_load(void *data, char *name, int size);
|
||||
static void *evas_engine_fb_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size);
|
||||
static void *evas_engine_fb_font_add(void *data, void *font, char *name, int size);
|
||||
static void *evas_engine_fb_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size);
|
||||
static void evas_engine_fb_font_free(void *data, void *font);
|
||||
static int evas_engine_fb_font_ascent_get(void *data, void *font);
|
||||
static int evas_engine_fb_font_descent_get(void *data, void *font);
|
||||
|
@ -144,6 +146,8 @@ Evas_Func evas_engine_fb_func =
|
|||
/* font draw functions */
|
||||
evas_engine_fb_font_load,
|
||||
evas_engine_fb_font_memory_load,
|
||||
evas_engine_fb_font_add,
|
||||
evas_engine_fb_font_memory_add,
|
||||
evas_engine_fb_font_free,
|
||||
evas_engine_fb_font_ascent_get,
|
||||
evas_engine_fb_font_descent_get,
|
||||
|
@ -855,6 +859,24 @@ evas_engine_fb_font_memory_load(void *data, char *name, int size, const void *fd
|
|||
return evas_common_font_memory_load(name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void *
|
||||
evas_engine_fb_font_add(void *data, void *font, char *name, int size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_add(font, name, size);
|
||||
}
|
||||
|
||||
static void *
|
||||
evas_engine_fb_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void
|
||||
evas_engine_fb_font_free(void *data, void *font)
|
||||
{
|
||||
|
|
|
@ -59,6 +59,8 @@ static void evas_engine_gl_x11_image_cache_set(void *data, int bytes);
|
|||
static int evas_engine_gl_x11_image_cache_get(void *data);
|
||||
static void *evas_engine_gl_x11_font_load(void *data, char *name, int size);
|
||||
static void *evas_engine_gl_x11_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size);
|
||||
static void *evas_engine_gl_x11_font_add(void *data, void *font, char *name, int size);
|
||||
static void *evas_engine_gl_x11_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size);
|
||||
static void evas_engine_gl_x11_font_free(void *data, void *font);
|
||||
static int evas_engine_gl_x11_font_ascent_get(void *data, void *font);
|
||||
static int evas_engine_gl_x11_font_descent_get(void *data, void *font);
|
||||
|
@ -150,6 +152,8 @@ Evas_Func evas_engine_gl_x11_func =
|
|||
/* font draw functions */
|
||||
evas_engine_gl_x11_font_load,
|
||||
evas_engine_gl_x11_font_memory_load,
|
||||
evas_engine_gl_x11_font_add,
|
||||
evas_engine_gl_x11_font_memory_add,
|
||||
evas_engine_gl_x11_font_free,
|
||||
evas_engine_gl_x11_font_ascent_get,
|
||||
evas_engine_gl_x11_font_descent_get,
|
||||
|
@ -870,6 +874,24 @@ evas_engine_gl_x11_font_memory_load(void *data, char *name, int size, const void
|
|||
return evas_common_font_memory_load(name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void *
|
||||
evas_engine_gl_x11_font_add(void *data, void *font, char *name, int size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_add(font, name, size);
|
||||
}
|
||||
|
||||
static void *
|
||||
evas_engine_gl_x11_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void
|
||||
evas_engine_gl_x11_font_free(void *data, void *font)
|
||||
{
|
||||
|
|
|
@ -58,6 +58,8 @@ static void evas_engine_software_qtopia_image_cache_set(void *data, int bytes);
|
|||
static int evas_engine_software_qtopia_image_cache_get(void *data);
|
||||
static void *evas_engine_software_qtopia_font_load(void *data, char *name, int size);
|
||||
static void *evas_engine_software_qtopia_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size);
|
||||
static void *evas_engine_software_qtopia_font_add(void *data, void *font, char *name, int size);
|
||||
static void *evas_engine_software_qtopia_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size);
|
||||
static void evas_engine_software_qtopia_font_free(void *data, void *font);
|
||||
static int evas_engine_software_qtopia_font_ascent_get(void *data, void *font);
|
||||
static int evas_engine_software_qtopia_font_descent_get(void *data, void *font);
|
||||
|
@ -147,6 +149,8 @@ Evas_Func evas_engine_software_qtopia_func =
|
|||
/* font draw functions */
|
||||
evas_engine_software_qtopia_font_load,
|
||||
evas_engine_software_qtopia_font_memory_load,
|
||||
evas_engine_software_qtopia_font_add,
|
||||
evas_engine_software_qtopia_font_memory_add,
|
||||
evas_engine_software_qtopia_font_free,
|
||||
evas_engine_software_qtopia_font_ascent_get,
|
||||
evas_engine_software_qtopia_font_descent_get,
|
||||
|
@ -878,6 +882,24 @@ evas_engine_software_qtopia_font_memory_load(void *data, char *name, int size, c
|
|||
return evas_common_font_load(name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void *
|
||||
evas_engine_software_qtopia_font_add(void *data, void *font, char *name, int size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_add(font, name, size);
|
||||
}
|
||||
|
||||
static void *
|
||||
evas_engine_software_qtopia_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void
|
||||
evas_engine_software_qtopia_font_free(void *data, void *font)
|
||||
{
|
||||
|
|
|
@ -58,6 +58,8 @@ static void evas_engine_software_x11_image_cache_set(void *data, int bytes);
|
|||
static int evas_engine_software_x11_image_cache_get(void *data);
|
||||
static void *evas_engine_software_x11_font_load(void *data, char *name, int size);
|
||||
static void *evas_engine_software_x11_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size);
|
||||
static void *evas_engine_software_x11_font_add(void *data, void *font, char *name, int size);
|
||||
static void *evas_engine_software_x11_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size);
|
||||
static void evas_engine_software_x11_font_free(void *data, void *font);
|
||||
static int evas_engine_software_x11_font_ascent_get(void *data, void *font);
|
||||
static int evas_engine_software_x11_font_descent_get(void *data, void *font);
|
||||
|
@ -159,6 +161,8 @@ Evas_Func evas_engine_software_x11_func =
|
|||
/* font draw functions */
|
||||
evas_engine_software_x11_font_load,
|
||||
evas_engine_software_x11_font_memory_load,
|
||||
evas_engine_software_x11_font_add,
|
||||
evas_engine_software_x11_font_memory_add,
|
||||
evas_engine_software_x11_font_free,
|
||||
evas_engine_software_x11_font_ascent_get,
|
||||
evas_engine_software_x11_font_descent_get,
|
||||
|
@ -934,6 +938,24 @@ evas_engine_software_x11_font_memory_load(void *data, char *name, int size, cons
|
|||
return evas_common_font_memory_load(name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void *
|
||||
evas_engine_software_x11_font_add(void *data, void *font, char *name, int size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_add(font, name, size);
|
||||
}
|
||||
|
||||
static void *
|
||||
evas_engine_software_x11_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void
|
||||
evas_engine_software_x11_font_free(void *data, void *font)
|
||||
{
|
||||
|
|
|
@ -171,6 +171,7 @@ typedef struct _RGBA_Gradient RGBA_Gradient;
|
|||
typedef struct _RGBA_Gradient_Color RGBA_Gradient_Color;
|
||||
typedef struct _RGBA_Polygon_Point RGBA_Polygon_Point;
|
||||
typedef struct _RGBA_Font RGBA_Font;
|
||||
typedef struct _RGBA_Font_Int RGBA_Font_Int;
|
||||
typedef struct _RGBA_Font_Source RGBA_Font_Source;
|
||||
typedef struct _RGBA_Font_Glyph RGBA_Font_Glyph;
|
||||
|
||||
|
@ -338,6 +339,11 @@ struct _RGBA_Polygon_Point
|
|||
};
|
||||
|
||||
struct _RGBA_Font
|
||||
{
|
||||
Evas_List *fonts;
|
||||
};
|
||||
|
||||
struct _RGBA_Font_Int
|
||||
{
|
||||
Evas_Object_List _list_data;
|
||||
|
||||
|
@ -882,16 +888,19 @@ void evas_common_font_source_free (RGBA_Font_Source *fs);
|
|||
void evas_common_font_size_use (RGBA_Font *fn);
|
||||
RGBA_Font *evas_common_font_memory_load (const char *name, int size, const void *data, int data_size);
|
||||
RGBA_Font *evas_common_font_load (const char *name, int size);
|
||||
RGBA_Font *evas_common_font_load_init (RGBA_Font *fn);
|
||||
int evas_common_font_add (RGBA_Font *fn, const char *name, int size);
|
||||
int evas_common_font_memory_add (RGBA_Font *fn, const char *name, int size, const void *data, int data_size);
|
||||
RGBA_Font_Int *evas_common_font_int_load_init (RGBA_Font_Int *fn);
|
||||
void evas_common_font_free (RGBA_Font *fn);
|
||||
void evas_common_font_modify_cache_by (RGBA_Font *fn, int dir);
|
||||
void evas_common_font_int_modify_cache_by(RGBA_Font_Int *fi, int dir);
|
||||
int evas_common_font_cache_get (void);
|
||||
void evas_common_font_cache_set (int size);
|
||||
void evas_common_font_flush (void);
|
||||
void evas_common_font_flush_last (void);
|
||||
RGBA_Font *evas_common_font_find (const char *name, int size);
|
||||
RGBA_Font_Int *evas_common_font_int_find (const char *name, int size);
|
||||
int evas_common_font_glyph_search (RGBA_Font *fn, RGBA_Font_Int **fi_ret, int gl);
|
||||
void evas_common_font_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int x, int y, const char *text);
|
||||
RGBA_Font_Glyph *evas_common_font_cache_glyph_get (RGBA_Font *fn, FT_UInt index);
|
||||
RGBA_Font_Glyph *evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt index);
|
||||
int evas_common_font_ascent_get (RGBA_Font *fn);
|
||||
int evas_common_font_descent_get (RGBA_Font *fn);
|
||||
int evas_common_font_max_ascent_get (RGBA_Font *fn);
|
||||
|
|
|
@ -593,6 +593,8 @@ struct _Evas_Func
|
|||
|
||||
void *(*font_load) (void *data, char *name, int size);
|
||||
void *(*font_memory_load) (void *data, char *name, int size, const void *fdata, int fdata_size);
|
||||
void *(*font_add) (void *data, char *name, int size);
|
||||
void *(*font_memory_add) (void *data, char *name, int size, const void *fdata, int fdata_size);
|
||||
void (*font_free) (void *data, void *font);
|
||||
int (*font_ascent_get) (void *data, void *font);
|
||||
int (*font_descent_get) (void *data, void *font);
|
||||
|
|
Loading…
Reference in New Issue