diff options
| author | Carl Hetherington <cth@carlh.net> | 2026-06-28 15:37:54 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-06-28 15:37:54 +0200 |
| commit | 679d076c4d353b489bc4b9fe56c67937b8013c63 (patch) | |
| tree | 53c8eeeb2ecba9c1b38fcfe37af404d2338f6592 /src | |
| parent | 8626b10f3b3ca009fa13226ae299c7333b951b56 (diff) | |
Otherwise the vertical position of the lines might not be properly
respected.
Diffstat (limited to 'src')
| -rw-r--r-- | src/subrip_writer.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/subrip_writer.cc b/src/subrip_writer.cc index 80602d0..ac42ff3 100644 --- a/src/subrip_writer.cc +++ b/src/subrip_writer.cc @@ -21,6 +21,7 @@ #include "subrip_writer.h" #include "subtitle.h" #include <fmt/format.h> +#include <algorithm> #include <fstream> @@ -62,7 +63,9 @@ sub::write_subrip(vector<Subtitle> const& subtitles, boost::filesystem::path fil f << index << "\n"; f << time_to_subrip_string(sub.from) << " --> " << time_to_subrip_string(sub.to) << "\n"; - for (auto const& line: sub.lines) { + auto sorted_lines = sub.lines; + std::sort(sorted_lines.begin(), sorted_lines.end(), [](Line const& a, Line const& b) { return a.vertical_position < b.vertical_position; }); + for (auto const& line: sorted_lines) { for (auto const& block: line.blocks) { f << wrap_with_tags(block.text, block.bold, block.italic, block.underline); } |
