+ if (asset) {
+ /* Add the font to the subtitle content */
+ for (auto const& j: fonts) {
+ asset->add_font (j.id, j.data.get_value_or(default_font));
+ }
+
+ if (auto interop = dynamic_pointer_cast<dcp::InteropSubtitleAsset>(asset)) {
+ auto directory = output_dcp / interop->id ();
+ boost::filesystem::create_directories (directory);
+ interop->write (directory / ("sub_" + interop->id() + ".xml"));
+ reel_asset = make_shared<Interop> (
+ interop,
+ dcp::Fraction(film->video_frame_rate(), 1),
+ picture_duration,
+ 0
+ );
+ } else if (auto smpte = dynamic_pointer_cast<dcp::SMPTESubtitleAsset>(asset)) {
+ /* All our assets should be the same length; use the picture asset length here
+ as a reference to set the subtitle one. We'll use the duration rather than
+ the intrinsic duration; we don't care if the picture asset has been trimmed, we're
+ just interested in its presentation length.
+ */
+ smpte->set_intrinsic_duration(picture_duration);
+ smpte->write (
+ output_dcp / ("sub_" + asset->id() + ".mxf")
+ );
+ reel_asset = make_shared<SMPTE> (
+ smpte,
+ dcp::Fraction(film->video_frame_rate(), 1),
+ picture_duration,
+ 0
+ );
+ }
+
+ } else {
+ /* We don't have a subtitle asset of our own; hopefully we have one to reference */
+ for (auto j: refs) {
+ auto k = dynamic_pointer_cast<Result> (j.asset);
+ if (k && j.period == period) {
+ reel_asset = k;
+ /* If we have a hash for this asset in the CPL, assume that it is correct */
+ if (k->hash()) {
+ k->asset_ref()->set_hash (k->hash().get());
+ }
+ }
+ }
+ }
+
+ if (reel_asset) {
+ if (!text_only && reel_asset->actual_duration() != period_duration) {
+ throw ProgrammingError (
+ __FILE__, __LINE__,
+ String::compose ("%1 vs %2", reel_asset->actual_duration(), period_duration)
+ );
+ }
+ reel->add (reel_asset);
+ }
+
+ return reel_asset;
+}
+
+
+shared_ptr<dcp::ReelPictureAsset>
+ReelWriter::create_reel_picture (shared_ptr<dcp::Reel> reel, list<ReferencedReelAsset> const & refs) const
+{
+ shared_ptr<dcp::ReelPictureAsset> reel_asset;