*/
+#include "font.h"
#include "subtitle_encoder.h"
#include "player.h"
#include "compose.hpp"
using boost::optional;
using dcp::raw_convert;
-SubtitleEncoder::SubtitleEncoder (shared_ptr<const Film> film, shared_ptr<Job> job, boost::filesystem::path output, bool split_reels)
+/** @param include_font true to refer to and export any font file (for Interop; ignored for SMPTE) */
+SubtitleEncoder::SubtitleEncoder (shared_ptr<const Film> film, shared_ptr<Job> job, boost::filesystem::path output, bool split_reels, bool include_font)
: Encoder (film, job)
, _split_reels (split_reels)
+ , _include_font (include_font)
, _reel_index (0)
, _length (film->length())
{
}
}
+ 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());
+ }
+ }
+
i->first->write (i->second);
++reel;
}
/* XXX: couldn't / shouldn't we use period here rather than getting time from the subtitle? */
i.set_in (i.in());
i.set_out (i.out());
+ if (_film->interop() && !_include_font) {
+ i.unset_font ();
+ }
_assets[_reel_index].first->add (shared_ptr<dcp::Subtitle>(new dcp::SubtitleString(i)));
}
class SubtitleEncoder : public Encoder
{
public:
- SubtitleEncoder (boost::shared_ptr<const Film> film, boost::shared_ptr<Job> job, boost::filesystem::path output, bool split_reels);
+ SubtitleEncoder (boost::shared_ptr<const Film> film, boost::shared_ptr<Job> job, boost::filesystem::path output, bool split_reels, bool include_font);
void go ();
std::vector<std::pair<boost::shared_ptr<dcp::SubtitleAsset>, boost::filesystem::path> > _assets;
std::vector<dcpomatic::DCPTimePeriod> _reels;
bool _split_reels;
+ bool _include_font;
int _reel_index;
boost::optional<dcpomatic::DCPTime> _last;
dcpomatic::DCPTime _length;
void jobs_export_subtitles ()
{
- ExportSubtitlesDialog* d = new ExportSubtitlesDialog (this, _film->isdcf_name(true));
+ ExportSubtitlesDialog* d = new ExportSubtitlesDialog (this, _film->isdcf_name(true), _film->interop());
if (d->ShowModal() == wxID_OK) {
if (boost::filesystem::exists(d->path())) {
bool ok = confirm_dialog(
shared_ptr<TranscodeJob> job (new TranscodeJob (_film));
job->set_encoder (
- shared_ptr<SubtitleEncoder>(new SubtitleEncoder(_film, job, d->path(), d->split_reels()))
+ shared_ptr<SubtitleEncoder>(new SubtitleEncoder(_film, job, d->path(), d->split_reels(), d->include_font()))
);
JobManager::instance()->add (job);
}
using boost::bind;
-ExportSubtitlesDialog::ExportSubtitlesDialog (wxWindow* parent, string name)
+ExportSubtitlesDialog::ExportSubtitlesDialog (wxWindow* parent, string name, bool interop)
: TableDialog (parent, _("Export subtitles"), 2, 1, true)
, _initial_name (name)
+ , _include_font (0)
{
_split_reels = new CheckBox (this, _("Write reels into separate files"));
add (_split_reels, false);
add_spacer ();
+ if (interop) {
+ _include_font = new CheckBox (this, _("Define font in output and export font file"));
+ add (_include_font, false);
+ add_spacer ();
+ }
add (_("Output file"), true);
/* Don't warn overwrite here, because on Linux (at least) if we specify a filename like foo
}
+bool
+ExportSubtitlesDialog::include_font () const
+{
+ return _include_font ? _include_font->GetValue () : true;
+}
+
+
void
ExportSubtitlesDialog::file_changed ()
{
- wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
+ wxButton* ok = dynamic_cast<wxButton *> (FindWindowById(wxID_OK, this));
DCPOMATIC_ASSERT (ok);
ok->Enable (path().is_absolute());
}
class ExportSubtitlesDialog : public TableDialog
{
public:
- ExportSubtitlesDialog (wxWindow* parent, std::string name);
+ ExportSubtitlesDialog (wxWindow* parent, std::string name, bool interop);
boost::filesystem::path path () const;
bool split_reels () const;
+ bool include_font () const;
private:
void file_changed ();
std::string _initial_name;
wxCheckBox* _split_reels;
+ wxCheckBox* _include_font;
FilePickerCtrl* _file;
};