Changeset 807

Show
Ignore:
Timestamp:
01/17/09 15:18:41 (19 months ago)
Author:
artem
Message:

+ mapnik-serialize-fontset.patch from jonb
This adds the fontset support into save_xml

  • Adds fontset_name into the text attributes
  • Adds the fontset definitions
  • glue to read fontsets from map
Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/include/mapnik/map.hpp

    r796 r807  
    7777        typedef std::map<std::string,feature_type_style>::const_iterator const_style_iterator; 
    7878        typedef std::map<std::string,feature_type_style>::iterator style_iterator; 
     79        typedef std::map<std::string,FontSet>::const_iterator const_fontset_iterator; 
     80        typedef std::map<std::string,FontSet>::iterator fontset_iterator; 
    7981         
    8082        /*! \brief Default constructor. 
     
    170172        FontSet const& find_fontset(std::string const& name) const; 
    171173 
     174        /*! \brief Get all fontsets 
     175         * @return Const reference to fontsets 
     176         */ 
     177        std::map<std::string,FontSet> const& fontsets() const; 
     178 
     179        /*! \brief Get all fontsets 
     180         * @return Non-constant reference to fontsets 
     181         */ 
     182        std::map<std::string,FontSet> & fontsets(); 
     183 
    172184        /*! \brief Get number of all layers. 
    173185         */ 
  • trunk/src/font_set.cpp

    r713 r807  
    3232{ 
    3333    FontSet::FontSet() 
    34         : name_("default") {} 
     34        : name_("") {} 
    3535 
    3636    FontSet::FontSet(std::string const& name) 
  • trunk/src/map.cpp

    r796 r807  
    126126    } 
    127127 
     128   std::map<std::string,FontSet> const& Map::fontsets() const 
     129   { 
     130      return fontsets_; 
     131   } 
     132 
     133   std::map<std::string,FontSet> & Map::fontsets() 
     134   { 
     135      return fontsets_; 
     136   } 
     137 
    128138   boost::optional<feature_type_style const&> Map::find_style(std::string const& name) const 
    129139   { 
  • trunk/src/save_map.cpp

    r796 r807  
    216216                    set_attr( node, "face_name", face_name );     
    217217                } 
    218                  
     218                const std::string & fontset_name = sym.get_fontset().get_name(); 
     219                if ( ! fontset_name.empty() ) { 
     220                    set_attr( node, "fontset_name", fontset_name ); 
     221                } 
     222 
    219223                set_attr( node, "size", sym.get_text_size() );     
    220224                set_attr( node, "fill", sym.get_fill() );     
     
    345349    } 
    346350 
     351    void serialize_fontset( ptree & map_node, Map::const_fontset_iterator fontset_it ) 
     352    { 
     353        const FontSet & fontset = fontset_it->second; 
     354        const std::string & name = fontset_it->first; 
     355 
     356        ptree & fontset_node = map_node.push_back( 
     357                ptree::value_type("FontSet", ptree()))->second; 
     358 
     359        set_attr(fontset_node, "name", name); 
     360 
     361        std::vector<std::string>::const_iterator it = fontset.get_face_names().begin(); 
     362        std::vector<std::string>::const_iterator end = fontset.get_face_names().end(); 
     363        for (; it != end; ++it) 
     364        { 
     365            ptree & font_node = fontset_node.push_back( 
     366                    ptree::value_type("Font", ptree()))->second; 
     367            set_attr(font_node, "face_name", *it); 
     368        } 
     369 
     370    } 
     371 
    347372    void serialize_datasource( ptree & layer_node, datasource_ptr datasource) 
    348373    { 
     
    435460        } 
    436461 
     462        { 
     463            Map::const_fontset_iterator it = map.fontsets().begin(); 
     464            Map::const_fontset_iterator end = map.fontsets().end(); 
     465            for (; it != end; ++it) 
     466            { 
     467                serialize_fontset( map_node, it); 
     468            } 
     469        } 
     470 
    437471        Map::const_style_iterator it = map.styles().begin(); 
    438472        Map::const_style_iterator end = map.styles().end();