2 Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "subtitle_string.h"
26 using boost::optional;
29 /** @param v_position Vertical position as a fraction of the screen height (between 0 and 1) from v_align */
30 SubtitleString::SubtitleString (
31 optional<string> font,
55 , _aspect_adjust (aspect_adjust)
58 , _h_position (h_position)
60 , _v_position (v_position)
62 , _direction (direction)
65 , _effect_colour (effect_colour)
66 , _fade_up_time (fade_up_time)
67 , _fade_down_time (fade_down_time)
73 SubtitleString::size_in_pixels (int screen_height) const
75 /* Size in the subtitle file is given in points as if the screen
76 height is 11 inches, so a 72pt font would be 1/11th of the screen
80 return _size * screen_height / (11 * 72);
84 dcp::operator== (SubtitleString const & a, SubtitleString const & b)
87 a.font() == b.font() &&
88 a.italic() == b.italic() &&
89 a.bold() == b.bold() &&
90 a.colour() == b.colour() &&
91 a.size() == b.size() &&
92 fabs (a.aspect_adjust() - b.aspect_adjust()) < ASPECT_ADJUST_EPSILON &&
95 a.h_position() == b.h_position() &&
96 a.h_align() == b.h_align() &&
97 a.v_position() == b.v_position() &&
98 a.v_align() == b.v_align() &&
99 a.direction() == b.direction() &&
100 a.text() == b.text() &&
101 a.effect() == b.effect() &&
102 a.effect_colour() == b.effect_colour() &&
103 a.fade_up_time() == b.fade_up_time() &&
104 a.fade_down_time() == b.fade_down_time()
109 dcp::operator<< (ostream& s, SubtitleString const & sub)
111 s << "\n`" << sub.text() << "' from " << sub.in() << " to " << sub.out() << ";\n"
112 << "fade up " << sub.fade_up_time() << ", fade down " << sub.fade_down_time() << ";\n"
113 << "font " << sub.font().get_value_or ("[default]") << ", ";
127 s << "size " << sub.size() << ", aspect " << sub.aspect_adjust() << ", colour " << sub.colour()
128 << ", vpos " << sub.v_position() << ", valign " << ((int) sub.v_align())
129 << ", hpos " << sub.h_position() << ", halign " << ((int) sub.h_align())
130 << ", direction " << ((int) sub.direction())
131 << ", effect " << ((int) sub.effect()) << ", effect colour " << sub.effect_colour();