From 66dba8dd21bbf81b25b26e2556c404006f80a43c Mon Sep 17 00:00:00 2001 From: Oleg Oshmyan Date: Tue, 14 Jul 2020 00:38:43 +0300 Subject: Disable bidi bracket matching unless enabled via ASS_Feature Bracket matching is incompatible with VSFilter (even on modern Windows), so disable it by default. But as it's generally a good thing (and 100% more compliant with current Unicode), keep it available as an ASS_Feature. It can be toggled individually or enabled as part of the catch-all ASS_FEATURE_INCOMPATIBLE_EXTENSIONS feature. If libass is compiled against FriBidi older than 1.0, bracket matching is impossible. Signal this at runtime by failing to recognize the ASS_FEATURE_BIDI_BRACKETS feature. This way, clients who want to use bracket matching can set the feature without any compile-time checks for FriBidi and can be freely linked against libass that is itself compiled against any version of FriBidi; and yet they can detect at runtime whether the feature is actually enabled. Fixes https://github.com/libass/libass/issues/374. --- libass/ass.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libass/ass.c') diff --git a/libass/ass.c b/libass/ass.c index 13cfea5..811a9a7 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -36,6 +36,7 @@ #include "ass_utils.h" #include "ass_library.h" #include "ass_priv.h" +#include "ass_shaper.h" #include "ass_string.h" #define ass_atof(STR) (ass_strtod((STR),NULL)) @@ -1468,7 +1469,11 @@ int ass_track_set_feature(ASS_Track *track, ASS_Feature feature, int enable) { switch (feature) { case ASS_FEATURE_INCOMPATIBLE_EXTENSIONS: - track->parser_priv->enable_extensions = !!enable; + //-fallthrough +#ifdef USE_FRIBIDI_EX_API + case ASS_FEATURE_BIDI_BRACKETS: + track->parser_priv->bidi_brackets = !!enable; +#endif return 0; default: return -1; -- cgit v1.2.3