diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/cross.cc | 19 | ||||
| -rw-r--r-- | src/lib/cross.h | 3 | ||||
| -rw-r--r-- | src/lib/dcp_subtitle_content.cc | 8 | ||||
| -rw-r--r-- | src/lib/font.h | 2 | ||||
| -rw-r--r-- | src/lib/util.cc | 2 | ||||
| -rw-r--r-- | src/lib/writer.cc | 34 | ||||
| -rw-r--r-- | src/lib/writer.h | 2 | ||||
| -rw-r--r-- | src/tools/dcpomatic_server.cc | 2 | ||||
| -rw-r--r-- | src/wx/wx_util.cc | 2 |
9 files changed, 52 insertions, 22 deletions
diff --git a/src/lib/cross.cc b/src/lib/cross.cc index e189222fa..7f95d1f71 100644 --- a/src/lib/cross.cc +++ b/src/lib/cross.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -151,6 +151,23 @@ app_contents () } #endif +boost::filesystem::path +shared_path () +{ +#ifdef DCPOMATIC_LINUX + return boost::filesystem::canonical (LINUX_SHARE_PREFIX); +#endif +#ifdef DCPOMATIC_WINDOWS + wchar_t dir[512]; + GetModuleFileName (GetModuleHandle (0), dir, sizeof (dir)); + PathRemoveFileSpec (dir); + return dir.parent_path(); +#endif +#ifdef DCPOMATIC_OSX + return app_contents(); +#endif +} + void run_ffprobe (boost::filesystem::path content, boost::filesystem::path out, shared_ptr<Log> log) { diff --git a/src/lib/cross.h b/src/lib/cross.h index 6a77aaa18..fee68cedc 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,6 +43,7 @@ extern boost::filesystem::path openssl_path (); #ifdef DCPOMATIC_OSX extern boost::filesystem::path app_contents (); #endif +extern boost::filesystem::path shared_path (); extern FILE * fopen_boost (boost::filesystem::path, std::string); extern int dcpomatic_fseek (FILE *, int64_t, int); diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc index f3198c58d..3f9772d59 100644 --- a/src/lib/dcp_subtitle_content.cc +++ b/src/lib/dcp_subtitle_content.cc @@ -22,7 +22,8 @@ #include "raw_convert.h" #include <dcp/interop_subtitle_content.h> #include <dcp/smpte_subtitle_content.h> -#include <dcp/interop_load_font.h> +#include <dcp/interop_load_font_node.h> +#include <boost/foreach.hpp> #include "i18n.h" @@ -57,9 +58,8 @@ DCPSubtitleContent::examine (shared_ptr<Job> job) _subtitle_language = sc->language (); _length = DCPTime::from_seconds (sc->latest_subtitle_out().to_seconds ()); - list<shared_ptr<dcp::LoadFont> > fonts = sc->load_font_nodes (); - for (list<shared_ptr<dcp::LoadFont> >::const_iterator i = fonts.begin(); i != fonts.end(); ++i) { - _fonts.push_back (shared_ptr<Font> (new Font ((*i)->id))); + BOOST_FOREACH (shared_ptr<dcp::LoadFontNode> i, sc->load_font_nodes ()) { + _fonts.push_back (shared_ptr<Font> (new Font (i->id))); } } diff --git a/src/lib/font.h b/src/lib/font.h index 7009555c4..8021ab5bc 100644 --- a/src/lib/font.h +++ b/src/lib/font.h @@ -35,7 +35,7 @@ public: void as_xml (xmlpp::Node* node); - /** Font ID */ + /** Font ID, used to describe it in the subtitle content */ std::string id; boost::optional<boost::filesystem::path> file; }; diff --git a/src/lib/util.cc b/src/lib/util.cc index 1c9968206..f98e5960b 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -381,7 +381,7 @@ dcpomatic_setup_gettext_i18n (string lang) #endif #ifdef DCPOMATIC_LINUX - bindtextdomain ("libdcpomatic", POSIX_LOCALE_PREFIX); + bindtextdomain ("libdcpomatic", LINUX_LOCALE_PREFIX); #endif } 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 diff --git a/src/lib/writer.h b/src/lib/writer.h index 68ac972ee..41d4d4474 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -152,4 +152,6 @@ private: boost::shared_ptr<dcp::SoundMXF> _sound_mxf; boost::shared_ptr<dcp::SoundMXFWriter> _sound_mxf_writer; boost::shared_ptr<dcp::InteropSubtitleContent> _subtitle_content; + + std::list<boost::shared_ptr<Font> > _fonts; }; diff --git a/src/tools/dcpomatic_server.cc b/src/tools/dcpomatic_server.cc index 9158a897e..8107949f5 100644 --- a/src/tools/dcpomatic_server.cc +++ b/src/tools/dcpomatic_server.cc @@ -108,7 +108,7 @@ public: #endif #ifdef __WXGTK__ wxInitAllImageHandlers(); - wxBitmap bitmap (wxString::Format (wxT ("%s/taskbar_icon.png"), POSIX_ICON_PREFIX), wxBITMAP_TYPE_PNG); + wxBitmap bitmap (wxString::Format (wxT ("%s/taskbar_icon.png"), LINUX_SHARE_PREFIX), wxBITMAP_TYPE_PNG); wxIcon icon; icon.CopyFromBitmap (bitmap); #endif diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index a46ba98e2..ea8255f81 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -272,7 +272,7 @@ dcpomatic_setup_i18n () #endif #ifdef DCPOMATIC_POSIX - locale->AddCatalogLookupPathPrefix (POSIX_LOCALE_PREFIX); + locale->AddCatalogLookupPathPrefix (LINUX_LOCALE_PREFIX); #endif #ifdef DCPOMATIC_LINUX |
