From 2ba300123f7e6e5b9bbc69976ca4017993af694b Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Sun, 11 Mar 2012 06:04:59 +0100 Subject: 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. --- libass/ass_utils.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'libass/ass_utils.c') 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, -- cgit v1.2.3