summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/hints.cc24
-rw-r--r--src/lib/render_text.cc6
-rw-r--r--src/lib/string_text.h2
-rw-r--r--test/render_subtitles_test.cc24
4 files changed, 43 insertions, 13 deletions
diff --git a/src/lib/hints.cc b/src/lib/hints.cc
index 99882ec0e..f3e91dbea 100644
--- a/src/lib/hints.cc
+++ b/src/lib/hints.cc
@@ -586,17 +586,19 @@ Hints::closed_caption(PlayerText text, DCPTimePeriod period)
{
int lines = text.string.size();
for (auto i: text.string) {
- if (utf8_strlen(i.text()) > MAX_CLOSED_CAPTION_LENGTH) {
- ++lines;
- if (!_long_ccap) {
- _long_ccap = true;
- hint(
- fmt::format(
- "At least one of your closed caption lines has more than {} characters. "
- "It is advisable to make each line {} characters at most in length.",
- MAX_CLOSED_CAPTION_LENGTH,
- MAX_CLOSED_CAPTION_LENGTH)
- );
+ if (auto text_string = i.string_text()) {
+ if (utf8_strlen(*text_string) > MAX_CLOSED_CAPTION_LENGTH) {
+ ++lines;
+ if (!_long_ccap) {
+ _long_ccap = true;
+ hint(
+ fmt::format(
+ "At least one of your closed caption lines has more than {} characters. "
+ "It is advisable to make each line {} characters at most in length.",
+ MAX_CLOSED_CAPTION_LENGTH,
+ MAX_CLOSED_CAPTION_LENGTH)
+ );
+ }
}
}
}
diff --git a/src/lib/render_text.cc b/src/lib/render_text.cc
index 3dcc317fa..7d9d1ea2e 100644
--- a/src/lib/render_text.cc
+++ b/src/lib/render_text.cc
@@ -151,7 +151,11 @@ marked_up(vector<StringText> subtitles, int target_height, float fade_factor, st
out += make_span(i, " ", "letter_spacing=\"" + fmt::to_string(std::round(spacing)) + "\"");
}
- out += make_span(i, i.text(), {});
+ if (i.string_text()) {
+ out += make_span(i, *i.string_text(), {});
+ } else {
+ out += make_span(i, i.ruby_text()->base, {});
+ }
}
return out;
diff --git a/src/lib/string_text.h b/src/lib/string_text.h
index d39a889cf..6908235f6 100644
--- a/src/lib/string_text.h
+++ b/src/lib/string_text.h
@@ -28,7 +28,7 @@
#include <dcp/text_string.h>
-/** A wrapper for SubtitleString which allows us to:
+/** A wrapper for dcp::TextString which allows us to:
*
* - include settings that are not applicable to true DCP subtitles.
* For example, we can set outline width for burn-in but this cannot be specified in DCP XML.
diff --git a/test/render_subtitles_test.cc b/test/render_subtitles_test.cc
index 4e87abde0..9f8792a40 100644
--- a/test/render_subtitles_test.cc
+++ b/test/render_subtitles_test.cc
@@ -227,6 +227,30 @@ BOOST_AUTO_TEST_CASE(render_text_with_stretch_test)
}
+BOOST_AUTO_TEST_CASE(render_ruby)
+{
+ auto dcp_string = dcp::TextString(
+ {}, true, false, false, dcp::Colour(255, 255, 255), 42, 1.0,
+ dcp::Time(0, 0, 0, 0, 24), dcp::Time(0, 0, 1, 0, 24),
+ 0.5, dcp::HAlign::CENTER,
+ 0.5, dcp::VAlign::CENTER,
+ 0.0,
+ vector<dcp::Text::VariableZPosition>(),
+ dcp::Direction::LTR,
+ "",
+ dcp::Effect::NONE, dcp::Colour(0, 0, 0),
+ {}, {},
+ 0,
+ std::vector<dcp::Ruby>{dcp::Ruby("新幹線", "しんかんせん")}
+ );
+
+ auto string_text = StringText(dcp_string, 0, make_shared<dcpomatic::Font>("foo"), dcp::SubtitleStandard::SMPTE_2014);
+ auto images = render_text({ string_text }, dcp::Size(1998, 1080), {}, 24);
+ BOOST_CHECK_EQUAL(images.size(), 1U);
+ image_as_png(Image::ensure_alignment(images.front().image, Image::Alignment::PADDED)).write("build/test/render_ruby.png");
+}
+
+
#if 0
BOOST_AUTO_TEST_CASE (render_text_test)