X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Frender_subtitles.cc;h=782d06532e378d240699419c3031ae41fe04191a;hp=16c6a3c4eee13552ecdd1f9b8581854b9b5ee1e6;hb=422be0eece2bf6ee80db1d3c21553cd82efff789;hpb=4835e35b1d483922ff6c80e6ed3a4d7055233e1b diff --git a/src/lib/render_subtitles.cc b/src/lib/render_subtitles.cc index 16c6a3c4e..782d06532 100644 --- a/src/lib/render_subtitles.cc +++ b/src/lib/render_subtitles.cc @@ -1,19 +1,20 @@ /* Copyright (C) 2014-2016 Carl Hetherington - 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 . */ @@ -43,6 +44,54 @@ using boost::optional; static FcConfig* fc_config = 0; static list > fc_config_fonts; +string +marked_up (list subtitles) +{ + string out; + bool italic = false; + bool bold = false; + bool underline = false; + BOOST_FOREACH (dcp::SubtitleString const & i, subtitles) { + + if (i.italic() && !italic) { + out += ""; + } + if (i.bold() && !bold) { + out += ""; + } + if (i.underline() && !underline) { + out += ""; + } + if (!i.underline() && underline) { + out += ""; + } + if (!i.bold() && bold) { + out += ""; + } + if (!i.italic() && italic) { + out += ""; + } + + italic = i.italic (); + bold = i.bold (); + underline = i.underline (); + + out += i.text (); + } + + if (underline) { + out += ""; + } + if (bold) { + out += ""; + } + if (italic) { + out += ""; + } + + return out; +} + /** @param subtitles A list of subtitles that are all on the same line */ static PositionImage render_line (list subtitles, list > fonts, dcp::Size target) @@ -196,27 +245,7 @@ render_line (list subtitles, list > fonts, 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 += ""; - } else { - marked_up += ""; - } - italic = i.italic (); - } - - marked_up += i.text (); - } - - if (italic) { - marked_up += ""; - } - - layout->set_markup (marked_up); + layout->set_markup (marked_up (subtitles)); /* Compute fade factor */ /* XXX */