- 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 ();
+ }