diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-06-01 13:03:38 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-06-07 17:01:06 +0200 |
| commit | 5a820bb8fae34591be5ac6d19a73461b9dab532a (patch) | |
| tree | 098e2dc959b6df0fefa62b2976976afc9f81b96b /src/lib/reel_writer.cc | |
| parent | 9a7b67aee32a40539f29bc2d7017edd4a4f65f11 (diff) | |
Rearrange subtitle font management.
With this change each subtitle coming out of the player has a reference
to a dcpomatic::Font that belongs to the TextContent. This hopefully
solves a few problems which all basically stemmed from the fact that
previously the decoders/player were deciding what the font ID in the
output DCP would be - they can't do that properly.
Diffstat (limited to 'src/lib/reel_writer.cc')
| -rw-r--r-- | src/lib/reel_writer.cc | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index 2f28ef9d4..30650cf7d 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -26,7 +26,6 @@ #include "dcpomatic_log.h" #include "digester.h" #include "film.h" -#include "font_data.h" #include "image.h" #include "image_png.h" #include "job.h" @@ -463,7 +462,8 @@ maybe_add_text ( int reel_count, optional<string> content_summary, list<ReferencedReelAsset> const & refs, - vector<FontData> const & fonts, + FontIdMap const& fonts, + shared_ptr<dcpomatic::Font> chosen_interop_font, dcp::ArrayData default_font, shared_ptr<const Film> film, DCPTimePeriod period, @@ -476,9 +476,17 @@ maybe_add_text ( shared_ptr<Result> reel_asset; if (asset) { - /* Add the font to the subtitle content */ - for (auto const& j: fonts) { - asset->add_font (j.id, j.data.get_value_or(default_font)); + if (film->interop()) { + if (chosen_interop_font) { + /* We only add one font, as Interop will ignore subsequent ones (and some validators will + * complain if they are even present) + */ + asset->add_font(fonts.get(chosen_interop_font), chosen_interop_font->data().get_value_or(default_font)); + } + } else { + for (auto const& font: fonts.map()) { + asset->add_font(font.second, font.first->data().get_value_or(default_font)); + } } if (auto interop = dynamic_pointer_cast<dcp::InteropSubtitleAsset>(asset)) { @@ -638,7 +646,8 @@ void ReelWriter::create_reel_text ( shared_ptr<dcp::Reel> reel, list<ReferencedReelAsset> const & refs, - vector<FontData> const& fonts, + FontIdMap const& fonts, + shared_ptr<dcpomatic::Font> chosen_interop_font, int64_t duration, boost::filesystem::path output_dcp, bool ensure_subtitles, @@ -646,7 +655,7 @@ ReelWriter::create_reel_text ( ) const { auto subtitle = maybe_add_text<dcp::ReelInteropSubtitleAsset, dcp::ReelSMPTESubtitleAsset, dcp::ReelSubtitleAsset> ( - _subtitle_asset, duration, reel, _reel_index, _reel_count, _content_summary, refs, fonts, _default_font, film(), _period, output_dcp, _text_only + _subtitle_asset, duration, reel, _reel_index, _reel_count, _content_summary, refs, fonts, chosen_interop_font, _default_font, film(), _period, output_dcp, _text_only ); if (subtitle) { @@ -665,6 +674,7 @@ ReelWriter::create_reel_text ( _content_summary, refs, fonts, + chosen_interop_font, _default_font, film(), _period, @@ -675,7 +685,7 @@ ReelWriter::create_reel_text ( for (auto const& i: _closed_caption_assets) { auto a = maybe_add_text<dcp::ReelInteropClosedCaptionAsset, dcp::ReelSMPTEClosedCaptionAsset, dcp::ReelClosedCaptionAsset> ( - i.second, duration, reel, _reel_index, _reel_count, _content_summary, refs, fonts, _default_font, film(), _period, output_dcp, _text_only + i.second, duration, reel, _reel_index, _reel_count, _content_summary, refs, fonts, chosen_interop_font, _default_font, film(), _period, output_dcp, _text_only ); DCPOMATIC_ASSERT (a); a->set_annotation_text (i.first.name); @@ -697,6 +707,7 @@ ReelWriter::create_reel_text ( _content_summary, refs, fonts, + chosen_interop_font, _default_font, film(), _period, @@ -742,7 +753,8 @@ ReelWriter::create_reel_markers (shared_ptr<dcp::Reel> reel) const shared_ptr<dcp::Reel> ReelWriter::create_reel ( list<ReferencedReelAsset> const & refs, - vector<FontData> const & fonts, + FontIdMap const & fonts, + shared_ptr<dcpomatic::Font> chosen_interop_font, boost::filesystem::path output_dcp, bool ensure_subtitles, set<DCPTextTrack> ensure_closed_captions @@ -764,7 +776,7 @@ ReelWriter::create_reel ( create_reel_markers (reel); } - create_reel_text (reel, refs, fonts, duration, output_dcp, ensure_subtitles, ensure_closed_captions); + create_reel_text (reel, refs, fonts, chosen_interop_font, duration, output_dcp, ensure_subtitles, ensure_closed_captions); if (_atmos_asset) { reel->add (make_shared<dcp::ReelAtmosAsset>(_atmos_asset, 0)); @@ -880,7 +892,7 @@ ReelWriter::empty_text_asset (TextType type, optional<DCPTextTrack> track, bool void -ReelWriter::write (PlayerText subs, TextType type, optional<DCPTextTrack> track, DCPTimePeriod period) +ReelWriter::write (PlayerText subs, TextType type, optional<DCPTextTrack> track, DCPTimePeriod period, FontIdMap const& fonts) { shared_ptr<dcp::SubtitleAsset> asset; @@ -918,7 +930,11 @@ ReelWriter::write (PlayerText subs, TextType type, optional<DCPTextTrack> track, for (auto i: subs.string) { i.set_in (dcp::Time(period.from.seconds() - _period.from.seconds(), tcr)); i.set_out (dcp::Time(period.to.seconds() - _period.from.seconds(), tcr)); - asset->add (make_shared<dcp::SubtitleString>(i)); + auto sub = make_shared<dcp::SubtitleString>(i); + if (type == TextType::OPEN_SUBTITLE) { + sub->set_font(fonts.get(i.font)); + } + asset->add(sub); } for (auto i: subs.bitmap) { |
