forked from enlightenment/efl
evas lets you choose font hinting - in theory. :)
SVN revision: 20823
This commit is contained in:
parent
0b74d51971
commit
10d6748b56
|
@ -54,6 +54,13 @@ typedef enum _Evas_Button_Flags
|
||||||
EVAS_BUTTON_TRIPLE_CLICK = (1 << 1) /**< This mouse button press was the 3rd press of a triple click */
|
EVAS_BUTTON_TRIPLE_CLICK = (1 << 1) /**< This mouse button press was the 3rd press of a triple click */
|
||||||
} Evas_Button_Flags; /**< Flags for Mouse Button events */
|
} Evas_Button_Flags; /**< Flags for Mouse Button events */
|
||||||
|
|
||||||
|
typedef enum _Evas_Font_Hinting_Flags
|
||||||
|
{
|
||||||
|
EVAS_FONT_HINTING_NONE,
|
||||||
|
EVAS_FONT_HINTING_AUTO,
|
||||||
|
EVAS_FONT_HINTING_BYTECODE
|
||||||
|
} Evas_Font_Hinting_Flags; /**< Flags for Font Hinting */
|
||||||
|
|
||||||
typedef struct _Evas_List Evas_List; /**< A generic linked list node handle */
|
typedef struct _Evas_List Evas_List; /**< A generic linked list node handle */
|
||||||
typedef struct _Evas_Rectangle Evas_Rectangle; /**< A generic rectangle handle */
|
typedef struct _Evas_Rectangle Evas_Rectangle; /**< A generic rectangle handle */
|
||||||
typedef struct _Evas_Smart_Class Evas_Smart_Class; /**< A smart object base class */
|
typedef struct _Evas_Smart_Class Evas_Smart_Class; /**< A smart object base class */
|
||||||
|
@ -712,6 +719,10 @@ tile_mode);
|
||||||
EAPI void evas_imaging_image_cache_set (int bytes);
|
EAPI void evas_imaging_image_cache_set (int bytes);
|
||||||
EAPI int evas_imaging_image_cache_get (void);
|
EAPI int evas_imaging_image_cache_get (void);
|
||||||
|
|
||||||
|
EAPI void evas_imaging_font_hinting_set (Evas_Font_Hinting_Flags hinting);
|
||||||
|
EAPI Evas_Font_Hinting_Flags evas_imaging_font_hinting_get (void);
|
||||||
|
EAPI Evas_Bool evas_imaging_font_hinting_can_hint (Evas_Font_Hinting_Flags hinting);
|
||||||
|
|
||||||
EAPI Evas_Imaging_Font *evas_imaging_font_load (const char *file, const char *key, int size);
|
EAPI Evas_Imaging_Font *evas_imaging_font_load (const char *file, const char *key, int size);
|
||||||
EAPI void evas_imaging_font_free (Evas_Imaging_Font *fn);
|
EAPI void evas_imaging_font_free (Evas_Imaging_Font *fn);
|
||||||
EAPI int evas_imaging_font_ascent_get (Evas_Imaging_Font *fn);
|
EAPI int evas_imaging_font_ascent_get (Evas_Imaging_Font *fn);
|
||||||
|
|
|
@ -6,6 +6,7 @@ evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt index)
|
||||||
RGBA_Font_Glyph *fg;
|
RGBA_Font_Glyph *fg;
|
||||||
char key[6];
|
char key[6];
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
|
FT_Int32 lflags;
|
||||||
|
|
||||||
key[0] = ((index ) & 0x7f) + 1;
|
key[0] = ((index ) & 0x7f) + 1;
|
||||||
key[1] = ((index >> 7 ) & 0x7f) + 1;
|
key[1] = ((index >> 7 ) & 0x7f) + 1;
|
||||||
|
@ -18,8 +19,11 @@ evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt index)
|
||||||
if (fg) return fg;
|
if (fg) return fg;
|
||||||
|
|
||||||
// error = FT_Load_Glyph(fi->src->ft.face, index, FT_LOAD_NO_BITMAP);
|
// error = FT_Load_Glyph(fi->src->ft.face, index, FT_LOAD_NO_BITMAP);
|
||||||
error = FT_Load_Glyph(fi->src->ft.face, index,
|
lflags = FT_LOAD_RENDER;
|
||||||
FT_LOAD_RENDER);
|
if (fi->hinting == FONT_NO_HINT) lflags |= FT_LOAD_NO_HINTING;
|
||||||
|
else if (fi->hinting == FONT_AUTO_HINT) lflags |= FT_LOAD_FORCE_AUTOHINT;
|
||||||
|
else if (fi->hinting == FONT_BYTECODE_HINT) lflags |= FT_LOAD_NO_AUTOHINT;
|
||||||
|
error = FT_Load_Glyph(fi->src->ft.face, index, lflags);
|
||||||
if (error) return NULL;
|
if (error) return NULL;
|
||||||
|
|
||||||
fg = malloc(sizeof(struct _RGBA_Font_Glyph));
|
fg = malloc(sizeof(struct _RGBA_Font_Glyph));
|
||||||
|
|
|
@ -232,11 +232,13 @@ evas_common_font_memory_load(const char *name, int size, const void *data, int d
|
||||||
if (!fi) return NULL;
|
if (!fi) return NULL;
|
||||||
fn = calloc(1, sizeof(RGBA_Font));
|
fn = calloc(1, sizeof(RGBA_Font));
|
||||||
if (!fn)
|
if (!fn)
|
||||||
{
|
{
|
||||||
free(fi);
|
free(fi);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
fn->fonts = evas_list_append(fn->fonts, fi);
|
fn->fonts = evas_list_append(fn->fonts, fi);
|
||||||
|
fn->hinting = FONT_BYTECODE_HINT;
|
||||||
|
fi->hinting = fn->hinting;
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,11 +252,13 @@ evas_common_font_load(const char *name, int size)
|
||||||
if (!fi) return NULL;
|
if (!fi) return NULL;
|
||||||
fn = calloc(1, sizeof(RGBA_Font));
|
fn = calloc(1, sizeof(RGBA_Font));
|
||||||
if (!fn)
|
if (!fn)
|
||||||
{
|
{
|
||||||
free(fi);
|
free(fi);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
fn->fonts = evas_list_append(fn->fonts, fi);
|
fn->fonts = evas_list_append(fn->fonts, fi);
|
||||||
|
fn->hinting = FONT_BYTECODE_HINT;
|
||||||
|
fi->hinting = fn->hinting;
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,6 +275,7 @@ evas_common_font_add(RGBA_Font *fn, const char *name, int size)
|
||||||
fn->fonts = evas_list_append(fn->fonts, fi);
|
fn->fonts = evas_list_append(fn->fonts, fi);
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
fi->hinting = fn->hinting;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,6 +292,7 @@ evas_common_font_memory_add(RGBA_Font *fn, const char *name, int size, const voi
|
||||||
fn->fonts = evas_list_append(fn->fonts, fi);
|
fn->fonts = evas_list_append(fn->fonts, fi);
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
fi->hinting = fn->hinting;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,6 +319,46 @@ evas_common_font_free(RGBA_Font *fn)
|
||||||
free(fn);
|
free(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
evas_common_font_hinting_set(RGBA_Font *fn, Font_Hint_Flags hinting)
|
||||||
|
{
|
||||||
|
Evas_List *l;
|
||||||
|
|
||||||
|
if (!fn)
|
||||||
|
return;
|
||||||
|
fn->hinting = hinting;
|
||||||
|
for (l = fn->fonts; l; l = l->next)
|
||||||
|
{
|
||||||
|
RGBA_Font_Int *fi;
|
||||||
|
|
||||||
|
fi = l->data;
|
||||||
|
fi->hinting = fn->hinting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Evas_Bool
|
||||||
|
evas_common_hinting_available(Font_Hint_Flags hinting)
|
||||||
|
{
|
||||||
|
if (hinting == FONT_NO_HINT) return 1;
|
||||||
|
else if (hinting == FONT_AUTO_HINT)
|
||||||
|
{
|
||||||
|
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (hinting == FONT_BYTECODE_HINT)
|
||||||
|
{
|
||||||
|
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static Evas_Bool
|
static Evas_Bool
|
||||||
font_modify_cache_cb(Evas_Hash *hash, const char *key, void *data, void *fdata)
|
font_modify_cache_cb(Evas_Hash *hash, const char *key, void *data, void *fdata)
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,11 +63,38 @@ evas_imaging_image_cache_get(void)
|
||||||
return evas_common_image_get_cache();
|
return evas_common_image_get_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Evas_Font_Hinting_Flags _evas_hinting = EVAS_FONT_HINTING_BYTECODE;
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
evas_imaging_font_hinting_set(Evas_Font_Hinting_Flags hinting)
|
||||||
|
{
|
||||||
|
_evas_hinting = hinting;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Evas_Font_Hinting_Flags
|
||||||
|
evas_imaging_font_hinting_get(void)
|
||||||
|
{
|
||||||
|
return _evas_hinting;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Evas_Bool
|
||||||
|
evas_imaging_font_hinting_can_hint(Evas_Font_Hinting_Flags hinting)
|
||||||
|
{
|
||||||
|
Font_Hint_Flags h;
|
||||||
|
|
||||||
|
h = FONT_BYTECODE_HINT;
|
||||||
|
if (hinting == EVAS_FONT_HINTING_NONE) h = FONT_NO_HINT;
|
||||||
|
else if (hinting == EVAS_FONT_HINTING_AUTO) h = FONT_AUTO_HINT;
|
||||||
|
else if (hinting == EVAS_FONT_HINTING_BYTECODE) h = FONT_BYTECODE_HINT;
|
||||||
|
return evas_common_hinting_available(h);
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Evas_Imaging_Font *
|
EAPI Evas_Imaging_Font *
|
||||||
evas_imaging_font_load(const char *file, const char *key, int size)
|
evas_imaging_font_load(const char *file, const char *key, int size)
|
||||||
{
|
{
|
||||||
Evas_Imaging_Font *fn;
|
Evas_Imaging_Font *fn;
|
||||||
RGBA_Font *font;
|
RGBA_Font *font;
|
||||||
|
Font_Hint_Flags h;
|
||||||
|
|
||||||
evas_common_cpu_init();
|
evas_common_cpu_init();
|
||||||
evas_common_font_init();
|
evas_common_font_init();
|
||||||
|
@ -109,6 +136,11 @@ evas_imaging_font_load(const char *file, const char *key, int size)
|
||||||
{
|
{
|
||||||
font = evas_common_font_load((char *)file, size);
|
font = evas_common_font_load((char *)file, size);
|
||||||
}
|
}
|
||||||
|
h = FONT_BYTECODE_HINT;
|
||||||
|
if (_evas_hinting == EVAS_FONT_HINTING_NONE) h = FONT_NO_HINT;
|
||||||
|
else if (_evas_hinting == EVAS_FONT_HINTING_AUTO) h = FONT_AUTO_HINT;
|
||||||
|
else if (_evas_hinting == EVAS_FONT_HINTING_BYTECODE) h = FONT_BYTECODE_HINT;
|
||||||
|
if (font) evas_common_font_hinting_set(font, h);
|
||||||
fn = calloc(1, sizeof(RGBA_Font));
|
fn = calloc(1, sizeof(RGBA_Font));
|
||||||
if (!fn) return NULL;
|
if (!fn) return NULL;
|
||||||
fn->font = font;
|
fn->font = font;
|
||||||
|
|
|
@ -166,6 +166,13 @@ typedef enum _CPU_Features
|
||||||
CPU_FEATURE_VIS2 = (1 << 5)
|
CPU_FEATURE_VIS2 = (1 << 5)
|
||||||
} CPU_Features;
|
} CPU_Features;
|
||||||
|
|
||||||
|
typedef enum _Font_Hint_Flags
|
||||||
|
{
|
||||||
|
FONT_NO_HINT,
|
||||||
|
FONT_AUTO_HINT,
|
||||||
|
FONT_BYTECODE_HINT
|
||||||
|
} Font_Hint_Flags;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
struct _Evas_Object_List
|
struct _Evas_Object_List
|
||||||
|
@ -299,6 +306,7 @@ struct _RGBA_Polygon_Point
|
||||||
struct _RGBA_Font
|
struct _RGBA_Font
|
||||||
{
|
{
|
||||||
Evas_List *fonts;
|
Evas_List *fonts;
|
||||||
|
Font_Hint_Flags hinting;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _RGBA_Font_Int
|
struct _RGBA_Font_Int
|
||||||
|
@ -317,6 +325,7 @@ struct _RGBA_Font_Int
|
||||||
Evas_Hash *glyphs;
|
Evas_Hash *glyphs;
|
||||||
|
|
||||||
int usage;
|
int usage;
|
||||||
|
Font_Hint_Flags hinting;
|
||||||
|
|
||||||
int references;
|
int references;
|
||||||
};
|
};
|
||||||
|
@ -864,6 +873,8 @@ RGBA_Font *evas_common_font_add (RGBA_Font *fn, const char *
|
||||||
RGBA_Font *evas_common_font_memory_add (RGBA_Font *fn, const char *name, int size, const void *data, int data_size);
|
RGBA_Font *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);
|
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_free (RGBA_Font *fn);
|
||||||
|
void evas_common_font_hinting_set (RGBA_Font *fn, Font_Hint_Flags hinting);
|
||||||
|
Evas_Bool evas_common_hinting_available (Font_Hint_Flags hinting);
|
||||||
void evas_common_font_int_modify_cache_by(RGBA_Font_Int *fi, int dir);
|
void evas_common_font_int_modify_cache_by(RGBA_Font_Int *fi, int dir);
|
||||||
int evas_common_font_cache_get (void);
|
int evas_common_font_cache_get (void);
|
||||||
void evas_common_font_cache_set (int size);
|
void evas_common_font_cache_set (int size);
|
||||||
|
|
Loading…
Reference in New Issue