diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-06-01 12:26:15 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-06-07 17:01:06 +0200 |
| commit | b00df7cfa33e3a1f57f727dabd0939c25d9f55d0 (patch) | |
| tree | 6c119fc2aa59801a17a988ba1b5ea3ace982ca68 | |
| parent | a7bd8d64d37ac0fd751226c0fba98e219dea9b0d (diff) | |
Extract method to set forced appearance.
| -rw-r--r-- | src/lib/text_decoder.cc | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc index c6563a260..2fdcab89e 100644 --- a/src/lib/text_decoder.cc +++ b/src/lib/text_decoder.cc @@ -81,28 +81,34 @@ escape_text (string text) } +static +void +set_forced_appearance(shared_ptr<const TextContent> content, dcp::SubtitleString& subtitle) +{ + if (content->colour()) { + subtitle.set_colour(*content->colour()); + } + if (content->effect_colour()) { + subtitle.set_effect_colour(*content->effect_colour()); + } + if (content->effect()) { + subtitle.set_effect(*content->effect()); + } + if (content->fade_in()) { + subtitle.set_fade_up_time(dcp::Time(content->fade_in()->seconds(), 1000)); + } + if (content->fade_out()) { + subtitle.set_fade_down_time (dcp::Time(content->fade_out()->seconds(), 1000)); + } +} + + void TextDecoder::emit_plain_start (ContentTime from, vector<dcp::SubtitleString> subtitles) { for (auto& subtitle: subtitles) { subtitle.set_text(escape_text(subtitle.text())); - - /* Set any forced appearance */ - if (content()->colour()) { - subtitle.set_colour(*content()->colour()); - } - if (content()->effect_colour()) { - subtitle.set_effect_colour(*content()->effect_colour()); - } - if (content()->effect()) { - subtitle.set_effect(*content()->effect()); - } - if (content()->fade_in()) { - subtitle.set_fade_up_time(dcp::Time(content()->fade_in()->seconds(), 1000)); - } - if (content()->fade_out()) { - subtitle.set_fade_down_time (dcp::Time(content()->fade_out()->seconds(), 1000)); - } + set_forced_appearance(content(), subtitle); } PlainStart(ContentStringText(from, subtitles)); |
