return (items > 0) ? items : 1;
}
-EAPI void
-evas_common_font_ot_load_face(void *_font)
-{
- RGBA_Font_Source *font = (RGBA_Font_Source *) _font;
- /* Unload the face if by any chance it's already loaded */
- evas_common_font_ot_unload_face(font);
- font->hb.face = hb_ft_face_create(font->ft.face, NULL);
-}
-
-EAPI void
-evas_common_font_ot_unload_face(void *_font)
-{
- RGBA_Font_Source *font = (RGBA_Font_Source *) _font;
- if (!font->hb.face) return;
- hb_face_destroy(font->hb.face);
- font->hb.face = NULL;
-}
-
/* Harfbuzz font functions */
-static void
+static hb_position_t
_evas_common_font_ot_hb_get_glyph_advance(hb_font_t *font,
void *font_data, hb_codepoint_t glyph,
- hb_position_t *x_advance, hb_position_t *y_advance,
void *user_data)
{
/* Use our cache*/
fg = evas_common_font_int_cache_glyph_get(fi, glyph);
if (fg)
{
- *x_advance = fg->glyph->advance.x >> 10;
- *y_advance = fg->glyph->advance.y >> 10;
+ return fg->glyph->advance.x >> 10;
}
+ return 0;
}
-static void
+static hb_position_t
_evas_common_font_ot_hb_get_kerning(hb_font_t *font, void *font_data,
- hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
- hb_position_t *x_kern, hb_position_t *y_kern, void *user_data)
+ hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, void *user_data)
{
RGBA_Font_Int *fi = (RGBA_Font_Int *) font_data;
int kern;
(void) font;
(void) user_data;
if (evas_common_font_query_kerning(fi, first_glyph, second_glyph, &kern))
- *x_kern = kern;
- else
- return;
- *y_kern = 0;
+ return kern;
+
+ return 0;
}
/* End of harfbuzz font funcs */
if (!font_funcs)
{
font_funcs = hb_font_funcs_create();
- hb_font_funcs_set_glyph_advance_func(font_funcs,
+ hb_font_funcs_set_glyph_h_advance_func(font_funcs,
_evas_common_font_ot_hb_get_glyph_advance, NULL, NULL);
- hb_font_funcs_set_kerning_func(font_funcs,
+ hb_font_funcs_set_glyph_h_kerning_func(font_funcs,
_evas_common_font_ot_hb_get_kerning, NULL, NULL);
}
static void
_evas_common_font_ot_shape(hb_buffer_t *buffer, RGBA_Font_Int *fi)
{
- hb_font_t *hb_font, *hb_ft_font;
-
- hb_ft_font = hb_ft_font_create(fi->src->ft.face, NULL);
- hb_font = hb_font_create_sub_font(hb_ft_font);
+ /* Create hb_font if not previously created */
+ if (!fi->ft.hb_font)
+ {
+ hb_font_t *hb_ft_font;
- hb_font_set_funcs(hb_font, _evas_common_font_ot_font_funcs_get(), fi, NULL);
+ hb_ft_font = hb_ft_font_create(fi->src->ft.face, NULL);
+ fi->ft.hb_font = hb_font_create_sub_font(hb_ft_font);
+ hb_font_destroy(hb_ft_font);
- hb_shape(hb_font, buffer, NULL, 0);
+ hb_font_set_funcs(fi->ft.hb_font,
+ _evas_common_font_ot_font_funcs_get(), fi, NULL);
+ }
- hb_font_destroy(hb_font);
- hb_font_destroy(hb_ft_font);
+ hb_shape(fi->ft.hb_font, buffer, NULL, 0);
}
EAPI Eina_Bool
-evas_common_font_ot_populate_text_props(void *_fn, const Eina_Unicode *text,
+evas_common_font_ot_populate_text_props(const Eina_Unicode *text,
Evas_Text_Props *props, int len)
{
- RGBA_Font *fn = (RGBA_Font *) _fn;
RGBA_Font_Int *fi;
hb_buffer_t *buffer;
hb_glyph_position_t *positions;
Evas_Font_OT_Info *ot_itr;
Evas_Coord pen_x = 0;
- fi = fn->fonts->data;
- /* Load the font needed for this script */
- {
- /* Skip common chars */
- const Eina_Unicode *tmp;
- for (tmp = text ;
- *tmp &&
- evas_common_language_char_script_get(*tmp) == EVAS_SCRIPT_COMMON ;
- tmp++)
- ;
- if (!*tmp && (tmp > text)) tmp--;
- evas_common_font_glyph_search(fn, &fi, *tmp);
- }
- evas_common_font_int_reload(fi);
- if (fi->src->current_size != fi->size)
- {
- FTLOCK();
- FT_Activate_Size(fi->ft.size);
- FTUNLOCK();
- fi->src->current_size = fi->size;
- }
+ fi = props->font_instance;
if (len < 0)
{
slen = len;
}
+#if HB_VERSION_CHECK(0,7,0)
buffer = hb_buffer_create(slen);
+#else
+ buffer = hb_buffer_create();
+#endif
hb_buffer_set_unicode_funcs(buffer, _evas_common_font_ot_unicode_funcs_get());
+#if HB_VERSION_CHECK(0,7,0)
hb_buffer_set_language(buffer, hb_language_from_string(
evas_common_language_from_locale_get()));
+#else
+ hb_buffer_set_language(buffer, hb_language_from_string(
+ evas_common_language_from_locale_get(), -1));
+#endif
hb_buffer_set_script(buffer, _evas_script_to_harfbuzz[props->script]);
hb_buffer_set_direction(buffer,
(props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) ?