summaryrefslogtreecommitdiffstats
path: root/libass/ass_parse.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-05 00:55:13 +0200
committerwm4 <wm4@nowhere>2014-06-05 01:15:14 +0200
commitdcecb9cba3ab2e9c1d082c9860aecb9e437e40f6 (patch)
treec366e02227a4814504f7911d0f6e2d48f5ec0ff4 /libass/ass_parse.c
parent4a4e464d1dadce90bc91dce5448890e987019d89 (diff)
downloadlibass-dcecb9cba3ab2e9c1d082c9860aecb9e437e40f6.tar.bz2
libass-dcecb9cba3ab2e9c1d082c9860aecb9e437e40f6.tar.xz
Add a mechanism for selective style overrides
This adds 2 new API functions: ass_set_selective_style_override() ass_set_selective_style_override_enabled() They can be used to force dialog text to use a specific ASS_Style. It uses a fuzzy heuristic for that, and the quality of results may vary. It does style overriding selectively and tries not to override things that need explicit styling. The heuristic for that isn't set in stone either, and can change with future libass versions. Closes libass#88.
Diffstat (limited to 'libass/ass_parse.c')
-rw-r--r--libass/ass_parse.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/libass/ass_parse.c b/libass/ass_parse.c
index d6b2627..d0d1972 100644
--- a/libass/ass_parse.c
+++ b/libass/ass_parse.c
@@ -1025,3 +1025,29 @@ unsigned get_next_char(ASS_Renderer *render_priv, char **str)
*str = p;
return chr;
}
+
+// Return 1 if the event contains tags that will put the renderer into the
+// EVENT_POSITIONED state. Return 0 otherwise.
+int event_is_positioned(char *str)
+{
+ // look for \pos and \move tags inside {...}
+ // mirrors get_next_char, but is faster and doesn't change any global state
+ while (*str) {
+ if (str[0] == '\\' && str[1] != '\0') {
+ str += 2;
+ } else if (str[0] == '{') {
+ str++;
+ while (*str && *str != '}') {
+ if (*str == '\\') {
+ char *p = str + 1;
+ if (mystrcmp(&p, "pos") || mystrcmp(&p, "move"))
+ return 1;
+ }
+ str++;
+ }
+ } else {
+ str++;
+ }
+ }
+ return 0;
+}