diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-04-05 00:22:32 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-04-05 00:22:32 +0100 |
| commit | bc118b663b0582cf4afdce3000beb8bac35b16ef (patch) | |
| tree | ac058ad2af7c88705606e7fe139d4d1a4ff80ac2 /src | |
| parent | bc7089956cefc9f8528918f8a5d48174ab680f13 (diff) | |
Basic untested support for bold in subtitles.
Diffstat (limited to 'src')
| -rw-r--r-- | src/font_node.cc | 5 | ||||
| -rw-r--r-- | src/font_node.h | 1 | ||||
| -rw-r--r-- | src/subtitle_asset.cc | 8 | ||||
| -rw-r--r-- | src/subtitle_string.cc | 17 | ||||
| -rw-r--r-- | src/subtitle_string.h | 9 |
5 files changed, 33 insertions, 7 deletions
diff --git a/src/font_node.cc b/src/font_node.cc index 5d857bc1..a5047211 100644 --- a/src/font_node.cc +++ b/src/font_node.cc @@ -39,6 +39,7 @@ FontNode::FontNode (cxml::ConstNodePtr node, int tcr, string font_id_attribute) size = node->optional_number_attribute<int64_t> ("Size").get_value_or (0); aspect_adjust = node->optional_number_attribute<float> ("AspectAdjust"); italic = node->optional_bool_attribute ("Italic"); + bold = node->optional_string_attribute("Weight").get_value_or("normal") == "bold"; optional<string> c = node->optional_string_attribute ("Color"); if (c) { colour = Colour (c.get ()); @@ -71,6 +72,7 @@ FontNode::FontNode (cxml::ConstNodePtr node, int tcr, string font_id_attribute) FontNode::FontNode (std::list<boost::shared_ptr<FontNode> > const & font_nodes) : size (0) , italic (false) + , bold (false) , colour ("FFFFFFFF") , effect_colour ("FFFFFFFF") { @@ -87,6 +89,9 @@ FontNode::FontNode (std::list<boost::shared_ptr<FontNode> > const & font_nodes) if ((*i)->italic) { italic = (*i)->italic.get (); } + if ((*i)->bold) { + bold = (*i)->bold.get (); + } if ((*i)->colour) { colour = (*i)->colour.get (); } diff --git a/src/font_node.h b/src/font_node.h index 50815636..b82308fb 100644 --- a/src/font_node.h +++ b/src/font_node.h @@ -48,6 +48,7 @@ public: int size; boost::optional<float> aspect_adjust; boost::optional<bool> italic; + boost::optional<bool> bold; boost::optional<Colour> colour; boost::optional<Effect> effect; boost::optional<Colour> effect_colour; diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc index 5074c35b..352aff9a 100644 --- a/src/subtitle_asset.cc +++ b/src/subtitle_asset.cc @@ -143,6 +143,7 @@ SubtitleAsset::maybe_add_subtitle (string text, ParseState const & parse_state) SubtitleString ( effective_font.id, effective_font.italic.get_value_or (false), + effective_font.bold.get_value_or (false), effective_font.colour.get_value_or (dcp::Colour (255, 255, 255)), effective_font.size, effective_font.aspect_adjust.get_value_or (1.0), @@ -233,10 +234,11 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand string const xmlns = standard == SMPTE ? "dcst" : ""; - /* XXX: script, underlined, weight not supported */ + /* XXX: script, underlined not supported */ optional<string> font; bool italic = false; + bool bold = false; Colour colour; int size = 0; float aspect_adjust = 1.0; @@ -261,6 +263,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand bool const font_changed = font != i.font() || italic != i.italic() || + bold != i.bold() || colour != i.colour() || size != i.size() || fabs (aspect_adjust - i.aspect_adjust()) > ASPECT_ADJUST_EPSILON || @@ -270,6 +273,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand if (font_changed) { font = i.font (); italic = i.italic (); + bold = i.bold (); colour = i.colour (); size = i.size (); aspect_adjust = i.aspect_adjust (); @@ -300,7 +304,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand } else { font_element->set_attribute ("Underlined", "no"); } - font_element->set_attribute ("Weight", "normal"); + font_element->set_attribute ("Weight", bold ? "bold" : "normal"); } if (!subtitle_element || font_changed || diff --git a/src/subtitle_string.cc b/src/subtitle_string.cc index d565d453..ea24e37f 100644 --- a/src/subtitle_string.cc +++ b/src/subtitle_string.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ using namespace dcp; SubtitleString::SubtitleString ( optional<string> font, bool italic, + bool bold, Colour colour, int size, float aspect_adjust, @@ -47,6 +48,7 @@ SubtitleString::SubtitleString ( ) : _font (font) , _italic (italic) + , _bold (bold) , _colour (colour) , _size (size) , _aspect_adjust (aspect_adjust) @@ -82,6 +84,7 @@ dcp::operator== (SubtitleString const & a, SubtitleString const & b) return ( a.font() == b.font() && a.italic() == b.italic() && + a.bold() == b.bold() && a.colour() == b.colour() && a.size() == b.size() && fabs (a.aspect_adjust() - b.aspect_adjust()) < ASPECT_ADJUST_EPSILON && @@ -107,12 +110,18 @@ dcp::operator<< (ostream& s, SubtitleString const & sub) << "font " << sub.font().get_value_or ("[default]") << ", "; if (sub.italic()) { - s << "italic"; + s << "italic, "; } else { - s << "non-italic"; + s << "non-italic, "; } - s << ", size " << sub.size() << ", aspect " << sub.aspect_adjust() << ", colour " << sub.colour() + if (sub.bold()) { + s << "bold, "; + } else { + s << "normal, "; + } + + s << "size " << sub.size() << ", aspect " << sub.aspect_adjust() << ", colour " << sub.colour() << ", vpos " << sub.v_position() << ", valign " << ((int) sub.v_align()) << ", hpos " << sub.h_position() << ", halign " << ((int) sub.h_align()) << ", effect " << ((int) sub.effect()) << ", effect colour " << sub.effect_colour(); diff --git a/src/subtitle_string.h b/src/subtitle_string.h index eaea94c0..bd71b8da 100644 --- a/src/subtitle_string.h +++ b/src/subtitle_string.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,6 +40,7 @@ public: SubtitleString ( boost::optional<std::string> font, bool italic, + bool bold, Colour colour, int size, float aspect_adjust, @@ -65,6 +66,10 @@ public: return _italic; } + bool bold () const { + return _bold; + } + Colour colour () const { return _colour; } @@ -163,6 +168,8 @@ private: boost::optional<std::string> _font; /** true if the text is italic */ bool _italic; + /** true if the weight is bold, false for normal */ + bool _bold; /** text colour */ Colour _colour; /** Size in points as if the screen height is 11 inches, so a 72pt font |
