summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-07-28 16:27:57 +0100
committerCarl Hetherington <cth@carlh.net>2017-07-28 16:28:05 +0100
commitec880edaea8841aab030325d8d14c9dfd5613bfd (patch)
treeb942015f7f40b735f0667e1da60404d3386056a7
parent0c7a195358580f65c9fcfd5342e01a70544c1405 (diff)
Support \fs in ssa.1.0-more-ssa-tags
-rw-r--r--src/ssa_reader.cc4
-rw-r--r--test/ssa_reader_test.cc24
2 files changed, 26 insertions, 2 deletions
diff --git a/src/ssa_reader.cc b/src/ssa_reader.cc
index da36014..471931f 100644
--- a/src/ssa_reader.cc
+++ b/src/ssa_reader.cc
@@ -279,8 +279,10 @@ SSAReader::parse_line (RawSubtitle base, string line, int play_res_x, int play_r
current.horizontal_position.proportional = raw_convert<float>(bits[1]) / play_res_x;
current.vertical_position.reference = sub::TOP_OF_SCREEN;
current.vertical_position.proportional = raw_convert<float>(bits[2]) / play_res_y;
+ } else if (boost::starts_with(style, "\\fs")) {
+ SUB_ASSERT (style.length() > 3);
+ current.font_size.set_points (raw_convert<int>(style.substr(3)));
}
-
style = "";
}
diff --git a/test/ssa_reader_test.cc b/test/ssa_reader_test.cc
index b127a86..e5638af 100644
--- a/test/ssa_reader_test.cc
+++ b/test/ssa_reader_test.cc
@@ -450,7 +450,7 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test6)
}
/** Test \pos */
-BOOST_AUTO_TEST_CASE (ssa_reader_line_pos)
+BOOST_AUTO_TEST_CASE (ssa_reader_pos)
{
boost::filesystem::path p = "test/data/test2.ssa";
FILE* f = fopen (p.string().c_str(), "r");
@@ -470,3 +470,25 @@ BOOST_AUTO_TEST_CASE (ssa_reader_line_pos)
BLOCK ("positioning.", "Arial", 20, false, false, false);
SUB_END();
}
+
+/** Test \fs */
+BOOST_AUTO_TEST_CASE (ssa_reader_fs)
+{
+ sub::RawSubtitle base;
+ list<sub::RawSubtitle> r = sub::SSAReader::parse_line (
+ base,
+ "This is a line with some {\\fs64}font sizing.",
+ 1920, 1080
+ );
+
+ list<sub::RawSubtitle>::const_iterator i = r.begin ();
+ BOOST_CHECK_EQUAL (i->text, "This is a line with some ");
+ ++i;
+ BOOST_REQUIRE (i != r.end ());
+
+ BOOST_CHECK_EQUAL (i->text, "font sizing.");
+ BOOST_CHECK (i->font_size.points());
+ BOOST_CHECK_EQUAL (i->font_size.points().get(), 64);
+ ++i;
+ BOOST_REQUIRE (i == r.end ());
+}