From e1b63bc3abfac4d1e994cbe46a4d3f820062b880 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Sun, 10 Jul 2011 02:25:24 +0200 Subject: Hook up FriBidi's simple Arabic shaper Use FriBidi's shaper not only for mirroring, but also for simplified Arabic shaping. --- libass/ass_shaper.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c index 5631be2..6efc177 100644 --- a/libass/ass_shaper.c +++ b/libass/ass_shaper.c @@ -42,6 +42,7 @@ void ass_shaper_shape(TextInfo *text_info, FriBidiCharType *ctypes, int i, last_break; FriBidiParType dir; FriBidiChar *event_text = calloc(sizeof(*event_text), text_info->length); + FriBidiJoiningType *joins = calloc(sizeof(*joins), text_info->length); GlyphInfo *glyphs = text_info->glyphs; // Get bidi character types and embedding levels @@ -68,25 +69,27 @@ void ass_shaper_shape(TextInfo *text_info, FriBidiCharType *ctypes, printf("\n"); #endif - // Call FriBidi's glyph mirroring shaper. - // This shaper implements rule L4 of the bidi algorithm - fribidi_shape_mirroring(emblevels, text_info->length, event_text); - for (i = 0; i < text_info->length; i++) { - glyphs[i].symbol = event_text[i]; - } + // Use FriBidi's shaper for mirroring and simple Arabic shaping + fribidi_get_joining_types(event_text, text_info->length, joins); + fribidi_join_arabic(ctypes, text_info->length, emblevels, joins); + fribidi_shape(FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC, emblevels, + text_info->length, joins, event_text); // XXX: insert HarfBuzz shaper here - // Skip direction override characters - // NOTE: Behdad said HarfBuzz is supposed to remove these, but this hasn't - // been implemented yet + // Update glyphs for (i = 0; i < text_info->length; i++) { + glyphs[i].symbol = event_text[i]; + // Skip direction override characters + // NOTE: Behdad said HarfBuzz is supposed to remove these, but this hasn't + // been implemented yet if (glyphs[i].symbol <= 0x202F && glyphs[i].symbol >= 0x202a) { glyphs[i].symbol = 0; glyphs[i].skip++; } } + free(joins); free(event_text); } -- cgit v1.2.3