diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-08-20 01:07:35 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-08-20 01:07:35 +0100 |
| commit | 2dd34ab7469a8a01de368b7a204ad0e8f2d5aefd (patch) | |
| tree | b88081b061c3b97daeb1c5bc87cdbaefda7fd6a0 /src | |
| parent | 8f698532b42f300029adf94c62c0f509489318c3 (diff) | |
Handle subtitles which contain Pango markup.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/subtitle_decoder.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc index ba6fe4600..bc4a75ca8 100644 --- a/src/lib/subtitle_decoder.cc +++ b/src/lib/subtitle_decoder.cc @@ -24,6 +24,7 @@ #include <sub/subtitle.h> #include <boost/shared_ptr.hpp> #include <boost/foreach.hpp> +#include <boost/algorithm/string.hpp> #include <iostream> using std::list; @@ -64,6 +65,16 @@ SubtitleDecoder::give_image (ContentTimePeriod period, shared_ptr<Image> image, void SubtitleDecoder::give_text (ContentTimePeriod period, list<dcp::SubtitleString> s) { + /* We must escape < and > in strings, otherwise they might confuse our subtitle + renderer (which uses some HTML-esque markup to do bold/italic etc.) + */ + BOOST_FOREACH (dcp::SubtitleString& i, s) { + string t = i.text (); + boost::algorithm::replace_all (t, "<", "<"); + boost::algorithm::replace_all (t, ">", ">"); + i.set_text (t); + } + _decoded_text.push_back (ContentTextSubtitle (period, s)); } |
