From db6ccb3634db5ccbce1a2fdaa383085242d52c82 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Mon, 11 Jul 2011 13:00:08 +0200 Subject: HarfBuzz shaping support Split up text into runs with the same direction, font face and font size, shape these runs with HarfBuzz and reorder accordingly. This noticeably improves Arabic shaping and should make shaping for many other scripts work. HarfBuzz also does kerning for Latin text. --- libass/ass_font.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'libass/ass_font.c') diff --git a/libass/ass_font.c b/libass/ass_font.c index af1f350d..14790b49 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -433,24 +433,32 @@ int ass_font_get_index(void *fcpriv, ASS_Font *font, uint32_t symbol, int i; FT_Face face = 0; - *face_index = 0; - *face_index = 0; + *glyph_index = 0; - if (symbol < 0x20) + if (symbol < 0x20) { + *face_index = 0; return 0; + } // Handle NBSP like a regular space when rendering the glyph if (symbol == 0xa0) symbol = ' '; - if (font->n_faces == 0) + if (font->n_faces == 0) { + *face_index = 0; return 0; + } - for (i = 0; i < font->n_faces; ++i) { + // try with the requested face + if (*face_index < font->n_faces) { + face = font->faces[i]; + index = FT_Get_Char_Index(face, symbol); + } + + // not found in requested face, try all others + for (i = 0; i < font->n_faces && index == 0; ++i) { face = font->faces[i]; index = FT_Get_Char_Index(face, symbol); - if (index) { + if (index) *face_index = i; - break; - } } #ifdef CONFIG_FONTCONFIG -- cgit v1.2.3