+ 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
This commit is contained in:
parent
cad0a839b6
commit
387ff213ef
4 changed files with 58 additions and 2 deletions
|
@ -76,6 +76,8 @@ namespace mapnik
|
|||
|
||||
typedef std::map<std::string,feature_type_style>::const_iterator const_style_iterator;
|
||||
typedef std::map<std::string,feature_type_style>::iterator style_iterator;
|
||||
typedef std::map<std::string,FontSet>::const_iterator const_fontset_iterator;
|
||||
typedef std::map<std::string,FontSet>::iterator fontset_iterator;
|
||||
|
||||
/*! \brief Default constructor.
|
||||
*
|
||||
|
@ -169,6 +171,16 @@ namespace mapnik
|
|||
*/
|
||||
FontSet const& find_fontset(std::string const& name) const;
|
||||
|
||||
/*! \brief Get all fontsets
|
||||
* @return Const reference to fontsets
|
||||
*/
|
||||
std::map<std::string,FontSet> const& fontsets() const;
|
||||
|
||||
/*! \brief Get all fontsets
|
||||
* @return Non-constant reference to fontsets
|
||||
*/
|
||||
std::map<std::string,FontSet> & fontsets();
|
||||
|
||||
/*! \brief Get number of all layers.
|
||||
*/
|
||||
size_t layerCount() const;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
namespace mapnik
|
||||
{
|
||||
FontSet::FontSet()
|
||||
: name_("default") {}
|
||||
: name_("") {}
|
||||
|
||||
FontSet::FontSet(std::string const& name)
|
||||
: name_(name) {}
|
||||
|
|
10
src/map.cpp
10
src/map.cpp
|
@ -125,6 +125,16 @@ namespace mapnik
|
|||
return default_fontset;
|
||||
}
|
||||
|
||||
std::map<std::string,FontSet> const& Map::fontsets() const
|
||||
{
|
||||
return fontsets_;
|
||||
}
|
||||
|
||||
std::map<std::string,FontSet> & Map::fontsets()
|
||||
{
|
||||
return fontsets_;
|
||||
}
|
||||
|
||||
boost::optional<feature_type_style const&> Map::find_style(std::string const& name) const
|
||||
{
|
||||
std::map<std::string,feature_type_style>::const_iterator itr = styles_.find(name);
|
||||
|
|
|
@ -215,6 +215,10 @@ namespace mapnik
|
|||
if ( ! face_name.empty() ) {
|
||||
set_attr( node, "face_name", face_name );
|
||||
}
|
||||
const std::string & fontset_name = sym.get_fontset().get_name();
|
||||
if ( ! fontset_name.empty() ) {
|
||||
set_attr( node, "fontset_name", fontset_name );
|
||||
}
|
||||
|
||||
set_attr( node, "size", sym.get_text_size() );
|
||||
set_attr( node, "fill", sym.get_fill() );
|
||||
|
@ -344,6 +348,27 @@ namespace mapnik
|
|||
|
||||
}
|
||||
|
||||
void serialize_fontset( ptree & map_node, Map::const_fontset_iterator fontset_it )
|
||||
{
|
||||
const FontSet & fontset = fontset_it->second;
|
||||
const std::string & name = fontset_it->first;
|
||||
|
||||
ptree & fontset_node = map_node.push_back(
|
||||
ptree::value_type("FontSet", ptree()))->second;
|
||||
|
||||
set_attr(fontset_node, "name", name);
|
||||
|
||||
std::vector<std::string>::const_iterator it = fontset.get_face_names().begin();
|
||||
std::vector<std::string>::const_iterator end = fontset.get_face_names().end();
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
ptree & font_node = fontset_node.push_back(
|
||||
ptree::value_type("Font", ptree()))->second;
|
||||
set_attr(font_node, "face_name", *it);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void serialize_datasource( ptree & layer_node, datasource_ptr datasource)
|
||||
{
|
||||
ptree & datasource_node = layer_node.push_back(
|
||||
|
@ -434,6 +459,15 @@ namespace mapnik
|
|||
set_attr( map_node, "bgcolor", * c );
|
||||
}
|
||||
|
||||
{
|
||||
Map::const_fontset_iterator it = map.fontsets().begin();
|
||||
Map::const_fontset_iterator end = map.fontsets().end();
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
serialize_fontset( map_node, it);
|
||||
}
|
||||
}
|
||||
|
||||
Map::const_style_iterator it = map.styles().begin();
|
||||
Map::const_style_iterator end = map.styles().end();
|
||||
for (; it != end; ++it)
|
||||
|
|
Loading…
Reference in a new issue