diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-01-13 23:34:35 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-01-15 10:21:59 +0100 |
| commit | db22f81ccce9e1a5f205e6d8b3c0631fc039a173 (patch) | |
| tree | 263c2a28165fe5d3cf03bae25d19cd60b0640bfd /src/lib/dcp_examiner.cc | |
| parent | 7a301e22de2a3c47a81ebc4c9f19b68131b482aa (diff) | |
Fix handling of empty font IDs and default DCP fonts (#2721) (part of #2722).
Previously we used an empty font ID as the default for when a subtitle
has no Font, but in #2721 we saw a DCP with an empty font ID which
raised an assertion (because we'd already added our default font with
the empty ID).
Here we try to fix this (and also make the default font correctly be
that from the first <LoadFont>).
Diffstat (limited to 'src/lib/dcp_examiner.cc')
| -rw-r--r-- | src/lib/dcp_examiner.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index 400c7d26b..d9c904720 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -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" @@ -210,7 +211,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>("")}); } } @@ -367,16 +367,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())); + } } |
