summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-05-07 12:54:04 +0100
committerCarl Hetherington <cth@carlh.net>2015-05-07 12:54:04 +0100
commit0463cc5d09fd759a8ec3e40560ab8fd31c369876 (patch)
treeab2eaba3a7f939017c387e4765eb104ab81064b7 /src
parent21fb4ee6deb1321b37ad360cabdc8963774a4897 (diff)
parent3c5905314398833aafa54a91c59c16e4e0d87d8c (diff)
Merge branch '1.0' of git.carlh.net:git/dcpomatic into 2.0
Diffstat (limited to 'src')
-rw-r--r--src/lib/writer.cc46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 9f6886a21..31c265e2f 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -505,18 +505,6 @@ Writer::finish ()
}
if (_subtitle_content) {
- _subtitle_content->write_xml (_film->dir (_film->dcp_name ()) / _film->subtitle_xml_filename ());
- reel->add (shared_ptr<dcp::ReelSubtitleAsset> (
- new dcp::ReelSubtitleAsset (
- _subtitle_content,
- dcp::Fraction (_film->video_frame_rate(), 1),
- _picture_mxf->intrinsic_duration (),
- 0
- )
- ));
-
- 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 */
@@ -524,16 +512,34 @@ Writer::finish ()
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::filesystem::path to = _film->dir (_film->dcp_name ()) / _subtitle_content->id ();
+ boost::filesystem::create_directories (to, ec);
+ if (ec) {
+ throw FileError (_("Could not create directory"), to);
+ }
+
+ to /= 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 ()));
+ if (ec) {
+ throw FileError ("Could not copy font to DCP", from);
}
+
+ dcp.add (shared_ptr<dcp::Font> (new dcp::Font (to)));
}
+
+ _subtitle_content->write_xml (_film->dir (_film->dcp_name ()) / _subtitle_content->id () / _film->subtitle_xml_filename ());
+ reel->add (shared_ptr<dcp::ReelSubtitleAsset> (
+ new dcp::ReelSubtitleAsset (
+ _subtitle_content,
+ dcp::Fraction (_film->video_frame_rate(), 1),
+ _picture_mxf->intrinsic_duration (),
+ 0
+ )
+ ));
+
+ dcp.add (_subtitle_content);
}
cpl->add (reel);
@@ -663,7 +669,11 @@ Writer::write (PlayerSubtitles subs)
}
if (!_subtitle_content) {
- _subtitle_content.reset (new dcp::InteropSubtitleContent (_film->name(), _film->subtitle_language ()));
+ string lang = _film->subtitle_language ();
+ if (lang.empty ()) {
+ lang = "Unknown";
+ }
+ _subtitle_content.reset (new dcp::InteropSubtitleContent (_film->name(), lang));
}
for (list<dcp::SubtitleString>::const_iterator i = subs.text.begin(); i != subs.text.end(); ++i) {