diff options
author | Oleg Oshmyan <chortos@inbox.lv> | 2020-10-26 02:13:17 +0200 |
---|---|---|
committer | Oleg Oshmyan <chortos@inbox.lv> | 2022-02-14 20:43:08 +0200 |
commit | 983df604eb33d854638122f67db1f4cb4accedf7 (patch) | |
tree | 6a5282891edffb9b5aa1751cb6d583c199f6d150 | |
parent | ffd0bdd2192106f1bd48bb1c0d90e056d55680f1 (diff) | |
download | libass-983df604eb33d854638122f67db1f4cb4accedf7.tar.bz2 libass-983df604eb33d854638122f67db1f4cb4accedf7.tar.xz |
ass_shaper_shape: combine FriBidi calls that are needlessly split
These calls don't perform any bidi or compute anything clever.
They just fetch some Unicode properties for each code point.
-rw-r--r-- | libass/ass_shaper.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c index a677227..3db939e 100644 --- a/libass/ass_shaper.c +++ b/libass/ass_shaper.c @@ -971,25 +971,31 @@ bool ass_shaper_shape(ASS_Shaper *shaper, TextInfo *text_info) if (!check_allocations(shaper, text_info->length)) return false; - // Get bidi character types and embedding levels + for (i = 0; i < text_info->length; i++) + shaper->event_text[i] = glyphs[i].symbol; + + fribidi_get_bidi_types(shaper->event_text, + text_info->length, shaper->ctypes); + +#ifdef USE_FRIBIDI_EX_API + if (shaper->bidi_brackets) { + fribidi_get_bracket_types(shaper->event_text, + text_info->length, shaper->ctypes, shaper->btypes); + } +#endif + + // Get bidi embedding levels last_break = 0; for (i = 0; i < text_info->length; i++) { - shaper->event_text[i] = glyphs[i].symbol; // embedding levels should be calculated paragraph by paragraph if (glyphs[i].symbol == '\n' || i == text_info->length - 1 || (!shaper->whole_text_layout && (glyphs[i + 1].starts_new_run || glyphs[i].hspacing))) { dir = shaper->base_direction; - fribidi_get_bidi_types(shaper->event_text + last_break, - i - last_break + 1, shaper->ctypes + last_break); #ifdef USE_FRIBIDI_EX_API FriBidiBracketType *btypes = NULL; - if (shaper->bidi_brackets) { + if (shaper->bidi_brackets) btypes = shaper->btypes + last_break; - fribidi_get_bracket_types(shaper->event_text + last_break, - i - last_break + 1, shaper->ctypes + last_break, - btypes); - } ret = fribidi_get_par_embedding_levels_ex( shaper->ctypes + last_break, btypes, i - last_break + 1, &dir, shaper->emblevels + last_break); |