Rationalise #undef-ing of ERROR.
[libdcp.git] / src / subtitle_asset_internal.cc
index bf73fcc3d17136d089c80df3df320b507cc4821c..bb67b45a83f333de0d2a9715c760535570631be8 100644 (file)
@@ -134,9 +134,17 @@ order::Part::as_xml (xmlpp::Element* parent, Context &) const
 
 
 xmlpp::Element*
-order::String::as_xml (xmlpp::Element* parent, Context &) const
+order::String::as_xml (xmlpp::Element* parent, Context& context) const
 {
-       parent->add_child_text (text);
+       if (fabs(_space_before) > SPACE_BEFORE_EPSILON) {
+               auto space = parent->add_child("Space");
+               auto size = raw_convert<string>(_space_before, 2);
+               if (context.standard == Standard::INTEROP) {
+                       size += "em";
+               }
+               space->set_attribute("Size", size);
+       }
+       parent->add_child_text (_text);
        return 0;
 }
 
@@ -157,7 +165,7 @@ order::Part::write_xml (xmlpp::Element* parent, order::Context& context) const
 
 
 static void
-position_align (xmlpp::Element* e, order::Context& context, HAlign h_align, float h_position, VAlign v_align, float v_position)
+position_align (xmlpp::Element* e, order::Context& context, HAlign h_align, float h_position, VAlign v_align, float v_position, float z_position)
 {
        if (h_align != HAlign::CENTER) {
                if (context.standard == Standard::SMPTE) {
@@ -194,6 +202,10 @@ position_align (xmlpp::Element* e, order::Context& context, HAlign h_align, floa
                        e->set_attribute ("VPosition", "0");
                }
        }
+
+       if (fabs(z_position) > ALIGN_EPSILON && context.standard == Standard::SMPTE) {
+               e->set_attribute("Zposition", raw_convert<string>(z_position * 100, 6));
+       }
 }
 
 
@@ -202,7 +214,7 @@ order::Text::as_xml (xmlpp::Element* parent, Context& context) const
 {
        auto e = parent->add_child ("Text");
 
-       position_align (e, context, _h_align, _h_position, _v_align, _v_position);
+       position_align(e, context, _h_align, _h_position, _v_align, _v_position, _z_position);
 
        /* Interop only supports "horizontal" or "vertical" for direction, so only write this
           for SMPTE.
@@ -252,7 +264,7 @@ order::Image::as_xml (xmlpp::Element* parent, Context& context) const
 {
        auto e = parent->add_child ("Image");
 
-       position_align (e, context, _h_align, _h_position, _v_align, _v_position);
+       position_align(e, context, _h_align, _h_position, _v_align, _v_position, _z_position);
        if (context.standard == Standard::SMPTE) {
                e->add_child_text ("urn:uuid:" + _id);
        } else {