diff options
| -rw-r--r-- | src/ssa_reader.cc | 12 | ||||
| -rw-r--r-- | test/ssa_reader_test.cc | 192 |
2 files changed, 102 insertions, 102 deletions
diff --git a/src/ssa_reader.cc b/src/ssa_reader.cc index 03d20dd..eb1e34e 100644 --- a/src/ssa_reader.cc +++ b/src/ssa_reader.cc @@ -243,7 +243,7 @@ SSAReader::parse_style (RawSubtitle& sub, string style, int play_res_x, int play sub.vertical_position.proportional = raw_convert<float>(bits[2]) / play_res_y; } else if (boost::starts_with(style, "\\fs")) { SUB_ASSERT (style.length() > 3); - sub.font_size.set_points (raw_convert<int>(style.substr(3))); + sub.font_size.set_proportional(raw_convert<float>(style.substr(3)) / play_res_y); } else if (boost::starts_with(style, "\\c")) { /* \c&Hbbggrr& */ if (style.length() <= 2) { @@ -285,8 +285,8 @@ SSAReader::parse_line (RawSubtitle base, string line, int play_res_x, int play_r in pixels and in that case we must know how big the subtitle lines are to work out the position on screen. */ - if (!current.font_size.points()) { - current.font_size.set_points (72); + if (!current.font_size.proportional()) { + current.font_size.set_proportional(72.0 / play_res_y); } /* Count the number of line breaks */ @@ -299,8 +299,8 @@ SSAReader::parse_line (RawSubtitle base, string line, int play_res_x, int play_r } } - /* Imagine that the screen is 792 points (i.e. 11 inches) high (as with DCP) */ - double const line_size = current.font_size.proportional(792) * 1.2; + /* Aegisub docs seem to suggest that 1 point == 1 pixel */ + double const line_size = current.font_size.proportional(play_res_y) * 1.2; for (size_t i = 0; i < line.length(); ++i) { char const c = line[i]; @@ -479,7 +479,7 @@ SSAReader::read (function<optional<string> ()> get_line) SUB_ASSERT (styles.find(event[i]) != styles.end()); Style style = styles[event[i]]; sub.font = style.font_name; - sub.font_size = FontSize::from_points (style.font_size); + sub.font_size = FontSize::from_proportional(static_cast<float>(style.font_size) / play_res_y); sub.colour = style.primary_colour; sub.effect_colour = style.back_colour; sub.bold = style.bold; diff --git a/test/ssa_reader_test.cc b/test/ssa_reader_test.cc index 59a161b..99d1dd9 100644 --- a/test/ssa_reader_test.cc +++ b/test/ssa_reader_test.cc @@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test) sub::Block b = j->blocks.front (); BOOST_CHECK_EQUAL (b.text, "Et les enregistrements de ses ondes delta ?"); BOOST_CHECK_EQUAL (b.font.get(), "Wolf_Rain"); - BOOST_CHECK_EQUAL (b.font_size.points().get(), 56); + BOOST_CHECK_EQUAL (b.font_size.proportional().get(), 56.0 / 1024); BOOST_CHECK_EQUAL (b.bold, false); BOOST_CHECK_EQUAL (b.italic, false); BOOST_CHECK_EQUAL (b.underline, false); @@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test) b = j->blocks.front (); BOOST_CHECK_EQUAL (b.text, "Toujours rien."); BOOST_CHECK_EQUAL (b.font.get(), "Wolf_Rain"); - BOOST_CHECK_EQUAL (b.font_size.points().get(), 56); + BOOST_CHECK_EQUAL (b.font_size.proportional().get(), 56.0 / 1024); BOOST_CHECK_EQUAL (b.bold, false); BOOST_CHECK_EQUAL (b.italic, false); BOOST_CHECK_EQUAL (b.underline, false); @@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE (ssa_reader_line_test2) i = r.begin (); BOOST_CHECK_EQUAL (i->text, "Italic"); BOOST_CHECK_EQUAL (i->italic, true); - BOOST_CHECK (fabs ((72.0 * 1.2 / 792) - i->vertical_position.proportional.get()) < 1e-5); + BOOST_CHECK (fabs ((72.0 * 1.2 / 1080) - i->vertical_position.proportional.get()) < 1e-5); ++i; BOOST_CHECK_EQUAL (i->text, "and new line"); BOOST_CHECK_EQUAL (i->italic, false); @@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test2) BOOST_REQUIRE (k != j->blocks.end ()); \ BOOST_CHECK_EQUAL (k->text, t); \ BOOST_CHECK_EQUAL (k->font.get(), f); \ - BOOST_CHECK_EQUAL (k->font_size.points().get(), s); \ + BOOST_CHECK_CLOSE (k->font_size.proportional().get(), s, 0.001); \ BOOST_CHECK_EQUAL (k->bold, b); \ BOOST_CHECK_EQUAL (k->italic, i); \ BOOST_CHECK_EQUAL (k->underline, u); \ @@ -200,7 +200,7 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test3) /* Hello world */ SUB_START (sub::Time::from_hms (0, 0, 1, 230), sub::Time::from_hms (0, 0, 4, 550)); LINE ((10.0 / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("Hello world", "Arial", 20, false, false, false); + BLOCK ("Hello world", "Arial", 20.0 / 1080, false, false, false); SUB_END(); /* This is vertically moved\nand has two lines. */ @@ -209,66 +209,66 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test3) points, 1.2 times spaced, as a proportion of the total screen height 729 points) up. */ - LINE((900.0 / 1080) - (20.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("This is vertically moved", "Arial", 20, false, false, false); + LINE((900.0 / 1080) - (20.0 * 1.2 / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK("This is vertically moved", "Arial", 20.0 / 1080, false, false, false); LINE((900.0 / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("and has two lines.", "Arial", 20, false, false, false); + BLOCK("and has two lines.", "Arial", 20.0 / 1080, false, false, false); SUB_END(); /* Some {\i1}italics{\i} are here. */ SUB_START (sub::Time::from_hms (0, 0, 7, 740), sub::Time::from_hms (0, 0, 9, 0)); LINE((10.0 / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("Some ", "Arial", 20, false, false, false); - BLOCK("italics", "Arial", 20, false, true, false); - BLOCK(" are here.", "Arial", 20, false, false, false); + BLOCK("Some ", "Arial", 20.0 / 1080, false, false, false); + BLOCK("italics", "Arial", 20.0 / 1080, false, true, false); + BLOCK(" are here.", "Arial", 20.0 / 1080, 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 ((10.0 / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::LEFT_OF_SCREEN); - BLOCK("bottom left", "Arial", 20, false, false, false); + BLOCK("bottom left", "Arial", 20.0 / 1080, false, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 9, 240), sub::Time::from_hms (0, 0, 11, 560)); LINE ((10.0 / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("bottom centre", "Arial", 20, false, false, false); + BLOCK("bottom centre", "Arial", 20.0 / 1080, false, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 9, 250), sub::Time::from_hms (0, 0, 11, 560)); LINE ((10.0 / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::RIGHT_OF_SCREEN); - BLOCK("bottom right", "Arial", 20, false, false, false); + BLOCK("bottom right", "Arial", 20.0 / 1080, false, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 9, 260), sub::Time::from_hms (0, 0, 11, 560)); /* Position is half of a 20pt line (with line spacing) above vertical centre */ - LINE (-(10.0 * 1.2 / 792), sub::VERTICAL_CENTRE_OF_SCREEN, 0, sub::LEFT_OF_SCREEN); - BLOCK("middle left", "Arial", 20, false, false, false); + LINE (-(10.0 * 1.2 / 1080), sub::VERTICAL_CENTRE_OF_SCREEN, 0, sub::LEFT_OF_SCREEN); + BLOCK("middle left", "Arial", 20.0 / 1080, false, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 9, 270), sub::Time::from_hms (0, 0, 11, 560)); - LINE (-(10.0 * 1.2 / 792), sub::VERTICAL_CENTRE_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("middle centre", "Arial", 20, false, false, false); + LINE (-(10.0 * 1.2 / 1080), sub::VERTICAL_CENTRE_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK("middle centre", "Arial", 20.0 / 1080, false, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 9, 280), sub::Time::from_hms (0, 0, 11, 560)); - LINE (-(10.0 * 1.2 / 792), sub::VERTICAL_CENTRE_OF_SCREEN, 0, sub::RIGHT_OF_SCREEN); - BLOCK("middle right", "Arial", 20, false, false, false); + LINE (-(10.0 * 1.2 / 1080), sub::VERTICAL_CENTRE_OF_SCREEN, 0, sub::RIGHT_OF_SCREEN); + BLOCK("middle right", "Arial", 20.0 / 1080, false, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 9, 290), sub::Time::from_hms (0, 0, 11, 560)); LINE ((10.0 / 1080), sub::TOP_OF_SCREEN, 0, sub::LEFT_OF_SCREEN); - BLOCK("top left", "Arial", 20, false, false, false); + BLOCK("top left", "Arial", 20.0 / 1080, false, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 9, 300), sub::Time::from_hms (0, 0, 11, 560)); LINE ((10.0 / 1080), sub::TOP_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("top centre", "Arial", 20, false, false, false); + BLOCK("top centre", "Arial", 20.0 / 1080, false, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 9, 310), sub::Time::from_hms (0, 0, 11, 560)); LINE ((10.0 / 1080), sub::TOP_OF_SCREEN, 0, sub::RIGHT_OF_SCREEN); - BLOCK("top right", "Arial", 20, false, false, false); + BLOCK("top right", "Arial", 20.0 / 1080, false, false, false); SUB_END (); BOOST_REQUIRE (i == subs.end ()); @@ -294,31 +294,31 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test4) spaced, as a proportion of the total screen height 729 points) up. */ - LINE ((50.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("1st line: This is normal", "Verdana", 50, false, false, false); + LINE ((50.0 * 1.2 / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("1st line: This is normal", "Verdana", 50.0 / 288, false, false, false); LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("2d line: this is bold", "Verdana", 50, true, false, false); + BLOCK ("2d line: this is bold", "Verdana", 50.0 / 288, true, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 3, 100), sub::Time::from_hms (0, 0, 5, 100)); - LINE ((50.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("1st line: this is bold", "Verdana", 50, true, false, false); + LINE ((50.0 * 1.2 / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("1st line: this is bold", "Verdana", 50.0 / 288, true, false, false); LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("2nd line: This is normal", "Verdana", 50, false, false, false); + BLOCK ("2nd line: This is normal", "Verdana", 50.0 / 288, false, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 5, 200), sub::Time::from_hms (0, 0, 7, 200)); - LINE ((50.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("1st line: this is bold", "Verdana", 50, true, false, false); + LINE ((50.0 * 1.2 / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("1st line: this is bold", "Verdana", 50.0 / 288, true, false, false); LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("2nd line: this is italics", "Verdana", 50, false, true, false); + BLOCK ("2nd line: this is italics", "Verdana", 50.0 / 288, false, true, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 7, 300), sub::Time::from_hms (0, 0, 9, 300)); - LINE ((50.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("1st line: this is italics", "Verdana", 50, false, true, false); + LINE ((50.0 * 1.2 / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("1st line: this is italics", "Verdana", 50.0 / 288, false, true, false); LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("2nd line: this is bold", "Verdana", 50, true, false, false); + BLOCK ("2nd line: this is bold", "Verdana", 50.0 / 288, true, false, false); SUB_END (); } @@ -342,31 +342,31 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test5) spaced, as a proportion of the total screen height 729 points) up. */ - LINE ((26.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("1st subtitle, 1st line", "arial", 26, true, false, false); + LINE ((26.0 * 1.2 / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("1st subtitle, 1st line", "arial", 26.0 / 288, true, false, false); LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("2nd subtitle, 2nd line", "arial", 26, true, false, false); + BLOCK ("2nd subtitle, 2nd line", "arial", 26.0 / 288, true, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 3, 100), sub::Time::from_hms (0, 0, 5, 100)); - LINE ((26.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("2nd subtitle, 1st line", "arial", 26, true, false, false); + LINE ((26.0 * 1.2 / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("2nd subtitle, 1st line", "arial", 26.0 / 288, true, false, false); LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("2nd subtitle, 2nd line", "arial", 26, true, false, false); + BLOCK ("2nd subtitle, 2nd line", "arial", 26.0 / 288, true, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 5, 200), sub::Time::from_hms (0, 0, 7, 200)); - LINE ((26.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("3rd subtitle, 1st line", "arial", 26, true, false, false); + LINE ((26.0 * 1.2 / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("3rd subtitle, 1st line", "arial", 26.0 / 288, true, false, false); LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("3rd subtitle, 2nd line", "arial", 26, true, false, false); + BLOCK ("3rd subtitle, 2nd line", "arial", 26.0 / 288, true, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 7, 300), sub::Time::from_hms (0, 0, 9, 300)); - LINE ((26.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("4th subtitle, 1st line", "arial", 26, true, false, false); + LINE ((26.0 * 1.2 / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("4th subtitle, 1st line", "arial", 26.0 / 288, true, false, false); LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("4th subtitle, 2nd line", "arial", 26, true, false, false); + BLOCK ("4th subtitle, 2nd line", "arial", 26.0 / 288, true, false, false); SUB_END (); } @@ -388,68 +388,68 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test6) SUB_START (sub::Time::from_hms (0, 0, 0, 70), sub::Time::from_hms (0, 0, 1, 110)); /* The first line should be one line (30 points, 1.2 times - spaced, as a proportion of the total screen height 792 + spaced, as a proportion of the total screen height 288 points) up. There's also a 10 pixel (with respect to a 288-pixel-high screen) margin. */ - LINE (((30.0 * 1.2 / 792) + (10.0 / 288.0)), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("This line is normal", "Arial", 30, false, false, false); + LINE (((30.0 * 1.2 + 10.0) / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("This line is normal", "Arial", 30.0 / 288, false, false, false); LINE ((10.0 / 288.0), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("This line is bold", "Arial", 30, true, false, false); + BLOCK ("This line is bold", "Arial", 30.0 / 288, true, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 1, 200), sub::Time::from_hms (0, 0, 2, 240)); - LINE (((30.0 * 1.2 / 792) + (10.0 / 288.0)), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("This line is bold", "Arial", 30, true, false, false); + LINE ((((30.0 * 1.2) + 10.0) / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("This line is bold", "Arial", 30.0 / 288, true, false, false); LINE ((10.0 / 288.0), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("This line is normal", "Arial", 30, false, false, false); + BLOCK ("This line is normal", "Arial", 30.0 / 288, false, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 2, 300), sub::Time::from_hms (0, 0, 3, 380)); - LINE (((30.0 * 1.2 / 792) + (10.0 / 288.0)), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("This line is bold", "Arial", 30, true, false, false); + LINE ((((30.0 * 1.2) + 10.0) / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("This line is bold", "Arial", 30.0 / 288, true, false, false); LINE ((10.0 / 288.0), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("This line is italic", "Arial", 30, false, true, false); + BLOCK ("This line is italic", "Arial", 30.0 / 288, false, true, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 3, 400), sub::Time::from_hms (0, 0, 4, 480)); - LINE (((30.0 * 1.2 / 792) + (10.0 / 288.0)), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("This line is italic", "Arial", 30, false, true, false); + LINE ((((30.0 * 1.2) + 10.0) / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("This line is italic", "Arial", 30.0 / 288, false, true, false); LINE ((10.0 / 288.0), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("This line is bold", "Arial", 30, true, false, false); + BLOCK ("This line is bold", "Arial", 30.0 / 288, true, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 4, 510), sub::Time::from_hms (0, 0, 5, 600)); - LINE (((30.0 * 1.2 / 792) + (10.0 / 288.0)), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("Last three words are ", "Arial", 30, false, false, false); - BLOCK ("bold AND italic", "Arial", 30, true, true, false); + LINE ((((30.0 * 1.2) + 10.0) / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("Last three words are ", "Arial", 30.0 / 288, false, false, false); + BLOCK ("bold AND italic", "Arial", 30.0 / 288, true, true, false); LINE ((10.0 / 288.0), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("Last three words are ", "Arial", 30, false, false, false); - BLOCK ("italic AND bold", "Arial", 30, true, true, false); + BLOCK ("Last three words are ", "Arial", 30.0 / 288, false, false, false); + BLOCK ("italic AND bold", "Arial", 30.0 / 288, true, true, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 5, 620), sub::Time::from_hms (0, 0, 6, 710)); - LINE (((30.0 * 1.2 / 792) + (10.0 / 288.0)), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("Last three words are ", "Arial", 30, false, false, false); - BLOCK ("bold AND italic", "Arial", 30, true, true, false); + LINE ((((30.0 * 1.2) + 10.0) / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("Last three words are ", "Arial", 30.0 / 288, false, false, false); + BLOCK ("bold AND italic", "Arial", 30.0 / 288, true, true, false); LINE ((10.0 / 288.0), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("First three words", "Arial", 30, true, true, false); - BLOCK (" are italic AND bold", "Arial", 30, false, false, false); + BLOCK ("First three words", "Arial", 30.0 / 288, true, true, false); + BLOCK (" are italic AND bold", "Arial", 30.0 / 288, false, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 6, 730), sub::Time::from_hms (0, 0, 8, 30)); - LINE (((30.0 * 1.2 / 792) + (10.0 / 288.0)), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("Last three words are ", "Arial", 30, false, false, false); - BLOCK ("bold AND italic", "Arial", 30, true, true, false); + LINE ((((30.0 * 1.2) + 10.0) / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("Last three words are ", "Arial", 30.0 / 288, false, false, false); + BLOCK ("bold AND italic", "Arial", 30.0 / 288, true, true, false); LINE ((10.0 / 288.0), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("This line is normal", "Arial", 30, false, false, false); + BLOCK ("This line is normal", "Arial", 30.0 / 288, false, false, false); SUB_END (); SUB_START (sub::Time::from_hms (0, 0, 8, 90), sub::Time::from_hms (0, 0, 9, 210)); - LINE (((30.0 * 1.2 / 792) + (10.0 / 288.0)), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("Both lines are bold AND italic", "Arial", 30, true, true, false); + LINE ((((30.0 * 1.2) + 10.0) / 288), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK ("Both lines are bold AND italic", "Arial", 30.0 / 288, true, true, false); LINE ((10.0 / 288.0), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("Both lines are bold AND italic", "Arial", 30, true, true, false); + BLOCK ("Both lines are bold AND italic", "Arial", 30.0 / 288, true, true, false); SUB_END (); } @@ -470,38 +470,38 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test7) BOOST_REQUIRE (i != subs.end()); SUB_START(sub::Time::from_hms(0, 0, 1, 0), sub::Time::from_hms(0, 0, 3, 0)); - LINE(((60.0 * 1.2 / 792) + (100.0 / 1080)), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("Helvetica Neue 60pt - Default", "Helvetica Neue", 60, false, false, false); + LINE((((60.0 * 1.2) + 100.0) / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK("Helvetica Neue 60pt - Default", "Helvetica Neue", 60.0 / 1080, false, false, false); LINE((100.0 / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("Bottom 100 pt off edge", "Helvetica Neue", 60, false, false, false); + BLOCK("Bottom 100 pt off edge", "Helvetica Neue", 60.0 / 1080, false, false, false); SUB_END(); SUB_START(sub::Time::from_hms(0, 0, 4, 0), sub::Time::from_hms(0, 0, 6, 0)); - LINE((((30.0 * 1.2) / 792) + (100.0 / 1080)), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("Helvetica Neue 30pt", "Helvetica Neue", 30, false, false, false); + LINE((((30.0 * 1.2) + 100.0) / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK("Helvetica Neue 30pt", "Helvetica Neue", 30.0 / 1080, false, false, false); LINE((100.0 / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("Bottom 100pt off edge", "Helvetica Neue", 30, false, false, false); + BLOCK("Bottom 100pt off edge", "Helvetica Neue", 30.0 / 1080, false, false, false); SUB_END(); SUB_START(sub::Time::from_hms(0, 0, 7, 0), sub::Time::from_hms(0, 0, 9, 0)); - LINE((((120.0 * 1.2) / 792) + (100.0 / 1080)), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("Helvetica Neue 120pt", "Helvetica Neue", 120, false, false, false); + LINE((((120.0 * 1.2) + 100.0) / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK("Helvetica Neue 120pt", "Helvetica Neue", 120.0 / 1080, false, false, false); LINE((100.0 / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("Bottom 100pt off edge", "Helvetica Neue", 120, false, false, false); + BLOCK("Bottom 100pt off edge", "Helvetica Neue", 120.0 / 1080, false, false, false); SUB_END(); SUB_START(sub::Time::from_hms(0, 0, 10, 0), sub::Time::from_hms(0, 0, 12, 0)); LINE((100.0 / 1080), sub::TOP_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("Helvetica Neue 60pt", "Helvetica Neue", 60, false, false, false); - LINE((((60.0) * 1.2 / 792) + (100.0 / 1080)), sub::TOP_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("Top Alignment 100pt off edge", "Helvetica Neue", 60, false, false, false); + BLOCK("Helvetica Neue 60pt", "Helvetica Neue", 60.0 / 1080, false, false, false); + LINE((((60.0 * 1.2) + 100.0) / 1080), sub::TOP_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK("Top Alignment 100pt off edge", "Helvetica Neue", 60.0 / 1080, false, false, false); SUB_END(); SUB_START(sub::Time::from_hms(0, 0, 13, 0), sub::Time::from_hms(0, 0, 15, 0)); - LINE((-60.0 * 1.2 / 792), sub::VERTICAL_CENTRE_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK("Helvetica Neue 60pt", "Helvetica Neue 60 Center", 60, false, false, false); + LINE((-60.0 * 1.2 / 1080), sub::VERTICAL_CENTRE_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); + BLOCK("Helvetica Neue 60pt", "Helvetica Neue 60 Center", 60.0 / 1080, false, false, false); LINE(0, sub::VERTICAL_CENTRE_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK(" Vertical Center Alignment", "Helvetica Neue 60 Center", 60, false, false, false); + BLOCK(" Vertical Center Alignment", "Helvetica Neue 60 Center", 60.0 / 1080, false, false, false); SUB_END(); } @@ -522,9 +522,9 @@ BOOST_AUTO_TEST_CASE (ssa_reader_pos) /* Hello world */ SUB_START (sub::Time::from_hms (0, 0, 1, 230), sub::Time::from_hms (0, 0, 4, 550)); LINE ((10.0 / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN); - BLOCK ("Hello world this is ", "Arial", 20, false, false, false); + BLOCK ("Hello world this is ", "Arial", 20.0 / 1080, false, false, false); LINE ((310.0 / 1080), sub::TOP_OF_SCREEN, 400.0 / 1920, sub::LEFT_OF_SCREEN); - BLOCK ("positioning.", "Arial", 20, false, false, false); + BLOCK ("positioning.", "Arial", 20.0 / 1080, false, false, false); SUB_END(); } @@ -544,8 +544,8 @@ BOOST_AUTO_TEST_CASE (ssa_reader_fs) 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); + BOOST_CHECK (i->font_size.proportional()); + BOOST_CHECK_CLOSE(i->font_size.proportional().get(), 64.0 / 1080, 0.001); ++i; BOOST_REQUIRE (i == r.end ()); } |
