Support horizontal alignment specification in subtitles.
[libdcp.git] / src / parse / subtitle.cc
index 56222c973473d076c03e3699487c4fb94b28f07c..8c53bd6819db8d775d6930d71c6f469e108c39aa 100644 (file)
@@ -147,7 +147,8 @@ Subtitle::fade_time (shared_ptr<const cxml::Node> node, string name, optional<in
 }
 
 Text::Text (shared_ptr<const cxml::Node> node, optional<int> 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<const cxml::Node> node, optional<int> tcr)
                v_align = string_to_valign (v.get ());
        }
 
+       /* Horizontal alignment */
+       optional<string> h = node->optional_string_attribute ("HAlign");
+       if (!h) {
+               h = node->optional_string_attribute ("Halign");
+       }
+       if (h) {
+               h_align = string_to_halign (h.get ());
+       }
+
        list<cxml::NodePtr> f = node->node_children ("Font");
        for (list<cxml::NodePtr>::iterator i = f.begin(); i != f.end(); ++i) {
                font_nodes.push_back (shared_ptr<Font> (new Font (*i, tcr)));