summaryrefslogtreecommitdiff
path: root/src/lib/subtitle_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-07-03 21:44:50 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-03 21:44:50 +0100
commit1dddcfdd50b38c239b93227c77c84337759de4c8 (patch)
tree88c60f0b080236f764b9c8af7dc53ae0de3af04c /src/lib/subtitle_decoder.cc
parent820d80608d5d03091d6ad9df541a2a4d55bd7644 (diff)
Adjust line spacing even with subs with specified proportional position.
Diffstat (limited to 'src/lib/subtitle_decoder.cc')
-rw-r--r--src/lib/subtitle_decoder.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc
index 72c6883fb..09f7a6700 100644
--- a/src/lib/subtitle_decoder.cc
+++ b/src/lib/subtitle_decoder.cc
@@ -29,6 +29,7 @@
using std::list;
using std::cout;
using std::string;
+using std::min;
using boost::shared_ptr;
using boost::optional;
using boost::function;
@@ -158,6 +159,18 @@ SubtitleDecoder::give_text (ContentTimePeriod period, sub::Subtitle const & subt
}
}
+ /* Find the lowest proportional postion */
+ optional<float> lowest_proportional;
+ BOOST_FOREACH (sub::Line i, subtitle.lines) {
+ if (i.vertical_position.proportional) {
+ if (!lowest_proportional) {
+ lowest_proportional = i.vertical_position.proportional;
+ } else {
+ lowest_proportional = min (lowest_proportional.get(), i.vertical_position.proportional.get());
+ }
+ }
+ }
+
list<dcp::SubtitleString> out;
BOOST_FOREACH (sub::Line i, subtitle.lines) {
BOOST_FOREACH (sub::Block j, i.blocks) {
@@ -183,6 +196,12 @@ SubtitleDecoder::give_text (ContentTimePeriod period, sub::Subtitle const & subt
DCPOMATIC_ASSERT (i.vertical_position.proportional);
DCPOMATIC_ASSERT (i.vertical_position.reference);
v_position = i.vertical_position.proportional.get();
+
+ if (lowest_proportional) {
+ /* Adjust line spacing */
+ v_position = ((v_position - lowest_proportional.get()) * content()->line_spacing()) + lowest_proportional.get();
+ }
+
switch (i.vertical_position.reference.get()) {
case sub::TOP_OF_SCREEN:
v_align = dcp::VALIGN_TOP;