From 92f6a37b6f0888447633202f6ef8a3a4768cad7c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 7 Jul 2021 14:02:09 +0300 Subject: [PATCH] libass: remove fribidi dependency --- extra/libass/build | 10 ++ extra/libass/checksums | 1 + extra/libass/depends | 1 - extra/libass/patches/no-fribidi.patch | 218 ++++++++++++++++++++++++++ extra/libass/sources | 1 + 5 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 extra/libass/patches/no-fribidi.patch diff --git a/extra/libass/build b/extra/libass/build index 11938895..14a26781 100755 --- a/extra/libass/build +++ b/extra/libass/build @@ -1,6 +1,16 @@ #!/bin/sh -e +patch -p1 < no-fribidi.patch + +# Remove fribidi configure checks. +sed -e 's/as_fn_error.*fribidi/: 0 "/' \ + -e '/pkg_requires="fribidi >= .*/d' \ + configure > _ +mv -f _ configure +chmod +x configure + ./configure \ + FRIBIDI_LIBS=" " \ --prefix=/usr \ --enable-fontconfig diff --git a/extra/libass/checksums b/extra/libass/checksums index ea2a7e08..777254de 100644 --- a/extra/libass/checksums +++ b/extra/libass/checksums @@ -1 +1,2 @@ 1cdd39c9d007b06e737e7738004d7f38cf9b1e92843f37307b24e7ff63ab8e53 +c6d5c147d795edde634178f3a1437c81fe932fcaaaf2c9fb8269f59f4da70897 diff --git a/extra/libass/depends b/extra/libass/depends index 42209260..58efa52d 100644 --- a/extra/libass/depends +++ b/extra/libass/depends @@ -1,6 +1,5 @@ expat fontconfig freetype-harfbuzz -fribidi nasm make pkgconf make diff --git a/extra/libass/patches/no-fribidi.patch b/extra/libass/patches/no-fribidi.patch new file mode 100644 index 00000000..4d033a67 --- /dev/null +++ b/extra/libass/patches/no-fribidi.patch @@ -0,0 +1,218 @@ +diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c +index ffcb36b..849b55f 100644 +--- a/libass/ass_shaper.c ++++ b/libass/ass_shaper.c +@@ -81,8 +81,7 @@ struct ass_shaper_font_data { + */ + void ass_shaper_info(ASS_Library *lib) + { +- ass_msg(lib, MSGL_INFO, "Shaper: FriBidi " +- FRIBIDI_VERSION " (SIMPLE)" ++ ass_msg(lib, MSGL_INFO, "Shaper: " + " HarfBuzz-ng %s (COMPLEX)", hb_version_string() + ); + } +@@ -686,8 +685,7 @@ static bool shape_harfbuzz(ASS_Shaper *shaper, GlyphInfo *glyphs, size_t len) + hb_buffer_add_utf32(buf, shaper->event_text + offset, i - offset + 1, + 0, i - offset + 1); + +- props.direction = FRIBIDI_LEVEL_IS_RTL(level) ? +- HB_DIRECTION_RTL : HB_DIRECTION_LTR; ++ props.direction = HB_DIRECTION_LTR; + props.script = glyphs[offset].script; + props.language = hb_shaper_get_run_language(shaper, props.script); + hb_buffer_set_segment_properties(buf, &props); +@@ -754,33 +752,6 @@ void ass_shaper_determine_script(ASS_Shaper *shaper, GlyphInfo *glyphs, + } + } + +-/** +- * \brief Shape event text with FriBidi. Does mirroring and simple +- * Arabic shaping. +- * \param len number of clusters +- */ +-static void shape_fribidi(ASS_Shaper *shaper, GlyphInfo *glyphs, size_t len) +-{ +- int i; +- FriBidiJoiningType *joins = calloc(sizeof(*joins), len); +- +- // shape on codepoint level +- fribidi_get_joining_types(shaper->event_text, len, joins); +- fribidi_join_arabic(shaper->ctypes, len, shaper->emblevels, joins); +- fribidi_shape(FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC, +- shaper->emblevels, len, joins, shaper->event_text); +- +- // update indexes +- for (i = 0; i < len; i++) { +- GlyphInfo *info = glyphs + i; +- FT_Face face = info->font->faces[info->face_index]; +- info->symbol = shaper->event_text[i]; +- info->glyph_index = FT_Get_Char_Index(face, ass_font_index_magic(face, shaper->event_text[i])); +- } +- +- free(joins); +-} +- + /** + * \brief Toggle kerning for HarfBuzz shaping. + * \param shaper shaper instance +@@ -864,33 +835,6 @@ void ass_shaper_set_bidi_brackets(ASS_Shaper *shaper, bool match_brackets) + } + #endif + +-/** +- * \brief Remove all zero-width invisible characters from the text. +- * \param text_info text +- */ +-static void ass_shaper_skip_characters(TextInfo *text_info) +-{ +- int i; +- GlyphInfo *glyphs = text_info->glyphs; +- +- for (i = 0; i < text_info->length; i++) { +- // Skip direction override control characters +- if ((glyphs[i].symbol <= 0x202e && glyphs[i].symbol >= 0x202a) +- || (glyphs[i].symbol <= 0x200f && glyphs[i].symbol >= 0x200b) +- || (glyphs[i].symbol <= 0x206f && glyphs[i].symbol >= 0x2060) +- || (glyphs[i].symbol <= 0xfe0f && glyphs[i].symbol >= 0xfe00) +- || (glyphs[i].symbol <= 0xe01ef && glyphs[i].symbol >= 0xe0100) +- || (glyphs[i].symbol <= 0x180f && glyphs[i].symbol >= 0x180b) +- || glyphs[i].symbol == 0x061c +- || glyphs[i].symbol == 0xfeff +- || glyphs[i].symbol == 0x00ad +- || glyphs[i].symbol == 0x034f) { +- glyphs[i].symbol = 0; +- glyphs[i].skip = true; +- } +- } +-} +- + /** + * \brief Shape an event's text. Calculates directional runs and shapes them. + * \param text_info event's text +@@ -898,52 +842,18 @@ static void ass_shaper_skip_characters(TextInfo *text_info) + */ + bool ass_shaper_shape(ASS_Shaper *shaper, TextInfo *text_info) + { +- int i, ret, last_break; +- FriBidiParType dir; ++ int i; + GlyphInfo *glyphs = text_info->glyphs; + + if (!check_allocations(shaper, text_info->length)) + return false; + + // Get bidi character types and 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) { +- 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) { +- 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); +-#else +- ret = fribidi_get_par_embedding_levels(shaper->ctypes + last_break, +- i - last_break + 1, &dir, shaper->emblevels + last_break); +-#endif +- if (ret == 0) +- return false; +- last_break = i + 1; +- } + } + +- switch (shaper->shaping_level) { +- case ASS_SHAPING_SIMPLE: +- shape_fribidi(shaper, glyphs, text_info->length); +- ass_shaper_skip_characters(text_info); +- return true; +- case ASS_SHAPING_COMPLEX: +- default: +- return shape_harfbuzz(shaper, glyphs, text_info->length); +- } ++ return shape_harfbuzz(shaper, glyphs, text_info->length); + } + + /** +@@ -955,7 +865,7 @@ ASS_Shaper *ass_shaper_new(void) + if (!shaper) + return NULL; + +- shaper->base_direction = FRIBIDI_PAR_ON; ++ shaper->base_direction = 0; + + if (!init_features(shaper)) + goto error; +@@ -998,25 +908,12 @@ void ass_shaper_cleanup(ASS_Shaper *shaper, TextInfo *text_info) + */ + FriBidiStrIndex *ass_shaper_reorder(ASS_Shaper *shaper, TextInfo *text_info) + { +- int i, ret; ++ int i; + + // Initialize reorder map + for (i = 0; i < text_info->length; i++) + shaper->cmap[i] = i; + +- // Create reorder map line-by-line +- for (i = 0; i < text_info->n_lines; i++) { +- LineInfo *line = text_info->lines + i; +- FriBidiParType dir = FRIBIDI_PAR_ON; +- +- ret = fribidi_reorder_line(0, +- shaper->ctypes + line->offset, line->len, 0, dir, +- shaper->emblevels + line->offset, NULL, +- shaper->cmap + line->offset); +- if (ret == 0) +- return NULL; +- } +- + return shaper->cmap; + } + +@@ -1034,10 +931,5 @@ FriBidiStrIndex *ass_shaper_get_reorder_map(ASS_Shaper *shaper) + */ + FriBidiParType resolve_base_direction(int enc) + { +- switch (enc) { +- case -1: +- return FRIBIDI_PAR_ON; +- default: +- return FRIBIDI_PAR_LTR; +- } ++ return 0; + } +diff --git a/libass/ass_shaper.h b/libass/ass_shaper.h +index 70bec9a..c0ff055 100644 +--- a/libass/ass_shaper.h ++++ b/libass/ass_shaper.h +@@ -21,13 +21,14 @@ + + typedef struct ass_shaper ASS_Shaper; + +-#include + #include + #include "ass_render.h" + +-#if FRIBIDI_MAJOR_VERSION >= 1 +-#define USE_FRIBIDI_EX_API +-#endif ++typedef uint32_t FriBidiChar; ++typedef uint32_t FriBidiCharType; ++typedef int FriBidiStrIndex; ++typedef int FriBidiParType; ++typedef signed char FriBidiLevel; + + void ass_shaper_info(ASS_Library *lib); + ASS_Shaper *ass_shaper_new(void); diff --git a/extra/libass/sources b/extra/libass/sources index a6271893..6e432bea 100644 --- a/extra/libass/sources +++ b/extra/libass/sources @@ -1 +1,2 @@ https://github.com/libass/libass/releases/download/0.15.1/libass-0.15.1.tar.xz +patches/no-fribidi.patch