summaryrefslogtreecommitdiff
path: root/src/ssa_reader.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-06-24 12:31:56 +0100
committerCarl Hetherington <cth@carlh.net>2019-06-28 23:26:10 +0100
commit759a2e6150e2a611db90cd81c0b2f81699eb22bd (patch)
treeae1a28f9873f598f699b9400040f8212eb8c846e /src/ssa_reader.cc
parent79e9e5e1ee2b6757c85a9e79893c4be413bd6d62 (diff)
Add support for \c in SSA.v1.4.9
Backported from 2e4089247c02f1f1bf43ab880594ce0218dfbc11 in master.
Diffstat (limited to 'src/ssa_reader.cc')
-rw-r--r--src/ssa_reader.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/ssa_reader.cc b/src/ssa_reader.cc
index a1672d8..bfcd0de 100644
--- a/src/ssa_reader.cc
+++ b/src/ssa_reader.cc
@@ -22,6 +22,7 @@
#include "sub_assert.h"
#include "raw_convert.h"
#include "subtitle.h"
+#include "compose.hpp"
#include <locked_sstream.h>
#include <boost/algorithm/string.hpp>
#include <boost/bind.hpp>
@@ -284,6 +285,16 @@ SSAReader::parse_line (RawSubtitle base, string line, int play_res_x, int play_r
} else if (boost::starts_with(style, "\\fs")) {
SUB_ASSERT (style.length() > 3);
current.font_size.set_points (raw_convert<int>(style.substr(3)));
+ } else if (boost::starts_with(style, "\\c")) {
+ /* \c&Hbbggrr& */
+ if (style.length() != 11 || style[2] != '&' || style[3] != 'H' || style[10] != '&') {
+ throw SSAError(String::compose("Badly formatted colour tag %1", style));
+ }
+ int ir, ig, ib;
+ if (sscanf(style.c_str() + 4, "%2x%2x%2x", &ib, &ig, &ir) < 3) {
+ throw SSAError(String::compose("Badly formatted colour tag %1", style));
+ }
+ current.colour = sub::Colour(ir / 255.0, ig / 255.0, ib / 255.0);
}
style = "";
}