- BOOST_FOREACH (StringText i, subs.string) {
- /* XXX: couldn't / shouldn't we use period here rather than getting time from the subtitle? */
- i.set_in (i.in() - dcp::Time (_period.from.seconds(), i.in().tcr));
- i.set_out (i.out() - dcp::Time (_period.from.seconds(), i.out().tcr));
- asset->add (shared_ptr<dcp::Subtitle>(new dcp::SubtitleString(i)));
- }
-
- BOOST_FOREACH (BitmapText i, subs.bitmap) {
+ /* timecode rate for subtitles we emit; we might as well stick to ms accuracy here, I think */
+ auto const tcr = 1000;
+
+ for (auto i: subs.string) {
+ i.set_in (dcp::Time(period.from.seconds() - _period.from.seconds(), tcr));
+ i.set_out (dcp::Time(period.to.seconds() - _period.from.seconds(), tcr));
+ i.set_v_position(convert_vertical_position(i, film()->interop() ? dcp::SubtitleStandard::INTEROP : dcp::SubtitleStandard::SMPTE_2014));
+ auto sub = make_shared<dcp::SubtitleString>(i);
+ /* i.font is a shared_ptr<Font> which uniquely identifies the font we want,
+ * though if we are Interop we can only have one font, so we'll use the chosen
+ * one instead.
+ */
+ auto font = film()->interop() ? chosen_interop_font : i.font;
+ /* We can get the corresponding ID from fonts */
+ auto const font_id_to_use = fonts.get(font);
+ /* Give this subtitle the correct font ID */
+ sub->set_font(font_id_to_use);
+ asset->add(sub);
+ /* Make sure the asset LoadFonts the font we just asked for */
+ asset->ensure_font(font_id_to_use, font->data().get_value_or(_default_font));
+ }
+
+ for (auto i: subs.bitmap) {