Escape & before sending it to pango, otherwise it won't render it.
authorCarl Hetherington <cth@carlh.net>
Tue, 15 May 2018 19:48:48 +0000 (20:48 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 15 May 2018 19:48:48 +0000 (20:48 +0100)
ChangeLog
src/lib/render_subtitles.cc

index e397d79..dcb0ef1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-05-15  Carl Hetherington  <cth@carlh.net>
+
+       * Fix missing burnt-in / previewed subtitles containing ampersands.
+
 2018-05-08  Carl Hetherington  <cth@carlh.net>
 
        * Look at subtitle colour and effect when deciding whether or not to
index ad2c10a..35fcd8b 100644 (file)
@@ -32,6 +32,7 @@
 #include <pango/pangocairo.h>
 #endif
 #include <boost/foreach.hpp>
+#include <boost/algorithm/string.hpp>
 #include <iostream>
 
 using std::list;
@@ -44,6 +45,7 @@ using std::cerr;
 using std::make_pair;
 using boost::shared_ptr;
 using boost::optional;
+using boost::algorithm::replace_all;
 
 static FcConfig* fc_config = 0;
 static list<pair<FontFiles, string> > fc_config_fonts;
@@ -68,7 +70,11 @@ marked_up (list<SubtitleString> subtitles, int target_height, float fade_factor)
                /* Between 1-65535 inclusive, apparently... */
                out += "alpha=\"" + dcp::raw_convert<string>(int(floor(fade_factor * 65534)) + 1) + "\" ";
                out += "color=\"#" + i.colour().to_rgb_string() + "\">";
-               out += i.text ();
+
+               string t = i.text();
+               replace_all(t, "&", "&amp;");
+               out += t;
+
                out += "</span>";
        }