+
+/** Test subtitles whose text includes things like <b> */
+BOOST_AUTO_TEST_CASE (dcp_subtitle_test2)
+{
+ auto film = new_test_film ("dcp_subtitle_test2");
+ film->set_container (Ratio::from_id ("185"));
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
+ film->set_name ("frobozz");
+ auto content = make_shared<DCPSubtitleContent>("test/data/dcp_sub2.xml");
+ film->examine_and_add_content (content);
+ BOOST_REQUIRE (!wait_for_jobs ());
+
+ auto decoder = make_shared<DCPSubtitleDecoder>(film, content);
+ decoder->only_text()->PlainStart.connect (bind (store, _1));
+
+ stored = optional<ContentStringText> ();
+ while (!decoder->pass()) {
+ if (stored && stored->from() == ContentTime(0)) {
+ BOOST_CHECK_EQUAL (stored->subs.front().text(), "<b>Hello world!</b>");
+ }
+ }
+}
+
+
+/** Test a failure case */
+BOOST_AUTO_TEST_CASE (dcp_subtitle_test3)
+{
+ auto film = new_test_film ("dcp_subtitle_test3");
+ film->set_container (Ratio::from_id ("185"));
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
+ film->set_name ("frobozz");
+ film->set_interop (true);
+ auto content = make_shared<DCPSubtitleContent>("test/data/dcp_sub3.xml");
+ film->examine_and_add_content (content);
+ BOOST_REQUIRE (!wait_for_jobs ());
+
+ make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_STANDARD });
+
+ auto decoder = make_shared<DCPSubtitleDecoder>(film, content);
+ stored = optional<ContentStringText> ();
+ while (!decoder->pass ()) {
+ decoder->only_text()->PlainStart.connect (bind (store, _1));
+ if (stored && stored->from() == ContentTime::from_seconds(0.08)) {
+ auto s = stored->subs;
+ auto i = s.begin ();
+ BOOST_CHECK_EQUAL (i->text(), "This");
+ ++i;
+ BOOST_REQUIRE (i != s.end ());
+ BOOST_CHECK_EQUAL (i->text(), " is ");
+ ++i;
+ BOOST_REQUIRE (i != s.end ());
+ BOOST_CHECK_EQUAL (i->text(), "wrong.");
+ ++i;
+ BOOST_REQUIRE (i == s.end ());
+ }
+ }
+}
+
+
+/** Check that Interop DCPs aren't made with more than one <LoadFont> (#1273) */
+BOOST_AUTO_TEST_CASE (dcp_subtitle_test4)
+{
+ auto content = make_shared<DCPSubtitleContent>("test/data/dcp_sub3.xml");
+ auto content2 = make_shared<DCPSubtitleContent>("test/data/dcp_sub3.xml");
+ auto film = new_test_film2 ("dcp_subtitle_test4", {content, content2});
+ film->set_interop (true);
+
+ content->only_text()->add_font (shared_ptr<Font> (new Font ("font1")));
+ content2->only_text()->add_font (shared_ptr<Font> (new Font ("font2")));
+
+ make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_STANDARD });
+
+ cxml::Document doc ("DCSubtitle");
+ doc.read_file (subtitle_file (film));
+ BOOST_REQUIRE_EQUAL (doc.node_children("LoadFont").size(), 1U);
+}
+
+
+static
+void
+check_font_tags (vector<cxml::NodePtr> nodes)
+{
+ for (auto i: nodes) {
+ if (i->name() == "Font") {
+ BOOST_CHECK (!i->optional_string_attribute("Id") || i->string_attribute("Id") != "");
+ }
+ check_font_tags (i->node_children());
+ }
+}
+
+
+/** Check that imported <LoadFont> tags with empty IDs (or corresponding Font tags with empty IDs)
+ * are not passed through into the DCP.
+ */
+BOOST_AUTO_TEST_CASE (dcp_subtitle_test5)
+{
+ auto content = make_shared<DCPSubtitleContent>("test/data/dcp_sub6.xml");
+ auto film = new_test_film2 ("dcp_subtitle_test5", {content});
+ film->set_interop (true);
+
+ make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_STANDARD });
+
+ cxml::Document doc ("DCSubtitle");
+ doc.read_file (subtitle_file(film));
+ BOOST_REQUIRE_EQUAL (doc.node_children("LoadFont").size(), 1U);
+ BOOST_CHECK (doc.node_children("LoadFont").front()->string_attribute("Id") != "");
+
+ check_font_tags (doc.node_children());
+}
+
+
+/** Check that fonts specified in the DoM content are used in the output and not ignored (#2074) */
+BOOST_AUTO_TEST_CASE (test_font_override)
+{
+ auto content = make_shared<DCPSubtitleContent>("test/data/dcp_sub4.xml");
+ auto film = new_test_film2("test_font_override", {content});
+ film->set_interop(true);
+
+ BOOST_REQUIRE_EQUAL(content->text.size(), 1U);
+ content->text.front()->add_font(make_shared<dcpomatic::Font>("theFontId", "test/data/Inconsolata-VF.ttf"));
+
+ make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_STANDARD });
+ check_file (subtitle_file(film).parent_path() / "font_0.ttf", "test/data/Inconsolata-VF.ttf");
+}
+