commit 54457fb
hovercats
·
2024-04-13 06:40:40 +0000 UTC
parent a236ef9
libass: import
8 files changed,
+325,
-0
+40,
-0
1@@ -0,0 +1,40 @@
2+libass
3+________________________________________________________________________________
4+
5+libass is a portable subtitle renderer for the ASS/SSA
6+(Advanced Substation Alpha/Substation Alpha) subtitle format. It is mostly
7+compatible with VSFilter. [0]
8+
9+Upstream: https://github.com/libass/libass
10+
11+
12+[000] Index
13+________________________________________________________________________________
14+
15+* Installation ........................................................... [001]
16+* Usage .................................................................. [002]
17+* References ............................................................. [003]
18+
19+
20+[001] Installation
21+________________________________________________________________________________
22+
23++------------------------------------------------------------------------------+
24+| |
25+| $ kiss b libass |
26+| |
27++------------------------------------------------------------------------------+
28+
29+
30+[002] Usage
31+________________________________________________________________________________
32+
33+No documentation is currently provided with the package, refer to online
34+documentation for the time being.
35+
36+
37+[003] References
38+________________________________________________________________________________
39+
40+[0] https://github.com/libass/libass
41+
+17,
-0
1@@ -0,0 +1,17 @@
2+#!/bin/sh -e
3+
4+patch -p1 < no-fribidi.patch
5+
6+# Remove fribidi configure checks.
7+sed -e 's/as_fn_error.*fribidi/: 0 "/' \
8+ -e '/pkg_requires="fribidi >= .*/d' \
9+ configure > _
10+mv -f _ configure
11+
12+sh ./configure \
13+ FRIBIDI_LIBS=" " \
14+ --prefix=/usr \
15+ --enable-fontconfig
16+
17+make
18+make install
+2,
-0
1@@ -0,0 +1,2 @@
2+049a2b9b2ca7a34eff8bdadcd7485e6a75fcbfbafb04ac6aeefb77923b7b69c2b0
3+344eb46475a7a19019c3b86184f415dc1e737f81e577770b6b0b051d9451969240
+5,
-0
1@@ -0,0 +1,5 @@
2+expat
3+fontconfig
4+freetype-harfbuzz
5+nasm make
6+pkgconf make
+14,
-0
1@@ -0,0 +1,14 @@
2+/var/db/kiss/installed/libass/version
3+/var/db/kiss/installed/libass/sources
4+/var/db/kiss/installed/libass/patches/no-fribidi.patch
5+/var/db/kiss/installed/libass/patches/
6+/var/db/kiss/installed/libass/manifest
7+/var/db/kiss/installed/libass/depends
8+/var/db/kiss/installed/libass/checksums
9+/var/db/kiss/installed/libass/build
10+/var/db/kiss/installed/libass/README
11+/var/db/kiss/installed/libass/
12+/var/db/kiss/installed/
13+/var/db/kiss/
14+/var/db/
15+/var/
+244,
-0
1@@ -0,0 +1,244 @@
2+diff --git a/libass/ass_render.h b/libass/ass_render.h
3+index 581c131..0cb5458 100644
4+--- a/libass/ass_render.h
5++++ b/libass/ass_render.h
6+@@ -22,7 +22,6 @@
7+
8+ #include <inttypes.h>
9+ #include <stdbool.h>
10+-#include <fribidi.h>
11+ #include <ft2build.h>
12+ #include FT_FREETYPE_H
13+ #include FT_GLYPH_H
14+@@ -49,6 +48,8 @@
15+ #define PARSED_FADE (1<<0)
16+ #define PARSED_A (1<<1)
17+
18++typedef uint32_t FriBidiChar;
19++
20+ typedef struct {
21+ ASS_Image result;
22+ CompositeHashValue *source;
23+diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c
24+index 77cf909..014b318 100644
25+--- a/libass/ass_shaper.c
26++++ b/libass/ass_shaper.c
27+@@ -90,8 +90,7 @@ struct ass_shaper_font_data {
28+ */
29+ void ass_shaper_info(ASS_Library *lib)
30+ {
31+- ass_msg(lib, MSGL_INFO, "Shaper: FriBidi "
32+- FRIBIDI_VERSION " (SIMPLE)"
33++ ass_msg(lib, MSGL_INFO, "Shaper: "
34+ " HarfBuzz-ng %s (COMPLEX)", hb_version_string()
35+ );
36+ }
37+@@ -722,8 +721,7 @@ static bool shape_harfbuzz(ASS_Shaper *shaper, GlyphInfo *glyphs, size_t len)
38+ lead_context, i - offset + 1);
39+ }
40+
41+- props.direction = FRIBIDI_LEVEL_IS_RTL(level) ?
42+- HB_DIRECTION_RTL : HB_DIRECTION_LTR;
43++ props.direction = HB_DIRECTION_LTR;
44+ props.script = glyphs[offset].script;
45+ props.language = hb_shaper_get_run_language(shaper, props.script);
46+ hb_buffer_set_segment_properties(buf, &props);
47+@@ -791,35 +789,6 @@ void ass_shaper_determine_script(ASS_Shaper *shaper, GlyphInfo *glyphs,
48+ }
49+ }
50+
51+-/**
52+- * \brief Shape event text with FriBidi. Does mirroring and simple
53+- * Arabic shaping.
54+- * \param len number of clusters
55+- */
56+-static void shape_fribidi(ASS_Shaper *shaper, GlyphInfo *glyphs, size_t len)
57+-{
58+- int i;
59+- FriBidiJoiningType *joins = calloc(sizeof(*joins), len);
60+-
61+- // shape on codepoint level
62+- fribidi_get_joining_types(shaper->event_text, len, joins);
63+- fribidi_join_arabic(shaper->ctypes, len, shaper->emblevels, joins);
64+- fribidi_shape(FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC,
65+- shaper->emblevels, len, joins, shaper->event_text);
66+-
67+- // update indexes
68+- for (i = 0; i < len; i++) {
69+- GlyphInfo *info = glyphs + i;
70+- FT_Face face = info->font->faces[info->face_index];
71+- info->symbol = shaper->event_text[i];
72+- info->glyph_index = ass_font_index_magic(face, shaper->event_text[i]);
73+- if (info->glyph_index)
74+- info->glyph_index = FT_Get_Char_Index(face, info->glyph_index);
75+- }
76+-
77+- free(joins);
78+-}
79+-
80+ /**
81+ * \brief Toggle kerning for HarfBuzz shaping.
82+ * \param shaper shaper instance
83+@@ -912,7 +881,7 @@ void ass_shaper_set_base_direction(ASS_Shaper *shaper, FriBidiParType dir)
84+ shaper->base_direction = dir;
85+
86+ if (shaper->whole_text_layout != WHOLE_TEXT_LAYOUT_EXPLICIT)
87+- shaper->whole_text_layout = dir == FRIBIDI_PAR_ON ?
88++ shaper->whole_text_layout = dir == 0 ?
89+ WHOLE_TEXT_LAYOUT_IMPLICIT : WHOLE_TEXT_LAYOUT_OFF;
90+ }
91+
92+@@ -952,7 +921,7 @@ void ass_shaper_set_whole_text_layout(ASS_Shaper *shaper, bool enable)
93+ {
94+ shaper->whole_text_layout = enable ?
95+ WHOLE_TEXT_LAYOUT_EXPLICIT :
96+- shaper->base_direction == FRIBIDI_PAR_ON ?
97++ shaper->base_direction == 0 ?
98+ WHOLE_TEXT_LAYOUT_IMPLICIT : WHOLE_TEXT_LAYOUT_OFF;
99+ }
100+
101+@@ -963,8 +932,7 @@ void ass_shaper_set_whole_text_layout(ASS_Shaper *shaper, bool enable)
102+ */
103+ bool ass_shaper_shape(ASS_Shaper *shaper, TextInfo *text_info)
104+ {
105+- int i, ret, last_break;
106+- FriBidiParType dir, *pdir;
107++ int i;
108+ GlyphInfo *glyphs = text_info->glyphs;
109+ shaper->event_text = text_info->event_text;
110+
111+@@ -979,52 +947,7 @@ bool ass_shaper_shape(ASS_Shaper *shaper, TextInfo *text_info)
112+ for (i = 0; i < text_info->length; i++)
113+ shaper->event_text[i] = glyphs[i].symbol;
114+
115+- fribidi_get_bidi_types(shaper->event_text,
116+- text_info->length, shaper->ctypes);
117+-
118+-#ifdef USE_FRIBIDI_EX_API
119+- if (shaper->bidi_brackets) {
120+- fribidi_get_bracket_types(shaper->event_text,
121+- text_info->length, shaper->ctypes, shaper->btypes);
122+- }
123+-#endif
124+-
125+- // Get bidi embedding levels
126+- last_break = 0;
127+- pdir = shaper->pbase_dir;
128+- for (i = 0; i < text_info->length; i++) {
129+- // embedding levels should be calculated paragraph by paragraph
130+- if (glyphs[i].symbol == '\n' || i == text_info->length - 1 ||
131+- (!shaper->whole_text_layout &&
132+- (glyphs[i + 1].starts_new_run || glyphs[i].hspacing))) {
133+- dir = shaper->base_direction;
134+-#ifdef USE_FRIBIDI_EX_API
135+- FriBidiBracketType *btypes = NULL;
136+- if (shaper->bidi_brackets)
137+- btypes = shaper->btypes + last_break;
138+- ret = fribidi_get_par_embedding_levels_ex(
139+- shaper->ctypes + last_break, btypes,
140+- i - last_break + 1, &dir, shaper->emblevels + last_break);
141+-#else
142+- ret = fribidi_get_par_embedding_levels(shaper->ctypes + last_break,
143+- i - last_break + 1, &dir, shaper->emblevels + last_break);
144+-#endif
145+- if (ret == 0)
146+- return false;
147+- last_break = i + 1;
148+- if (shaper->whole_text_layout)
149+- *pdir++ = dir;
150+- }
151+- }
152+-
153+- switch (shaper->shaping_level) {
154+- case ASS_SHAPING_SIMPLE:
155+- shape_fribidi(shaper, glyphs, text_info->length);
156+- return true;
157+- case ASS_SHAPING_COMPLEX:
158+- default:
159+- return shape_harfbuzz(shaper, glyphs, text_info->length);
160+- }
161++ return shape_harfbuzz(shaper, glyphs, text_info->length);
162+ }
163+
164+ /**
165+@@ -1038,7 +961,7 @@ ASS_Shaper *ass_shaper_new(Cache *metrics_cache)
166+ if (!shaper)
167+ return NULL;
168+
169+- shaper->base_direction = FRIBIDI_PAR_ON;
170++ shaper->base_direction = 0;
171+
172+ if (!init_features(shaper))
173+ goto error;
174+@@ -1079,34 +1002,12 @@ void ass_shaper_cleanup(ASS_Shaper *shaper, TextInfo *text_info)
175+ */
176+ FriBidiStrIndex *ass_shaper_reorder(ASS_Shaper *shaper, TextInfo *text_info)
177+ {
178+- int i, ret;
179++ int i;
180+
181+ // Initialize reorder map
182+ for (i = 0; i < text_info->length; i++)
183+ shaper->cmap[i] = i;
184+
185+- // Create reorder map line-by-line or run-by-run
186+- int last_break = 0;
187+- FriBidiParType *pdir = shaper->whole_text_layout ?
188+- shaper->pbase_dir : &shaper->base_direction;
189+- GlyphInfo *glyphs = text_info->glyphs;
190+- for (i = 0; i < text_info->length; i++) {
191+- if (i == text_info->length - 1 || glyphs[i + 1].linebreak ||
192+- (!shaper->whole_text_layout &&
193+- (glyphs[i + 1].starts_new_run || glyphs[i].hspacing))) {
194+- ret = fribidi_reorder_line(0,
195+- shaper->ctypes, i - last_break + 1, last_break, *pdir,
196+- shaper->emblevels, NULL,
197+- shaper->cmap);
198+- if (ret == 0)
199+- return NULL;
200+-
201+- last_break = i + 1;
202+- if (shaper->whole_text_layout && glyphs[i].symbol == '\n')
203+- pdir++;
204+- }
205+- }
206+-
207+ return shaper->cmap;
208+ }
209+
210+@@ -1124,10 +1025,5 @@ FriBidiStrIndex *ass_shaper_get_reorder_map(ASS_Shaper *shaper)
211+ */
212+ FriBidiParType ass_resolve_base_direction(int enc)
213+ {
214+- switch (enc) {
215+- case -1:
216+- return FRIBIDI_PAR_ON;
217+- default:
218+- return FRIBIDI_PAR_LTR;
219+- }
220++ return 0;
221+ }
222+diff --git a/libass/ass_shaper.h b/libass/ass_shaper.h
223+index 819a3fd..3eef8d7 100644
224+--- a/libass/ass_shaper.h
225++++ b/libass/ass_shaper.h
226+@@ -21,14 +21,15 @@
227+
228+ typedef struct ass_shaper ASS_Shaper;
229+
230+-#include <fribidi.h>
231+ #include <stdbool.h>
232+ #include "ass_render.h"
233+ #include "ass_cache.h"
234+
235+-#if FRIBIDI_MAJOR_VERSION >= 1
236+-#define USE_FRIBIDI_EX_API
237+-#endif
238++typedef uint32_t FriBidiChar;
239++typedef uint32_t FriBidiCharType;
240++typedef int FriBidiStrIndex;
241++typedef int FriBidiParType;
242++typedef signed char FriBidiLevel;
243+
244+ void ass_shaper_info(ASS_Library *lib);
245+ ASS_Shaper *ass_shaper_new(Cache *metrics_cache);
+2,
-0
1@@ -0,0 +1,2 @@
2+https://github.com/libass/libass/releases/download/0.17.1/libass-0.17.1.tar.xz
3+patches/no-fribidi.patch
+1,
-0
1@@ -0,0 +1 @@
2+0.17.1 1