From 0beaf6245ef0c1462cbe7eaf6faeabb651b68de3 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 28 Dec 2025 01:21:20 +0100 Subject: Fix closed caption layout in the presence of italics / other markup (#3067). --- src/lib/layout_closed_captions.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/layout_closed_captions.cc b/src/lib/layout_closed_captions.cc index 0f55f79f5..858b91c39 100644 --- a/src/lib/layout_closed_captions.cc +++ b/src/lib/layout_closed_captions.cc @@ -22,10 +22,12 @@ #include "dcpomatic_assert.h" #include "layout_closed_captions.h" #include "string_text.h" +#include "util.h" using std::string; using std::vector; +using boost::optional; vector @@ -48,8 +50,19 @@ layout_closed_captions(vector text) std::sort(text.begin(), text.end(), [&](StringText const & a, StringText const & b) { return from_top(a) < from_top(b); }); vector strings; + string current; + optional last_position; for (auto const& t: text) { - strings.push_back(t.text()); + if (last_position && !text_positions_close(*last_position, t.v_position()) && !current.empty()) { + strings.push_back(current); + current = ""; + } + current += t.text(); + last_position = t.v_position(); + } + + if (!current.empty()) { + strings.push_back(current); } return strings; -- cgit v1.2.3