using boost::optional;
using namespace dcp;
-FontNode::FontNode (cxml::ConstNodePtr node, int tcr)
+FontNode::FontNode (cxml::ConstNodePtr node, int tcr, string font_id_attribute)
{
text = node->content ();
- id = node->optional_string_attribute ("Id");
+ id = node->optional_string_attribute (font_id_attribute);
size = node->optional_number_attribute<int64_t> ("Size").get_value_or (0);
aspect_adjust = node->optional_number_attribute<float> ("AspectAdjust");
italic = node->optional_bool_attribute ("Italic");
list<cxml::NodePtr> s = node->node_children ("Subtitle");
BOOST_FOREACH (cxml::NodePtr& i, s) {
- subtitle_nodes.push_back (shared_ptr<SubtitleNode> (new SubtitleNode (i, tcr)));
+ subtitle_nodes.push_back (shared_ptr<SubtitleNode> (new SubtitleNode (i, tcr, font_id_attribute)));
}
list<cxml::NodePtr> f = node->node_children ("Font");
BOOST_FOREACH (cxml::NodePtr& i, f) {
- font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, tcr)));
+ font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, tcr, font_id_attribute)));
}
list<cxml::NodePtr> t = node->node_children ("Text");
BOOST_FOREACH (cxml::NodePtr& i, t) {
- text_nodes.push_back (shared_ptr<TextNode> (new TextNode (i, tcr)));
+ text_nodes.push_back (shared_ptr<TextNode> (new TextNode (i, tcr, font_id_attribute)));
}
}
: size (0)
{}
- FontNode (cxml::ConstNodePtr node, int tcr);
+ FontNode (cxml::ConstNodePtr node, int tcr, std::string font_id_attribute);
FontNode (std::list<boost::shared_ptr<FontNode> > const & font_nodes);
std::string text;
list<cxml::NodePtr> f = xml->node_children ("Font");
list<shared_ptr<dcp::FontNode> > font_nodes;
BOOST_FOREACH (cxml::NodePtr& i, f) {
- font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, 250)));
+ font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, 250, "Id")));
}
parse_subtitles (xml, font_nodes);
list<cxml::NodePtr> f = subtitle_list->node_children ("Font");
list<shared_ptr<dcp::FontNode> > font_nodes;
BOOST_FOREACH (cxml::NodePtr& i, f) {
- font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, _time_code_rate)));
+ font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, _time_code_rate, "ID")));
}
parse_subtitles (xml, font_nodes);
using boost::lexical_cast;
using namespace dcp;
-SubtitleNode::SubtitleNode (boost::shared_ptr<const cxml::Node> node, int tcr)
+SubtitleNode::SubtitleNode (boost::shared_ptr<const cxml::Node> node, int tcr, string font_id_attribute)
{
in = Time (node->string_attribute ("TimeIn"), tcr);
out = Time (node->string_attribute ("TimeOut"), tcr);
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<FontNode> (new FontNode (*i, tcr)));
+ font_nodes.push_back (shared_ptr<FontNode> (new FontNode (*i, tcr, font_id_attribute)));
}
list<cxml::NodePtr> t = node->node_children ("Text");
for (list<cxml::NodePtr>::iterator i = t.begin(); i != t.end(); ++i) {
- text_nodes.push_back (shared_ptr<TextNode> (new TextNode (*i, tcr)));
+ text_nodes.push_back (shared_ptr<TextNode> (new TextNode (*i, tcr, font_id_attribute)));
}
fade_up_time = fade_time (node, "FadeUpTime", tcr);
{
public:
SubtitleNode () {}
- SubtitleNode (boost::shared_ptr<const cxml::Node> node, int tcr);
+ SubtitleNode (boost::shared_ptr<const cxml::Node> node, int tcr, std::string font_id_attribute);
Time in;
Time out;
* in this object's member variables.
* @param node Node to read.
*/
-TextNode::TextNode (boost::shared_ptr<const cxml::Node> node, int tcr)
+TextNode::TextNode (boost::shared_ptr<const cxml::Node> node, int tcr, string font_id_attribute)
: h_position (0)
, h_align (HALIGN_CENTER)
, v_position (0)
list<cxml::NodePtr> f = node->node_children ("Font");
BOOST_FOREACH (cxml::NodePtr& i, f) {
- font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, tcr)));
+ font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, tcr, font_id_attribute)));
}
}
, v_align (VALIGN_TOP)
{}
- TextNode (boost::shared_ptr<const cxml::Node> node, int tcr);
+ TextNode (boost::shared_ptr<const cxml::Node> node, int tcr, std::string font_id_attribute);
float h_position;
HAlign h_align;
text->set_attribute("VAlign", "top");
text->add_child_text("Hello world");
- dcp::TextNode t (cxml::NodePtr (new cxml::Node (text)), 250);
+ dcp::TextNode t (cxml::NodePtr (new cxml::Node (text)), 250, "Id");
BOOST_CHECK_CLOSE (t.v_position, 0.042, 0.001);
BOOST_CHECK_EQUAL (t.v_align, dcp::VALIGN_TOP);
BOOST_CHECK_EQUAL (t.text, "Hello world");
text->set_attribute("Valign", "top");
text->add_child_text("Hello world");
- dcp::TextNode t (cxml::NodePtr (new cxml::Node (text)), 250);
+ dcp::TextNode t (cxml::NodePtr (new cxml::Node (text)), 250, "Id");
BOOST_CHECK_CLOSE (t.v_position, 0.042, 0.001);
BOOST_CHECK_EQUAL (t.v_align, dcp::VALIGN_TOP);
BOOST_CHECK_EQUAL (t.text, "Hello world");