diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-06-24 12:24:16 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-06-24 12:24:16 +0100 |
| commit | 715410f7b36075b39d712479476e83a28042ed7e (patch) | |
| tree | 46615302452a954c9d1593b1ba16a705380ad933 /src | |
| parent | 2c8270716ac21c05b5f7ce0e45096a1e9e62a619 (diff) | |
Support underlining of subtitles.
Diffstat (limited to 'src')
| -rw-r--r-- | src/font_node.cc | 9 | ||||
| -rw-r--r-- | src/font_node.h | 1 | ||||
| -rw-r--r-- | src/subtitle_asset.cc | 10 | ||||
| -rw-r--r-- | src/subtitle_string.cc | 7 | ||||
| -rw-r--r-- | src/subtitle_string.h | 7 |
5 files changed, 31 insertions, 3 deletions
diff --git a/src/font_node.cc b/src/font_node.cc index c24c29d6..1aa4be6b 100644 --- a/src/font_node.cc +++ b/src/font_node.cc @@ -58,6 +58,11 @@ FontNode::FontNode (cxml::ConstNodePtr node, optional<int> tcr, Standard standar 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"; + if (standard == INTEROP) { + underline = node->optional_bool_attribute ("Underlined"); + } else { + underline = node->optional_bool_attribute ("Underline"); + } optional<string> c = node->optional_string_attribute ("Color"); if (c) { colour = Colour (c.get ()); @@ -91,6 +96,7 @@ FontNode::FontNode (std::list<boost::shared_ptr<FontNode> > const & font_nodes) : size (0) , italic (false) , bold (false) + , underline (false) , colour ("FFFFFFFF") , effect_colour ("FFFFFFFF") { @@ -110,6 +116,9 @@ FontNode::FontNode (std::list<boost::shared_ptr<FontNode> > const & font_nodes) if ((*i)->bold) { bold = (*i)->bold.get (); } + if ((*i)->underline) { + underline = (*i)->underline.get (); + } if ((*i)->colour) { colour = (*i)->colour.get (); } diff --git a/src/font_node.h b/src/font_node.h index 656c0264..2108af9e 100644 --- a/src/font_node.h +++ b/src/font_node.h @@ -63,6 +63,7 @@ public: boost::optional<float> aspect_adjust; boost::optional<bool> italic; boost::optional<bool> bold; + boost::optional<bool> underline; 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 f1365118..35ca6174 100644 --- a/src/subtitle_asset.cc +++ b/src/subtitle_asset.cc @@ -158,6 +158,7 @@ SubtitleAsset::maybe_add_subtitle (string text, ParseState const & parse_state) effective_font.id, effective_font.italic.get_value_or (false), effective_font.bold.get_value_or (false), + effective_font.underline.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), @@ -249,11 +250,12 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand string const xmlns = standard == SMPTE ? "dcst" : ""; - /* XXX: script, underlined not supported */ + /* XXX: script not supported */ optional<string> font; bool italic = false; bool bold = false; + bool underline = false; Colour colour; int size = 0; float aspect_adjust = 1.0; @@ -279,6 +281,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand font != i.font() || italic != i.italic() || bold != i.bold() || + underline != i.underline() || colour != i.colour() || size != i.size() || fabs (aspect_adjust - i.aspect_adjust()) > ASPECT_ADJUST_EPSILON || @@ -289,6 +292,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand font = i.font (); italic = i.italic (); bold = i.bold (); + underline = i.underline (); colour = i.colour (); size = i.size (); aspect_adjust = i.aspect_adjust (); @@ -315,9 +319,9 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand font_element->set_attribute ("EffectColor", effect_colour.to_argb_string()); font_element->set_attribute ("Script", "normal"); if (standard == SMPTE) { - font_element->set_attribute ("Underline", "no"); + font_element->set_attribute ("Underline", underline ? "yes" : "no"); } else { - font_element->set_attribute ("Underlined", "no"); + font_element->set_attribute ("Underlined", underline ? "yes" : "no"); } font_element->set_attribute ("Weight", bold ? "bold" : "normal"); } diff --git a/src/subtitle_string.cc b/src/subtitle_string.cc index 8e106c6d..5a22475c 100644 --- a/src/subtitle_string.cc +++ b/src/subtitle_string.cc @@ -45,6 +45,7 @@ SubtitleString::SubtitleString ( optional<string> font, bool italic, bool bold, + bool underline, Colour colour, int size, float aspect_adjust, @@ -64,6 +65,7 @@ SubtitleString::SubtitleString ( : _font (font) , _italic (italic) , _bold (bold) + , _underline (underline) , _colour (colour) , _size (size) , _aspect_adjust (aspect_adjust) @@ -101,6 +103,7 @@ dcp::operator== (SubtitleString const & a, SubtitleString const & b) a.font() == b.font() && a.italic() == b.italic() && a.bold() == b.bold() && + a.underline() == b.underline() && a.colour() == b.colour() && a.size() == b.size() && fabs (a.aspect_adjust() - b.aspect_adjust()) < ASPECT_ADJUST_EPSILON && @@ -138,6 +141,10 @@ dcp::operator<< (ostream& s, SubtitleString const & sub) s << "normal, "; } + if (sub.underline()) { + s << "underlined, "; + } + 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()) diff --git a/src/subtitle_string.h b/src/subtitle_string.h index b16f764b..51b37564 100644 --- a/src/subtitle_string.h +++ b/src/subtitle_string.h @@ -55,6 +55,7 @@ public: boost::optional<std::string> font, bool italic, bool bold, + bool underline, Colour colour, int size, float aspect_adjust, @@ -85,6 +86,10 @@ public: return _bold; } + bool underline () const { + return _underline; + } + Colour colour () const { return _colour; } @@ -189,6 +194,8 @@ private: bool _italic; /** true if the weight is bold, false for normal */ bool _bold; + /** true to enable underlining, false otherwise */ + bool _underline; /** text colour */ Colour _colour; /** Size in points as if the screen height is 11 inches, so a 72pt font |
