summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-04-13 23:39:40 +0200
committerCarl Hetherington <cth@carlh.net>2023-04-13 23:39:40 +0200
commit776836d2700123f8a0f109d3a2ac00fad5cdfd48 (patch)
tree1d73fdcd93480d461405483f115ea8a723d1d667 /src
parentb87af40c55522bae1f23ac43cd25698c0a21f75d (diff)
Add check for Interop font assets being present (in the ASSETMAP and on disk).
Diffstat (limited to 'src')
-rw-r--r--src/interop_subtitle_asset.cc13
-rw-r--r--src/interop_subtitle_asset.h6
-rw-r--r--src/verify.cc6
-rw-r--r--src/verify.h4
4 files changed, 29 insertions, 0 deletions
diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc
index b815da55..24cd907d 100644
--- a/src/interop_subtitle_asset.cc
+++ b/src/interop_subtitle_asset.cc
@@ -309,3 +309,16 @@ InteropSubtitleAsset::set_font_file (string load_id, boost::filesystem::path fil
}
}
+
+vector<string>
+InteropSubtitleAsset::unresolved_fonts() const
+{
+ vector<string> unresolved;
+ for (auto load_font_node: _load_font_nodes) {
+ if (std::find_if(_fonts.begin(), _fonts.end(), [load_font_node](Font const& font) { return font.load_id == load_font_node->id; }) == _fonts.end()) {
+ unresolved.push_back(load_font_node->id);
+ }
+ }
+ return unresolved;
+}
+
diff --git a/src/interop_subtitle_asset.h b/src/interop_subtitle_asset.h
index 23cf0b49..467728db 100644
--- a/src/interop_subtitle_asset.h
+++ b/src/interop_subtitle_asset.h
@@ -85,6 +85,12 @@ public:
void add_font_assets (std::vector<std::shared_ptr<Asset>>& assets);
void set_font_file (std::string load_id, boost::filesystem::path file);
+ /** @return the <LoadFont> IDs of fonts for which we have not (yet) found a font asset.
+ * This could be because resolve_fonts() has not yet been called, or because there is
+ * a missing font file.
+ */
+ std::vector<std::string> unresolved_fonts() const;
+
/** Set the reel number or sub-element identifier
* of these subtitles.
* @param n New reel number.
diff --git a/src/verify.cc b/src/verify.cc
index ab66a00e..d43c7ff1 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -715,6 +715,10 @@ verify_interop_subtitle_asset(shared_ptr<const InteropSubtitleAsset> asset, vect
if (asset->subtitles().empty()) {
notes.push_back({VerificationNote::Type::ERROR, VerificationNote::Code::MISSING_SUBTITLE, asset->id(), asset->file().get() });
}
+ auto const unresolved = asset->unresolved_fonts();
+ if (!unresolved.empty()) {
+ notes.push_back({VerificationNote::Type::ERROR, VerificationNote::Code::MISSING_FONT, unresolved.front() });
+ }
}
@@ -2008,6 +2012,8 @@ dcp::note_to_string (VerificationNote note)
return String::compose("The sound assets do not all have the same channel count; the first to differ is %1", note.file()->filename());
case VerificationNote::Code::INVALID_MAIN_SOUND_CONFIGURATION:
return String::compose("<MainSoundConfiguration> has an invalid value: %1", note.note().get());
+ case VerificationNote::Code::MISSING_FONT:
+ return String::compose("The font file for font ID \"%1\" was not found, or was not referred to in the ASSETMAP.", note.note().get());
}
return "";
diff --git a/src/verify.h b/src/verify.h
index 7696ea85..ed5cac4c 100644
--- a/src/verify.h
+++ b/src/verify.h
@@ -432,6 +432,10 @@ public:
* file contains the CPL filename
*/
INVALID_MAIN_SOUND_CONFIGURATION,
+ /** An interop subtitle file has a <LoadFont> node which refers to a font file that is not found.
+ * note contains the <LoadFont> ID
+ */
+ MISSING_FONT
};
VerificationNote (Type type, Code code)