diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-08-21 18:01:59 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-08-21 18:01:59 +0100 |
| commit | 3f867002a036c40b188a7874231824cfd1b4d862 (patch) | |
| tree | ed5cb1d1fe6c2dbf73301832c4a6b3f41e19a02b /src | |
| parent | b56b008e2ad86bd2c29a42390891a32ae658d6c4 (diff) | |
Tweak font handling.
Diffstat (limited to 'src')
| -rw-r--r-- | src/subtitle_asset.cc | 60 | ||||
| -rw-r--r-- | src/subtitle_asset.h | 4 |
2 files changed, 21 insertions, 43 deletions
diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc index 2b200a2f..c27fd2c0 100644 --- a/src/subtitle_asset.cc +++ b/src/subtitle_asset.cc @@ -54,12 +54,13 @@ SubtitleAsset::examine_font_node (shared_ptr<FontNode> font_node, list<shared_pt for (list<shared_ptr<SubtitleNode> >::iterator j = font_node->subtitle_nodes.begin(); j != font_node->subtitle_nodes.end(); ++j) { for (list<shared_ptr<TextNode> >::iterator k = (*j)->text_nodes.begin(); k != (*j)->text_nodes.end(); ++k) { + FontNode effective (current_font_nodes); _subtitles.push_back ( shared_ptr<Subtitle> ( new Subtitle ( - font_id_to_name (id_from_font_nodes (current_font_nodes)), - italic_from_font_nodes (current_font_nodes), - size_from_font_nodes (current_font_nodes), + font_id_to_name (effective.id), + effective.italic.get(), + effective.size, (*j)->in, (*j)->out, (*k)->v_position, @@ -77,52 +78,31 @@ SubtitleAsset::examine_font_node (shared_ptr<FontNode> font_node, list<shared_pt current_font_nodes.pop_back (); } -string -SubtitleAsset::id_from_font_nodes (list<shared_ptr<FontNode> > const & font_nodes) const +FontNode::FontNode (xmlpp::Node const * node) + : XMLNode (node) { - for (list<shared_ptr<FontNode> >::const_reverse_iterator i = font_nodes.rbegin(); i != font_nodes.rend(); ++i) { - if (!(*i)->id.empty ()) { - return (*i)->id; - } - } - - return ""; + id = string_attribute ("Id"); + size = optional_int64_attribute ("Size"); + italic = optional_bool_attribute ("Italic"); + subtitle_nodes = sub_nodes<SubtitleNode> ("Subtitle"); + font_nodes = sub_nodes<FontNode> ("Font"); } -int -SubtitleAsset::size_from_font_nodes (list<shared_ptr<FontNode> > const & font_nodes) const +FontNode::FontNode (list<shared_ptr<FontNode> > const & font_nodes) + : size (0) + , italic (false) { - for (list<shared_ptr<FontNode> >::const_reverse_iterator i = font_nodes.rbegin(); i != font_nodes.rend(); ++i) { + for (list<shared_ptr<FontNode> >::const_iterator i = font_nodes.begin(); i != font_nodes.end(); ++i) { + if (!(*i)->id.empty ()) { + id = (*i)->id; + } if ((*i)->size != 0) { - return (*i)->size; + size = (*i)->size; } - } - - return 0; - -} - -bool -SubtitleAsset::italic_from_font_nodes (list<shared_ptr<FontNode> > const & font_nodes) const -{ - for (list<shared_ptr<FontNode> >::const_reverse_iterator i = font_nodes.rbegin(); i != font_nodes.rend(); ++i) { if ((*i)->italic) { - return (*i)->italic.get (); + italic = (*i)->italic.get (); } } - - return false; - -} - -FontNode::FontNode (xmlpp::Node const * node) - : XMLNode (node) -{ - id = string_attribute ("Id"); - size = optional_int64_attribute ("Size"); - italic = optional_bool_attribute ("Italic"); - subtitle_nodes = sub_nodes<SubtitleNode> ("Subtitle"); - font_nodes = sub_nodes<FontNode> ("Font"); } LoadFontNode::LoadFontNode (xmlpp::Node const * node) diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h index 04154a45..3df30e62 100644 --- a/src/subtitle_asset.h +++ b/src/subtitle_asset.h @@ -50,6 +50,7 @@ class FontNode : public XMLNode public: FontNode () {} FontNode (xmlpp::Node const * node); + FontNode (std::list<boost::shared_ptr<FontNode> > const & font_nodes); std::string id; int size; @@ -138,9 +139,6 @@ public: private: std::string font_id_to_name (std::string id) const; void examine_font_node (boost::shared_ptr<FontNode> font_node, std::list<boost::shared_ptr<FontNode> >& current_font_nodes); - std::string id_from_font_nodes (std::list<boost::shared_ptr<FontNode> > const & font_nodes) const; - int size_from_font_nodes (std::list<boost::shared_ptr<FontNode> > const & font_nodes) const; - bool italic_from_font_nodes (std::list<boost::shared_ptr<FontNode> > const & font_nodes) const; std::string _subtitle_id; std::string _movie_title; |
