summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-06-11 23:32:05 +0100
committerCarl Hetherington <cth@carlh.net>2016-06-11 23:32:05 +0100
commit3e299e5610b5e5929769a9ced21f8b45f8820d81 (patch)
tree306449fa7c922d560f4ea7751c4eb635c6a68e26
parentf7769c330bed741d39c713c206b2445b8feddfd1 (diff)
Support an commands in SSA.
-rw-r--r--src/ssa_reader.cc6
-rw-r--r--test/data/test.ssa9
-rw-r--r--test/ssa_reader_test.cc47
3 files changed, 62 insertions, 0 deletions
diff --git a/src/ssa_reader.cc b/src/ssa_reader.cc
index d3555cb..c1614a8 100644
--- a/src/ssa_reader.cc
+++ b/src/ssa_reader.cc
@@ -239,6 +239,12 @@ SSAReader::parse_line (RawSubtitle base, string line)
current.italic = true;
} else if (style == "\\i0" || style == "\\i") {
current.italic = false;
+ } else if (style == "\\an1" || style == "\\an2" || style == "\\an3") {
+ current.vertical_position.reference = sub::BOTTOM_OF_SCREEN;
+ } else if (style == "\\an4" || style == "\\an5" || style == "\\an6") {
+ current.vertical_position.reference = sub::CENTRE_OF_SCREEN;
+ } else if (style == "\\an7" || style == "\\an8" || style == "\\an9") {
+ current.vertical_position.reference = sub::TOP_OF_SCREEN;
}
style = "";
state = TEXT;
diff --git a/test/data/test.ssa b/test/data/test.ssa
index a0cc0a4..162d31e 100644
--- a/test/data/test.ssa
+++ b/test/data/test.ssa
@@ -19,3 +19,12 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: Marked=0,0:00:01.23,0:00:04.55,Default,,0,0,0,,Hello world
Dialogue: Marked=0,0:00:05.74,0:00:11.00,Default,,0,0,900,,This is vertically moved\nand has two lines.
Dialogue: Marked=0,0:00:07.74,0:00:09.00,Default,,0,0,0,,Some {\i1}italics{\i} are here.
+Dialogue: Marked=0,0:00:09.23,0:00:11.56,Default,,0,0,0,,{\an1}bottom left
+Dialogue: Marked=0,0:00:09.24,0:00:11.56,Default,,0,0,0,,{\an2}bottom centre
+Dialogue: Marked=0,0:00:09.25,0:00:11.56,Default,,0,0,0,,{\an3}bottom right
+Dialogue: Marked=0,0:00:09.26,0:00:11.56,Default,,0,0,0,,{\an4}middle left
+Dialogue: Marked=0,0:00:09.27,0:00:11.56,Default,,0,0,0,,{\an5}middle centre
+Dialogue: Marked=0,0:00:09.28,0:00:11.56,Default,,0,0,0,,{\an6}middle right
+Dialogue: Marked=0,0:00:09.29,0:00:11.56,Default,,0,0,0,,{\an7}top left
+Dialogue: Marked=0,0:00:09.30,0:00:11.56,Default,,0,0,0,,{\an8}top centre
+Dialogue: Marked=0,0:00:09.31,0:00:11.56,Default,,0,0,0,,{\an9}top right
diff --git a/test/ssa_reader_test.cc b/test/ssa_reader_test.cc
index 1aa7b7a..46b5cb7 100644
--- a/test/ssa_reader_test.cc
+++ b/test/ssa_reader_test.cc
@@ -193,5 +193,52 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test3)
BLOCK(" are here.", "Arial", 20, false, false, false);
SUB_END();
+ /* Alignments */
+
+ SUB_START (sub::Time::from_hms (0, 0, 9, 230), sub::Time::from_hms (0, 0, 11, 560));
+ LINE (0, sub::BOTTOM_OF_SCREEN);
+ BLOCK("bottom left", "Arial", 20, false, false, false);
+ SUB_END ();
+
+ SUB_START (sub::Time::from_hms (0, 0, 9, 240), sub::Time::from_hms (0, 0, 11, 560));
+ LINE (0, sub::BOTTOM_OF_SCREEN);
+ BLOCK("bottom centre", "Arial", 20, false, false, false);
+ SUB_END ();
+
+ SUB_START (sub::Time::from_hms (0, 0, 9, 250), sub::Time::from_hms (0, 0, 11, 560));
+ LINE (0, sub::BOTTOM_OF_SCREEN);
+ BLOCK("bottom right", "Arial", 20, false, false, false);
+ SUB_END ();
+
+ SUB_START (sub::Time::from_hms (0, 0, 9, 260), sub::Time::from_hms (0, 0, 11, 560));
+ LINE (0, sub::CENTRE_OF_SCREEN);
+ BLOCK("middle left", "Arial", 20, false, false, false);
+ SUB_END ();
+
+ SUB_START (sub::Time::from_hms (0, 0, 9, 270), sub::Time::from_hms (0, 0, 11, 560));
+ LINE (0, sub::CENTRE_OF_SCREEN);
+ BLOCK("middle centre", "Arial", 20, false, false, false);
+ SUB_END ();
+
+ SUB_START (sub::Time::from_hms (0, 0, 9, 280), sub::Time::from_hms (0, 0, 11, 560));
+ LINE (0, sub::CENTRE_OF_SCREEN);
+ BLOCK("middle right", "Arial", 20, false, false, false);
+ SUB_END ();
+
+ SUB_START (sub::Time::from_hms (0, 0, 9, 290), sub::Time::from_hms (0, 0, 11, 560));
+ LINE (0, sub::TOP_OF_SCREEN);
+ BLOCK("top left", "Arial", 20, false, false, false);
+ SUB_END ();
+
+ SUB_START (sub::Time::from_hms (0, 0, 9, 300), sub::Time::from_hms (0, 0, 11, 560));
+ LINE (0, sub::TOP_OF_SCREEN);
+ BLOCK("top centre", "Arial", 20, false, false, false);
+ SUB_END ();
+
+ SUB_START (sub::Time::from_hms (0, 0, 9, 310), sub::Time::from_hms (0, 0, 11, 560));
+ LINE (0, sub::TOP_OF_SCREEN);
+ BLOCK("top right", "Arial", 20, false, false, false);
+ SUB_END ();
+
BOOST_REQUIRE (i == subs.end ());
}