diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-08-26 19:51:51 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-08-29 18:29:59 +0200 |
| commit | a2507e28a631ee68b0ba898b4fc0c22bbaa2eef2 (patch) | |
| tree | 6b889ad4c7f652a26920f283229a021943d7a1dd | |
| parent | 54b2c8580ee0553fbfb88e8881af60e3afa2e2fd (diff) | |
Fix incorrect horizontal positions when different HPositions are used with one VPosition.
Previously if HPosition changed we would still use a single "line" (i.e. Pango layout)
for all the text, meaning that HPosition would not be respected.
| -rw-r--r-- | src/lib/render_text.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/render_text.cc b/src/lib/render_text.cc index 84fc8414d..ddfccbde8 100644 --- a/src/lib/render_text.cc +++ b/src/lib/render_text.cc @@ -408,9 +408,15 @@ render_text(vector<StringText> subtitles, dcp::Size target, DCPTime time, int fr vector<PositionImage> images; for (auto const& i: subtitles) { - if (!pending.empty() && (i.v_align() != pending.back().v_align() || fabs(i.v_position() - pending.back().v_position()) > 1e-4)) { - images.push_back(render_line(pending, target, time, frame_rate)); - pending.clear (); + if (!pending.empty()) { + auto const last = pending.back(); + auto const different_v = i.v_align() != last.v_align() || fabs(i.v_position() - last.v_position()) > 1e-4; + auto const different_h = i.h_align() != last.h_align() || fabs(i.h_position() - pending.back().h_position()) > 1e-4; + if (different_v || different_h) { + /* We need a new line if any new positioning (horizontal or vertical) changes for this section */ + images.push_back(render_line(pending, target, time, frame_rate)); + pending.clear (); + } } pending.push_back (i); } |
