summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-09-26 01:02:43 +0200
committerCarl Hetherington <cth@carlh.net>2022-09-26 01:02:43 +0200
commitdbf2fbd90051f646ed827505ed1523f9449373f5 (patch)
treed35e9ea8a2b24eea4f6b3ff4e150ae16ffad8488
parentdea555a6d395e74c20436123a5f3b5bd623ebcf6 (diff)
Provide a similar fix to the one in ff639b3cf30afcc097bfd21d39c8d15f466cadd6
for DCPs that contain subtitle files without <Font> tags.
-rw-r--r--src/lib/dcp_examiner.cc4
-rw-r--r--test/subtitle_font_id_test.cc60
2 files changed, 64 insertions, 0 deletions
diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc
index 5de8c8905..0cfe499a3 100644
--- a/src/lib/dcp_examiner.cc
+++ b/src/lib/dcp_examiner.cc
@@ -252,6 +252,10 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
_reel_lengths.push_back (i->atmos()->actual_duration());
}
+ if (reel_fonts.empty()) {
+ reel_fonts.push_back(make_shared<dcpomatic::Font>(""));
+ }
+
_fonts.push_back(reel_fonts);
}
diff --git a/test/subtitle_font_id_test.cc b/test/subtitle_font_id_test.cc
index 5bcf454bd..658d970e1 100644
--- a/test/subtitle_font_id_test.cc
+++ b/test/subtitle_font_id_test.cc
@@ -24,12 +24,17 @@
#include "lib/film.h"
#include "lib/font.h"
#include "lib/text_content.h"
+#include <dcp/cpl.h>
+#include <dcp/dcp.h>
+#include <dcp/reel.h>
+#include <dcp/reel_subtitle_asset.h>
#include <dcp/smpte_subtitle_asset.h>
#include "test.h"
#include <boost/test/unit_test.hpp>
using std::make_shared;
+using std::shared_ptr;
BOOST_AUTO_TEST_CASE(full_dcp_subtitle_font_id_test)
@@ -123,3 +128,58 @@ BOOST_AUTO_TEST_CASE(make_dcp_with_subs_without_font_tag)
BOOST_CHECK(check_font_data.begin()->second == dcp::ArrayData(default_font_file()));
}
+
+BOOST_AUTO_TEST_CASE(make_dcp_with_subs_in_dcp_without_font_tag)
+{
+ /* Make a DCP with some subs in */
+ auto source_subs = content_factory("test/data/short.srt");
+ auto source = new_test_film2("make_dcp_with_subs_in_dcp_without_font_tag_source", { source_subs });
+ source->set_interop(true);
+ make_and_verify_dcp(
+ source,
+ {
+ dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
+ dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
+ dcp::VerificationNote::Code::MISSING_CPL_METADATA,
+ dcp::VerificationNote::Code::INVALID_STANDARD
+ });
+
+ /* Find the ID of the subs */
+ dcp::DCP source_dcp(source->dir(source->dcp_name()));
+ source_dcp.read();
+ BOOST_REQUIRE(!source_dcp.cpls().empty());
+ BOOST_REQUIRE(!source_dcp.cpls()[0]->reels().empty());
+ BOOST_REQUIRE(source_dcp.cpls()[0]->reels()[0]->main_subtitle());
+ auto const id = source_dcp.cpls()[0]->reels()[0]->main_subtitle()->asset()->id();
+
+ /* Graft in some bad subs with no <Font> tag */
+ auto source_subtitle_file = subtitle_file(source);
+ boost::filesystem::copy_file("test/data/no_font.xml", source_subtitle_file, boost::filesystem::copy_options::overwrite_existing);
+
+ /* Fix the <Id> tag */
+ {
+ Editor editor(source_subtitle_file);
+ editor.replace("4dd8ee05-5986-4c67-a6f8-bbeac62e21db", id);
+ }
+
+ /* Now make a project which imports that DCP and makes another DCP from it */
+ auto dcp_content = make_shared<DCPContent>(source->dir(source->dcp_name()));
+ auto film = new_test_film2("make_dcp_with_subs_without_font_tag", { dcp_content });
+ BOOST_REQUIRE(!dcp_content->text.empty());
+ dcp_content->text.front()->set_use(true);
+ make_and_verify_dcp(
+ film,
+ {
+ dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
+ dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
+ dcp::VerificationNote::Code::MISSING_CPL_METADATA
+ });
+
+ auto check_file = subtitle_file(film);
+ dcp::SMPTESubtitleAsset check_asset(check_file);
+ BOOST_CHECK_EQUAL(check_asset.load_font_nodes().size(), 1U);
+ auto check_font_data = check_asset.font_data();
+ BOOST_CHECK_EQUAL(check_font_data.size(), 1U);
+ BOOST_CHECK(check_font_data.begin()->second == dcp::ArrayData(default_font_file()));
+}
+