- 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 (),
- h_position,
- h_align,
- v_position,
- v_align,
- dcp::Direction::LTR,
- j.text,
- dcp::Effect::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 (),
- 0
- )
+ auto dcp_colour = [](sub::Colour const& c) {
+ return dcp::Colour(lrintf(c.r * 255), lrintf(c.g * 255), lrintf(c.b * 255));
+ };
+
+ auto dcp_subtitle = dcp::SubtitleString(
+ optional<string>(),
+ block.italic,
+ block.bold,
+ block.underline,
+ dcp_colour(block.colour),
+ block.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 (),
+ h_position,
+ h_align,
+ v_position,
+ v_align,
+ 0,
+ dcp::Direction::LTR,
+ remove_invalid_characters_for_xml(block.text),
+ dcp::Effect::NONE,
+ dcp_colour(block.effect_colour.get_value_or(sub::Colour(0, 0, 0))),
+ /* 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 (),
+ 0,
+ std::vector<dcp::Ruby>()
+ );
+
+ auto font = content()->get_font(block.font.get_value_or(""));
+ DCPOMATIC_ASSERT(font);
+
+ auto string_text = StringText(
+ dcp_subtitle,
+ content()->outline_width(),
+ font,
+ dcp::SubtitleStandard::SMPTE_2014