Make use of default_font_file().
[dcpomatic.git] / src / lib / render_text.cc
index 41f3563db117b861698e50f62d7ef584f817a5a2..f9c04dc4dc09b7678b65596a5a04b473b75f0869 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>
@@ -139,19 +140,7 @@ setup_font (StringText const& subtitle, list<shared_ptr<Font> > const& fonts)
                fc_config = FcInitLoadConfig ();
        }
 
-       optional<boost::filesystem::path> font_file;
-
-       try {
-               font_file = shared_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";
-       }
+       optional<boost::filesystem::path> font_file = default_font_file ();
 
        BOOST_FOREACH (shared_ptr<Font> i, fonts) {
                if (i->id() == subtitle.font() && i->file()) {
@@ -375,7 +364,7 @@ render_line (list<StringText> subtitles, list<shared_ptr<Font> > fonts, dcp::Siz
        }
 
        if (first.effect() == dcp::BORDER) {
-               /* Border effect; stroke the subtitle with a large (arbitrarily chosen) line width */
+               /* Border effect */
                set_source_rgba (context, first.effect_colour(), fade_factor);
                context->set_line_width (border_width);
                context->set_line_join (Cairo::LINE_JOIN_ROUND);
@@ -386,13 +375,16 @@ render_line (list<StringText> subtitles, list<shared_ptr<Font> > fonts, dcp::Siz
 
        /* The actual subtitle */
 
-       context->set_line_width (0);
+       set_source_rgba (context, first.colour(), fade_factor);
+
        context->move_to (x_offset, y_offset);
-#ifdef DCPOMATIC_HAVE_SHOW_IN_CAIRO_CONTEXT
-       layout->show_in_cairo_context (context);
-#else
-       pango_cairo_show_layout (context->cobj(), layout->gobj());
-#endif
+       layout->add_to_cairo_context (context);
+       context->fill ();
+
+       context->set_line_width (0.5);
+       context->move_to (x_offset, y_offset);
+       layout->add_to_cairo_context (context);
+       context->stroke ();
 
        int const x = x_position (first, target.width, size.width);
        int const y = y_position (first, target.height, size.height);