complete support for face-name/fontset-name in <Format> node - closes #1900
|
@ -44,6 +44,7 @@ public:
|
|||
node_ptr get_child() const;
|
||||
|
||||
boost::optional<std::string> face_name;
|
||||
boost::optional<font_set> fontset;
|
||||
boost::optional<symbolizer_base::value_type> text_size;
|
||||
boost::optional<symbolizer_base::value_type> character_spacing;
|
||||
boost::optional<symbolizer_base::value_type> line_spacing;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <mapnik/xml_node.hpp>
|
||||
|
||||
//boost
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace mapnik { namespace formatting {
|
||||
|
@ -52,6 +52,7 @@ void format_node::to_xml(ptree & xml) const
|
|||
if (text_transform) serialize_property("text-transform", *text_transform, new_node);
|
||||
|
||||
if (face_name) set_attr(new_node, "face-name", *face_name);
|
||||
if (fontset) set_attr(new_node, "fontset-name", fontset->get_name());
|
||||
|
||||
if (child_) child_->to_xml(new_node);
|
||||
}
|
||||
|
@ -63,8 +64,6 @@ node_ptr format_node::from_xml(xml_node const& xml, fontset_map const& fontsets)
|
|||
node_ptr child = node::from_xml(xml,fontsets);
|
||||
n->set_child(child);
|
||||
|
||||
//TODO: Fontset is problematic. We don't have the fontsets pointer here...
|
||||
// exprs
|
||||
set_property_from_xml<double>(n->text_size, "size", xml);
|
||||
set_property_from_xml<double>(n->character_spacing, "character-spacing", xml);
|
||||
set_property_from_xml<double>(n->line_spacing, "line-spacing", xml);
|
||||
|
@ -72,12 +71,32 @@ node_ptr format_node::from_xml(xml_node const& xml, fontset_map const& fontsets)
|
|||
//set_property_from_xml<double>(n->halo_opacity, "halo-opacity", xml); FIXME
|
||||
set_property_from_xml<double>(n->halo_radius, "halo-radius", xml);
|
||||
set_property_from_xml<std::string>(n->wrap_char, "wrap-character", xml);
|
||||
//
|
||||
set_property_from_xml<color>(n->fill, "fill", xml);
|
||||
set_property_from_xml<color>(n->halo_fill, "halo-fill", xml);
|
||||
set_property_from_xml<text_transform_e>(n->text_transform, "text-transform", xml);
|
||||
|
||||
n->face_name = xml.get_opt_attr<std::string>("face-name");
|
||||
boost::optional<std::string> face_name = xml.get_opt_attr<std::string>("face-name");
|
||||
if (face_name)
|
||||
{
|
||||
n->face_name = *face_name;
|
||||
}
|
||||
boost::optional<std::string> fontset_name = xml.get_opt_attr<std::string>("fontset-name");
|
||||
if (fontset_name)
|
||||
{
|
||||
std::map<std::string,font_set>::const_iterator itr = fontsets.find(*fontset_name);
|
||||
if (itr != fontsets.end())
|
||||
{
|
||||
n->fontset = itr->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw config_error("Unable to find any fontset named '" + *fontset_name + "' for <Format> node", xml);
|
||||
}
|
||||
}
|
||||
if (face_name && !face_name->empty() && n->fontset)
|
||||
{
|
||||
throw config_error("Can't have both face-name and fontset-name", xml);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -104,8 +123,18 @@ void format_node::apply(evaluated_format_properties_ptr p, feature_impl const& f
|
|||
if (halo_fill) new_properties->halo_fill = boost::apply_visitor(extract_value<color>(feature,attrs), *halo_fill);
|
||||
if (text_transform) new_properties->text_transform = boost::apply_visitor(extract_value<text_transform_enum>(feature,attrs), *text_transform);
|
||||
|
||||
if (face_name) new_properties->face_name = *face_name;
|
||||
|
||||
if (fontset)
|
||||
{
|
||||
new_properties->fontset = *fontset;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (face_name)
|
||||
{
|
||||
new_properties->face_name = *face_name;
|
||||
new_properties->fontset.reset();
|
||||
}
|
||||
}
|
||||
|
||||
if (child_) child_->apply(new_properties, feature, attrs, output);
|
||||
else MAPNIK_LOG_WARN(format) << "Useless format: No text to format";
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"keys": [
|
||||
"",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"10"
|
||||
],
|
||||
"data": {},
|
||||
"grid": [
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ! # $ % & ' ( ) * + ",
|
||||
" ",
|
||||
"! $$ $ $ &&& & & ((( ** * ",
|
||||
"! !! ! $$ $ $ $$ $$ && & &&& & (( ( ( ( (((( ((( ** * * ** ",
|
||||
"! !! !! ! $$ $$ $ $$ $$$ && && & & & (( ( ( (((( ( ** ** * ** ",
|
||||
" ",
|
||||
" !!! !!!!!! $$$ $$$$$$$$ &&& &&&& & ((((( (( (((( **** ***** ",
|
||||
" !!!! !!!!! $$$$$$$$ $$$ &&&& & &&& ((( (( (( *** * ** ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
]
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"keys": [
|
||||
"",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"10"
|
||||
],
|
||||
"data": {},
|
||||
"grid": [
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ! # $ % & ' ( ) * + ",
|
||||
" ",
|
||||
"! $$ $ $ &&& & & ((( ** * ",
|
||||
"! !! ! $$ $ $ $$ $$ && & &&& & (( ( ( ( (((( ((( ** * * ** ",
|
||||
"! !! !! ! $$ $$ $ $$ $$$ && && & & & (( ( ( (((( ( ** ** * ** ",
|
||||
" ",
|
||||
" !!! !!!!!! $$$ $$$$$$$$ &&& &&&& & ((((( (( (((( **** ***** ",
|
||||
" !!!! !!!!! $$$$$$$$ $$$ &&&& & &&& ((( (( (( *** * ** ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
]
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"keys": [
|
||||
"",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"10"
|
||||
],
|
||||
"data": {},
|
||||
"grid": [
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ! # $ % & ' ( ) * + ",
|
||||
" ",
|
||||
"! $$ $ $ &&& & & ((( ** * ",
|
||||
"! !! ! $$ $ $ $$ $$ && & &&& & (( ( ( ( (((( ((( ** * * ** ",
|
||||
"! !! !! ! $$ $$ $ $$ $$$ && && & & & (( ( ( (((( ( ** ** * ** ",
|
||||
" ",
|
||||
" !!! !!!!!! $$$ $$$$$$$$ &&& &&&& & ((((( (( (((( **** ***** ",
|
||||
" !!!! !!!!! $$$$$$$$ $$$ &&&& & &&& ((( (( (( *** * ** ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
]
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"keys": [
|
||||
"",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"10"
|
||||
],
|
||||
"data": {},
|
||||
"grid": [
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ! # $ % & ' ( ) * + ",
|
||||
" ",
|
||||
"! $$ $ $ &&& & & ((( ** * ",
|
||||
"! !! ! $$ $ $ $$ $$ && & &&& & (( ( ( ( (((( ((( ** * * ** ",
|
||||
"! !! !! ! $$ $$ $ $$ $$$ && && & & & (( ( ( (((( ( ** ** * ** ",
|
||||
" ",
|
||||
" !!! !!!!!! $$$ $$$$$$$$ &&& &&&& & ((((( (( (((( **** ***** ",
|
||||
" !!!! !!!!! $$$$$$$$ $$$ &&&& & &&& ((( (( (( *** * ** ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
]
|
||||
}
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 2 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 2 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 17 KiB |
|
@ -1,7 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE Map>
|
||||
<Map background-color="white" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
|
||||
<FontSet name="book"><Font face-name="DejaVu Sans Book"/></FontSet>
|
||||
<FontSet name="book">
|
||||
<Font face-name="DejaVu Sans Book"/>
|
||||
</FontSet>
|
||||
|
||||
<Layer name="layer" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
|
||||
<StyleName>My Style</StyleName>
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE Map>
|
||||
<Map background-color="white" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
|
||||
<FontSet name="book"><Font face-name="DejaVu Sans Book"/></FontSet>
|
||||
<FontSet name="oblique"><Font face-name="DejaVu Sans Oblique"/></FontSet>
|
||||
<FontSet name="book">
|
||||
<Font face-name="DejaVu Sans Book"/>
|
||||
</FontSet>
|
||||
<FontSet name="oblique">
|
||||
<Font face-name="DejaVu Sans Oblique"/>
|
||||
</FontSet>
|
||||
|
||||
<Layer name="layer" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
|
||||
<StyleName>My Style</StyleName>
|
||||
|
|
25
tests/visual_tests/styles/formatting-7.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE Map>
|
||||
<Map background-color="white" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
|
||||
<FontSet name="oblique">
|
||||
<Font face-name="DejaVu Sans Oblique"/>
|
||||
</FontSet>
|
||||
|
||||
<Layer name="layer" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
|
||||
<StyleName>My Style</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="type">csv</Parameter>
|
||||
<Parameter name="file">../data/points.csv</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
<Style name="My Style">
|
||||
<Rule>
|
||||
<PointSymbolizer/>
|
||||
<!-- Basic test -->
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="16" placement="point" dx="0" dy="5">
|
||||
[name]+' '<Format fontset-name="oblique" size="9" opacity="1">'('+[name]+')'</Format></TextSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
</Map>
|
25
tests/visual_tests/styles/formatting-8.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE Map>
|
||||
<Map background-color="white" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
|
||||
<FontSet name="oblique">
|
||||
<Font face-name="DejaVu Sans Oblique"/>
|
||||
</FontSet>
|
||||
|
||||
<Layer name="layer" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
|
||||
<StyleName>My Style</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="type">csv</Parameter>
|
||||
<Parameter name="file">../data/points.csv</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
<Style name="My Style">
|
||||
<Rule>
|
||||
<PointSymbolizer/>
|
||||
<!-- Basic test -->
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="16" placement="point" dx="0" dy="5">
|
||||
[name]+' '<Format face-name="DejaVu Sans Oblique" size="9" opacity="1">'('+[name]+')'</Format></TextSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
</Map>
|
|
@ -140,6 +140,8 @@ files = {
|
|||
'formatting-4': {'bbox':default_text_box},
|
||||
'formatting-5': {'bbox':default_text_box},
|
||||
'formatting-6': {'bbox':default_text_box},
|
||||
'formatting-7': {'bbox':default_text_box},
|
||||
'formatting-8': {'bbox':default_text_box},
|
||||
'expressionformat': {'bbox':default_text_box},
|
||||
'shieldsymbolizer-1': {'sizes': sizes_many_in_small_range,'bbox':default_text_box},
|
||||
'shieldsymbolizer-2': {'sizes': sizes_many_in_small_range,'bbox':default_text_box},
|
||||
|
|