From ee03fd414e2c6e3dd398107ceb4ee365ff427adc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 16 Jan 2015 10:35:44 +0000 Subject: Support horizontal alignment specification in subtitles. --- src/parse/subtitle.cc | 12 +++++++++++- src/parse/subtitle.h | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/parse') diff --git a/src/parse/subtitle.cc b/src/parse/subtitle.cc index 56222c97..8c53bd68 100644 --- a/src/parse/subtitle.cc +++ b/src/parse/subtitle.cc @@ -147,7 +147,8 @@ Subtitle::fade_time (shared_ptr node, string name, optional node, optional tcr) - : v_align (CENTER) + : v_align (VERTICAL_CENTER) + , h_align (HORIZONTAL_CENTER) { /* Vertical position */ text = node->content (); @@ -166,6 +167,15 @@ Text::Text (shared_ptr node, optional tcr) v_align = string_to_valign (v.get ()); } + /* Horizontal alignment */ + optional h = node->optional_string_attribute ("HAlign"); + if (!h) { + h = node->optional_string_attribute ("Halign"); + } + if (h) { + h_align = string_to_halign (h.get ()); + } + list f = node->node_children ("Font"); for (list::iterator i = f.begin(); i != f.end(); ++i) { font_nodes.push_back (shared_ptr (new Font (*i, tcr))); diff --git a/src/parse/subtitle.h b/src/parse/subtitle.h index 867b3f0e..3993a6be 100644 --- a/src/parse/subtitle.h +++ b/src/parse/subtitle.h @@ -34,13 +34,14 @@ class Text public: Text () : v_position (0) - , v_align (TOP) + , v_align (VERTICAL_TOP) {} Text (boost::shared_ptr node, boost::optional tcr); float v_position; VAlign v_align; + HAlign h_align; std::string text; std::list > font_nodes; }; -- cgit v1.2.3