diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-04-30 22:20:57 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-04-30 22:20:57 +0100 |
| commit | a5e87b6f0f496f4ed71d9129d40a5baebb68495f (patch) | |
| tree | a9f7dcf6a2020e986e1d709f24ce46e51d238ca2 /src/lib/writer.cc | |
| parent | 895e908f7dcc8deb9e6a333d3d6b3a92aec2dc09 (diff) | |
Various bits related to subtitle font handling, particularly copying fonts to the DCP.
Diffstat (limited to 'src/lib/writer.cc')
| -rw-r--r-- | src/lib/writer.cc | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 8d73b3126..9f6886a21 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -46,6 +46,8 @@ #include <dcp/cpl.h> #include <dcp/signer.h> #include <dcp/interop_subtitle_content.h> +#include <dcp/font.h> +#include <boost/foreach.hpp> #include <fstream> #include <cerrno> @@ -514,6 +516,24 @@ Writer::finish () )); dcp.add (_subtitle_content); + + boost::filesystem::path const liberation = shared_path () / "LiberationSans-Regular.ttf"; + + /* Add all the fonts to the subtitle content and as assets to the DCP */ + BOOST_FOREACH (shared_ptr<Font> i, _fonts) { + boost::filesystem::path const from = i->file.get_value_or (liberation); + _subtitle_content->add_font (i->id, from.leaf().string ()); + + boost::filesystem::path to = _film->dir (_film->dcp_name ()) / from.leaf(); + + boost::system::error_code ec; + boost::filesystem::copy_file (from, to, ec); + if (!ec) { + dcp.add (shared_ptr<dcp::Font> (new dcp::Font (to))); + } else { + LOG_WARNING_NC (String::compose ("Could not copy font %1 to DCP", from.string ())); + } + } } cpl->add (reel); @@ -654,18 +674,8 @@ Writer::write (PlayerSubtitles subs) void Writer::write (list<shared_ptr<Font> > fonts) { - if (fonts.empty ()) { - return; - } - - if (!_subtitle_content) { - _subtitle_content.reset (new dcp::InteropSubtitleContent (_film->name(), _film->subtitle_language ())); - } - - for (list<shared_ptr<Font> >::const_iterator i = fonts.begin(); i != fonts.end(); ++i) { - /* XXX: this LiberationSans-Regular needs to be a path to a DCP-o-matic-distributed copy */ - _subtitle_content->add_font ((*i)->id, (*i)->file.get_value_or ("LiberationSans-Regular.ttf").leaf().string ()); - } + /* Just keep a list of fonts and we'll deal with them in ::finish */ + copy (fonts.begin (), fonts.end (), back_inserter (_fonts)); } bool |
