diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-06-01 12:26:15 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-06-06 23:25:56 +0200 |
| commit | 43cedbb426aa99cd603b4abac1aa2d81f70e11fe (patch) | |
| tree | d716d719c837690b8926b5a64254ad7b99c5027f | |
| parent | 4d6ca25589de9893687f5dc7aeaad3d04471ecac (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)); |
