Fix handling of timing in SMPTE subtitles.
[libdcp.git] / src / text.cc
index 888cab2917433d17fdcb123d726caf30f7ada59a..a846d9613921fff3c631aa0de9c5fb6326fbfddc 100644 (file)
 #include "xml.h"
 #include "font.h"
 #include <libcxml/cxml.h>
+#include <boost/foreach.hpp>
 
 using std::string;
+using std::list;
 using boost::shared_ptr;
 using boost::optional;
 using namespace dcp;
@@ -35,15 +37,27 @@ using namespace dcp;
  *  in this object's member variables.
  *  @param node Node to read.
  */
-Text::Text (boost::shared_ptr<const cxml::Node> node)
+Text::Text (boost::shared_ptr<const cxml::Node> node, int tcr)
        : v_align (CENTER)
 {
        text = node->content ();
-       v_position = node->number_attribute<float> ("VPosition");
+       optional<float> x = node->optional_number_attribute<float> ("VPosition");
+       if (!x) {
+               x = node->number_attribute<float> ("Vposition");
+       }
+       v_position = x.get ();
+       
        optional<string> v = node->optional_string_attribute ("VAlign");
+       if (!v) {
+               v = node->optional_string_attribute ("Valign");
+       }
+       
        if (v) {
                v_align = string_to_valign (v.get ());
        }
 
-       font_nodes = type_children<Font> (node, "Font");
+       list<cxml::NodePtr> f = node->node_children ("Font");
+       BOOST_FOREACH (cxml::NodePtr& i, f) {
+               font_nodes.push_back (shared_ptr<Font> (new Font (i, tcr)));
+       }
 }