Rename shared_path -> resources_path.
[dcpomatic.git] / src / lib / render_text.cc
index de33f9380b1b09dfd4a9cde380874aba93e9251f..1e15c7aaca0446286ddff2bd870d40da4e7e4f7c 100644 (file)
 #include "cross.h"
 #include "font.h"
 #include "dcpomatic_assert.h"
+#include "warnings.h"
 #include <dcp/raw_convert.h>
 #include <fontconfig/fontconfig.h>
 #include <cairomm/cairomm.h>
+DCPOMATIC_DISABLE_WARNINGS
 #include <pangomm.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <pango/pangocairo.h>
 #ifndef DCPOMATIC_HAVE_SHOW_IN_CAIRO_CONTEXT
 #include <pango/pangocairo.h>
@@ -139,7 +142,7 @@ setup_font (StringText const& subtitle, list<shared_ptr<Font> > const& fonts)
        optional<boost::filesystem::path> font_file;
 
        try {
-               font_file = shared_path () / "LiberationSans-Regular.ttf";
+               font_file = resources_path() / "LiberationSans-Regular.ttf";
        } catch (boost::filesystem::filesystem_error& e) {
 
        }
@@ -340,13 +343,15 @@ 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;
+       size.width += 2 * ceil (border_width);
+       size.height += 2 * ceil (border_width);
+
        size.width *= x_scale;
        size.height *= y_scale;
 
-       /* Shuffle the subtitle over very slightly if it has a border so that the left-hand
-          side of the first character's border is not cut off.
-       */
-       int const x_offset = first.effect() == dcp::BORDER ? (target.width / 600.0) : 0;
+       /* Shuffle the subtitle over by the border width (if we have any) so it's not cut off */
+       int const x_offset = ceil (border_width);
        /* Move down a bit so that accents on capital letters can be seen */
        int const y_offset = target.height / 100.0;
 
@@ -372,7 +377,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 */
                set_source_rgba (context, first.effect_colour(), fade_factor);
-               context->set_line_width (first.outline_width * target.width / 2048.0);
+               context->set_line_width (border_width);
                context->set_line_join (Cairo::LINE_JOIN_ROUND);
                context->move_to (x_offset, y_offset);
                layout->add_to_cairo_context (context);
@@ -396,6 +401,7 @@ render_line (list<StringText> subtitles, list<shared_ptr<Font> > fonts, dcp::Siz
 
 
 /** @param time Time of the frame that these subtitles are going on.
+ *  @param target Size of the container that this subtitle will end up in.
  *  @param frame_rate DCP frame rate.
  */
 list<PositionImage>