std::shared_ptr
[dcpomatic.git] / src / lib / subtitle_encoder.cc
index 5e76f5e738d294449c7a33e5bb0e970be7c50cbd..1a83c5c67fe868eace79fa82e1ccff390bab3a41 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2019-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -18,7 +18,7 @@
 
 */
 
-#include "font.h"
+#include "font_data.h"
 #include "subtitle_encoder.h"
 #include "player.h"
 #include "compose.hpp"
@@ -26,9 +26,8 @@
 #include <dcp/interop_subtitle_asset.h>
 #include <dcp/raw_convert.h>
 #include <dcp/smpte_subtitle_asset.h>
-#include <boost/shared_ptr.hpp>
 #include <boost/filesystem.hpp>
-#include <boost/bind.hpp>
+#include <boost/bind/bind.hpp>
 
 #include "i18n.h"
 
@@ -36,8 +35,11 @@ using std::string;
 using std::make_pair;
 using std::pair;
 using std::vector;
-using boost::shared_ptr;
+using std::shared_ptr;
 using boost::optional;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
 using dcp::raw_convert;
 
 /** @param output Directory, if there will be multiple output files, or a filename.
@@ -78,6 +80,8 @@ SubtitleEncoder::SubtitleEncoder (shared_ptr<const Film> film, shared_ptr<Job> j
        BOOST_FOREACH (dcpomatic::DCPTimePeriod i, film->reels()) {
                _reels.push_back (i);
        }
+
+       _default_font = dcp::ArrayData (default_font_file());
 }
 
 void
@@ -111,8 +115,8 @@ SubtitleEncoder::go ()
                }
 
                if (!_film->interop() || _include_font) {
-                       BOOST_FOREACH (shared_ptr<dcpomatic::Font> j, _player->get_subtitle_fonts()) {
-                               i->first->add_font (j->id(), default_font_file());
+                       BOOST_FOREACH (dcpomatic::FontData j, _player->get_subtitle_fonts()) {
+                               i->first->add_font (j.id, _default_font);
                        }
                }
 
@@ -134,16 +138,18 @@ SubtitleEncoder::text (PlayerText subs, TextType type, optional<DCPTextTrack> tr
                if (_film->interop ()) {
                        shared_ptr<dcp::InteropSubtitleAsset> s (new dcp::InteropSubtitleAsset());
                        s->set_movie_title (_film->name());
-                       s->set_language (lang.empty() ? "Unknown" : lang.front().to_string());
+                       if (!lang.empty()) {
+                               s->set_language (lang.front().to_string());
+                       }
                        s->set_reel_number (raw_convert<string>(_reel_index + 1));
                        _assets[_reel_index].first = s;
                } else {
                        shared_ptr<dcp::SMPTESubtitleAsset> s (new dcp::SMPTESubtitleAsset());
                        s->set_content_title_text (_film->name());
                        if (!lang.empty()) {
-                               s->set_language (lang.front().to_string());
-                       } else {
-                               s->set_language (track->language);
+                               s->set_language (lang.front());
+                       } else if (!track->language.empty()) {
+                               s->set_language (dcp::LanguageTag(track->language));
                        }
                        s->set_edit_rate (dcp::Fraction (_film->video_frame_rate(), 1));
                        s->set_reel_number (_reel_index + 1);