2 Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of portions of this program with the
21 OpenSSL library under certain conditions as described in each
22 individual source file, and distribute linked combinations
25 You must obey the GNU General Public License in all respects
26 for all of the code used other than OpenSSL. If you modify
27 file(s) with this exception, you may extend this exception to your
28 version of the file(s), but you are not obligated to do so. If you
29 do not wish to do so, delete this exception statement from your
30 version. If you delete this exception statement from all source
31 files in the program, then also delete it here.
35 /** @file src/subtitle_string.h
36 * @brief SubtitleString class
40 #ifndef LIBDCP_SUBTITLE_STRING_H
41 #define LIBDCP_SUBTITLE_STRING_H
46 #include <boost/optional.hpp>
53 /** @class SubtitleString
54 * @brief A single line of subtitle text with all the associated attributes.
56 class SubtitleString : public Subtitle
59 /** @param font Font ID, or empty to use the default
60 * @param italic true for italic text
61 * @param bold true for bold text
62 * @param underline true for underlined text
63 * @param colour Colour of the text
64 * @param size Size in points as if the screen height is 11 inches, so a 72pt font would be 1/11th of the screen height
65 * @param aspect_adjust greater than 1 to stretch text to be wider, less than 1 to shrink text to be narrower (must be between 0.25 and 4)
66 * @param in start time
67 * @param out finish time
68 * @param h_position Horizontal position as a fraction of the screen width (between 0 and 1) from h_align
69 * @param h_align Horizontal alignment point
70 * @param v_position Vertical position as a fraction of the screen height (between 0 and 1) from v_align
71 * @param v_align Vertical alignment point
72 * @param z_position Z position as a proportion of the primary picture width between -1 and +1;
73 * +ve moves the image away from the viewer, -ve moves it toward the viewer, 0 is in the plane of the screen.
74 * @param direction Direction of text
75 * @param text The text to display
76 * @param effect Effect to use
77 * @param effect_colour Colour of the effect
78 * @param fade_up_time Time to fade the text in
79 * @param fade_down_time Time to fade the text out
80 * @param space_before Space to add before this string, in ems (could be negative to remove space).
83 boost::optional<std::string> font,
100 Colour effect_colour,
106 /** @return font ID */
107 boost::optional<std::string> font () const {
111 bool italic () const {
119 bool underline () const {
123 Colour colour () const {
127 std::string text () const {
131 Direction direction () const {
135 Effect effect () const {
139 Colour effect_colour () const {
140 return _effect_colour;
147 float size_in_pixels (int screen_height) const;
149 float space_before () const {
150 return _space_before;
153 /** @return Aspect ratio `adjustment' of the font size.
154 * Values greater than 1 widen each character, values less than 1 narrow each character,
155 * and the value must be between 0.25 and 4.
157 float aspect_adjust () const {
158 return _aspect_adjust;
161 void set_font (std::string id) {
166 _font = boost::optional<std::string>();
169 void set_size (int s) {
173 void set_aspect_adjust (float a) {
177 void set_text (std::string t) {
181 void set_colour (Colour c) {
185 void set_effect (Effect e) {
189 void set_effect_colour (Colour c) {
193 bool equals(std::shared_ptr<const dcp::Subtitle> other_sub, EqualityOptions const& options, NoteHandler node) const override;
197 boost::optional<std::string> _font;
198 /** true if the text is italic */
200 /** true if the weight is bold, false for normal */
202 /** true to enable underlining, false otherwise */
206 /** Size in points as if the screen height is 11 inches, so a 72pt font
207 * would be 1/11th of the screen height.
210 float _aspect_adjust;
211 Direction _direction;
214 Colour _effect_colour;
218 bool operator== (SubtitleString const & a, SubtitleString const & b);
219 bool operator!= (SubtitleString const & a, SubtitleString const & b);
220 std::ostream& operator<< (std::ostream& s, SubtitleString const & sub);