+ list<dcp::SubtitleString> out;
+ BOOST_FOREACH (sub::Line i, subtitle.lines) {
+ BOOST_FOREACH (sub::Block j, i.blocks) {
+
+ if (!j.font_size.specified()) {
+ /* Fallback default font size if no other has been specified */
+ j.font_size.set_points (48);
+ }
+
+ float v_position;
+ dcp::VAlign v_align;
+ if (needs_placement) {
+ DCPOMATIC_ASSERT (i.vertical_position.line);
+ /* This 1.015 is an arbitrary value to lift the bottom sub off the bottom
+ of the screen a bit to a pleasing degree.
+ */
+ v_position = 1.015 -
+ (1 + bottom_line.get() - i.vertical_position.line.get())
+ * 1.2 * content()->line_spacing() * content()->y_scale() * j.font_size.proportional (72 * 11);
+
+ v_align = dcp::VALIGN_TOP;
+ } else {
+ DCPOMATIC_ASSERT (i.vertical_position.proportional);
+ DCPOMATIC_ASSERT (i.vertical_position.reference);
+ v_position = i.vertical_position.proportional.get();
+
+ if (lowest_proportional) {
+ /* Adjust line spacing */
+ v_position = ((v_position - lowest_proportional.get()) * content()->line_spacing()) + lowest_proportional.get();
+ }
+
+ switch (i.vertical_position.reference.get()) {
+ case sub::TOP_OF_SCREEN:
+ v_align = dcp::VALIGN_TOP;
+ break;
+ case sub::VERTICAL_CENTRE_OF_SCREEN:
+ v_align = dcp::VALIGN_CENTER;
+ break;
+ case sub::BOTTOM_OF_SCREEN:
+ v_align = dcp::VALIGN_BOTTOM;
+ break;
+ default:
+ v_align = dcp::VALIGN_TOP;
+ break;
+ }
+ }
+
+ dcp::HAlign h_align;
+ switch (i.horizontal_position.reference) {
+ case sub::LEFT_OF_SCREEN:
+ h_align = dcp::HALIGN_LEFT;
+ break;
+ case sub::HORIZONTAL_CENTRE_OF_SCREEN:
+ h_align = dcp::HALIGN_CENTER;
+ break;
+ case sub::RIGHT_OF_SCREEN:
+ h_align = dcp::HALIGN_RIGHT;
+ break;
+ default:
+ h_align = dcp::HALIGN_CENTER;
+ break;
+ }
+
+ /* The idea here (rightly or wrongly) is that we set the appearance based on the
+ values in the libsub objects, and these are overridden with values from the
+ content by the other emit_text_start() above.
+ */
+
+ out.push_back (
+ dcp::SubtitleString (
+ string(TEXT_FONT_ID),
+ j.italic,
+ j.bold,
+ j.underline,
+ j.colour.dcp(),
+ j.font_size.points (72 * 11),
+ 1.0,
+ dcp::Time (from.seconds(), 1000),
+ /* XXX: hmm; this is a bit ugly (we don't know the to time yet) */
+ dcp::Time (),
+ i.horizontal_position.proportional,
+ h_align,
+ v_position,
+ v_align,
+ dcp::DIRECTION_LTR,
+ j.text,
+ dcp::NONE,
+ j.effect_colour.get_value_or(sub::Colour(0, 0, 0)).dcp(),
+ /* Hack: we should use subtitle.fade_up and subtitle.fade_down here
+ but the times of these often don't have a frame rate associated
+ with them so the sub::Time won't convert them to milliseconds without
+ throwing an exception. Since only DCP subs fill those in (and we don't
+ use libsub for DCP subs) we can cheat by just putting 0 in here.
+ */
+ dcp::Time (),
+ dcp::Time ()
+ )
+ );