/*
Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
- This program is free software; you can redistribute it and/or modify
+ 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.
- This program is distributed in the hope that it will be useful,
+ 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
static FcConfig* fc_config = 0;
static list<pair<FontFiles, string> > fc_config_fonts;
+string
+marked_up (list<dcp::SubtitleString> subtitles)
+{
+ string out;
+ bool italic = false;
+ bool bold = false;
+ bool underline = false;
+ BOOST_FOREACH (dcp::SubtitleString const & i, subtitles) {
+
+ if (i.italic() && !italic) {
+ out += "<i>";
+ }
+ if (i.bold() && !bold) {
+ out += "<b>";
+ }
+ if (i.underline() && !underline) {
+ out += "<u>";
+ }
+ if (!i.underline() && underline) {
+ out += "</u>";
+ }
+ if (!i.bold() && bold) {
+ out += "</b>";
+ }
+ if (!i.italic() && italic) {
+ out += "</i>";
+ }
+
+ italic = i.italic ();
+ bold = i.bold ();
+ underline = i.underline ();
+
+ out += i.text ();
+ }
+
+ if (underline) {
+ out += "</u>";
+ }
+ if (bold) {
+ out += "</b>";
+ }
+ if (italic) {
+ out += "</i>";
+ }
+
+ return out;
+}
+
/** @param subtitles A list of subtitles that are all on the same line */
static PositionImage
render_line (list<dcp::SubtitleString> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target)
Pango::FontDescription font (font_name);
font.set_absolute_size (subtitles.front().size_in_pixels (target.height) * PANGO_SCALE);
layout->set_font_description (font);
-
- string marked_up;
- bool italic = false;
- BOOST_FOREACH (dcp::SubtitleString const & i, subtitles) {
- if (i.italic() != italic) {
- if (i.italic()) {
- marked_up += "<i>";
- } else {
- marked_up += "</i>";
- }
- italic = i.italic ();
- }
-
- marked_up += i.text ();
- }
-
- if (italic) {
- marked_up += "</i>";
- }
-
- layout->set_markup (marked_up);
+ layout->set_markup (marked_up (subtitles));
/* Compute fade factor */
/* XXX */