Support an commands in SSA.
authorCarl Hetherington <cth@carlh.net>
Sat, 11 Jun 2016 22:32:05 +0000 (23:32 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 11 Jun 2016 22:32:05 +0000 (23:32 +0100)
src/ssa_reader.cc
test/data/test.ssa
test/ssa_reader_test.cc

index d3555cbb85b9bcc71b46d4f0f417c7545ec9ef33..c1614a8ce5f15d07b1d0b5716eff58776b31df2a 100644 (file)
@@ -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;
index a0cc0a4a4f6ce147bb9fa477e1cb00ed2c4ac935..162d31eeb8aa26ece664a1f5ec8b6217d16f75f5 100644 (file)
@@ -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
index 1aa7b7a9a78548adf60f05f8e1e9d6ffba63dfa4..46b5cb75600c010d003401afef027dedbdef633f 100644 (file)
@@ -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 ());
 }