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_subtitle_decoder.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_subtitle_decoder.cc')
| -rw-r--r-- | src/lib/dcp_subtitle_decoder.cc | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index b3e6d7553..711dc77f2 100644 --- a/src/lib/dcp_subtitle_decoder.cc +++ b/src/lib/dcp_subtitle_decoder.cc @@ -43,15 +43,22 @@ DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr<const Film> film, shared_ptr< : Decoder (film) { /* Load the XML or MXF file */ - auto const asset = load (content->path(0)); - asset->fix_empty_font_ids (); - _subtitles = asset->subtitles (); + _asset = load(content->path(0)); + _asset->fix_empty_font_ids(); + _subtitles = _asset->subtitles(); _next = _subtitles.begin (); - _subtitle_standard = asset->subtitle_standard(); + _subtitle_standard = _asset->subtitle_standard(); text.push_back (make_shared<TextDecoder>(this, content->only_text())); update_position(); + + FontIDAllocator font_id_allocator; + + for (auto node: _asset->load_font_nodes()) { + _font_id_allocator.add_font(0, _asset->id(), node->id); + } + _font_id_allocator.allocate(); } @@ -91,7 +98,13 @@ DCPSubtitleDecoder::pass () while (_next != _subtitles.end () && content_time_period (*_next) == p) { auto ns = dynamic_pointer_cast<const dcp::SubtitleString>(*_next); if (ns) { - s.push_back (*ns); + dcp::SubtitleString ns_copy = *ns; + if (ns_copy.font()) { + ns_copy.set_font(_font_id_allocator.font_id(0, _asset->id(), ns_copy.font().get())); + } else { + ns_copy.set_font(_font_id_allocator.default_font_id()); + } + s.push_back(ns_copy); ++_next; } else { /* XXX: perhaps these image subs should also be collected together like the string ones are; |
