summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-09-20 12:22:02 +0200
committerCarl Hetherington <cth@carlh.net>2022-09-20 21:24:16 +0200
commitff639b3cf30afcc097bfd21d39c8d15f466cadd6 (patch)
tree4f45b9c9007bd9fd36f39ed11f045e6fbfbef786
parentdc5e11944a30a9d381dc0e67cf657c5f2cb65845 (diff)
Fix font_id_map errors when importing DCP subtitles that have no
font declarations / tags (#2339).
-rw-r--r--src/lib/dcp_subtitle_content.cc4
-rw-r--r--src/lib/text_decoder.cc2
m---------test/data0
-rw-r--r--test/subtitle_font_id_test.cc23
4 files changed, 28 insertions, 1 deletions
diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc
index a6cfd8d93..b111bdb2a 100644
--- a/src/lib/dcp_subtitle_content.cc
+++ b/src/lib/dcp_subtitle_content.cc
@@ -83,6 +83,10 @@ DCPSubtitleContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
only_text()->add_font(make_shared<Font>(node->id));
}
}
+
+ if (only_text()->fonts().empty()) {
+ only_text()->add_font(make_shared<Font>(""));
+ }
}
DCPTime
diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc
index c691f795d..fa5ed6c7a 100644
--- a/src/lib/text_decoder.cc
+++ b/src/lib/text_decoder.cc
@@ -110,7 +110,7 @@ TextDecoder::emit_plain_start (ContentTime from, vector<dcp::SubtitleString> sub
auto string_text = StringText(
subtitle,
content()->outline_width(),
- subtitle.font() ? content()->get_font(*subtitle.font()) : shared_ptr<Font>(),
+ content()->get_font(subtitle.font().get_value_or("")),
valign_standard
);
string_text.set_text(escape_text(string_text.text()));
diff --git a/test/data b/test/data
-Subproject a92011d3c4ebe0e443b6ea37c749f27c9102c15
+Subproject 04fc3a153081196d7f67ccf3aea1dc04f5a8b51
diff --git a/test/subtitle_font_id_test.cc b/test/subtitle_font_id_test.cc
index 51bccc70a..5bcf454bd 100644
--- a/test/subtitle_font_id_test.cc
+++ b/test/subtitle_font_id_test.cc
@@ -24,6 +24,7 @@
#include "lib/film.h"
#include "lib/font.h"
#include "lib/text_content.h"
+#include <dcp/smpte_subtitle_asset.h>
#include "test.h"
#include <boost/test/unit_test.hpp>
@@ -100,3 +101,25 @@ BOOST_AUTO_TEST_CASE(make_dcp_with_subs_from_mkv)
make_and_verify_dcp(film, { dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_2K });
}
+
+BOOST_AUTO_TEST_CASE(make_dcp_with_subs_without_font_tag)
+{
+ auto subs = content_factory("test/data/no_font.xml");
+ auto film = new_test_film2("make_dcp_with_subs_without_font_tag", { subs });
+ subs[0]->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()));
+}
+