BOOST_FOREACH.
[dcpomatic.git] / src / lib / render_text.cc
index f0866267866f68dbe318d02e9d28dca27b9a376c..3dc1e9ff0e4efcd0839281439c86be8b01364977 100644 (file)
@@ -25,6 +25,7 @@
 #include "font.h"
 #include "dcpomatic_assert.h"
 #include "warnings.h"
+#include "util.h"
 #include <dcp/raw_convert.h>
 #include <fontconfig/fontconfig.h>
 #include <cairomm/cairomm.h>
@@ -35,7 +36,6 @@ DCPOMATIC_ENABLE_WARNINGS
 #ifndef DCPOMATIC_HAVE_SHOW_IN_CAIRO_CONTEXT
 #include <pango/pangocairo.h>
 #endif
-#include <boost/foreach.hpp>
 #include <boost/algorithm/string.hpp>
 #include <iostream>
 
@@ -47,7 +47,7 @@ using std::max;
 using std::pair;
 using std::cerr;
 using std::make_pair;
-using boost::shared_ptr;
+using std::shared_ptr;
 using boost::optional;
 using boost::algorithm::replace_all;
 using namespace dcpomatic;
@@ -60,7 +60,7 @@ marked_up (list<StringText> subtitles, int target_height, float fade_factor)
 {
        string out;
 
-       BOOST_FOREACH (StringText const & i, subtitles) {
+       for (auto const& i: subtitles) {
                out += "<span ";
                if (i.italic()) {
                        out += "style=\"italic\" ";
@@ -139,21 +139,9 @@ setup_font (StringText const& subtitle, list<shared_ptr<Font> > const& fonts)
                fc_config = FcInitLoadConfig ();
        }
 
-       optional<boost::filesystem::path> font_file;
+       optional<boost::filesystem::path> font_file = default_font_file ();
 
-       try {
-               font_file = resources_path() / "LiberationSans-Regular.ttf";
-       } catch (boost::filesystem::filesystem_error& e) {
-
-       }
-
-       /* Hack: try the debian/ubuntu locations if getting the shared path failed */
-
-       if (!font_file || !boost::filesystem::exists(*font_file)) {
-               font_file = "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf";
-       }
-
-       BOOST_FOREACH (shared_ptr<Font> i, fonts) {
+       for (auto i: fonts) {
                if (i->id() == subtitle.font() && i->file()) {
                        font_file = i->file ();
                }
@@ -300,8 +288,10 @@ static Glib::RefPtr<Pango::Layout>
 create_layout()
 {
        PangoFontMap* c_font_map = pango_cairo_font_map_new ();
+       DCPOMATIC_ASSERT (c_font_map);
        Glib::RefPtr<Pango::FontMap> font_map = Glib::wrap (c_font_map);
        PangoContext* c_context = pango_font_map_create_context (c_font_map);
+       DCPOMATIC_ASSERT (c_context);
        Glib::RefPtr<Pango::Context> context = Glib::wrap (c_context);
        return Pango::Layout::create (context);
 }
@@ -343,7 +333,7 @@ render_line (list<StringText> subtitles, list<shared_ptr<Font> > fonts, dcp::Siz
                }
        }
 
-       float const border_width = dcp::BORDER ? (first.outline_width * target.width / 2048.0) : 0;
+       float const border_width = first.effect() == dcp::BORDER ? (first.outline_width * target.width / 2048.0) : 0;
        size.width += 2 * ceil (border_width);
        size.height += 2 * ceil (border_width);
 
@@ -413,7 +403,7 @@ render_text (list<StringText> subtitles, list<shared_ptr<Font> > fonts, dcp::Siz
        list<StringText> pending;
        list<PositionImage> images;
 
-       BOOST_FOREACH (StringText const & i, subtitles) {
+       for (auto const& i: subtitles) {
                if (!pending.empty() && (i.v_align() != pending.back().v_align() || fabs(i.v_position() - pending.back().v_position()) > 1e-4)) {
                        images.push_back (render_line (pending, fonts, target, time, frame_rate));
                        pending.clear ();