summaryrefslogtreecommitdiffstats
path: root/libass/ass_utils.c
diff options
context:
space:
mode:
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,