summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-06-02 23:38:16 +0200
committerCarl Hetherington <cth@carlh.net>2023-06-02 23:38:59 +0200
commite7245abe84a1a09a5f680e426b5dfac2de2e472a (patch)
tree54b1cdc8cb740963cfe8f57a3dd7a7d199ec2e84 /src/lib
parent8ea0d3bbc98054a2b6582343c96c4d03bcc2d4c1 (diff)
Fix incorrect hint about having too many subtitle lines in some cases (#2546).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/hints.cc25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/lib/hints.cc b/src/lib/hints.cc
index b628efc31..6c574d991 100644
--- a/src/lib/hints.cc
+++ b/src/lib/hints.cc
@@ -584,7 +584,30 @@ Hints::open_subtitle (PlayerText text, DCPTimePeriod period)
hint (_("At least one of your subtitles starts less than 2 frames after the previous one. It is advisable to make the gap between subtitles at least 2 frames."));
}
- if (text.string.size() > 3 && !_too_many_subtitle_lines) {
+ struct VPos
+ {
+ public:
+ dcp::VAlign align;
+ float position;
+
+ bool operator<(VPos const& other) const {
+ if (static_cast<int>(align) != static_cast<int>(other.align)) {
+ return static_cast<int>(align) < static_cast<int>(other.align);
+ }
+ return position < other.position;
+ }
+ };
+
+ /* This is rather an approximate way to count distinct lines, but I guess it will do;
+ * to make it better we need to take into account font metrics, and the SMPTE alignment
+ * debacle, and so on.
+ */
+ std::set<VPos> lines;
+ for (auto const& line: text.string) {
+ lines.insert({ line.v_align(), line.v_position() });
+ }
+
+ if (lines.size() > 3 && !_too_many_subtitle_lines) {
_too_many_subtitle_lines = true;
hint (_("At least one of your subtitles has more than 3 lines. It is advisable to use no more than 3 lines."));
}