added in loading froms from memory buffers at the engine level, and now an
api to set a font "source" (blank is normal filing system) but the source can be a device or file etc. in this case it currently supports eet files as the source and then the font name is used as a key in th eet file as to where to find the font - edb support would be trivial to add. :) if the font is not found in the "source" it falls back to the font path etc. SVN revision: 8625
This commit is contained in:
parent
a9cfdc0688
commit
8523421b7c
|
@ -95,7 +95,7 @@ suggested configure options for evas for a P2/AMD/P3/P4 desktop X display:
|
||||||
|
|
||||||
make CFLAGS="-O9 -mpentiumpro -march=pentiumpro -mcpu=pentiumpro"
|
make CFLAGS="-O9 -mpentiumpro -march=pentiumpro -mcpu=pentiumpro"
|
||||||
|
|
||||||
for those that want eet and edb image loading ability:
|
for those that want eet and edb image loading ability and eet font loading:
|
||||||
|
|
||||||
./configure \
|
./configure \
|
||||||
--enable-software-x11 \
|
--enable-software-x11 \
|
||||||
|
@ -103,6 +103,7 @@ for those that want eet and edb image loading ability:
|
||||||
--enable-image-loader-jpeg \
|
--enable-image-loader-jpeg \
|
||||||
--enable-image-loader-eet \
|
--enable-image-loader-eet \
|
||||||
--enable-image-loader-edb \
|
--enable-image-loader-edb \
|
||||||
|
--enable-font-loader-eet \
|
||||||
--enable-cpu-p2-only \
|
--enable-cpu-p2-only \
|
||||||
--enable-cpu-mmx \
|
--enable-cpu-mmx \
|
||||||
--enable-cpu-sse \
|
--enable-cpu-sse \
|
||||||
|
|
|
@ -9,6 +9,7 @@ rm config.cache
|
||||||
--enable-image-loader-jpeg \
|
--enable-image-loader-jpeg \
|
||||||
--enable-image-loader-eet \
|
--enable-image-loader-eet \
|
||||||
--enable-image-loader-edb \
|
--enable-image-loader-edb \
|
||||||
|
--enable-font-loader-eet \
|
||||||
--enable-cpu-mmx \
|
--enable-cpu-mmx \
|
||||||
--enable-cpu-sse \
|
--enable-cpu-sse \
|
||||||
--enable-cpu-c \
|
--enable-cpu-c \
|
||||||
|
|
|
@ -405,6 +405,34 @@ if test "x$have_jpeg" = "xyes"; then
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
have_eet_fonts="";
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(whether to enable eet font loader)
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(font-loader-eet,
|
||||||
|
[ --enable-font-loader-eet enable eet font loader], [
|
||||||
|
if [ test "$enableval" = "yes" ]; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
have_eet_fonts="yes"
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
], [
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
have_eet_fonts="yes"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
if test "x$have_eet_fonts" = "xyes"; then
|
||||||
|
AC_CHECK_LIB(eet, eet_open,
|
||||||
|
[
|
||||||
|
AC_DEFINE(BUILD_FONT_LOADER_EET, 1, [EET Font Loader Support])
|
||||||
|
eet_cflags=`eet-config --cflags`
|
||||||
|
eet_libs=`eet-config --libs`
|
||||||
|
]
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
have_eet="";
|
have_eet="";
|
||||||
|
|
||||||
AC_MSG_CHECKING(whether to enable eet image loader)
|
AC_MSG_CHECKING(whether to enable eet image loader)
|
||||||
|
|
|
@ -248,7 +248,8 @@ Suggested configure options for evas for a P2/AMD/P3/P4 desktop X display:
|
||||||
make CFLAGS="-O9 -mpentiumpro -march=pentiumpro -mcpu=pentiumpro"
|
make CFLAGS="-O9 -mpentiumpro -march=pentiumpro -mcpu=pentiumpro"
|
||||||
@endverbatim
|
@endverbatim
|
||||||
|
|
||||||
For those that want eet and edb image loading ability:
|
For those that want eet and edb image loading ability and eet font loading
|
||||||
|
ability:
|
||||||
|
|
||||||
@verbatim
|
@verbatim
|
||||||
./configure \
|
./configure \
|
||||||
|
@ -257,6 +258,7 @@ For those that want eet and edb image loading ability:
|
||||||
--enable-image-loader-jpeg \
|
--enable-image-loader-jpeg \
|
||||||
--enable-image-loader-eet \
|
--enable-image-loader-eet \
|
||||||
--enable-image-loader-edb \
|
--enable-image-loader-edb \
|
||||||
|
--enable-font-loader-eet \
|
||||||
--enable-cpu-p2-only \
|
--enable-cpu-p2-only \
|
||||||
--enable-cpu-mmx \
|
--enable-cpu-mmx \
|
||||||
--enable-cpu-sse \
|
--enable-cpu-sse \
|
||||||
|
|
|
@ -359,6 +359,8 @@ extern "C" {
|
||||||
int evas_image_cache_get (Evas *e);
|
int evas_image_cache_get (Evas *e);
|
||||||
|
|
||||||
Evas_Object *evas_object_text_add (Evas *e);
|
Evas_Object *evas_object_text_add (Evas *e);
|
||||||
|
void evas_object_text_font_source_set (Evas_Object *obj, const char *font);
|
||||||
|
const char *evas_object_text_font_source_get (Evas_Object *obj);
|
||||||
void evas_object_text_font_set (Evas_Object *obj, const char *font, Evas_Font_Size size);
|
void evas_object_text_font_set (Evas_Object *obj, const char *font, Evas_Font_Size size);
|
||||||
void evas_object_text_font_get (Evas_Object *obj, char **font, Evas_Font_Size *size);
|
void evas_object_text_font_get (Evas_Object *obj, char **font, Evas_Font_Size *size);
|
||||||
void evas_object_text_text_set (Evas_Object *obj, const char *text);
|
void evas_object_text_text_set (Evas_Object *obj, const char *text);
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#include "evas_common.h"
|
#include "evas_common.h"
|
||||||
#include "evas_private.h"
|
#include "evas_private.h"
|
||||||
#include "Evas.h"
|
#include "Evas.h"
|
||||||
|
#ifdef BUILD_FONT_LOADER_EET
|
||||||
|
#include <Eet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* private magic number for text objects */
|
/* private magic number for text objects */
|
||||||
static const char o_type[] = "text";
|
static const char o_type[] = "text";
|
||||||
|
@ -15,6 +18,7 @@ struct _Evas_Object_Text
|
||||||
struct {
|
struct {
|
||||||
char *text;
|
char *text;
|
||||||
char *font;
|
char *font;
|
||||||
|
char *source;
|
||||||
Evas_Font_Size size;
|
Evas_Font_Size size;
|
||||||
} cur, prev;
|
} cur, prev;
|
||||||
char changed : 1;
|
char changed : 1;
|
||||||
|
@ -500,6 +504,53 @@ evas_object_text_add(Evas *e)
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be documented.
|
||||||
|
*
|
||||||
|
* FIXME: To be fixed.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
evas_object_text_font_source_set(Evas_Object *obj, const char *font_source)
|
||||||
|
{
|
||||||
|
Evas_Object_Text *o;
|
||||||
|
|
||||||
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
||||||
|
return;
|
||||||
|
MAGIC_CHECK_END();
|
||||||
|
o = (Evas_Object_Text *)(obj->object_data);
|
||||||
|
MAGIC_CHECK(o, Evas_Object_Text, MAGIC_OBJ_TEXT);
|
||||||
|
return;
|
||||||
|
MAGIC_CHECK_END();
|
||||||
|
if ((o->cur.source) && (font_source) &&
|
||||||
|
(!strcmp(o->cur.source, font_source)))
|
||||||
|
return;
|
||||||
|
if (o->cur.source) free(o->cur.source);
|
||||||
|
if (font_source) o->cur.source = strdup(font_source);
|
||||||
|
else o->cur.source = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be documented.
|
||||||
|
*
|
||||||
|
* FIXME: To be fixed.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
evas_object_text_font_source_get(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
Evas_Object_Text *o;
|
||||||
|
|
||||||
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
||||||
|
return NULL;
|
||||||
|
MAGIC_CHECK_END();
|
||||||
|
o = (Evas_Object_Text *)(obj->object_data);
|
||||||
|
MAGIC_CHECK(o, Evas_Object_Text, MAGIC_OBJ_TEXT);
|
||||||
|
return NULL;
|
||||||
|
MAGIC_CHECK_END();
|
||||||
|
return o->cur.source;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To be documented.
|
* To be documented.
|
||||||
*
|
*
|
||||||
|
@ -542,18 +593,61 @@ evas_object_text_font_set(Evas_Object *obj, const char *font, Evas_Font_Size siz
|
||||||
{
|
{
|
||||||
Evas_List *l;
|
Evas_List *l;
|
||||||
|
|
||||||
for (l = obj->layer->evas->font_path; l; l = l->next)
|
#ifdef BUILD_FONT_LOADER_EET
|
||||||
|
if (o->cur.source)
|
||||||
{
|
{
|
||||||
char *f_file;
|
Eet_File *ef;
|
||||||
|
char *fake_name;
|
||||||
f_file = object_text_font_cache_find(l->data, (char *)font);
|
|
||||||
if (f_file)
|
fake_name = evas_file_path_join(o->cur.source, font);
|
||||||
|
if (fake_name)
|
||||||
{
|
{
|
||||||
o->engine_data = obj->layer->evas->engine.func->font_load(obj->layer->evas->engine.data.output,
|
o->engine_data =
|
||||||
f_file, size);
|
obj->layer->evas->engine.func->font_load
|
||||||
if (o->engine_data) break;
|
(obj->layer->evas->engine.data.output, fake_name,
|
||||||
|
size);
|
||||||
|
if (!o->engine_data)
|
||||||
|
{
|
||||||
|
/* read original!!! */
|
||||||
|
ef = eet_open(o->cur.source, EET_FILE_MODE_READ);
|
||||||
|
if (ef)
|
||||||
|
{
|
||||||
|
void *fdata;
|
||||||
|
int fsize = 0;
|
||||||
|
|
||||||
|
fdata = eet_read(ef, font, &fsize);
|
||||||
|
if ((fdata) && (fsize > 0))
|
||||||
|
{
|
||||||
|
o->engine_data =
|
||||||
|
obj->layer->evas->engine.func->font_memory_load
|
||||||
|
(obj->layer->evas->engine.data.output,
|
||||||
|
fake_name, size, fdata, fsize);
|
||||||
|
free(fdata);
|
||||||
|
}
|
||||||
|
eet_close(ef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(fake_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!o->engine_data)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
for (l = obj->layer->evas->font_path; l; l = l->next)
|
||||||
|
{
|
||||||
|
char *f_file;
|
||||||
|
|
||||||
|
f_file = object_text_font_cache_find(l->data, (char *)font);
|
||||||
|
if (f_file)
|
||||||
|
{
|
||||||
|
o->engine_data = obj->layer->evas->engine.func->font_load(obj->layer->evas->engine.data.output,
|
||||||
|
f_file, size);
|
||||||
|
if (o->engine_data) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef BUILD_FONT_LOADER_EET
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (o->cur.font) free(o->cur.font);
|
if (o->cur.font) free(o->cur.font);
|
||||||
if (font) o->cur.font = strdup(font);
|
if (font) o->cur.font = strdup(font);
|
||||||
|
@ -1206,6 +1300,7 @@ evas_object_text_free(Evas_Object *obj)
|
||||||
/* free obj */
|
/* free obj */
|
||||||
if (o->cur.text) free(o->cur.text);
|
if (o->cur.text) free(o->cur.text);
|
||||||
if (o->cur.font) free(o->cur.font);
|
if (o->cur.font) free(o->cur.font);
|
||||||
|
if (o->cur.source) free(o->cur.source);
|
||||||
if (o->engine_data)
|
if (o->engine_data)
|
||||||
obj->layer->evas->engine.func->font_free(obj->layer->evas->engine.data.output,
|
obj->layer->evas->engine.func->font_free(obj->layer->evas->engine.data.output,
|
||||||
o->engine_data);
|
o->engine_data);
|
||||||
|
|
|
@ -69,6 +69,7 @@ static void evas_engine_buffer_image_cache_flush(void *data);
|
||||||
static void evas_engine_buffer_image_cache_set(void *data, int bytes);
|
static void evas_engine_buffer_image_cache_set(void *data, int bytes);
|
||||||
static int evas_engine_buffer_image_cache_get(void *data);
|
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_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_free(void *data, void *font);
|
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_ascent_get(void *data, void *font);
|
||||||
static int evas_engine_buffer_font_descent_get(void *data, void *font);
|
static int evas_engine_buffer_font_descent_get(void *data, void *font);
|
||||||
|
@ -154,6 +155,7 @@ Evas_Func evas_engine_buffer_func =
|
||||||
evas_engine_buffer_image_cache_get,
|
evas_engine_buffer_image_cache_get,
|
||||||
/* font draw functions */
|
/* font draw functions */
|
||||||
evas_engine_buffer_font_load,
|
evas_engine_buffer_font_load,
|
||||||
|
evas_engine_buffer_font_memory_load,
|
||||||
evas_engine_buffer_font_free,
|
evas_engine_buffer_font_free,
|
||||||
evas_engine_buffer_font_ascent_get,
|
evas_engine_buffer_font_ascent_get,
|
||||||
evas_engine_buffer_font_descent_get,
|
evas_engine_buffer_font_descent_get,
|
||||||
|
@ -925,6 +927,15 @@ evas_engine_buffer_font_load(void *data, char *name, int size)
|
||||||
return evas_common_font_load(name, size);
|
return evas_common_font_load(name, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
evas_engine_buffer_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size)
|
||||||
|
{
|
||||||
|
Render_Engine *re;
|
||||||
|
|
||||||
|
re = (Render_Engine *)data;
|
||||||
|
return evas_common_font_memory_load(name, size, fdata, fdata_size);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
evas_engine_buffer_font_free(void *data, void *font)
|
evas_engine_buffer_font_free(void *data, void *font)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,14 +17,14 @@ evas_common_font_cache_glyph_get(RGBA_Font *fn, FT_UInt index)
|
||||||
fg = evas_hash_find(fn->glyphs, key);
|
fg = evas_hash_find(fn->glyphs, key);
|
||||||
if (fg) return fg;
|
if (fg) return fg;
|
||||||
|
|
||||||
error = FT_Load_Glyph(fn->ft.face, index, FT_LOAD_NO_BITMAP);
|
error = FT_Load_Glyph(fn->src->ft.face, index, FT_LOAD_NO_BITMAP);
|
||||||
if (error) return NULL;
|
if (error) return NULL;
|
||||||
|
|
||||||
fg = malloc(sizeof(struct _RGBA_Font_Glyph));
|
fg = malloc(sizeof(struct _RGBA_Font_Glyph));
|
||||||
if (!fg) return NULL;
|
if (!fg) return NULL;
|
||||||
memset(fg, 0, (sizeof(struct _RGBA_Font_Glyph)));
|
memset(fg, 0, (sizeof(struct _RGBA_Font_Glyph)));
|
||||||
|
|
||||||
error = FT_Get_Glyph(fn->ft.face->glyph, &(fg->glyph));
|
error = FT_Get_Glyph(fn->src->ft.face->glyph, &(fg->glyph));
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
free(fg);
|
free(fg);
|
||||||
|
@ -90,7 +90,8 @@ evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int
|
||||||
|
|
||||||
pen_x = x << 8;
|
pen_x = x << 8;
|
||||||
pen_y = y << 8;
|
pen_y = y << 8;
|
||||||
use_kerning = FT_HAS_KERNING(fn->ft.face);
|
evas_common_font_size_use(fn);
|
||||||
|
use_kerning = FT_HAS_KERNING(fn->src->ft.face);
|
||||||
prev_index = 0;
|
prev_index = 0;
|
||||||
func = evas_common_draw_func_blend_alpha_get(dst);
|
func = evas_common_draw_func_blend_alpha_get(dst);
|
||||||
for (c = 0, chr = 0; text[chr];)
|
for (c = 0, chr = 0; text[chr];)
|
||||||
|
@ -102,12 +103,12 @@ 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);
|
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
||||||
if (gl == 0) break;
|
if (gl == 0) break;
|
||||||
index = FT_Get_Char_Index(fn->ft.face, gl);
|
index = FT_Get_Char_Index(fn->src->ft.face, gl);
|
||||||
if ((use_kerning) && (prev_index) && (index))
|
if ((use_kerning) && (prev_index) && (index))
|
||||||
{
|
{
|
||||||
FT_Vector delta;
|
FT_Vector delta;
|
||||||
|
|
||||||
FT_Get_Kerning(fn->ft.face, prev_index, index,
|
FT_Get_Kerning(fn->src->ft.face, prev_index, index,
|
||||||
ft_kerning_default, &delta);
|
ft_kerning_default, &delta);
|
||||||
pen_x += delta.x << 2;
|
pen_x += delta.x << 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,94 +4,236 @@ extern FT_Library evas_ft_lib;
|
||||||
|
|
||||||
static int font_cache_usage = 0;
|
static int font_cache_usage = 0;
|
||||||
static int font_cache = 0;
|
static int font_cache = 0;
|
||||||
|
static Evas_Object_List * fonts_src = NULL;
|
||||||
static Evas_Object_List * fonts = NULL;
|
static Evas_Object_List * fonts = NULL;
|
||||||
|
|
||||||
static int font_modify_cache_cb(Evas_Hash *hash, const char *key, void *data, void *fdata);
|
static int font_modify_cache_cb(Evas_Hash *hash, const char *key, void *data, void *fdata);
|
||||||
static int font_flush_free_glyph_cb(Evas_Hash *hash, const char *key, void *data, void *fdata);
|
static int font_flush_free_glyph_cb(Evas_Hash *hash, const char *key, void *data, void *fdata);
|
||||||
|
|
||||||
/* FIXME: */
|
RGBA_Font_Source *
|
||||||
/* we should share face handles and have different ft sizes from the same */
|
evas_common_font_source_memory_load(const char *name, const void *data, int data_size)
|
||||||
/* face (if applicable) */
|
|
||||||
|
|
||||||
RGBA_Font *
|
|
||||||
evas_common_font_load(const char *name, int size)
|
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
RGBA_Font_Source *fs;
|
||||||
|
|
||||||
|
fs = malloc(sizeof(RGBA_Font_Source));
|
||||||
|
if (!fs) return NULL;
|
||||||
|
fs->name = strdup(name);
|
||||||
|
fs->file = NULL;
|
||||||
|
fs->data = malloc(data_size);
|
||||||
|
if (!fs->data)
|
||||||
|
{
|
||||||
|
if (fs->name) free(fs->name);
|
||||||
|
free(fs);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
memcpy(fs->data, data, data_size);
|
||||||
|
fs->data_size = data_size;
|
||||||
|
error = FT_New_Memory_Face(evas_ft_lib, fs->data, fs->data_size, 0, &(fs->ft.face));
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
if (fs->name) free(fs->name);
|
||||||
|
if (fs->data) free(fs->data);
|
||||||
|
free(fs);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs->references = 1;
|
||||||
|
|
||||||
|
fonts_src = evas_object_list_prepend(fonts_src, fs);
|
||||||
|
return fs;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBA_Font_Source *
|
||||||
|
evas_common_font_source_load(const char *name)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
RGBA_Font_Source *fs;
|
||||||
|
|
||||||
|
fs = malloc(sizeof(RGBA_Font_Source));
|
||||||
|
if (!fs) return NULL;
|
||||||
|
fs->name = strdup(name);
|
||||||
|
fs->file = strdup(name);
|
||||||
|
error = FT_New_Face(evas_ft_lib, fs->file, 0, &(fs->ft.face));
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
if (fs->name) free(fs->name);
|
||||||
|
if (fs->file) free(fs->file);
|
||||||
|
free(fs);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs->references = 1;
|
||||||
|
|
||||||
|
fonts_src = evas_object_list_prepend(fonts_src, fs);
|
||||||
|
return fs;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBA_Font_Source *
|
||||||
|
evas_common_font_source_find(const char *name)
|
||||||
|
{
|
||||||
|
Evas_Object_List *l;
|
||||||
|
|
||||||
|
if (!name) return NULL;
|
||||||
|
for (l = fonts_src; l; l = l->next)
|
||||||
|
{
|
||||||
|
RGBA_Font_Source *fs;
|
||||||
|
|
||||||
|
fs = (RGBA_Font_Source *)l;
|
||||||
|
if ((fs->name) && (!strcmp(name, fs->name)))
|
||||||
|
{
|
||||||
|
fs->references++;
|
||||||
|
fonts_src = evas_object_list_remove(fonts_src, fs);
|
||||||
|
fonts_src = evas_object_list_prepend(fonts_src, fs);
|
||||||
|
return fs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
evas_common_font_source_free(RGBA_Font_Source *fs)
|
||||||
|
{
|
||||||
|
fs->references--;
|
||||||
|
if (fs->references > 0) return;
|
||||||
|
|
||||||
|
fonts_src = evas_object_list_remove(fonts_src, fs);
|
||||||
|
if (fs->name) free(fs->name);
|
||||||
|
if (fs->file) free(fs->file);
|
||||||
|
if (fs->data) free(fs->data);
|
||||||
|
FT_Done_Face(fs->ft.face);
|
||||||
|
free(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
evas_common_font_size_use(RGBA_Font *fn)
|
||||||
|
{
|
||||||
|
if (fn->src->current_size == fn->real_size) return;
|
||||||
|
FT_Set_Char_Size(fn->src->ft.face, 0, fn->real_size, 96, 96);
|
||||||
|
fn->src->current_size = fn->real_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBA_Font *
|
||||||
|
evas_common_font_memory_load(const char *name, int size, const void *data, int data_size)
|
||||||
|
{
|
||||||
RGBA_Font *fn;
|
RGBA_Font *fn;
|
||||||
char *file;
|
|
||||||
|
|
||||||
fn = evas_common_font_find(name, size);
|
fn = evas_common_font_find(name, size);
|
||||||
if (fn) return fn;
|
if (fn) return fn;
|
||||||
|
|
||||||
fn = malloc(sizeof(RGBA_Font));
|
fn = malloc(sizeof(RGBA_Font));
|
||||||
file = (char *)name;
|
if (!fn) return NULL;
|
||||||
|
|
||||||
error = FT_New_Face(evas_ft_lib, file, 0, &(fn->ft.face));
|
fn->src = evas_common_font_source_find(name);
|
||||||
if (error)
|
if (!fn->src) fn->src = evas_common_font_source_memory_load(name, data, data_size);
|
||||||
|
|
||||||
|
if (!fn->src)
|
||||||
{
|
{
|
||||||
free(fn);
|
free(fn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
error = FT_Set_Char_Size(fn->ft.face, 0, (size * 64), 96, 96);
|
|
||||||
|
fn->size = size;
|
||||||
|
|
||||||
|
return evas_common_font_load_init(fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBA_Font *
|
||||||
|
evas_common_font_load(const char *name, int size)
|
||||||
|
{
|
||||||
|
RGBA_Font *fn;
|
||||||
|
|
||||||
|
fn = evas_common_font_find(name, size);
|
||||||
|
if (fn) return fn;
|
||||||
|
|
||||||
|
fn = malloc(sizeof(RGBA_Font));
|
||||||
|
if (!fn) return NULL;
|
||||||
|
|
||||||
|
fn->src = evas_common_font_source_find(name);
|
||||||
|
if (!fn->src) fn->src = evas_common_font_source_load(name);
|
||||||
|
|
||||||
|
if (!fn->src)
|
||||||
|
{
|
||||||
|
free(fn);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn->size = size;
|
||||||
|
|
||||||
|
return evas_common_font_load_init(fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBA_Font *
|
||||||
|
evas_common_font_load_init(RGBA_Font *fn)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
fn->real_size = fn->size * 64;
|
||||||
|
error = FT_Set_Char_Size(fn->src->ft.face, 0, (fn->size * 64), 96, 96);
|
||||||
if (error)
|
if (error)
|
||||||
error = FT_Set_Pixel_Sizes(fn->ft.face, 0, size);
|
{
|
||||||
|
error = FT_Set_Pixel_Sizes(fn->src->ft.face, 0, fn->size);
|
||||||
|
fn->real_size = fn->size;
|
||||||
|
}
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int chosen_size = 0;
|
int chosen_size = 0;
|
||||||
int chosen_width = 0;
|
int chosen_width = 0;
|
||||||
|
|
||||||
for (i = 0; i < fn->ft.face->num_fixed_sizes; i++)
|
for (i = 0; i < fn->src->ft.face->num_fixed_sizes; i++)
|
||||||
{
|
{
|
||||||
int s;
|
int s;
|
||||||
int d, cd;
|
int d, cd;
|
||||||
|
|
||||||
s = fn->ft.face->available_sizes[i].height;
|
s = fn->src->ft.face->available_sizes[i].height;
|
||||||
cd = chosen_size - size;
|
cd = chosen_size - fn->size;
|
||||||
if (cd < 0) cd = -cd;
|
if (cd < 0) cd = -cd;
|
||||||
d = s - size;
|
d = s - fn->size;
|
||||||
if (d < 0) d = -d;
|
if (d < 0) d = -d;
|
||||||
if (d < cd)
|
if (d < cd)
|
||||||
{
|
{
|
||||||
chosen_width = fn->ft.face->available_sizes[i].width;
|
chosen_width = fn->src->ft.face->available_sizes[i].width;
|
||||||
chosen_size = s;
|
chosen_size = s;
|
||||||
}
|
}
|
||||||
if (d == 0) break;
|
if (d == 0) break;
|
||||||
}
|
}
|
||||||
error = FT_Set_Pixel_Sizes(fn->ft.face, chosen_width, chosen_size);
|
error = FT_Set_Pixel_Sizes(fn->src->ft.face, chosen_width, chosen_size);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
/* couldn't choose the size anyway... what now? */
|
/* couldn't choose the size anyway... what now? */
|
||||||
}
|
}
|
||||||
|
fn->real_size = chosen_size;
|
||||||
}
|
}
|
||||||
|
fn->src->current_size = fn->real_size;
|
||||||
|
|
||||||
#if 0 /* debugging to look at charmaps in a ttf */
|
#if 0 /* debugging to look at charmaps in a ttf */
|
||||||
printf("%i\n", fn->ft.face->num_charmaps);
|
printf("%i\n", fn->src->ft.face->num_charmaps);
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < fn->ft.face->num_charmaps; i++)
|
for (i = 0; i < fn->src->ft.face->num_charmaps; i++)
|
||||||
{
|
{
|
||||||
printf("%i: %x, %c\n",
|
printf("%i: %x, %c\n",
|
||||||
i, fn->ft.face->charmaps[i]->encoding,
|
i, fn->src->ft.face->charmaps[i]->encoding,
|
||||||
fn->ft.face->charmaps[i]->encoding);
|
fn->src->ft.face->charmaps[i]->encoding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
error = FT_Select_Charmap(fn->ft.face, ft_encoding_unicode);
|
error = FT_Select_Charmap(fn->src->ft.face, ft_encoding_unicode);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
/* disable this for now...
|
/* disable this for now...
|
||||||
error = FT_Select_Charmap(fn->ft.face, ft_encoding_latin_2);
|
error = FT_Select_Charmap(fn->src->ft.face, ft_encoding_latin_2);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
error = FT_Select_Charmap(fn->ft.face, ft_encoding_sjis);
|
error = FT_Select_Charmap(fn->src->ft.face, ft_encoding_sjis);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
error = FT_Select_Charmap(fn->ft.face, ft_encoding_gb2312);
|
error = FT_Select_Charmap(fn->src->ft.face, ft_encoding_gb2312);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
error = FT_Select_Charmap(fn->ft.face, ft_encoding_big5);
|
error = FT_Select_Charmap(fn->src->ft.face, ft_encoding_big5);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -101,16 +243,9 @@ evas_common_font_load(const char *name, int size)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
fn->file = strdup(file);
|
|
||||||
fn->name = strdup(file);
|
|
||||||
fn->size = size;
|
|
||||||
|
|
||||||
fn->glyphs = NULL;
|
fn->glyphs = NULL;
|
||||||
|
|
||||||
fn->usage = 0;
|
fn->usage = 0;
|
||||||
|
|
||||||
fn->references = 1;
|
fn->references = 1;
|
||||||
|
|
||||||
fonts = evas_object_list_prepend(fonts, fn);
|
fonts = evas_object_list_prepend(fonts, fn);
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
@ -145,13 +280,11 @@ font_modify_cache_cb(Evas_Hash *hash, const char *key, void *data, void *fdata)
|
||||||
void
|
void
|
||||||
evas_common_font_modify_cache_by(RGBA_Font *fn, int dir)
|
evas_common_font_modify_cache_by(RGBA_Font *fn, int dir)
|
||||||
{
|
{
|
||||||
int sz_name = 0, sz_file = 0, sz_hash = 0;
|
int sz_hash = 0;
|
||||||
|
|
||||||
if (fn->name) sz_name = strlen(fn->name);
|
|
||||||
if (fn->file) sz_file = strlen(fn->file);
|
|
||||||
if (fn->glyphs) sz_hash = sizeof(Evas_Hash);
|
if (fn->glyphs) sz_hash = sizeof(Evas_Hash);
|
||||||
evas_hash_foreach(fn->glyphs, font_modify_cache_cb, &dir);
|
evas_hash_foreach(fn->glyphs, font_modify_cache_cb, &dir);
|
||||||
font_cache_usage += dir * (sizeof(RGBA_Font) + sz_name + sz_file + sz_hash +
|
font_cache_usage += dir * (sizeof(RGBA_Font) + sz_hash +
|
||||||
sizeof(FT_FaceRec) + 16384); /* fudge values */
|
sizeof(FT_FaceRec) + 16384); /* fudge values */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,9 +345,8 @@ evas_common_font_flush_last(void)
|
||||||
evas_hash_foreach(fn->glyphs, font_flush_free_glyph_cb, NULL);
|
evas_hash_foreach(fn->glyphs, font_flush_free_glyph_cb, NULL);
|
||||||
evas_hash_free(fn->glyphs);
|
evas_hash_free(fn->glyphs);
|
||||||
|
|
||||||
if (fn->file) free(fn->file);
|
evas_common_font_source_free(fn->src);
|
||||||
if (fn->name) free(fn->name);
|
|
||||||
FT_Done_Face(fn->ft.face);
|
|
||||||
free(fn);
|
free(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +360,7 @@ evas_common_font_find(const char *name, int size)
|
||||||
RGBA_Font *fn;
|
RGBA_Font *fn;
|
||||||
|
|
||||||
fn = (RGBA_Font *)l;
|
fn = (RGBA_Font *)l;
|
||||||
if ((fn->size == size) && (!strcmp(name, fn->name)))
|
if ((fn->size == size) && (!strcmp(name, fn->src->name)))
|
||||||
{
|
{
|
||||||
if (fn->references == 0) evas_common_font_modify_cache_by(fn, -1);
|
if (fn->references == 0) evas_common_font_modify_cache_by(fn, -1);
|
||||||
fn->references++;
|
fn->references++;
|
||||||
|
|
|
@ -34,9 +34,9 @@ evas_common_font_ascent_get(RGBA_Font *fn)
|
||||||
int val;
|
int val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
val = (int)fn->ft.face->ascender;
|
val = (int)fn->src->ft.face->ascender;
|
||||||
fn->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */
|
fn->src->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */
|
||||||
ret = (val * fn->ft.face->size->metrics.y_scale) / (fn->ft.face->units_per_EM * fn->ft.face->units_per_EM);
|
ret = (val * fn->src->ft.face->size->metrics.y_scale) / (fn->src->ft.face->units_per_EM * fn->src->ft.face->units_per_EM);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,9 +46,10 @@ evas_common_font_descent_get(RGBA_Font *fn)
|
||||||
int val;
|
int val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
val = -(int)fn->ft.face->descender;
|
evas_common_font_size_use(fn);
|
||||||
fn->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */
|
val = -(int)fn->src->ft.face->descender;
|
||||||
ret = (val * fn->ft.face->size->metrics.y_scale) / (fn->ft.face->units_per_EM * fn->ft.face->units_per_EM);
|
fn->src->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */
|
||||||
|
ret = (val * fn->src->ft.face->size->metrics.y_scale) / (fn->src->ft.face->units_per_EM * fn->src->ft.face->units_per_EM);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +59,10 @@ evas_common_font_max_ascent_get(RGBA_Font *fn)
|
||||||
int val;
|
int val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
val = (int)fn->ft.face->bbox.yMax;
|
evas_common_font_size_use(fn);
|
||||||
fn->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */
|
val = (int)fn->src->ft.face->bbox.yMax;
|
||||||
ret = (val * fn->ft.face->size->metrics.y_scale) / (fn->ft.face->units_per_EM * fn->ft.face->units_per_EM);
|
fn->src->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */
|
||||||
|
ret = (val * fn->src->ft.face->size->metrics.y_scale) / (fn->src->ft.face->units_per_EM * fn->src->ft.face->units_per_EM);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,9 +72,10 @@ evas_common_font_max_descent_get(RGBA_Font *fn)
|
||||||
int val;
|
int val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
val = -(int)fn->ft.face->bbox.yMin;
|
evas_common_font_size_use(fn);
|
||||||
fn->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */
|
val = -(int)fn->src->ft.face->bbox.yMin;
|
||||||
ret = (val * fn->ft.face->size->metrics.y_scale) / (fn->ft.face->units_per_EM * fn->ft.face->units_per_EM);
|
fn->src->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */
|
||||||
|
ret = (val * fn->src->ft.face->size->metrics.y_scale) / (fn->src->ft.face->units_per_EM * fn->src->ft.face->units_per_EM);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,9 +85,10 @@ evas_common_font_get_line_advance(RGBA_Font *fn)
|
||||||
int val;
|
int val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
val = (int)fn->ft.face->height;
|
evas_common_font_size_use(fn);
|
||||||
fn->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */
|
val = (int)fn->src->ft.face->height;
|
||||||
ret = (val * fn->ft.face->size->metrics.y_scale) / (fn->ft.face->units_per_EM * fn->ft.face->units_per_EM);
|
fn->src->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct val */
|
||||||
|
ret = (val * fn->src->ft.face->size->metrics.y_scale) / (fn->src->ft.face->units_per_EM * fn->src->ft.face->units_per_EM);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@ evas_common_font_query_size(RGBA_Font *fn, const char *text, int *w, int *h)
|
||||||
end_x = 0;
|
end_x = 0;
|
||||||
pen_x = 0;
|
pen_x = 0;
|
||||||
pen_y = 0;
|
pen_y = 0;
|
||||||
use_kerning = FT_HAS_KERNING(fn->ft.face);
|
evas_common_font_size_use(fn);
|
||||||
|
use_kerning = FT_HAS_KERNING(fn->src->ft.face);
|
||||||
prev_index = 0;
|
prev_index = 0;
|
||||||
for (chr = 0; text[chr];)
|
for (chr = 0; text[chr];)
|
||||||
{
|
{
|
||||||
|
@ -25,12 +26,12 @@ 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);
|
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
||||||
if (gl == 0) break;
|
if (gl == 0) break;
|
||||||
index = FT_Get_Char_Index(fn->ft.face, gl);
|
index = FT_Get_Char_Index(fn->src->ft.face, gl);
|
||||||
if ((use_kerning) && (prev_index) && (index))
|
if ((use_kerning) && (prev_index) && (index))
|
||||||
{
|
{
|
||||||
FT_Vector delta;
|
FT_Vector delta;
|
||||||
|
|
||||||
FT_Get_Kerning(fn->ft.face, prev_index, index,
|
FT_Get_Kerning(fn->src->ft.face, prev_index, index,
|
||||||
ft_kerning_default, &delta);
|
ft_kerning_default, &delta);
|
||||||
pen_x += delta.x << 2;
|
pen_x += delta.x << 2;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +65,8 @@ evas_common_font_query_inset(RGBA_Font *fn, const char *text)
|
||||||
if (!text[0]) return 0;
|
if (!text[0]) return 0;
|
||||||
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
||||||
if (gl == 0) return 0;
|
if (gl == 0) return 0;
|
||||||
index = FT_Get_Char_Index(fn->ft.face, gl);
|
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);
|
fg = evas_common_font_cache_glyph_get(fn, index);
|
||||||
if (!fg) return 0;
|
if (!fg) return 0;
|
||||||
return fg->glyph_out->left;
|
return fg->glyph_out->left;
|
||||||
|
@ -83,7 +85,8 @@ evas_common_font_query_advance(RGBA_Font *fn, const char *text, int *h_adv, int
|
||||||
start_x = 0;
|
start_x = 0;
|
||||||
pen_x = 0;
|
pen_x = 0;
|
||||||
pen_y = 0;
|
pen_y = 0;
|
||||||
use_kerning = FT_HAS_KERNING(fn->ft.face);
|
evas_common_font_size_use(fn);
|
||||||
|
use_kerning = FT_HAS_KERNING(fn->src->ft.face);
|
||||||
prev_index = 0;
|
prev_index = 0;
|
||||||
for (chr = 0; text[chr];)
|
for (chr = 0; text[chr];)
|
||||||
{
|
{
|
||||||
|
@ -94,12 +97,12 @@ 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);
|
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
||||||
if (gl == 0) break;
|
if (gl == 0) break;
|
||||||
index = FT_Get_Char_Index(fn->ft.face, gl);
|
index = FT_Get_Char_Index(fn->src->ft.face, gl);
|
||||||
if ((use_kerning) && (prev_index) && (index))
|
if ((use_kerning) && (prev_index) && (index))
|
||||||
{
|
{
|
||||||
FT_Vector delta;
|
FT_Vector delta;
|
||||||
|
|
||||||
FT_Get_Kerning(fn->ft.face, prev_index, index,
|
FT_Get_Kerning(fn->src->ft.face, prev_index, index,
|
||||||
ft_kerning_default, &delta);
|
ft_kerning_default, &delta);
|
||||||
pen_x += delta.x << 2;
|
pen_x += delta.x << 2;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +133,8 @@ evas_common_font_query_char_coords(RGBA_Font *fn, const char *text, int pos, int
|
||||||
|
|
||||||
pen_x = 0;
|
pen_x = 0;
|
||||||
pen_y = 0;
|
pen_y = 0;
|
||||||
use_kerning = FT_HAS_KERNING(fn->ft.face);
|
evas_common_font_size_use(fn);
|
||||||
|
use_kerning = FT_HAS_KERNING(fn->src->ft.face);
|
||||||
prev_index = 0;
|
prev_index = 0;
|
||||||
prev_chr_end = 0;
|
prev_chr_end = 0;
|
||||||
asc = evas_common_font_max_ascent_get(fn);
|
asc = evas_common_font_max_ascent_get(fn);
|
||||||
|
@ -147,11 +151,11 @@ evas_common_font_query_char_coords(RGBA_Font *fn, const char *text, int pos, int
|
||||||
pchr = chr;
|
pchr = chr;
|
||||||
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
||||||
if (gl == 0) break;
|
if (gl == 0) break;
|
||||||
index = FT_Get_Char_Index(fn->ft.face, gl);
|
index = FT_Get_Char_Index(fn->src->ft.face, gl);
|
||||||
kern = 0;
|
kern = 0;
|
||||||
if ((use_kerning) && (prev_index) && (index))
|
if ((use_kerning) && (prev_index) && (index))
|
||||||
{
|
{
|
||||||
FT_Get_Kerning(fn->ft.face, prev_index, index,
|
FT_Get_Kerning(fn->src->ft.face, prev_index, index,
|
||||||
ft_kerning_default, &delta);
|
ft_kerning_default, &delta);
|
||||||
kern = delta.x << 2;
|
kern = delta.x << 2;
|
||||||
pen_x += kern;
|
pen_x += kern;
|
||||||
|
@ -203,7 +207,8 @@ evas_common_font_query_text_at_pos(RGBA_Font *fn, const char *text, int x, int y
|
||||||
|
|
||||||
pen_x = 0;
|
pen_x = 0;
|
||||||
pen_y = 0;
|
pen_y = 0;
|
||||||
use_kerning = FT_HAS_KERNING(fn->ft.face);
|
evas_common_font_size_use(fn);
|
||||||
|
use_kerning = FT_HAS_KERNING(fn->src->ft.face);
|
||||||
prev_index = 0;
|
prev_index = 0;
|
||||||
prev_chr_end = 0;
|
prev_chr_end = 0;
|
||||||
asc = evas_common_font_max_ascent_get(fn);
|
asc = evas_common_font_max_ascent_get(fn);
|
||||||
|
@ -220,11 +225,11 @@ evas_common_font_query_text_at_pos(RGBA_Font *fn, const char *text, int x, int y
|
||||||
pchr = chr;
|
pchr = chr;
|
||||||
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
|
||||||
if (gl == 0) break;
|
if (gl == 0) break;
|
||||||
index = FT_Get_Char_Index(fn->ft.face, gl);
|
index = FT_Get_Char_Index(fn->src->ft.face, gl);
|
||||||
kern = 0;
|
kern = 0;
|
||||||
if ((use_kerning) && (prev_index) && (index))
|
if ((use_kerning) && (prev_index) && (index))
|
||||||
{
|
{
|
||||||
FT_Get_Kerning(fn->ft.face, prev_index, index,
|
FT_Get_Kerning(fn->src->ft.face, prev_index, index,
|
||||||
ft_kerning_default, &delta);
|
ft_kerning_default, &delta);
|
||||||
kern = delta.x << 2;
|
kern = delta.x << 2;
|
||||||
pen_x += kern;
|
pen_x += kern;
|
||||||
|
|
|
@ -62,6 +62,7 @@ Evas_Func evas_engine_directfb_func = {
|
||||||
evas_engine_directfb_image_cache_get,
|
evas_engine_directfb_image_cache_get,
|
||||||
/* more to come */
|
/* more to come */
|
||||||
evas_engine_directfb_font_load,
|
evas_engine_directfb_font_load,
|
||||||
|
evas_engine_directfb_font_memory_load,
|
||||||
evas_engine_directfb_font_free,
|
evas_engine_directfb_font_free,
|
||||||
evas_engine_directfb_font_ascent_get,
|
evas_engine_directfb_font_ascent_get,
|
||||||
evas_engine_directfb_font_descent_get,
|
evas_engine_directfb_font_descent_get,
|
||||||
|
@ -759,6 +760,15 @@ evas_engine_directfb_font_load(void *data, char *name, int size)
|
||||||
return evas_common_font_load(name, size);
|
return evas_common_font_load(name, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
evas_engine_directfb_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size)
|
||||||
|
{
|
||||||
|
Render_Engine *re;
|
||||||
|
|
||||||
|
re = (Render_Engine *) data;
|
||||||
|
return evas_common_font_memory_load(name, size, fdata, fdata_size);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
evas_engine_directfb_font_free(void *data, void *font)
|
evas_engine_directfb_font_free(void *data, void *font)
|
||||||
{
|
{
|
||||||
|
|
|
@ -133,6 +133,11 @@ void evas_engine_directfb_gradient_draw(void *data,
|
||||||
double angle);
|
double angle);
|
||||||
void *evas_engine_directfb_font_load(void *data, char *name,
|
void *evas_engine_directfb_font_load(void *data, char *name,
|
||||||
int size);
|
int size);
|
||||||
|
void *evas_engine_directfb_font_memory_load(void *data,
|
||||||
|
char *name,
|
||||||
|
int size,
|
||||||
|
const void *fdata,
|
||||||
|
int fdata_size);
|
||||||
void evas_engine_directfb_font_free(void *data, void *font);
|
void evas_engine_directfb_font_free(void *data, void *font);
|
||||||
int evas_engine_directfb_font_ascent_get(void *data,
|
int evas_engine_directfb_font_ascent_get(void *data,
|
||||||
void *font);
|
void *font);
|
||||||
|
|
|
@ -57,6 +57,7 @@ static void evas_engine_fb_image_cache_flush(void *data);
|
||||||
static void evas_engine_fb_image_cache_set(void *data, int bytes);
|
static void evas_engine_fb_image_cache_set(void *data, int bytes);
|
||||||
static int evas_engine_fb_image_cache_get(void *data);
|
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_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_free(void *data, void *font);
|
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_ascent_get(void *data, void *font);
|
||||||
static int evas_engine_fb_font_descent_get(void *data, void *font);
|
static int evas_engine_fb_font_descent_get(void *data, void *font);
|
||||||
|
@ -142,6 +143,7 @@ Evas_Func evas_engine_fb_func =
|
||||||
evas_engine_fb_image_cache_get,
|
evas_engine_fb_image_cache_get,
|
||||||
/* font draw functions */
|
/* font draw functions */
|
||||||
evas_engine_fb_font_load,
|
evas_engine_fb_font_load,
|
||||||
|
evas_engine_fb_font_memory_load,
|
||||||
evas_engine_fb_font_free,
|
evas_engine_fb_font_free,
|
||||||
evas_engine_fb_font_ascent_get,
|
evas_engine_fb_font_ascent_get,
|
||||||
evas_engine_fb_font_descent_get,
|
evas_engine_fb_font_descent_get,
|
||||||
|
@ -844,6 +846,15 @@ evas_engine_fb_font_load(void *data, char *name, int size)
|
||||||
return evas_common_font_load(name, size);
|
return evas_common_font_load(name, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
evas_engine_fb_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size)
|
||||||
|
{
|
||||||
|
Render_Engine *re;
|
||||||
|
|
||||||
|
re = (Render_Engine *)data;
|
||||||
|
return evas_common_font_memory_load(name, size, fdata, fdata_size);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
evas_engine_fb_font_free(void *data, void *font)
|
evas_engine_fb_font_free(void *data, void *font)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,6 +58,7 @@ static void evas_engine_gl_x11_image_cache_flush(void *data);
|
||||||
static void evas_engine_gl_x11_image_cache_set(void *data, int bytes);
|
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 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_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_free(void *data, void *font);
|
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_ascent_get(void *data, void *font);
|
||||||
static int evas_engine_gl_x11_font_descent_get(void *data, void *font);
|
static int evas_engine_gl_x11_font_descent_get(void *data, void *font);
|
||||||
|
@ -148,6 +149,7 @@ Evas_Func evas_engine_gl_x11_func =
|
||||||
evas_engine_gl_x11_image_cache_get,
|
evas_engine_gl_x11_image_cache_get,
|
||||||
/* font draw functions */
|
/* font draw functions */
|
||||||
evas_engine_gl_x11_font_load,
|
evas_engine_gl_x11_font_load,
|
||||||
|
evas_engine_gl_x11_font_memory_load,
|
||||||
evas_engine_gl_x11_font_free,
|
evas_engine_gl_x11_font_free,
|
||||||
evas_engine_gl_x11_font_ascent_get,
|
evas_engine_gl_x11_font_ascent_get,
|
||||||
evas_engine_gl_x11_font_descent_get,
|
evas_engine_gl_x11_font_descent_get,
|
||||||
|
@ -851,6 +853,15 @@ evas_engine_gl_x11_font_load(void *data, char *name, int size)
|
||||||
return evas_common_font_load(name, size);
|
return evas_common_font_load(name, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
evas_engine_gl_x11_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size)
|
||||||
|
{
|
||||||
|
Render_Engine *re;
|
||||||
|
|
||||||
|
re = (Render_Engine *)data;
|
||||||
|
return evas_common_font_memory_load(name, size, fdata, fdata_size);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
evas_engine_gl_x11_font_free(void *data, void *font)
|
evas_engine_gl_x11_font_free(void *data, void *font)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,6 +57,7 @@ static void evas_engine_software_qtopia_image_cache_flush(void *data);
|
||||||
static void evas_engine_software_qtopia_image_cache_set(void *data, int bytes);
|
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 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_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_free(void *data, void *font);
|
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_ascent_get(void *data, void *font);
|
||||||
static int evas_engine_software_qtopia_font_descent_get(void *data, void *font);
|
static int evas_engine_software_qtopia_font_descent_get(void *data, void *font);
|
||||||
|
@ -145,6 +146,7 @@ Evas_Func evas_engine_software_qtopia_func =
|
||||||
evas_engine_software_qtopia_image_cache_get,
|
evas_engine_software_qtopia_image_cache_get,
|
||||||
/* font draw functions */
|
/* font draw functions */
|
||||||
evas_engine_software_qtopia_font_load,
|
evas_engine_software_qtopia_font_load,
|
||||||
|
evas_engine_software_qtopia_font_memory_load,
|
||||||
evas_engine_software_qtopia_font_free,
|
evas_engine_software_qtopia_font_free,
|
||||||
evas_engine_software_qtopia_font_ascent_get,
|
evas_engine_software_qtopia_font_ascent_get,
|
||||||
evas_engine_software_qtopia_font_descent_get,
|
evas_engine_software_qtopia_font_descent_get,
|
||||||
|
@ -867,6 +869,15 @@ evas_engine_software_qtopia_font_load(void *data, char *name, int size)
|
||||||
return evas_common_font_load(name, size);
|
return evas_common_font_load(name, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
evas_engine_software_qtopia_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size)
|
||||||
|
{
|
||||||
|
Render_Engine *re;
|
||||||
|
|
||||||
|
re = (Render_Engine *)data;
|
||||||
|
return evas_common_font_load(name, size, fdata, fdata_size);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
evas_engine_software_qtopia_font_free(void *data, void *font)
|
evas_engine_software_qtopia_font_free(void *data, void *font)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,6 +57,7 @@ static void evas_engine_software_x11_image_cache_flush(void *data);
|
||||||
static void evas_engine_software_x11_image_cache_set(void *data, int bytes);
|
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 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_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_free(void *data, void *font);
|
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_ascent_get(void *data, void *font);
|
||||||
static int evas_engine_software_x11_font_descent_get(void *data, void *font);
|
static int evas_engine_software_x11_font_descent_get(void *data, void *font);
|
||||||
|
@ -157,6 +158,7 @@ Evas_Func evas_engine_software_x11_func =
|
||||||
evas_engine_software_x11_image_cache_get,
|
evas_engine_software_x11_image_cache_get,
|
||||||
/* font draw functions */
|
/* font draw functions */
|
||||||
evas_engine_software_x11_font_load,
|
evas_engine_software_x11_font_load,
|
||||||
|
evas_engine_software_x11_font_memory_load,
|
||||||
evas_engine_software_x11_font_free,
|
evas_engine_software_x11_font_free,
|
||||||
evas_engine_software_x11_font_ascent_get,
|
evas_engine_software_x11_font_ascent_get,
|
||||||
evas_engine_software_x11_font_descent_get,
|
evas_engine_software_x11_font_descent_get,
|
||||||
|
@ -911,6 +913,15 @@ evas_engine_software_x11_font_load(void *data, char *name, int size)
|
||||||
return evas_common_font_load(name, size);
|
return evas_common_font_load(name, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
evas_engine_software_x11_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size)
|
||||||
|
{
|
||||||
|
Render_Engine *re;
|
||||||
|
|
||||||
|
re = (Render_Engine *)data;
|
||||||
|
return evas_common_font_memory_load(name, size, fdata, fdata_size);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
evas_engine_software_x11_font_free(void *data, void *font)
|
evas_engine_software_x11_font_free(void *data, void *font)
|
||||||
{
|
{
|
||||||
|
|
|
@ -165,6 +165,7 @@ typedef struct _RGBA_Gradient RGBA_Gradient;
|
||||||
typedef struct _RGBA_Gradient_Color RGBA_Gradient_Color;
|
typedef struct _RGBA_Gradient_Color RGBA_Gradient_Color;
|
||||||
typedef struct _RGBA_Polygon_Point RGBA_Polygon_Point;
|
typedef struct _RGBA_Polygon_Point RGBA_Polygon_Point;
|
||||||
typedef struct _RGBA_Font RGBA_Font;
|
typedef struct _RGBA_Font RGBA_Font;
|
||||||
|
typedef struct _RGBA_Font_Source RGBA_Font_Source;
|
||||||
typedef struct _RGBA_Font_Glyph RGBA_Font_Glyph;
|
typedef struct _RGBA_Font_Glyph RGBA_Font_Glyph;
|
||||||
|
|
||||||
typedef struct _Cutout_Rect Cutout_Rect;
|
typedef struct _Cutout_Rect Cutout_Rect;
|
||||||
|
@ -332,13 +333,11 @@ struct _RGBA_Polygon_Point
|
||||||
struct _RGBA_Font
|
struct _RGBA_Font
|
||||||
{
|
{
|
||||||
Evas_Object_List _list_data;
|
Evas_Object_List _list_data;
|
||||||
char *name;
|
|
||||||
char *file;
|
|
||||||
int size;
|
|
||||||
|
|
||||||
struct {
|
RGBA_Font_Source *src;
|
||||||
FT_Face face;
|
|
||||||
} ft;
|
int size;
|
||||||
|
int real_size;
|
||||||
|
|
||||||
Evas_Hash *glyphs;
|
Evas_Hash *glyphs;
|
||||||
|
|
||||||
|
@ -347,6 +346,25 @@ struct _RGBA_Font
|
||||||
int references;
|
int references;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _RGBA_Font_Source
|
||||||
|
{
|
||||||
|
Evas_Object_List _list_data;
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
char *file;
|
||||||
|
|
||||||
|
void *data;
|
||||||
|
int data_size;
|
||||||
|
|
||||||
|
int current_size;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
FT_Face face;
|
||||||
|
} ft;
|
||||||
|
|
||||||
|
int references;
|
||||||
|
};
|
||||||
|
|
||||||
struct _RGBA_Font_Glyph
|
struct _RGBA_Font_Glyph
|
||||||
{
|
{
|
||||||
FT_Glyph glyph;
|
FT_Glyph glyph;
|
||||||
|
@ -805,8 +823,14 @@ void evas_common_blit_rectangle (RGBA_Image *src, RGBA_Image *
|
||||||
/****/
|
/****/
|
||||||
void evas_common_font_init (void);
|
void evas_common_font_init (void);
|
||||||
void evas_common_font_shutdown (void);
|
void evas_common_font_shutdown (void);
|
||||||
|
RGBA_Font_Source *evas_common_font_source_memory_load(const char *name, const void *data, int data_size);
|
||||||
|
RGBA_Font_Source *evas_common_font_source_load (const char *name);
|
||||||
|
RGBA_Font_Source *evas_common_font_source_find (const char *name);
|
||||||
|
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 (const char *name, int size);
|
||||||
|
RGBA_Font *evas_common_font_load_init (RGBA_Font *fn);
|
||||||
void evas_common_font_free (RGBA_Font *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_modify_cache_by (RGBA_Font *fn, int dir);
|
||||||
int evas_common_font_cache_get (void);
|
int evas_common_font_cache_get (void);
|
||||||
|
|
|
@ -524,6 +524,7 @@ struct _Evas_Func
|
||||||
int (*image_cache_get) (void *data);
|
int (*image_cache_get) (void *data);
|
||||||
|
|
||||||
void *(*font_load) (void *data, char *name, int size);
|
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_free) (void *data, void *font);
|
void (*font_free) (void *data, void *font);
|
||||||
int (*font_ascent_get) (void *data, void *font);
|
int (*font_ascent_get) (void *data, void *font);
|
||||||
int (*font_descent_get) (void *data, void *font);
|
int (*font_descent_get) (void *data, void *font);
|
||||||
|
|
Loading…
Reference in New Issue