1 diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c
2 index ffcb36b..849b55f 100644
3 --- a/libass/ass_shaper.c
4 +++ b/libass/ass_shaper.c
5 @@ -81,8 +81,7 @@ struct ass_shaper_font_data {
7 void ass_shaper_info(ASS_Library *lib)
9 - ass_msg(lib, MSGL_INFO, "Shaper: FriBidi "
10 - FRIBIDI_VERSION " (SIMPLE)"
11 + ass_msg(lib, MSGL_INFO, "Shaper: "
12 " HarfBuzz-ng %s (COMPLEX)", hb_version_string()
15 @@ -686,8 +685,7 @@ static bool shape_harfbuzz(ASS_Shaper *shaper, GlyphInfo *glyphs, size_t len)
16 hb_buffer_add_utf32(buf, shaper->event_text + offset, i - offset + 1,
19 - props.direction = FRIBIDI_LEVEL_IS_RTL(level) ?
20 - HB_DIRECTION_RTL : HB_DIRECTION_LTR;
21 + props.direction = HB_DIRECTION_LTR;
22 props.script = glyphs[offset].script;
23 props.language = hb_shaper_get_run_language(shaper, props.script);
24 hb_buffer_set_segment_properties(buf, &props);
25 @@ -754,33 +752,6 @@ void ass_shaper_determine_script(ASS_Shaper *shaper, GlyphInfo *glyphs,
30 - * \brief Shape event text with FriBidi. Does mirroring and simple
32 - * \param len number of clusters
34 -static void shape_fribidi(ASS_Shaper *shaper, GlyphInfo *glyphs, size_t len)
37 - FriBidiJoiningType *joins = calloc(sizeof(*joins), len);
39 - // shape on codepoint level
40 - fribidi_get_joining_types(shaper->event_text, len, joins);
41 - fribidi_join_arabic(shaper->ctypes, len, shaper->emblevels, joins);
42 - fribidi_shape(FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC,
43 - shaper->emblevels, len, joins, shaper->event_text);
46 - for (i = 0; i < len; i++) {
47 - GlyphInfo *info = glyphs + i;
48 - FT_Face face = info->font->faces[info->face_index];
49 - info->symbol = shaper->event_text[i];
50 - info->glyph_index = FT_Get_Char_Index(face, ass_font_index_magic(face, shaper->event_text[i]));
57 * \brief Toggle kerning for HarfBuzz shaping.
58 * \param shaper shaper instance
59 @@ -864,33 +835,6 @@ void ass_shaper_set_bidi_brackets(ASS_Shaper *shaper, bool match_brackets)
64 - * \brief Remove all zero-width invisible characters from the text.
65 - * \param text_info text
67 -static void ass_shaper_skip_characters(TextInfo *text_info)
70 - GlyphInfo *glyphs = text_info->glyphs;
72 - for (i = 0; i < text_info->length; i++) {
73 - // Skip direction override control characters
74 - if ((glyphs[i].symbol <= 0x202e && glyphs[i].symbol >= 0x202a)
75 - || (glyphs[i].symbol <= 0x200f && glyphs[i].symbol >= 0x200b)
76 - || (glyphs[i].symbol <= 0x206f && glyphs[i].symbol >= 0x2060)
77 - || (glyphs[i].symbol <= 0xfe0f && glyphs[i].symbol >= 0xfe00)
78 - || (glyphs[i].symbol <= 0xe01ef && glyphs[i].symbol >= 0xe0100)
79 - || (glyphs[i].symbol <= 0x180f && glyphs[i].symbol >= 0x180b)
80 - || glyphs[i].symbol == 0x061c
81 - || glyphs[i].symbol == 0xfeff
82 - || glyphs[i].symbol == 0x00ad
83 - || glyphs[i].symbol == 0x034f) {
84 - glyphs[i].symbol = 0;
85 - glyphs[i].skip = true;
91 * \brief Shape an event's text. Calculates directional runs and shapes them.
92 * \param text_info event's text
93 @@ -898,52 +842,18 @@ static void ass_shaper_skip_characters(TextInfo *text_info)
95 bool ass_shaper_shape(ASS_Shaper *shaper, TextInfo *text_info)
97 - int i, ret, last_break;
100 GlyphInfo *glyphs = text_info->glyphs;
102 if (!check_allocations(shaper, text_info->length))
105 // Get bidi character types and embedding levels
107 for (i = 0; i < text_info->length; i++) {
108 shaper->event_text[i] = glyphs[i].symbol;
109 - // embedding levels should be calculated paragraph by paragraph
110 - if (glyphs[i].symbol == '\n' || i == text_info->length - 1) {
111 - dir = shaper->base_direction;
112 - fribidi_get_bidi_types(shaper->event_text + last_break,
113 - i - last_break + 1, shaper->ctypes + last_break);
114 -#ifdef USE_FRIBIDI_EX_API
115 - FriBidiBracketType *btypes = NULL;
116 - if (shaper->bidi_brackets) {
117 - btypes = shaper->btypes + last_break;
118 - fribidi_get_bracket_types(shaper->event_text + last_break,
119 - i - last_break + 1, shaper->ctypes + last_break,
122 - ret = fribidi_get_par_embedding_levels_ex(
123 - shaper->ctypes + last_break, btypes,
124 - i - last_break + 1, &dir, shaper->emblevels + last_break);
126 - ret = fribidi_get_par_embedding_levels(shaper->ctypes + last_break,
127 - i - last_break + 1, &dir, shaper->emblevels + last_break);
131 - last_break = i + 1;
135 - switch (shaper->shaping_level) {
136 - case ASS_SHAPING_SIMPLE:
137 - shape_fribidi(shaper, glyphs, text_info->length);
138 - ass_shaper_skip_characters(text_info);
140 - case ASS_SHAPING_COMPLEX:
142 - return shape_harfbuzz(shaper, glyphs, text_info->length);
144 + return shape_harfbuzz(shaper, glyphs, text_info->length);
148 @@ -955,7 +865,7 @@ ASS_Shaper *ass_shaper_new(void)
152 - shaper->base_direction = FRIBIDI_PAR_ON;
153 + shaper->base_direction = 0;
155 if (!init_features(shaper))
157 @@ -998,25 +908,12 @@ void ass_shaper_cleanup(ASS_Shaper *shaper, TextInfo *text_info)
159 FriBidiStrIndex *ass_shaper_reorder(ASS_Shaper *shaper, TextInfo *text_info)
164 // Initialize reorder map
165 for (i = 0; i < text_info->length; i++)
168 - // Create reorder map line-by-line
169 - for (i = 0; i < text_info->n_lines; i++) {
170 - LineInfo *line = text_info->lines + i;
171 - FriBidiParType dir = FRIBIDI_PAR_ON;
173 - ret = fribidi_reorder_line(0,
174 - shaper->ctypes + line->offset, line->len, 0, dir,
175 - shaper->emblevels + line->offset, NULL,
176 - shaper->cmap + line->offset);
184 @@ -1034,10 +931,5 @@ FriBidiStrIndex *ass_shaper_get_reorder_map(ASS_Shaper *shaper)
186 FriBidiParType resolve_base_direction(int enc)
190 - return FRIBIDI_PAR_ON;
192 - return FRIBIDI_PAR_LTR;
196 diff --git a/libass/ass_shaper.h b/libass/ass_shaper.h
197 index 70bec9a..c0ff055 100644
198 --- a/libass/ass_shaper.h
199 +++ b/libass/ass_shaper.h
202 typedef struct ass_shaper ASS_Shaper;
204 -#include <fribidi.h>
206 #include "ass_render.h"
208 -#if FRIBIDI_MAJOR_VERSION >= 1
209 -#define USE_FRIBIDI_EX_API
211 +typedef uint32_t FriBidiChar;
212 +typedef uint32_t FriBidiCharType;
213 +typedef int FriBidiStrIndex;
214 +typedef int FriBidiParType;
215 +typedef signed char FriBidiLevel;
217 void ass_shaper_info(ASS_Library *lib);
218 ASS_Shaper *ass_shaper_new(void);