diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-06-24 12:31:56 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-06-24 12:31:56 +0100 |
| commit | 2e4089247c02f1f1bf43ab880594ce0218dfbc11 (patch) | |
| tree | 58dd1be3979e0ac6ebf3d5baf0a8f1606669170d /src/ssa_reader.cc | |
| parent | 2aad7dee4a98569826feeed841791383284d085e (diff) | |
Add support for \c in SSA.
Diffstat (limited to 'src/ssa_reader.cc')
| -rw-r--r-- | src/ssa_reader.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/ssa_reader.cc b/src/ssa_reader.cc index f592b9e..111a4cb 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 <boost/algorithm/string.hpp> #include <boost/bind.hpp> #include <boost/foreach.hpp> @@ -282,6 +283,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 = ""; } |
