d588620e70bf15da29cc242e4ae8d86977e8f36a from master; fix hang if you cancel a paused...
[dcpomatic.git] / src / lib / render_subtitles.cc
index 6f103246c9c6f3538de616f153062308fe6b0de9..9620eacbf5c58ebe4a3dc847262067c6802ea54e 100644 (file)
@@ -50,10 +50,6 @@ calculate_position (dcp::VAlign v_align, double v_position, int target_height, i
 PositionImage
 render_subtitles (list<dcp::SubtitleString> subtitles, dcp::Size target)
 {
-       if (subtitles.empty ()) {
-               return PositionImage ();
-       }
-
        /* Estimate height that the subtitle image needs to be */
        optional<int> top;
        optional<int> bottom;
@@ -88,11 +84,7 @@ render_subtitles (list<dcp::SubtitleString> subtitles, dcp::Size target)
        context->set_line_width (1);
 
        for (list<dcp::SubtitleString>::const_iterator i = subtitles.begin(); i != subtitles.end(); ++i) {
-               string f = i->font ();
-               if (f.empty ()) {
-                       f = "Arial";
-               }
-               Pango::FontDescription font (f);
+               Pango::FontDescription font (i->font().get_value_or ("Arial"));
                font.set_absolute_size (i->size_in_pixels (target.height) * PANGO_SCALE);
                if (i->italic ()) {
                        font.set_style (Pango::STYLE_ITALIC);
@@ -103,16 +95,6 @@ render_subtitles (list<dcp::SubtitleString> subtitles, dcp::Size target)
                /* Compute fade factor */
                /* XXX */
                float fade_factor = 1;
-#if 0          
-               dcp::Time now (time * 1000 / (4 * TIME_HZ));
-               dcp::Time end_fade_up = i->in() + i->fade_up_time ();
-               dcp::Time start_fade_down = i->out() - i->fade_down_time ();
-               if (now < end_fade_up) {
-                       fade_factor = (now - i->in()) / i->fade_up_time();
-               } else if (now > start_fade_down) {
-                       fade_factor = 1.0 - ((now - start_fade_down) / i->fade_down_time ());
-               }
-#endif         
 
                layout->update_from_cairo_context (context);
                
@@ -123,7 +105,7 @@ render_subtitles (list<dcp::SubtitleString> subtitles, dcp::Size target)
 
                if (i->effect() == dcp::SHADOW) {
                        /* Drop-shadow effect */
-                       dcp::Color const ec = i->effect_color ();
+                       dcp::Colour const ec = i->effect_colour ();
                        context->set_source_rgba (float(ec.r) / 255, float(ec.g) / 255, float(ec.b) / 255, fade_factor);
                        context->move_to (x + 4, y + 4);
                        layout->add_to_cairo_context (context);
@@ -132,7 +114,7 @@ render_subtitles (list<dcp::SubtitleString> subtitles, dcp::Size target)
 
                /* The actual subtitle */
                context->move_to (x, y);
-               dcp::Color const c = i->color ();
+               dcp::Colour const c = i->colour ();
                context->set_source_rgba (float(c.r) / 255, float(c.g) / 255, float(c.b) / 255, fade_factor);
                layout->add_to_cairo_context (context);
                context->fill ();
@@ -140,7 +122,7 @@ render_subtitles (list<dcp::SubtitleString> subtitles, dcp::Size target)
                if (i->effect() == dcp::BORDER) {
                        /* Border effect */
                        context->move_to (x, y);
-                       dcp::Color ec = i->effect_color ();
+                       dcp::Colour ec = i->effect_colour ();
                        context->set_source_rgba (float(ec.r) / 255, float(ec.g) / 255, float(ec.b) / 255, fade_factor);
                        layout->add_to_cairo_context (context);
                        context->stroke ();