Fix failure to examine non-flat-ratio VFs (#2775).
[dcpomatic.git] / src / lib / dcp_examiner.cc
index 400c7d26ba86eeb35799276af4cdce24a3b87517..88c9a5b700a64e279c5b459610c29f70955ec1d3 100644 (file)
@@ -25,6 +25,7 @@
 #include "dcp_examiner.h"
 #include "dcpomatic_log.h"
 #include "exceptions.h"
+#include "font_id_allocator.h"
 #include "image.h"
 #include "text_content.h"
 #include "util.h"
@@ -144,8 +145,6 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
                        if (!reel->main_picture()->asset_ref().resolved()) {
                                LOG_GENERAL("Main picture %1 of reel %2 is missing", reel->main_picture()->id(), reel->id());
                                _needs_assets = true;
-                               /* Use a dummy value here; it will be replaced when the VF is re-examined. */
-                               _video_size = dcp::Size(1998, 1080);
                        } else {
                                LOG_GENERAL("Main picture %1 of reel %2 found", reel->main_picture()->id(), reel->id());
 
@@ -210,7 +209,6 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
                                for (auto const& font: asset->font_data()) {
                                        _fonts.push_back({reel_index, asset->id(), make_shared<dcpomatic::Font>(font.first, font.second)});
                                }
-                               _fonts.push_back({reel_index, asset->id(), make_shared<dcpomatic::Font>("")});
                        }
                }
 
@@ -237,9 +235,6 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
                                for (auto const& font: asset->font_data()) {
                                        _fonts.push_back({reel_index, asset->id(), make_shared<dcpomatic::Font>(font.first, font.second)});
                                }
-                               if (asset->font_data().empty()) {
-                                       _fonts.push_back({reel_index, asset->id(), make_shared<dcpomatic::Font>("")});
-                               }
                        }
                }
 
@@ -367,16 +362,22 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
 void
 DCPExaminer::add_fonts(shared_ptr<TextContent> content)
 {
+       FontIDAllocator font_id_allocator;
+
        for (auto const& font: _fonts) {
-               _font_id_allocator.add_font(font.reel_index, font.asset_id, font.font->id());
+               font_id_allocator.add_font(font.reel_index, font.asset_id, font.font->id());
        }
 
-       _font_id_allocator.allocate();
+       font_id_allocator.allocate();
 
        for (auto const& font: _fonts) {
                auto font_copy = make_shared<dcpomatic::Font>(*font.font);
-               font_copy->set_id(_font_id_allocator.font_id(font.reel_index, font.asset_id, font.font->id()));
+               font_copy->set_id(font_id_allocator.font_id(font.reel_index, font.asset_id, font.font->id()));
                content->add_font(font_copy);
        }
+
+       if (!font_id_allocator.has_default_font()) {
+               content->add_font(make_shared<dcpomatic::Font>(font_id_allocator.default_font_id(), default_font_file()));
+       }
 }