2 Copyright (C) 2012-2016 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.
34 /** @file src/subtitle_string.h
35 * @brief SubtitleString class.
38 #ifndef LIBDCP_SUBTITLE_STRING_H
39 #define LIBDCP_SUBTITLE_STRING_H
44 #include <boost/optional.hpp>
49 /** @class SubtitleString
50 * @brief A single line of subtitle text with all the associated attributes.
52 class SubtitleString : public Subtitle
56 boost::optional<std::string> font,
77 /** @return font ID */
78 boost::optional<std::string> font () const {
82 bool italic () const {
90 bool underline () const {
94 Colour colour () const {
98 std::string text () const {
102 Direction direction () const {
106 Effect effect () const {
110 Colour effect_colour () const {
111 return _effect_colour;
118 int size_in_pixels (int screen_height) const;
120 /** @return Aspect ratio `adjustment' of the font size.
121 * Values greater than 1 widen each character, values less than 1 narrow each character,
122 * and the value must be between 0.25 and 4.
124 float aspect_adjust () const {
125 return _aspect_adjust;
128 void set_font (std::string id) {
133 _font = boost::optional<std::string>();
136 void set_size (int s) {
140 void set_aspect_adjust (float a) {
144 void set_text (std::string t) {
148 void set_colour (Colour c) {
152 void set_effect (Effect e) {
156 void set_effect_colour (Colour c) {
162 boost::optional<std::string> _font;
163 /** true if the text is italic */
165 /** true if the weight is bold, false for normal */
167 /** true to enable underlining, false otherwise */
171 /** Size in points as if the screen height is 11 inches, so a 72pt font
172 * would be 1/11th of the screen height.
175 float _aspect_adjust;
176 Direction _direction;
179 Colour _effect_colour;
182 bool operator== (SubtitleString const & a, SubtitleString const & b);
183 bool operator!= (SubtitleString const & a, SubtitleString const & b);
184 std::ostream& operator<< (std::ostream& s, SubtitleString const & sub);