From e61cc4ff73a82ef0a6575ca5a6f960e1577af480 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 5 Mar 2025 00:47:24 +0100 Subject: Find missing fonts after finding missing content. --- src/lib/find_missing.cc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/lib') diff --git a/src/lib/find_missing.cc b/src/lib/find_missing.cc index 14394af04..ce8c65af3 100644 --- a/src/lib/find_missing.cc +++ b/src/lib/find_missing.cc @@ -84,6 +84,27 @@ search_by_name(Replacements& replacement_paths, boost::filesystem::path director } +static +void +search_by_name(map& replacements, boost::filesystem::path directory, int depth = 0) +{ + boost::system::error_code ec; + + for (auto candidate: dcp::filesystem::directory_iterator(directory, ec)) { + if (dcp::filesystem::is_regular_file(candidate.path())) { + for (auto& replacement: replacements) { + if (should_replace(replacement.first, candidate.path())) { + replacement.second = candidate.path(); + } + } + } else if (dcp::filesystem::is_directory(candidate.path()) && depth <= 2) { + search_by_name(replacements, candidate, depth + 1); + } + } +} + + + static void search_by_digest(Replacements& replacement_paths, boost::filesystem::path directory, int depth = 0) @@ -148,4 +169,20 @@ dcpomatic::find_missing (vector> content_to_fix, boost::file } } } + + /* Check fonts */ + for (auto content: content_to_fix) { + map fonts; + for (auto i: content->font_paths()) { + fonts[i] = i; + } + + search_by_name(fonts, is_directory(clue) ? clue : clue.parent_path()); + + for (auto const& font: fonts) { + if (font.first != font.second) { + content->replace_font_path(font.first, font.second); + } + } + } } -- cgit v1.2.3