diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-07-20 16:25:43 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-07-20 16:25:43 +0200 |
| commit | 660caac5a4b023050fe04aaf1a299677d65050f5 (patch) | |
| tree | 63e2ba092bbd0b2ac208bb37df1e8b7de1fc0f85 | |
| parent | 21589191f6094ac58852effc0e790c4b97fb9434 (diff) | |
Fix vertical alignment with subrip and embedded SSA \an codes.v2.15.90
| -rw-r--r-- | src/lib/text_decoder.cc | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc index 28dace7af..8146d33aa 100644 --- a/src/lib/text_decoder.cc +++ b/src/lib/text_decoder.cc @@ -139,14 +139,28 @@ TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & subtitle) dcp::VAlign v_align; if (needs_placement) { DCPOMATIC_ASSERT (i.vertical_position.line); - /* This 1.015 is an arbitrary value to lift the bottom sub off the bottom - of the screen a bit to a pleasing degree. - */ - v_position = 1.015 - - (1 + bottom_line.get() - i.vertical_position.line.get()) - * 1.2 * content()->line_spacing() * content()->y_scale() * j.font_size.proportional (72 * 11); + double const multiplier = 1.2 * content()->line_spacing() * content()->y_scale() * j.font_size.proportional (72 * 11); + switch (i.vertical_position.reference.get_value_or(sub::BOTTOM_OF_SCREEN)) { + case sub::BOTTOM_OF_SCREEN: + case sub::TOP_OF_SUBTITLE: + /* This 1.015 is an arbitrary value to lift the bottom sub off the bottom + of the screen a bit to a pleasing degree. + */ + v_position = 1.015 - + (1 + bottom_line.get() - i.vertical_position.line.get()) * multiplier; - v_align = dcp::VALIGN_TOP; + v_align = dcp::VALIGN_TOP; + break; + case sub::TOP_OF_SCREEN: + /* This 0.1 is another fudge factor to bring the top line away from the top of the screen a little */ + v_position = 0.12 + i.vertical_position.line.get() * multiplier; + v_align = dcp::VALIGN_TOP; + break; + case sub::VERTICAL_CENTRE_OF_SCREEN: + v_position = i.vertical_position.line.get() * multiplier; + v_align = dcp::VALIGN_CENTER; + break; + } } else { DCPOMATIC_ASSERT (i.vertical_position.reference); if (i.vertical_position.proportional) { |
