summaryrefslogtreecommitdiffstats
path: root/libass/ass_utils.c
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2012-03-11 06:04:59 +0100
committerGrigori Goronzy <greg@blackbox>2012-03-11 06:04:59 +0100
commit2ba300123f7e6e5b9bbc69976ca4017993af694b (patch)
treea5b8b83ee77a63c71595ddf0abec6f1811954f7f /libass/ass_utils.c
parent94b4c0d87182cd0bc84cf49cb793a0ab184df502 (diff)
downloadlibass-2ba300123f7e6e5b9bbc69976ca4017993af694b.tar.bz2
libass-2ba300123f7e6e5b9bbc69976ca4017993af694b.tar.xz
Support \rSTYLENAME syntax
This allows to reset to a certain style, instead of the default style for the current line. For some reason, this was completely missing.
Diffstat (limited to 'libass/ass_utils.c')
-rw-r--r--libass/ass_utils.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libass/ass_utils.c b/libass/ass_utils.c
index 4c9d4bc..222e99a 100644
--- a/libass/ass_utils.c
+++ b/libass/ass_utils.c
@@ -160,6 +160,30 @@ unsigned ass_utf8_get_char(char **str)
return c;
}
+/**
+ * \brief find style by name
+ * \param track track
+ * \param name style name
+ * \return index in track->styles
+ * Returnes 0 if no styles found => expects at least 1 style.
+ * Parsing code always adds "Default" style in the end.
+ */
+int lookup_style(ASS_Track *track, char *name)
+{
+ int i;
+ if (*name == '*')
+ ++name; // FIXME: what does '*' really mean ?
+ for (i = track->n_styles - 1; i >= 0; --i) {
+ if (strcmp(track->styles[i].Name, name) == 0)
+ return i;
+ }
+ i = track->default_style;
+ ass_msg(track->library, MSGL_WARN,
+ "[%p]: Warning: no style named '%s' found, using '%s'",
+ track, name, track->styles[i].Name);
+ return i; // use the first style
+}
+
#ifdef CONFIG_ENCA
void *ass_guess_buffer_cp(ASS_Library *library, unsigned char *buffer,
int buflen, char *preferred_language,