More renaming.
authorCarl Hetherington <cth@carlh.net>
Wed, 18 Jul 2018 23:42:56 +0000 (00:42 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 19 Jul 2018 22:36:56 +0000 (23:36 +0100)
sed -i "s/emit_text/emit_plain/g" src/lib/*.cc src/lib/*.h
sed -i "s/emit_image_start/emit_bitmap_start/g" src/lib/*.cc src/lib/*.h
sed -i "s/emit_text_start/emit_plain_start/g" src/lib/*.cc src/lib/*.h
sed -i "s/render_subtitles/render_text/g" src/lib/*.cc src/lib/*.h src/lib/wscript test/*.cc
sed -i "s/ImageStart/BitmapStart/g" src/lib/*.cc src/lib/*.h
sed -i "s/TextStart/PlainStart/g" src/lib/*.cc src/lib/*.h test/*.cc src/wx/*.cc
sed -i "s/ImageSubtitle/BitmapText/g" src/lib/*.cc src/lib/*.h
sed -i "s/text_subtitle/plain_text/g" src/lib/*.cc src/lib/*.h src/lib/wscript src/wx/*.cc src/wx/*.h test/*.cc
sed -i "s/image_subtitle/bitmap_text/g" src/lib/*.cc src/lib/*.h
mv src/lib/render_subtitles.cc src/lib/render_text.cc
mv src/lib/render_subtitles.h src/lib/render_text.h
mv src/lib/text_subtitle.cc src/lib/plain_text.cc
mv src/lib/text_subtitle.h src/lib/plain_text.h

31 files changed:
src/lib/bitmap_text.h [new file with mode: 0644]
src/lib/content_subtitle.h
src/lib/dcp_decoder.cc
src/lib/dcp_text_decoder.cc
src/lib/ffmpeg_decoder.cc
src/lib/image_subtitle.h
src/lib/plain_text.cc [new file with mode: 0644]
src/lib/plain_text.h [new file with mode: 0644]
src/lib/plain_text_content.cc
src/lib/plain_text_decoder.cc
src/lib/plain_text_decoder.h
src/lib/player.cc
src/lib/player.h
src/lib/player_subtitles.h
src/lib/reel_writer.cc
src/lib/render_subtitles.cc [deleted file]
src/lib/render_subtitles.h [deleted file]
src/lib/render_text.cc [new file with mode: 0644]
src/lib/render_text.h [new file with mode: 0644]
src/lib/text_decoder.cc
src/lib/text_decoder.h
src/lib/text_file_decoder.cc
src/lib/text_subtitle.cc [deleted file]
src/lib/text_subtitle.h [deleted file]
src/lib/wscript
src/wx/content_panel.cc
src/wx/subtitle_view.cc
test/dcp_subtitle_test.cc
test/render_subtitles_test.cc
test/srt_subtitle_test.cc
test/subtitle_charset_test.cc

diff --git a/src/lib/bitmap_text.h b/src/lib/bitmap_text.h
new file mode 100644 (file)
index 0000000..64de768
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+    Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef DCPOMATIC_BITMAP_TEXT_H
+#define DCPOMATIC_BITMAP_TEXT_H
+
+#include "rect.h"
+#include <boost/shared_ptr.hpp>
+
+class Image;
+
+class BitmapText
+{
+public:
+       BitmapText (boost::shared_ptr<Image> i, dcpomatic::Rect<double> r)
+               : image (i)
+               , rectangle (r)
+       {}
+
+       boost::shared_ptr<Image> image;
+       /** Area that the subtitle covers on its corresponding video, expressed in
+        *  proportions of the image size; e.g. rectangle.x = 0.5 would mean that
+        *  the rectangle starts half-way across the video.
+        *
+        *  This rectangle may or may not have had a TextContent's offsets and
+        *  scale applied to it, depending on context.
+        */
+       dcpomatic::Rect<double> rectangle;
+};
+
+#endif
index f834fe197c202eba95fb2f78d26d01dae4412527..5a3e8157cfb06011c16ded74831164b82aab1c6d 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "dcpomatic_time.h"
 #include "rect.h"
-#include "image_subtitle.h"
+#include "bitmap_text.h"
 #include <dcp/subtitle_string.h>
 #include <list>
 
@@ -44,16 +44,16 @@ private:
        ContentTime _from;
 };
 
-class ContentImageSubtitle : public ContentSubtitle
+class ContentBitmapText : public ContentSubtitle
 {
 public:
-       ContentImageSubtitle (ContentTime f, boost::shared_ptr<Image> im, dcpomatic::Rect<double> r)
+       ContentBitmapText (ContentTime f, boost::shared_ptr<Image> im, dcpomatic::Rect<double> r)
                : ContentSubtitle (f)
                , sub (im, r)
        {}
 
        /* Our subtitle, with its rectangle unmodified by any offsets or scales that the content specifies */
-       ImageSubtitle sub;
+       BitmapText sub;
 };
 
 /** A text subtitle.  We store the time period separately (as well as in the dcp::SubtitleStrings)
index 03bd95d90f8a7671131e23f108bdf1ab32acdeba..6a9de841d51f078bc41c6962b0230a473ce42876 100644 (file)
@@ -209,7 +209,7 @@ DCPDecoder::pass_subtitles (ContentTime next)
                        if (is) {
                                list<dcp::SubtitleString> s;
                                s.push_back (*is);
-                               subtitle->emit_text (
+                               subtitle->emit_plain (
                                        ContentTimePeriod (
                                                ContentTime::from_frames (_offset - entry_point, vfr) + ContentTime::from_seconds (i->in().as_seconds ()),
                                                ContentTime::from_frames (_offset - entry_point, vfr) + ContentTime::from_seconds (i->out().as_seconds ())
index 576cfd3579b475d70549f6164f26be03eb14b653..168bfa5cc7f12c0948c83c4ca003943aeacde87f 100644 (file)
@@ -63,7 +63,7 @@ DCPTextDecoder::pass ()
 
        /* Gather all subtitles with the same time period that are next
           on the list.  We must emit all subtitles for the same time
-          period with the same text_subtitle() call otherwise the
+          period with the same plain_text() call otherwise the
           TextDecoder will assume there is nothing else at the
           time of emit the first.
        */
@@ -81,7 +81,7 @@ DCPTextDecoder::pass ()
                /* XXX: image subtitles */
        }
 
-       subtitle->emit_text (p, s);
+       subtitle->emit_plain (p, s);
        return false;
 }
 
index 4d10f8ef7400069332ccdde4c08be5172ce642f2..909a9d443d1383ebca4179554fa9745c12e5acfb 100644 (file)
@@ -669,7 +669,7 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTime
                static_cast<double> (rect->h) / target_height
                );
 
-       subtitle->emit_image_start (from, image, scaled_rect);
+       subtitle->emit_bitmap_start (from, image, scaled_rect);
 }
 
 void
@@ -702,6 +702,6 @@ FFmpegDecoder::decode_ass_subtitle (string ass, ContentTime from)
                );
 
        BOOST_FOREACH (sub::Subtitle const & i, sub::collect<list<sub::Subtitle> > (raw)) {
-               subtitle->emit_text_start (from, i);
+               subtitle->emit_plain_start (from, i);
        }
 }
index e0687e5817783b0858eadbe448887e0ae58042f3..1d2dcd7934b5d65ca92ad9b6dfc03ebb01d323dd 100644 (file)
 
 class Image;
 
-class ImageSubtitle
+class BitmapText
 {
 public:
-       ImageSubtitle (boost::shared_ptr<Image> i, dcpomatic::Rect<double> r)
+       BitmapText (boost::shared_ptr<Image> i, dcpomatic::Rect<double> r)
                : image (i)
                , rectangle (r)
        {}
diff --git a/src/lib/plain_text.cc b/src/lib/plain_text.cc
new file mode 100644 (file)
index 0000000..ee9bc4b
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+    Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "plain_text.h"
+#include "cross.h"
+#include "exceptions.h"
+#include "plain_text_content.h"
+#include <sub/subrip_reader.h>
+#include <sub/ssa_reader.h>
+#include <sub/collect.h>
+#include <unicode/ucsdet.h>
+#include <unicode/ucnv.h>
+#include <iostream>
+
+#include "i18n.h"
+
+using std::vector;
+using std::cout;
+using std::string;
+using boost::shared_ptr;
+using boost::scoped_array;
+using boost::optional;
+using dcp::Data;
+
+TextSubtitle::TextSubtitle (shared_ptr<const PlainText> content)
+{
+       Data in (content->path (0));
+
+       UErrorCode status = U_ZERO_ERROR;
+       UCharsetDetector* detector = ucsdet_open (&status);
+       ucsdet_setText (detector, reinterpret_cast<const char *> (in.data().get()), in.size(), &status);
+
+       UCharsetMatch const * match = ucsdet_detect (detector, &status);
+       char const * in_charset = ucsdet_getName (match, &status);
+
+       UConverter* to_utf16 = ucnv_open (in_charset, &status);
+       /* This is a guess; I think we should be able to encode any input in 4 times its input size */
+       scoped_array<uint16_t> utf16 (new uint16_t[in.size() * 2]);
+       int const utf16_len = ucnv_toUChars (
+               to_utf16, reinterpret_cast<UChar*>(utf16.get()), in.size() * 2,
+               reinterpret_cast<const char *> (in.data().get()), in.size(),
+               &status
+               );
+
+       UConverter* to_utf8 = ucnv_open ("UTF-8", &status);
+       /* Another guess */
+       scoped_array<char> utf8 (new char[utf16_len * 2]);
+       ucnv_fromUChars (to_utf8, utf8.get(), utf16_len * 2, reinterpret_cast<UChar*>(utf16.get()), utf16_len, &status);
+
+       /* Fix OS X line endings */
+       size_t utf8_len = strlen (utf8.get ());
+       for (size_t i = 0; i < utf8_len; ++i) {
+               if (utf8[i] == '\r' && ((i == utf8_len - 1) || utf8[i + 1] != '\n')) {
+                       utf8[i] = '\n';
+               }
+       }
+
+       ucsdet_close (detector);
+       ucnv_close (to_utf16);
+       ucnv_close (to_utf8);
+
+       sub::Reader* reader = 0;
+
+       string ext = content->path(0).extension().string();
+       transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
+
+       if (ext == ".srt") {
+               reader = new sub::SubripReader (utf8.get());
+       } else if (ext == ".ssa" || ext == ".ass") {
+               reader = new sub::SSAReader (utf8.get());
+       }
+
+       if (reader) {
+               _subtitles = sub::collect<vector<sub::Subtitle> > (reader->subtitles ());
+       }
+
+       delete reader;
+}
+
+/** @return time of first subtitle, if there is one */
+optional<ContentTime>
+TextSubtitle::first () const
+{
+       if (_subtitles.empty()) {
+               return optional<ContentTime>();
+       }
+
+       return ContentTime::from_seconds(_subtitles[0].from.all_as_seconds());
+}
+
+ContentTime
+TextSubtitle::length () const
+{
+       if (_subtitles.empty ()) {
+               return ContentTime ();
+       }
+
+       return ContentTime::from_seconds (_subtitles.back().to.all_as_seconds ());
+}
diff --git a/src/lib/plain_text.h b/src/lib/plain_text.h
new file mode 100644 (file)
index 0000000..61d7147
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef DCPOMATIC_TEXT_SUBTITLE_H
+#define DCPOMATIC_TEXT_SUBTITLE_H
+
+#include "dcpomatic_time.h"
+#include <sub/subtitle.h>
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+class PlainText;
+class plain_text_time_test;
+class plain_text_coordinate_test;
+class plain_text_content_test;
+class plain_text_parse_test;
+
+class TextSubtitle
+{
+public:
+       explicit TextSubtitle (boost::shared_ptr<const PlainText>);
+
+       boost::optional<ContentTime> first () const;
+       ContentTime length () const;
+
+protected:
+       std::vector<sub::Subtitle> _subtitles;
+};
+
+#endif
index 6ca783c1692d86b5b0fb01df32145535a5de0c1d..f51e365d52f225e62b3bf30bbcbded57a5a76289 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "plain_text_content.h"
 #include "util.h"
-#include "text_subtitle.h"
+#include "plain_text.h"
 #include "film.h"
 #include "font.h"
 #include "text_content.h"
index 71f7bed42d49197f4f12feab78b1237bedce90c5..46a4bd552f2d5264c4aa9e62d7d7b4ede4edbbf5 100644 (file)
@@ -72,7 +72,7 @@ TextTextDecoder::pass ()
        }
 
        ContentTimePeriod const p = content_time_period (_subtitles[_next]);
-       subtitle->emit_text (p, _subtitles[_next]);
+       subtitle->emit_plain (p, _subtitles[_next]);
 
        ++_next;
        return false;
index 4bdedf58d380e90c915e58c5371c527db69a1d22..046c5f8e011332e56eabefd03c7441af6ffe0c6e 100644 (file)
@@ -22,7 +22,7 @@
 #define DCPOMATIC_TEXT_SUBTITLE_DECODER_H
 
 #include "text_decoder.h"
-#include "text_subtitle.h"
+#include "plain_text.h"
 
 class PlainText;
 
index b701deb5eb59fdbcd205a632de46bd5f933e3239..92e8141e14460d4cb17769a3aa3f13186f73d05e 100644 (file)
@@ -28,7 +28,7 @@
 #include "raw_image_proxy.h"
 #include "ratio.h"
 #include "log.h"
-#include "render_subtitles.h"
+#include "render_text.h"
 #include "config.h"
 #include "content_video.h"
 #include "player_video.h"
@@ -167,8 +167,8 @@ Player::setup_pieces ()
                }
 
                if (decoder->subtitle) {
-                       decoder->subtitle->ImageStart.connect (bind (&Player::image_subtitle_start, this, weak_ptr<Piece> (piece), _1));
-                       decoder->subtitle->TextStart.connect (bind (&Player::text_subtitle_start, this, weak_ptr<Piece> (piece), _1));
+                       decoder->subtitle->BitmapStart.connect (bind (&Player::bitmap_text_start, this, weak_ptr<Piece> (piece), _1));
+                       decoder->subtitle->PlainStart.connect (bind (&Player::plain_text_start, this, weak_ptr<Piece> (piece), _1));
                        decoder->subtitle->Stop.connect (bind (&Player::subtitle_stop, this, weak_ptr<Piece> (piece), _1));
                }
        }
@@ -290,11 +290,11 @@ Player::film_changed (Film::Property p)
 }
 
 list<PositionImage>
-Player::transform_image_subtitles (list<ImageSubtitle> subs) const
+Player::transform_bitmap_texts (list<BitmapText> subs) const
 {
        list<PositionImage> all;
 
-       for (list<ImageSubtitle>::const_iterator i = subs.begin(); i != subs.end(); ++i) {
+       for (list<BitmapText>::const_iterator i = subs.begin(); i != subs.end(); ++i) {
                if (!i->image) {
                        continue;
                }
@@ -667,12 +667,12 @@ Player::subtitles_for_frame (DCPTime time) const
        BOOST_FOREACH (PlayerSubtitles i, _active_subtitles.get_burnt (DCPTimePeriod(time, time + DCPTime::from_frames(1, vfr)), _always_burn_subtitles)) {
 
                /* Image subtitles */
-               list<PositionImage> c = transform_image_subtitles (i.image);
+               list<PositionImage> c = transform_bitmap_texts (i.image);
                copy (c.begin(), c.end(), back_inserter (subtitles));
 
                /* Text subtitles (rendered to an image) */
                if (!i.text.empty ()) {
-                       list<PositionImage> s = render_subtitles (i.text, i.fonts, _video_container_size, time, vfr);
+                       list<PositionImage> s = render_text (i.text, i.fonts, _video_container_size, time, vfr);
                        copy (s.begin(), s.end(), back_inserter (subtitles));
                }
        }
@@ -840,7 +840,7 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a
 }
 
 void
-Player::image_subtitle_start (weak_ptr<Piece> wp, ContentImageSubtitle subtitle)
+Player::bitmap_text_start (weak_ptr<Piece> wp, ContentBitmapText subtitle)
 {
        shared_ptr<Piece> piece = wp.lock ();
        if (!piece) {
@@ -867,7 +867,7 @@ Player::image_subtitle_start (weak_ptr<Piece> wp, ContentImageSubtitle subtitle)
 }
 
 void
-Player::text_subtitle_start (weak_ptr<Piece> wp, ContentTextSubtitle subtitle)
+Player::plain_text_start (weak_ptr<Piece> wp, ContentTextSubtitle subtitle)
 {
        shared_ptr<Piece> piece = wp.lock ();
        if (!piece) {
index 54fa074c011cd0d038e40d96de371e1bf47df098..b0ffe0e0465001c5ad4daa93e8e58120983e2282 100644 (file)
@@ -116,7 +116,7 @@ private:
        void film_changed (Film::Property);
        void playlist_changed ();
        void playlist_content_changed (boost::weak_ptr<Content>, int, bool);
-       std::list<PositionImage> transform_image_subtitles (std::list<ImageSubtitle>) const;
+       std::list<PositionImage> transform_bitmap_texts (std::list<BitmapText>) const;
        Frame dcp_to_content_video (boost::shared_ptr<const Piece> piece, DCPTime t) const;
        DCPTime content_video_to_dcp (boost::shared_ptr<const Piece> piece, Frame f) const;
        Frame dcp_to_resampled_audio (boost::shared_ptr<const Piece> piece, DCPTime t) const;
@@ -126,8 +126,8 @@ private:
        boost::shared_ptr<PlayerVideo> black_player_video_frame (Eyes eyes) const;
        void video (boost::weak_ptr<Piece>, ContentVideo);
        void audio (boost::weak_ptr<Piece>, AudioStreamPtr, ContentAudio);
-       void image_subtitle_start (boost::weak_ptr<Piece>, ContentImageSubtitle);
-       void text_subtitle_start (boost::weak_ptr<Piece>, ContentTextSubtitle);
+       void bitmap_text_start (boost::weak_ptr<Piece>, ContentBitmapText);
+       void plain_text_start (boost::weak_ptr<Piece>, ContentTextSubtitle);
        void subtitle_stop (boost::weak_ptr<Piece>, ContentTime);
        DCPTime one_video_frame () const;
        void fill_audio (DCPTimePeriod period);
index e1a104f2127c89a4d56e865f513f5f5320baab7b..4e3a739d8b1990941a6a9b54093bd9c5b85f3810 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef DCPOMATIC_PLAYER_SUBTITLES_H
 #define DCPOMATIC_PLAYER_SUBTITLES_H
 
-#include "image_subtitle.h"
+#include "bitmap_text.h"
 #include "dcpomatic_time.h"
 #include "subtitle_string.h"
 
@@ -34,8 +34,8 @@ public:
        void add_fonts (std::list<boost::shared_ptr<Font> > fonts_);
        std::list<boost::shared_ptr<Font> > fonts;
 
-       /** ImageSubtitles, with their rectangles transformed as specified by their content */
-       std::list<ImageSubtitle> image;
+       /** BitmapTexts, with their rectangles transformed as specified by their content */
+       std::list<BitmapText> image;
        std::list<SubtitleString> text;
 };
 
index 24ab1c534c1069c3cd6b0c02ebf47e9742b13a78..197773a20832f43820710065c190d2ff87966f91 100644 (file)
@@ -563,7 +563,7 @@ ReelWriter::write (PlayerSubtitles subs, DCPTimePeriod period)
                _subtitle_asset->add (shared_ptr<dcp::Subtitle>(new dcp::SubtitleString(i)));
        }
 
-       BOOST_FOREACH (ImageSubtitle i, subs.image) {
+       BOOST_FOREACH (BitmapText i, subs.image) {
                _subtitle_asset->add (
                        shared_ptr<dcp::Subtitle>(
                                new dcp::SubtitleImage(
diff --git a/src/lib/render_subtitles.cc b/src/lib/render_subtitles.cc
deleted file mode 100644 (file)
index 35fcd8b..0000000
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
-    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    DCP-o-matic is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "render_subtitles.h"
-#include "types.h"
-#include "image.h"
-#include "cross.h"
-#include "font.h"
-#include "dcpomatic_assert.h"
-#include <dcp/raw_convert.h>
-#include <fontconfig/fontconfig.h>
-#include <cairomm/cairomm.h>
-#include <pangomm.h>
-#ifndef DCPOMATIC_HAVE_SHOW_IN_CAIRO_CONTEXT
-#include <pango/pangocairo.h>
-#endif
-#include <boost/foreach.hpp>
-#include <boost/algorithm/string.hpp>
-#include <iostream>
-
-using std::list;
-using std::cout;
-using std::string;
-using std::min;
-using std::max;
-using std::pair;
-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;
-
-string
-marked_up (list<SubtitleString> subtitles, int target_height, float fade_factor)
-{
-       string out;
-
-       BOOST_FOREACH (SubtitleString const & i, subtitles) {
-               out += "<span ";
-               if (i.italic()) {
-                       out += "style=\"italic\" ";
-               }
-               if (i.bold()) {
-                       out += "weight=\"bold\" ";
-               }
-               if (i.underline()) {
-                       out += "underline=\"single\" ";
-               }
-               out += "size=\"" + dcp::raw_convert<string>(i.size_in_pixels(target_height) * 72 * 1024 / 96) + "\" ";
-               /* Between 1-65535 inclusive, apparently... */
-               out += "alpha=\"" + dcp::raw_convert<string>(int(floor(fade_factor * 65534)) + 1) + "\" ";
-               out += "color=\"#" + i.colour().to_rgb_string() + "\">";
-
-               string t = i.text();
-               replace_all(t, "&", "&amp;");
-               out += t;
-
-               out += "</span>";
-       }
-
-       return out;
-}
-
-static void
-set_source_rgba (Cairo::RefPtr<Cairo::Context> context, dcp::Colour colour, float fade_factor)
-{
-       context->set_source_rgba (float(colour.r) / 255, float(colour.g) / 255, float(colour.b) / 255, fade_factor);
-}
-
-/** @param subtitles A list of subtitles that are all on the same line,
- *  at the same time and with the same fade in/out.
- */
-static PositionImage
-render_line (list<SubtitleString> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target, DCPTime time, int frame_rate)
-{
-       /* XXX: this method can only handle italic / bold changes mid-line,
-          nothing else yet.
-       */
-
-       DCPOMATIC_ASSERT (!subtitles.empty ());
-
-       /* Calculate x and y scale factors.  These are only used to stretch
-          the font away from its normal aspect ratio.
-       */
-       float xscale = 1;
-       float yscale = 1;
-       if (fabs (subtitles.front().aspect_adjust() - 1.0) > dcp::ASPECT_ADJUST_EPSILON) {
-               if (subtitles.front().aspect_adjust() < 1) {
-                       xscale = max (0.25f, subtitles.front().aspect_adjust ());
-                       yscale = 1;
-               } else {
-                       xscale = 1;
-                       yscale = 1 / min (4.0f, subtitles.front().aspect_adjust ());
-               }
-       }
-
-       /* Make an empty bitmap as wide as target and at
-          least tall enough for this subtitle.
-       */
-
-       int largest = 0;
-       BOOST_FOREACH (dcp::SubtitleString const & i, subtitles) {
-               largest = max (largest, i.size());
-       }
-       /* Basic guess on height... */
-       int height = largest * target.height / (11 * 72);
-       /* ...scaled... */
-       height *= yscale;
-       /* ...and add a bit more for luck */
-       height += target.height / 11;
-
-       /* FFmpeg BGRA means first byte blue, second byte green, third byte red, fourth byte alpha */
-       shared_ptr<Image> image (new Image (AV_PIX_FMT_BGRA, dcp::Size (target.width, height), false));
-       image->make_black ();
-
-#ifdef DCPOMATIC_HAVE_FORMAT_STRIDE_FOR_WIDTH
-       Cairo::RefPtr<Cairo::ImageSurface> surface = Cairo::ImageSurface::create (
-               image->data()[0],
-               Cairo::FORMAT_ARGB32,
-               image->size().width,
-               image->size().height,
-               /* Cairo ARGB32 means first byte blue, second byte green, third byte red, fourth byte alpha */
-               Cairo::ImageSurface::format_stride_for_width (Cairo::FORMAT_ARGB32, image->size().width)
-               );
-#else
-       /* Centos 5 does not have Cairo::ImageSurface::format_stride_for_width, so just use width * 4
-          which I hope is safe (if slow)
-       */
-       Cairo::RefPtr<Cairo::ImageSurface> surface = Cairo::ImageSurface::create (
-               image->data()[0],
-               Cairo::FORMAT_ARGB32,
-               image->size().width,
-               image->size().height,
-               image->size().width * 4
-               );
-#endif
-
-       Cairo::RefPtr<Cairo::Context> context = Cairo::Context::create (surface);
-
-       if (!fc_config) {
-               fc_config = FcConfigCreate ();
-       }
-
-       FontFiles font_files;
-
-       try {
-               font_files.set (FontFiles::NORMAL, shared_path () / "LiberationSans-Regular.ttf");
-               font_files.set (FontFiles::ITALIC, shared_path () / "LiberationSans-Italic.ttf");
-               font_files.set (FontFiles::BOLD, shared_path () / "LiberationSans-Bold.ttf");
-       } catch (boost::filesystem::filesystem_error& e) {
-
-       }
-
-       /* Hack: try the debian/ubuntu locations if getting the shared path failed */
-
-       if (!font_files.get(FontFiles::NORMAL) || !boost::filesystem::exists(font_files.get(FontFiles::NORMAL).get())) {
-               font_files.set (FontFiles::NORMAL, "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf");
-       }
-       if (!font_files.get(FontFiles::ITALIC) || !boost::filesystem::exists(font_files.get(FontFiles::ITALIC).get())) {
-               font_files.set (FontFiles::ITALIC, "/usr/share/fonts/truetype/liberation/LiberationSans-Italic.ttf");
-       }
-       if (!font_files.get(FontFiles::BOLD) || !boost::filesystem::exists(font_files.get(FontFiles::BOLD).get())) {
-               font_files.set (FontFiles::BOLD, "/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf");
-       }
-
-       BOOST_FOREACH (shared_ptr<Font> i, fonts) {
-               if (i->id() == subtitles.front().font() && i->file(FontFiles::NORMAL)) {
-                       font_files = i->files ();
-               }
-       }
-
-       list<pair<FontFiles, string> >::const_iterator existing = fc_config_fonts.begin ();
-       while (existing != fc_config_fonts.end() && existing->first != font_files) {
-               ++existing;
-       }
-
-       string font_name;
-       if (existing != fc_config_fonts.end ()) {
-               font_name = existing->second;
-       } else {
-               /* Make this font available to DCP-o-matic */
-               for (int i = 0; i < FontFiles::VARIANTS; ++i) {
-                       if (font_files.get(static_cast<FontFiles::Variant>(i))) {
-                               FcConfigAppFontAddFile (
-                                       fc_config,
-                                       reinterpret_cast<FcChar8 const *> (font_files.get(static_cast<FontFiles::Variant>(i)).get().string().c_str())
-                                       );
-                       }
-               }
-
-               FcPattern* pattern = FcPatternBuild (
-                       0, FC_FILE, FcTypeString, font_files.get(FontFiles::NORMAL).get().string().c_str(), static_cast<char *> (0)
-                       );
-               FcObjectSet* object_set = FcObjectSetBuild (FC_FAMILY, FC_STYLE, FC_LANG, FC_FILE, static_cast<char *> (0));
-               FcFontSet* font_set = FcFontList (fc_config, pattern, object_set);
-               if (font_set) {
-                       for (int i = 0; i < font_set->nfont; ++i) {
-                               FcPattern* font = font_set->fonts[i];
-                               FcChar8* file;
-                               FcChar8* family;
-                               FcChar8* style;
-                               if (
-                                       FcPatternGetString (font, FC_FILE, 0, &file) == FcResultMatch &&
-                                       FcPatternGetString (font, FC_FAMILY, 0, &family) == FcResultMatch &&
-                                       FcPatternGetString (font, FC_STYLE, 0, &style) == FcResultMatch
-                                       ) {
-                                       font_name = reinterpret_cast<char const *> (family);
-                               }
-                       }
-
-                       FcFontSetDestroy (font_set);
-               }
-
-               FcObjectSetDestroy (object_set);
-               FcPatternDestroy (pattern);
-
-               fc_config_fonts.push_back (make_pair (font_files, font_name));
-       }
-
-       FcConfigSetCurrent (fc_config);
-
-       Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context);
-
-       layout->set_alignment (Pango::ALIGN_LEFT);
-
-       context->set_line_width (1);
-       context->set_antialias (Cairo::ANTIALIAS_GRAY);
-       Cairo::FontOptions fo;
-       context->get_font_options (fo);
-       fo.set_antialias (Cairo::ANTIALIAS_GRAY);
-       context->set_font_options (fo);
-
-       /* Compute fade factor */
-       float fade_factor = 1;
-
-       /* Round the fade start/end to the nearest frame start.  Otherwise if a subtitle starts just after
-          the start of a frame it will be faded out.
-       */
-       DCPTime const fade_in_start = DCPTime::from_seconds(subtitles.front().in().as_seconds()).round(frame_rate);
-       DCPTime const fade_in_end = fade_in_start + DCPTime::from_seconds (subtitles.front().fade_up_time().as_seconds ());
-       DCPTime const fade_out_end =  DCPTime::from_seconds (subtitles.front().out().as_seconds()).round(frame_rate);
-       DCPTime const fade_out_start = fade_out_end - DCPTime::from_seconds (subtitles.front().fade_down_time().as_seconds ());
-
-       if (fade_in_start <= time && time <= fade_in_end && fade_in_start != fade_in_end) {
-               fade_factor *= DCPTime(time - fade_in_start).seconds() / DCPTime(fade_in_end - fade_in_start).seconds();
-       }
-       if (fade_out_start <= time && time <= fade_out_end && fade_out_start != fade_out_end) {
-               fade_factor *= 1 - DCPTime(time - fade_out_start).seconds() / DCPTime(fade_out_end - fade_out_start).seconds();
-       }
-       if (time < fade_in_start || time > fade_out_end) {
-               fade_factor = 0;
-       }
-
-       /* Render the subtitle at the top left-hand corner of image */
-
-       Pango::FontDescription font (font_name);
-       layout->set_font_description (font);
-       layout->set_markup (marked_up (subtitles, target.height, fade_factor));
-
-       context->scale (xscale, yscale);
-       layout->update_from_cairo_context (context);
-
-       /* 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 = subtitles.front().effect() == dcp::BORDER ? (target.width / 600.0) : 0;
-       /* Move down a bit so that accents on capital letters can be seen */
-       int const y_offset = target.height / 100.0;
-
-       if (subtitles.front().effect() == dcp::SHADOW) {
-               /* Drop-shadow effect */
-               set_source_rgba (context, subtitles.front().effect_colour(), fade_factor);
-               context->move_to (x_offset + 4, y_offset + 4);
-               layout->add_to_cairo_context (context);
-               context->fill ();
-       }
-
-       if (subtitles.front().effect() == dcp::BORDER) {
-               /* Border effect; stroke the subtitle with a large (arbitrarily chosen) line width */
-               set_source_rgba (context, subtitles.front().effect_colour(), fade_factor);
-               context->set_line_width (subtitles.front().outline_width * target.width / 2048.0);
-               context->set_line_join (Cairo::LINE_JOIN_ROUND);
-               context->move_to (x_offset, y_offset);
-               layout->add_to_cairo_context (context);
-               context->stroke ();
-       }
-
-       /* The actual subtitle */
-
-       context->set_line_width (0);
-       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
-
-       int layout_width;
-       int layout_height;
-       layout->get_pixel_size (layout_width, layout_height);
-       layout_width *= xscale;
-       layout_height *= yscale;
-
-       int x = 0;
-       switch (subtitles.front().h_align ()) {
-       case dcp::HALIGN_LEFT:
-               /* h_position is distance between left of frame and left of subtitle */
-               x = subtitles.front().h_position() * target.width;
-               break;
-       case dcp::HALIGN_CENTER:
-               /* h_position is distance between centre of frame and centre of subtitle */
-               x = (0.5 + subtitles.front().h_position()) * target.width - layout_width / 2;
-               break;
-       case dcp::HALIGN_RIGHT:
-               /* h_position is distance between right of frame and right of subtitle */
-               x = (1.0 - subtitles.front().h_position()) * target.width - layout_width;
-               break;
-       }
-
-       int y = 0;
-       switch (subtitles.front().v_align ()) {
-       case dcp::VALIGN_TOP:
-               /* SMPTE says that v_position is the distance between top
-                  of frame and top of subtitle, but this doesn't always seem to be
-                  the case in practice; Gunnar Ásgeirsson's Dolby server appears
-                  to put VALIGN_TOP subs with v_position as the distance between top
-                  of frame and bottom of subtitle.
-               */
-               y = subtitles.front().v_position() * target.height - layout_height;
-               break;
-       case dcp::VALIGN_CENTER:
-               /* v_position is distance between centre of frame and centre of subtitle */
-               y = (0.5 + subtitles.front().v_position()) * target.height - layout_height / 2;
-               break;
-       case dcp::VALIGN_BOTTOM:
-               /* v_position is distance between bottom of frame and bottom of subtitle */
-               y = (1.0 - subtitles.front().v_position()) * target.height - layout_height;
-               break;
-       }
-
-       return PositionImage (image, Position<int> (max (0, x), max (0, y)));
-}
-
-/** @param time Time of the frame that these subtitles are going on.
- *  @param frame_rate DCP frame rate.
- */
-list<PositionImage>
-render_subtitles (list<SubtitleString> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target, DCPTime time, int frame_rate)
-{
-       list<SubtitleString> pending;
-       list<PositionImage> images;
-
-       BOOST_FOREACH (SubtitleString const & i, subtitles) {
-               if (!pending.empty() && fabs (i.v_position() - pending.back().v_position()) > 1e-4) {
-                       images.push_back (render_line (pending, fonts, target, time, frame_rate));
-                       pending.clear ();
-               }
-               pending.push_back (i);
-       }
-
-       if (!pending.empty ()) {
-               images.push_back (render_line (pending, fonts, target, time, frame_rate));
-       }
-
-       return images;
-}
diff --git a/src/lib/render_subtitles.h b/src/lib/render_subtitles.h
deleted file mode 100644 (file)
index b1239bb..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    DCP-o-matic is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "position_image.h"
-#include "dcpomatic_time.h"
-#include "subtitle_string.h"
-#include <dcp/util.h>
-
-class Font;
-
-std::string marked_up (std::list<SubtitleString> subtitles, int target_height, float fade_factor);
-std::list<PositionImage> render_subtitles (
-       std::list<SubtitleString>, std::list<boost::shared_ptr<Font> > fonts, dcp::Size, DCPTime, int
-       );
diff --git a/src/lib/render_text.cc b/src/lib/render_text.cc
new file mode 100644 (file)
index 0000000..6730783
--- /dev/null
@@ -0,0 +1,386 @@
+/*
+    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "render_text.h"
+#include "types.h"
+#include "image.h"
+#include "cross.h"
+#include "font.h"
+#include "dcpomatic_assert.h"
+#include <dcp/raw_convert.h>
+#include <fontconfig/fontconfig.h>
+#include <cairomm/cairomm.h>
+#include <pangomm.h>
+#ifndef DCPOMATIC_HAVE_SHOW_IN_CAIRO_CONTEXT
+#include <pango/pangocairo.h>
+#endif
+#include <boost/foreach.hpp>
+#include <boost/algorithm/string.hpp>
+#include <iostream>
+
+using std::list;
+using std::cout;
+using std::string;
+using std::min;
+using std::max;
+using std::pair;
+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;
+
+string
+marked_up (list<SubtitleString> subtitles, int target_height, float fade_factor)
+{
+       string out;
+
+       BOOST_FOREACH (SubtitleString const & i, subtitles) {
+               out += "<span ";
+               if (i.italic()) {
+                       out += "style=\"italic\" ";
+               }
+               if (i.bold()) {
+                       out += "weight=\"bold\" ";
+               }
+               if (i.underline()) {
+                       out += "underline=\"single\" ";
+               }
+               out += "size=\"" + dcp::raw_convert<string>(i.size_in_pixels(target_height) * 72 * 1024 / 96) + "\" ";
+               /* Between 1-65535 inclusive, apparently... */
+               out += "alpha=\"" + dcp::raw_convert<string>(int(floor(fade_factor * 65534)) + 1) + "\" ";
+               out += "color=\"#" + i.colour().to_rgb_string() + "\">";
+
+               string t = i.text();
+               replace_all(t, "&", "&amp;");
+               out += t;
+
+               out += "</span>";
+       }
+
+       return out;
+}
+
+static void
+set_source_rgba (Cairo::RefPtr<Cairo::Context> context, dcp::Colour colour, float fade_factor)
+{
+       context->set_source_rgba (float(colour.r) / 255, float(colour.g) / 255, float(colour.b) / 255, fade_factor);
+}
+
+/** @param subtitles A list of subtitles that are all on the same line,
+ *  at the same time and with the same fade in/out.
+ */
+static PositionImage
+render_line (list<SubtitleString> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target, DCPTime time, int frame_rate)
+{
+       /* XXX: this method can only handle italic / bold changes mid-line,
+          nothing else yet.
+       */
+
+       DCPOMATIC_ASSERT (!subtitles.empty ());
+
+       /* Calculate x and y scale factors.  These are only used to stretch
+          the font away from its normal aspect ratio.
+       */
+       float xscale = 1;
+       float yscale = 1;
+       if (fabs (subtitles.front().aspect_adjust() - 1.0) > dcp::ASPECT_ADJUST_EPSILON) {
+               if (subtitles.front().aspect_adjust() < 1) {
+                       xscale = max (0.25f, subtitles.front().aspect_adjust ());
+                       yscale = 1;
+               } else {
+                       xscale = 1;
+                       yscale = 1 / min (4.0f, subtitles.front().aspect_adjust ());
+               }
+       }
+
+       /* Make an empty bitmap as wide as target and at
+          least tall enough for this subtitle.
+       */
+
+       int largest = 0;
+       BOOST_FOREACH (dcp::SubtitleString const & i, subtitles) {
+               largest = max (largest, i.size());
+       }
+       /* Basic guess on height... */
+       int height = largest * target.height / (11 * 72);
+       /* ...scaled... */
+       height *= yscale;
+       /* ...and add a bit more for luck */
+       height += target.height / 11;
+
+       /* FFmpeg BGRA means first byte blue, second byte green, third byte red, fourth byte alpha */
+       shared_ptr<Image> image (new Image (AV_PIX_FMT_BGRA, dcp::Size (target.width, height), false));
+       image->make_black ();
+
+#ifdef DCPOMATIC_HAVE_FORMAT_STRIDE_FOR_WIDTH
+       Cairo::RefPtr<Cairo::ImageSurface> surface = Cairo::ImageSurface::create (
+               image->data()[0],
+               Cairo::FORMAT_ARGB32,
+               image->size().width,
+               image->size().height,
+               /* Cairo ARGB32 means first byte blue, second byte green, third byte red, fourth byte alpha */
+               Cairo::ImageSurface::format_stride_for_width (Cairo::FORMAT_ARGB32, image->size().width)
+               );
+#else
+       /* Centos 5 does not have Cairo::ImageSurface::format_stride_for_width, so just use width * 4
+          which I hope is safe (if slow)
+       */
+       Cairo::RefPtr<Cairo::ImageSurface> surface = Cairo::ImageSurface::create (
+               image->data()[0],
+               Cairo::FORMAT_ARGB32,
+               image->size().width,
+               image->size().height,
+               image->size().width * 4
+               );
+#endif
+
+       Cairo::RefPtr<Cairo::Context> context = Cairo::Context::create (surface);
+
+       if (!fc_config) {
+               fc_config = FcConfigCreate ();
+       }
+
+       FontFiles font_files;
+
+       try {
+               font_files.set (FontFiles::NORMAL, shared_path () / "LiberationSans-Regular.ttf");
+               font_files.set (FontFiles::ITALIC, shared_path () / "LiberationSans-Italic.ttf");
+               font_files.set (FontFiles::BOLD, shared_path () / "LiberationSans-Bold.ttf");
+       } catch (boost::filesystem::filesystem_error& e) {
+
+       }
+
+       /* Hack: try the debian/ubuntu locations if getting the shared path failed */
+
+       if (!font_files.get(FontFiles::NORMAL) || !boost::filesystem::exists(font_files.get(FontFiles::NORMAL).get())) {
+               font_files.set (FontFiles::NORMAL, "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf");
+       }
+       if (!font_files.get(FontFiles::ITALIC) || !boost::filesystem::exists(font_files.get(FontFiles::ITALIC).get())) {
+               font_files.set (FontFiles::ITALIC, "/usr/share/fonts/truetype/liberation/LiberationSans-Italic.ttf");
+       }
+       if (!font_files.get(FontFiles::BOLD) || !boost::filesystem::exists(font_files.get(FontFiles::BOLD).get())) {
+               font_files.set (FontFiles::BOLD, "/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf");
+       }
+
+       BOOST_FOREACH (shared_ptr<Font> i, fonts) {
+               if (i->id() == subtitles.front().font() && i->file(FontFiles::NORMAL)) {
+                       font_files = i->files ();
+               }
+       }
+
+       list<pair<FontFiles, string> >::const_iterator existing = fc_config_fonts.begin ();
+       while (existing != fc_config_fonts.end() && existing->first != font_files) {
+               ++existing;
+       }
+
+       string font_name;
+       if (existing != fc_config_fonts.end ()) {
+               font_name = existing->second;
+       } else {
+               /* Make this font available to DCP-o-matic */
+               for (int i = 0; i < FontFiles::VARIANTS; ++i) {
+                       if (font_files.get(static_cast<FontFiles::Variant>(i))) {
+                               FcConfigAppFontAddFile (
+                                       fc_config,
+                                       reinterpret_cast<FcChar8 const *> (font_files.get(static_cast<FontFiles::Variant>(i)).get().string().c_str())
+                                       );
+                       }
+               }
+
+               FcPattern* pattern = FcPatternBuild (
+                       0, FC_FILE, FcTypeString, font_files.get(FontFiles::NORMAL).get().string().c_str(), static_cast<char *> (0)
+                       );
+               FcObjectSet* object_set = FcObjectSetBuild (FC_FAMILY, FC_STYLE, FC_LANG, FC_FILE, static_cast<char *> (0));
+               FcFontSet* font_set = FcFontList (fc_config, pattern, object_set);
+               if (font_set) {
+                       for (int i = 0; i < font_set->nfont; ++i) {
+                               FcPattern* font = font_set->fonts[i];
+                               FcChar8* file;
+                               FcChar8* family;
+                               FcChar8* style;
+                               if (
+                                       FcPatternGetString (font, FC_FILE, 0, &file) == FcResultMatch &&
+                                       FcPatternGetString (font, FC_FAMILY, 0, &family) == FcResultMatch &&
+                                       FcPatternGetString (font, FC_STYLE, 0, &style) == FcResultMatch
+                                       ) {
+                                       font_name = reinterpret_cast<char const *> (family);
+                               }
+                       }
+
+                       FcFontSetDestroy (font_set);
+               }
+
+               FcObjectSetDestroy (object_set);
+               FcPatternDestroy (pattern);
+
+               fc_config_fonts.push_back (make_pair (font_files, font_name));
+       }
+
+       FcConfigSetCurrent (fc_config);
+
+       Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context);
+
+       layout->set_alignment (Pango::ALIGN_LEFT);
+
+       context->set_line_width (1);
+       context->set_antialias (Cairo::ANTIALIAS_GRAY);
+       Cairo::FontOptions fo;
+       context->get_font_options (fo);
+       fo.set_antialias (Cairo::ANTIALIAS_GRAY);
+       context->set_font_options (fo);
+
+       /* Compute fade factor */
+       float fade_factor = 1;
+
+       /* Round the fade start/end to the nearest frame start.  Otherwise if a subtitle starts just after
+          the start of a frame it will be faded out.
+       */
+       DCPTime const fade_in_start = DCPTime::from_seconds(subtitles.front().in().as_seconds()).round(frame_rate);
+       DCPTime const fade_in_end = fade_in_start + DCPTime::from_seconds (subtitles.front().fade_up_time().as_seconds ());
+       DCPTime const fade_out_end =  DCPTime::from_seconds (subtitles.front().out().as_seconds()).round(frame_rate);
+       DCPTime const fade_out_start = fade_out_end - DCPTime::from_seconds (subtitles.front().fade_down_time().as_seconds ());
+
+       if (fade_in_start <= time && time <= fade_in_end && fade_in_start != fade_in_end) {
+               fade_factor *= DCPTime(time - fade_in_start).seconds() / DCPTime(fade_in_end - fade_in_start).seconds();
+       }
+       if (fade_out_start <= time && time <= fade_out_end && fade_out_start != fade_out_end) {
+               fade_factor *= 1 - DCPTime(time - fade_out_start).seconds() / DCPTime(fade_out_end - fade_out_start).seconds();
+       }
+       if (time < fade_in_start || time > fade_out_end) {
+               fade_factor = 0;
+       }
+
+       /* Render the subtitle at the top left-hand corner of image */
+
+       Pango::FontDescription font (font_name);
+       layout->set_font_description (font);
+       layout->set_markup (marked_up (subtitles, target.height, fade_factor));
+
+       context->scale (xscale, yscale);
+       layout->update_from_cairo_context (context);
+
+       /* 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 = subtitles.front().effect() == dcp::BORDER ? (target.width / 600.0) : 0;
+       /* Move down a bit so that accents on capital letters can be seen */
+       int const y_offset = target.height / 100.0;
+
+       if (subtitles.front().effect() == dcp::SHADOW) {
+               /* Drop-shadow effect */
+               set_source_rgba (context, subtitles.front().effect_colour(), fade_factor);
+               context->move_to (x_offset + 4, y_offset + 4);
+               layout->add_to_cairo_context (context);
+               context->fill ();
+       }
+
+       if (subtitles.front().effect() == dcp::BORDER) {
+               /* Border effect; stroke the subtitle with a large (arbitrarily chosen) line width */
+               set_source_rgba (context, subtitles.front().effect_colour(), fade_factor);
+               context->set_line_width (subtitles.front().outline_width * target.width / 2048.0);
+               context->set_line_join (Cairo::LINE_JOIN_ROUND);
+               context->move_to (x_offset, y_offset);
+               layout->add_to_cairo_context (context);
+               context->stroke ();
+       }
+
+       /* The actual subtitle */
+
+       context->set_line_width (0);
+       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
+
+       int layout_width;
+       int layout_height;
+       layout->get_pixel_size (layout_width, layout_height);
+       layout_width *= xscale;
+       layout_height *= yscale;
+
+       int x = 0;
+       switch (subtitles.front().h_align ()) {
+       case dcp::HALIGN_LEFT:
+               /* h_position is distance between left of frame and left of subtitle */
+               x = subtitles.front().h_position() * target.width;
+               break;
+       case dcp::HALIGN_CENTER:
+               /* h_position is distance between centre of frame and centre of subtitle */
+               x = (0.5 + subtitles.front().h_position()) * target.width - layout_width / 2;
+               break;
+       case dcp::HALIGN_RIGHT:
+               /* h_position is distance between right of frame and right of subtitle */
+               x = (1.0 - subtitles.front().h_position()) * target.width - layout_width;
+               break;
+       }
+
+       int y = 0;
+       switch (subtitles.front().v_align ()) {
+       case dcp::VALIGN_TOP:
+               /* SMPTE says that v_position is the distance between top
+                  of frame and top of subtitle, but this doesn't always seem to be
+                  the case in practice; Gunnar Ásgeirsson's Dolby server appears
+                  to put VALIGN_TOP subs with v_position as the distance between top
+                  of frame and bottom of subtitle.
+               */
+               y = subtitles.front().v_position() * target.height - layout_height;
+               break;
+       case dcp::VALIGN_CENTER:
+               /* v_position is distance between centre of frame and centre of subtitle */
+               y = (0.5 + subtitles.front().v_position()) * target.height - layout_height / 2;
+               break;
+       case dcp::VALIGN_BOTTOM:
+               /* v_position is distance between bottom of frame and bottom of subtitle */
+               y = (1.0 - subtitles.front().v_position()) * target.height - layout_height;
+               break;
+       }
+
+       return PositionImage (image, Position<int> (max (0, x), max (0, y)));
+}
+
+/** @param time Time of the frame that these subtitles are going on.
+ *  @param frame_rate DCP frame rate.
+ */
+list<PositionImage>
+render_text (list<SubtitleString> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target, DCPTime time, int frame_rate)
+{
+       list<SubtitleString> pending;
+       list<PositionImage> images;
+
+       BOOST_FOREACH (SubtitleString const & i, subtitles) {
+               if (!pending.empty() && fabs (i.v_position() - pending.back().v_position()) > 1e-4) {
+                       images.push_back (render_line (pending, fonts, target, time, frame_rate));
+                       pending.clear ();
+               }
+               pending.push_back (i);
+       }
+
+       if (!pending.empty ()) {
+               images.push_back (render_line (pending, fonts, target, time, frame_rate));
+       }
+
+       return images;
+}
diff --git a/src/lib/render_text.h b/src/lib/render_text.h
new file mode 100644 (file)
index 0000000..0f3a31e
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "position_image.h"
+#include "dcpomatic_time.h"
+#include "subtitle_string.h"
+#include <dcp/util.h>
+
+class Font;
+
+std::string marked_up (std::list<SubtitleString> subtitles, int target_height, float fade_factor);
+std::list<PositionImage> render_text (
+       std::list<SubtitleString>, std::list<boost::shared_ptr<Font> > fonts, dcp::Size, DCPTime, int
+       );
index 56a7e1e1598a4853f80903b6e5aa69f54d87351d..8b825936a3ddf3f314fd8baa1a279d6a5fbef154 100644 (file)
@@ -58,14 +58,14 @@ TextDecoder::TextDecoder (
  *  of the video frame)
  */
 void
-TextDecoder::emit_image_start (ContentTime from, shared_ptr<Image> image, dcpomatic::Rect<double> rect)
+TextDecoder::emit_bitmap_start (ContentTime from, shared_ptr<Image> image, dcpomatic::Rect<double> rect)
 {
-       ImageStart (ContentImageSubtitle (from, image, rect));
+       BitmapStart (ContentBitmapText (from, image, rect));
        _position = from;
 }
 
 void
-TextDecoder::emit_text_start (ContentTime from, list<dcp::SubtitleString> s)
+TextDecoder::emit_plain_start (ContentTime from, list<dcp::SubtitleString> s)
 {
        BOOST_FOREACH (dcp::SubtitleString& i, s) {
                /* We must escape < and > in strings, otherwise they might confuse our subtitle
@@ -94,12 +94,12 @@ TextDecoder::emit_text_start (ContentTime from, list<dcp::SubtitleString> s)
                }
        }
 
-       TextStart (ContentTextSubtitle (from, s));
+       PlainStart (ContentTextSubtitle (from, s));
        _position = from;
 }
 
 void
-TextDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtitle)
+TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & subtitle)
 {
        /* See if our next subtitle needs to be vertically placed on screen by us */
        bool needs_placement = false;
@@ -191,7 +191,7 @@ TextDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtitle)
 
                        /* The idea here (rightly or wrongly) is that we set the appearance based on the
                           values in the libsub objects, and these are overridden with values from the
-                          content by the other emit_text_start() above.
+                          content by the other emit_plain_start() above.
                        */
 
                        out.push_back (
@@ -227,7 +227,7 @@ TextDecoder::emit_text_start (ContentTime from, sub::Subtitle const & subtitle)
                }
        }
 
-       emit_text_start (from, out);
+       emit_plain_start (from, out);
 }
 
 void
@@ -237,16 +237,16 @@ TextDecoder::emit_stop (ContentTime to)
 }
 
 void
-TextDecoder::emit_text (ContentTimePeriod period, list<dcp::SubtitleString> s)
+TextDecoder::emit_plain (ContentTimePeriod period, list<dcp::SubtitleString> s)
 {
-       emit_text_start (period.from, s);
+       emit_plain_start (period.from, s);
        emit_stop (period.to);
 }
 
 void
-TextDecoder::emit_text (ContentTimePeriod period, sub::Subtitle const & s)
+TextDecoder::emit_plain (ContentTimePeriod period, sub::Subtitle const & s)
 {
-       emit_text_start (period.from, s);
+       emit_plain_start (period.from, s);
        emit_stop (period.to);
 }
 
index d9d351d92dd0286ac879aad61574344f13ea25c0..221ed6d373d098a49eb751a263edb4b23e597439 100644 (file)
@@ -49,11 +49,11 @@ public:
                return _position;
        }
 
-       void emit_image_start (ContentTime from, boost::shared_ptr<Image> image, dcpomatic::Rect<double> rect);
-       void emit_text_start (ContentTime from, std::list<dcp::SubtitleString> s);
-       void emit_text_start (ContentTime from, sub::Subtitle const & subtitle);
-       void emit_text (ContentTimePeriod period, std::list<dcp::SubtitleString> s);
-       void emit_text (ContentTimePeriod period, sub::Subtitle const & subtitle);
+       void emit_bitmap_start (ContentTime from, boost::shared_ptr<Image> image, dcpomatic::Rect<double> rect);
+       void emit_plain_start (ContentTime from, std::list<dcp::SubtitleString> s);
+       void emit_plain_start (ContentTime from, sub::Subtitle const & subtitle);
+       void emit_plain (ContentTimePeriod period, std::list<dcp::SubtitleString> s);
+       void emit_plain (ContentTimePeriod period, sub::Subtitle const & subtitle);
        void emit_stop (ContentTime to);
 
        void seek ();
@@ -62,8 +62,8 @@ public:
                return _content;
        }
 
-       boost::signals2::signal<void (ContentImageSubtitle)> ImageStart;
-       boost::signals2::signal<void (ContentTextSubtitle)> TextStart;
+       boost::signals2::signal<void (ContentBitmapText)> BitmapStart;
+       boost::signals2::signal<void (ContentTextSubtitle)> PlainStart;
        boost::signals2::signal<void (ContentTime)> Stop;
 
 private:
index 1dba3acd02f9df667d8f3813327b9f2c95558296..a6d7b327bc00a95115d8b3e42d5c9bc2886f57a8 100644 (file)
@@ -68,7 +68,7 @@ TextTextDecoder::pass ()
        }
 
        ContentTimePeriod const p = content_time_period (_subtitles[_next]);
-       subtitle->emit_text (p, _subtitles[_next]);
+       subtitle->emit_plain (p, _subtitles[_next]);
 
        ++_next;
        return false;
diff --git a/src/lib/text_subtitle.cc b/src/lib/text_subtitle.cc
deleted file mode 100644 (file)
index 35801e1..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-    Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    DCP-o-matic is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "text_subtitle.h"
-#include "cross.h"
-#include "exceptions.h"
-#include "plain_text_content.h"
-#include <sub/subrip_reader.h>
-#include <sub/ssa_reader.h>
-#include <sub/collect.h>
-#include <unicode/ucsdet.h>
-#include <unicode/ucnv.h>
-#include <iostream>
-
-#include "i18n.h"
-
-using std::vector;
-using std::cout;
-using std::string;
-using boost::shared_ptr;
-using boost::scoped_array;
-using boost::optional;
-using dcp::Data;
-
-TextSubtitle::TextSubtitle (shared_ptr<const PlainText> content)
-{
-       Data in (content->path (0));
-
-       UErrorCode status = U_ZERO_ERROR;
-       UCharsetDetector* detector = ucsdet_open (&status);
-       ucsdet_setText (detector, reinterpret_cast<const char *> (in.data().get()), in.size(), &status);
-
-       UCharsetMatch const * match = ucsdet_detect (detector, &status);
-       char const * in_charset = ucsdet_getName (match, &status);
-
-       UConverter* to_utf16 = ucnv_open (in_charset, &status);
-       /* This is a guess; I think we should be able to encode any input in 4 times its input size */
-       scoped_array<uint16_t> utf16 (new uint16_t[in.size() * 2]);
-       int const utf16_len = ucnv_toUChars (
-               to_utf16, reinterpret_cast<UChar*>(utf16.get()), in.size() * 2,
-               reinterpret_cast<const char *> (in.data().get()), in.size(),
-               &status
-               );
-
-       UConverter* to_utf8 = ucnv_open ("UTF-8", &status);
-       /* Another guess */
-       scoped_array<char> utf8 (new char[utf16_len * 2]);
-       ucnv_fromUChars (to_utf8, utf8.get(), utf16_len * 2, reinterpret_cast<UChar*>(utf16.get()), utf16_len, &status);
-
-       /* Fix OS X line endings */
-       size_t utf8_len = strlen (utf8.get ());
-       for (size_t i = 0; i < utf8_len; ++i) {
-               if (utf8[i] == '\r' && ((i == utf8_len - 1) || utf8[i + 1] != '\n')) {
-                       utf8[i] = '\n';
-               }
-       }
-
-       ucsdet_close (detector);
-       ucnv_close (to_utf16);
-       ucnv_close (to_utf8);
-
-       sub::Reader* reader = 0;
-
-       string ext = content->path(0).extension().string();
-       transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
-
-       if (ext == ".srt") {
-               reader = new sub::SubripReader (utf8.get());
-       } else if (ext == ".ssa" || ext == ".ass") {
-               reader = new sub::SSAReader (utf8.get());
-       }
-
-       if (reader) {
-               _subtitles = sub::collect<vector<sub::Subtitle> > (reader->subtitles ());
-       }
-
-       delete reader;
-}
-
-/** @return time of first subtitle, if there is one */
-optional<ContentTime>
-TextSubtitle::first () const
-{
-       if (_subtitles.empty()) {
-               return optional<ContentTime>();
-       }
-
-       return ContentTime::from_seconds(_subtitles[0].from.all_as_seconds());
-}
-
-ContentTime
-TextSubtitle::length () const
-{
-       if (_subtitles.empty ()) {
-               return ContentTime ();
-       }
-
-       return ContentTime::from_seconds (_subtitles.back().to.all_as_seconds ());
-}
diff --git a/src/lib/text_subtitle.h b/src/lib/text_subtitle.h
deleted file mode 100644 (file)
index 60571a4..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    DCP-o-matic is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef DCPOMATIC_TEXT_SUBTITLE_H
-#define DCPOMATIC_TEXT_SUBTITLE_H
-
-#include "dcpomatic_time.h"
-#include <sub/subtitle.h>
-#include <boost/shared_ptr.hpp>
-#include <vector>
-
-class PlainText;
-class text_subtitle_time_test;
-class text_subtitle_coordinate_test;
-class plain_text_content_test;
-class text_subtitle_parse_test;
-
-class TextSubtitle
-{
-public:
-       explicit TextSubtitle (boost::shared_ptr<const PlainText>);
-
-       boost::optional<ContentTime> first () const;
-       ContentTime length () const;
-
-protected:
-       std::vector<sub::Subtitle> _subtitles;
-};
-
-#endif
index b3e04e28b24de5275facf96e9c14fad52d615cd9..dd7c87f398d0571a513ea10d4a700fb1a6e3c013 100644 (file)
@@ -119,7 +119,7 @@ sources = """
           ratio.cc
           raw_image_proxy.cc
           reel_writer.cc
-          render_subtitles.cc
+          render_text.cc
           resampler.cc
           rgba.cc
           scoped_temporary.cc
@@ -134,7 +134,7 @@ sources = """
           string_log_entry.cc
           text_content.cc
           text_decoder.cc
-          text_subtitle.cc
+          plain_text.cc
           plain_text_content.cc
           plain_text_decoder.cc
           timer.cc
index 225ac5d6b22ebf6a6b836766df2697555c2d4ee7..578c9fa242cbf0a471802de00bc5322898bd849b 100644 (file)
@@ -40,7 +40,7 @@
 #include "lib/log.h"
 #include "lib/compose.hpp"
 #include "lib/plain_text_content.h"
-#include "lib/text_subtitle.h"
+#include "lib/plain_text.h"
 #include <wx/wx.h>
 #include <wx/notebook.h>
 #include <wx/listctrl.h>
index eb63ca443106643c4265ccf4b5d5d5961830bf26..41bf4b049f86700942b5cf7487a90a8628a7b919 100644 (file)
@@ -84,7 +84,7 @@ SubtitleView::SubtitleView (wxWindow* parent, shared_ptr<Film> film, shared_ptr<
 
        _subs = 0;
        _frc = film->active_frame_rate_change (content->position());
-       decoder->subtitle->TextStart.connect (bind (&SubtitleView::data_start, this, _1));
+       decoder->subtitle->PlainStart.connect (bind (&SubtitleView::data_start, this, _1));
        decoder->subtitle->Stop.connect (bind (&SubtitleView::data_stop, this, _1));
        while (!decoder->pass ()) {}
        SetSizerAndFit (sizer);
index 3d05e143dd544b86738e00f313ef837d6ff07dcd..026fbd12a04f786d4ffadbfc72656c888b44b399 100644 (file)
@@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_within_dcp_test)
        BOOST_REQUIRE (!wait_for_jobs ());
 
        shared_ptr<DCPDecoder> decoder (new DCPDecoder (content, film->log(), false));
-       decoder->subtitle->TextStart.connect (bind (store, _1));
+       decoder->subtitle->PlainStart.connect (bind (store, _1));
 
        stored = optional<ContentTextSubtitle> ();
        while (!decoder->pass() && !stored) {}
@@ -114,7 +114,7 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test2)
        BOOST_REQUIRE (!wait_for_jobs ());
 
        shared_ptr<DCPTextDecoder> decoder (new DCPTextDecoder (content, film->log()));
-       decoder->subtitle->TextStart.connect (bind (store, _1));
+       decoder->subtitle->PlainStart.connect (bind (store, _1));
 
        stored = optional<ContentTextSubtitle> ();
        while (!decoder->pass ()) {
@@ -142,7 +142,7 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test3)
        shared_ptr<DCPTextDecoder> decoder (new DCPTextDecoder (content, film->log()));
        stored = optional<ContentTextSubtitle> ();
        while (!decoder->pass ()) {
-               decoder->subtitle->TextStart.connect (bind (store, _1));
+               decoder->subtitle->PlainStart.connect (bind (store, _1));
                if (stored && stored->from() == ContentTime::from_seconds(0.08)) {
                        list<dcp::SubtitleString> s = stored->subs;
                        list<dcp::SubtitleString>::const_iterator i = s.begin ();
index 4276a2b01e58ae155a595a5f223bcb3303484001..bd676eab0ad2e19471b4523259042fb59badeb8b 100644 (file)
 
 */
 
-/** @file  test/render_subtitles_test.cc
+/** @file  test/render_text_test.cc
  *  @brief Check markup of subtitles for rendering.
  *  @ingroup specific
  */
 
-#include "lib/render_subtitles.h"
+#include "lib/render_text.h"
 #include <dcp/subtitle_string.h>
 #include <boost/test/unit_test.hpp>
 
@@ -57,7 +57,7 @@ add (std::list<SubtitleString>& s, std::string text, bool italic, bool bold, boo
                );
 }
 
-/** Test marked_up() in render_subtitles.cc */
+/** Test marked_up() in render_text.cc */
 BOOST_AUTO_TEST_CASE (render_markup_test1)
 {
        std::list<SubtitleString> s;
@@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test1)
        BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
 }
 
-/** Test marked_up() in render_subtitles.cc */
+/** Test marked_up() in render_text.cc */
 BOOST_AUTO_TEST_CASE (render_markup_test2)
 {
        std::list<SubtitleString> s;
@@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test2)
 }
 
 
-/** Test marked_up() in render_subtitles.cc */
+/** Test marked_up() in render_text.cc */
 BOOST_AUTO_TEST_CASE (render_markup_test3)
 {
        std::list<SubtitleString> s;
@@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test3)
        BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span style=\"italic\" weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
 }
 
-/** Test marked_up() in render_subtitles.cc */
+/** Test marked_up() in render_text.cc */
 BOOST_AUTO_TEST_CASE (render_markup_test4)
 {
        std::list<SubtitleString> s;
@@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test4)
        BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span style=\"italic\" weight=\"bold\" underline=\"single\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
 }
 
-/** Test marked_up() in render_subtitles.cc */
+/** Test marked_up() in render_text.cc */
 BOOST_AUTO_TEST_CASE (render_markup_test5)
 {
        std::list<SubtitleString> s;
@@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test5)
        BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span><span size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\"> world.</span>");
 }
 
-/** Test marked_up() in render_subtitles.cc */
+/** Test marked_up() in render_text.cc */
 BOOST_AUTO_TEST_CASE (render_markup_test6)
 {
        std::list<SubtitleString> s;
index 199af34ad1c3b0f2bb640c508ad32c11a4ef41d6..1570cdce96773b936f6d5bd5c3fca7ac55039b7b 100644 (file)
@@ -190,14 +190,14 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test4)
        BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds ((3 * 60) + 56.471));
 
        shared_ptr<SubRipDecoder> decoder (new SubRipDecoder (content));
-       list<ContentTextSubtitle> cts = decoder->get_text_subtitles (
+       list<ContentTextSubtitle> cts = decoder->get_plain_texts (
                ContentTimePeriod (
                        ContentTime::from_seconds (109), ContentTime::from_seconds (110)
                        ), false
                );
        BOOST_CHECK_EQUAL (cts.size(), 1);
 
-       PositionImage image = render_subtitles (cts.front().subs, dcp::Size (1998, 1080));
+       PositionImage image = render_text (cts.front().subs, dcp::Size (1998, 1080));
        write_image (image.image, "build/test/subrip_render_test.png");
        check_file ("build/test/subrip_render_test.png", "test/data/subrip_render_test.png");
 }
index 9b2de21327578b0ffdde57b29f5407360a6a7790..2b1b97b256883fea83f40ceeddd71d61ac31fa2d 100644 (file)
@@ -22,7 +22,7 @@
 #include "lib/content.h"
 #include "lib/film.h"
 #include "lib/content_factory.h"
-#include "lib/text_subtitle.h"
+#include "lib/plain_text.h"
 #include "lib/plain_text_content.h"
 #include <boost/test/unit_test.hpp>