summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2011-04-09 04:06:39 +0200
committerGrigori Goronzy <greg@blackbox>2011-04-09 04:16:26 +0200
commit7225aed43f7ebf65900ba7dc0f12ef2b6d87f00c (patch)
treeb76b1a03f4d9f45dc2a10a80299a8365ebf7cf84
parentf9283004c4f03b316e1b1cb5fe4491acd98a2a6f (diff)
downloadlibass-7225aed43f7ebf65900ba7dc0f12ef2b6d87f00c.tar.bz2
libass-7225aed43f7ebf65900ba7dc0f12ef2b6d87f00c.tar.xz
Much improved "Default" style
Make the "Default" style, useful as a fallback and required by few scripts for proper rendering, actually do something sensible. Font, sizes, et cetera are set up mostly like VSFilter.
-rw-r--r--libass/ass.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/libass/ass.c b/libass/ass.c
index 3683772..ff2e395 100644
--- a/libass/ass.c
+++ b/libass/ass.c
@@ -164,6 +164,32 @@ static void rskip_spaces(char **str, char *limit)
}
/**
+ * \brief Set up default style
+ * \param style style to edit to defaults
+ * The parameters are mostly taken directly from VSFilter source for
+ * best compatibility.
+ */
+static void set_default_style(ASS_Style *style)
+{
+ style->Name = strdup("Default");
+ style->FontName = strdup("Arial");
+ style->FontSize = 18;
+ style->PrimaryColour = 0xffffff00;
+ style->SecondaryColour = 0x00ffff00;
+ style->OutlineColour = 0x00000000;
+ style->BackColour = 0x00000000;
+ style->Bold = 200;
+ style->ScaleX = 1.0;
+ style->ScaleY = 1.0;
+ style->Spacing = 0;
+ style->BorderStyle = 1;
+ style->Outline = 2;
+ style->Shadow = 3;
+ style->Alignment = 2;
+ style->MarginL = style->MarginR = style->MarginV = 20;
+}
+
+/**
* \brief find style by name
* \param track track
* \param name style name
@@ -308,8 +334,8 @@ static int process_event_tail(ASS_Track *track, ASS_Event *event,
// add "Default" style to the end
// will be used if track does not contain a default style (or even does not contain styles at all)
int sid = ass_alloc_style(track);
- track->styles[sid].Name = strdup("Default");
- track->styles[sid].FontName = strdup("Arial");
+ set_default_style(&track->styles[sid]);
+ track->default_style = sid;
}
for (i = 0; i < n_ignored; ++i) {
@@ -468,6 +494,14 @@ static int process_style(ASS_Track *track, char *str)
q = format = strdup(track->style_format);
+ // Add default style first
+ if (track->n_styles == 0) {
+ // will be used if track does not contain a default style (or even does not contain styles at all)
+ int sid = ass_alloc_style(track);
+ set_default_style(&track->styles[sid]);
+ track->default_style = sid;
+ }
+
ass_msg(track->library, MSGL_V, "[%p] Style: %s", track, str);
sid = ass_alloc_style(track);