diff --git a/bindings/python/mapnik_text_placement.cpp b/bindings/python/mapnik_text_placement.cpp index 2e598747a..a8aded194 100644 --- a/bindings/python/mapnik_text_placement.cpp +++ b/bindings/python/mapnik_text_placement.cpp @@ -124,7 +124,7 @@ struct NodeWrap NodeWrap() : formatting::node(), wrapper() {} - void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const + void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const { python_block_auto_unblock b; this->get_override("apply")(ptr(&p), ptr(&feature), ptr(&vars), ptr(&output)); @@ -159,7 +159,7 @@ struct TextNodeWrap TextNodeWrap(std::string expr_text) : formatting::text_node(expr_text), wrapper() {} - virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const + virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const { if(override o = this->get_override("apply")) { @@ -172,7 +172,7 @@ struct TextNodeWrap } } - void default_apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const + void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const { formatting::text_node::apply(p, feature, vars, output); } @@ -182,7 +182,7 @@ struct TextNodeWrap struct FormatNodeWrap : formatting::format_node, wrapper { - virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const + virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const { if(override o = this->get_override("apply")) { @@ -195,7 +195,7 @@ struct FormatNodeWrap } } - void default_apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const + void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const { formatting::format_node::apply(p, feature, vars, output); } @@ -203,7 +203,7 @@ struct FormatNodeWrap struct ExprFormatWrap: formatting::expression_format, wrapper { - virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const + virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const { if(override o = this->get_override("apply")) { @@ -216,7 +216,7 @@ struct ExprFormatWrap: formatting::expression_format, wrapper { - virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const + virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const { if(override o = this->get_override("apply")) { @@ -237,7 +237,7 @@ struct LayoutNodeWrap: formatting::layout_node, wrapper } } - void default_apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const + void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const { formatting::layout_node::apply(p, feature, vars, output); } @@ -264,7 +264,7 @@ struct ListNodeWrap: formatting::list_node, wrapper // TODO: Add constructor taking variable number of arguments. http://wiki.python.org/moin/boost.python/HowTo#A.22Raw.22_function - virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const + virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const { if(override o = this->get_override("apply")) { @@ -277,7 +277,7 @@ struct ListNodeWrap: formatting::list_node, wrapper } } - void default_apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const + void default_apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const { formatting::list_node::apply(p, feature, vars, output); } @@ -346,12 +346,12 @@ void insert_expression(expression_set *set, expression_ptr p) } /* -char_properties_ptr get_format(text_symbolizer const& sym) +evaluated_format_properties_ptr get_format(text_symbolizer const& sym) { return sym.get_placement_options()->defaults.format; } -void set_format(text_symbolizer const& sym, char_properties_ptr format) +void set_format(text_symbolizer const& sym, evaluated_format_properties_ptr format) { sym.get_placement_options()->defaults.format = format; } @@ -453,25 +453,25 @@ void export_text_placement() .def_readwrite("orientation", &text_layout_properties::orientation) .def_readwrite("rotate_displacement", &text_layout_properties::rotate_displacement) .add_property("displacement", &get_displacement, &set_displacement); - - class_with_converter +/* + class_with_converter ("CharProperties") - .def_readwrite_convert("text_transform", &char_properties::text_transform) - .def_readwrite_convert("fontset", &char_properties::fontset) - .def(init()) //Copy constructor - .def_readwrite("face_name", &char_properties::face_name) - .def_readwrite("text_size", &char_properties::text_size) - .def_readwrite("character_spacing", &char_properties::character_spacing) - .def_readwrite("line_spacing", &char_properties::line_spacing) - .def_readwrite("text_opacity", &char_properties::text_opacity) - .def_readwrite("wrap_char", &char_properties::wrap_char) - .def_readwrite("wrap_character", &char_properties::wrap_char) - .def_readwrite("fill", &char_properties::fill) - .def_readwrite("halo_fill", &char_properties::halo_fill) - .def_readwrite("halo_radius", &char_properties::halo_radius) - /* from_xml, to_xml operate on mapnik's internal XML tree and don't make sense in python.*/ + .def_readwrite_convert("text_transform", &detail::evaluated_format_properties::text_transform) + .def_readwrite_convert("fontset", &detail::evaluated_format_properties::fontset) + .def(init()) //Copy constructor + .def_readwrite("face_name", &detail::evaluated_format_properties::face_name) + .def_readwrite("text_size", &detail::evaluated_format_properties::text_size) + .def_readwrite("character_spacing", &detail::evaluated_format_properties::character_spacing) + .def_readwrite("line_spacing", &detail::evaluated_format_properties::line_spacing) + .def_readwrite("text_opacity", &detail::evaluated_format_properties::text_opacity) + .def_readwrite("wrap_char", &detail::evaluated_format_properties::wrap_char) + .def_readwrite("wrap_character", &detail::evaluated_format_properties::wrap_char) + .def_readwrite("fill", &detail::evaluated_format_properties::fill) + .def_readwrite("halo_fill", &detail::evaluated_format_properties::halo_fill) + .def_readwrite("halo_radius", &evaluated_format_properties::halo_radius) + //from_xml, to_xml operate on mapnik's internal XML tree and don't make sense in python. ; - +*/ class_, boost::noncopyable> diff --git a/include/mapnik/text/char_properties_ptr.hpp b/include/mapnik/text/evaluated_format_properties_ptr.hpp similarity index 77% rename from include/mapnik/text/char_properties_ptr.hpp rename to include/mapnik/text/evaluated_format_properties_ptr.hpp index e325f117b..0a5695f3f 100644 --- a/include/mapnik/text/char_properties_ptr.hpp +++ b/include/mapnik/text/evaluated_format_properties_ptr.hpp @@ -20,15 +20,15 @@ * *****************************************************************************/ -#ifndef CHAR_PROPERTIES_PTR_HPP -#define CHAR_PROPERTIES_PTR_HPP +#ifndef EVALUATED_FORMAT_PROPERTIES_PTR_HPP +#define EVALUATED_FORMAT_PROPERTIES_PTR_HPP #include -namespace mapnik -{ -struct char_properties; -using char_properties_ptr = std::shared_ptr; +namespace mapnik { namespace detail { +struct evaluated_format_properties; +} +using evaluated_format_properties_ptr = std::shared_ptr; } -#endif // CHAR_PROPERTIES_PTR_HPP +#endif // EVALUATED_FORMAT_PROPERTIES_PTR_HPP diff --git a/include/mapnik/text/formatting/base.hpp b/include/mapnik/text/formatting/base.hpp index c94d9c34c..23a469033 100644 --- a/include/mapnik/text/formatting/base.hpp +++ b/include/mapnik/text/formatting/base.hpp @@ -25,7 +25,7 @@ // mapnik #include #include -#include +#include // boost #include @@ -47,7 +47,7 @@ public: virtual ~node() {} virtual void to_xml(boost::property_tree::ptree & xml) const = 0; static node_ptr from_xml(xml_node const& xml); - virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const = 0; + virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const = 0; virtual void add_expressions(expression_set & output) const = 0; }; } //ns formatting diff --git a/include/mapnik/text/formatting/format.hpp b/include/mapnik/text/formatting/format.hpp index 4b4af9c1b..7150497e6 100644 --- a/include/mapnik/text/formatting/format.hpp +++ b/include/mapnik/text/formatting/format.hpp @@ -37,7 +37,7 @@ class MAPNIK_DECL format_node: public node public: void to_xml(boost::property_tree::ptree & xml) const; static node_ptr from_xml(xml_node const& xml); - virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const; + virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const; virtual void add_expressions(expression_set & output) const; void set_child(node_ptr child); diff --git a/include/mapnik/text/formatting/layout.hpp b/include/mapnik/text/formatting/layout.hpp index b61f40cca..3dde20567 100644 --- a/include/mapnik/text/formatting/layout.hpp +++ b/include/mapnik/text/formatting/layout.hpp @@ -35,7 +35,7 @@ class MAPNIK_DECL layout_node: public node public: void to_xml(boost::property_tree::ptree &xml) const; static node_ptr from_xml(xml_node const& xml); - virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const; + virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const; virtual void add_expressions(expression_set &output) const; void set_child(node_ptr child); node_ptr get_child() const; diff --git a/include/mapnik/text/formatting/list.hpp b/include/mapnik/text/formatting/list.hpp index dc22daff8..683717c05 100644 --- a/include/mapnik/text/formatting/list.hpp +++ b/include/mapnik/text/formatting/list.hpp @@ -35,7 +35,7 @@ class MAPNIK_DECL list_node: public node { public: list_node() : node(), children_() {} virtual void to_xml(boost::property_tree::ptree &xml) const; - virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const; + virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const; virtual void add_expressions(expression_set &output) const; void push_back(node_ptr n); diff --git a/include/mapnik/text/formatting/text.hpp b/include/mapnik/text/formatting/text.hpp index f7a48e44e..93c8051e9 100644 --- a/include/mapnik/text/formatting/text.hpp +++ b/include/mapnik/text/formatting/text.hpp @@ -36,7 +36,7 @@ public: text_node(std::string text): node(), text_(parse_expression(text)) {} void to_xml(boost::property_tree::ptree &xml) const; static node_ptr from_xml(xml_node const& xml); - virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const; + virtual void apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const; virtual void add_expressions(expression_set &output) const; void set_text(expression_ptr text); diff --git a/include/mapnik/text/glyph_info.hpp b/include/mapnik/text/glyph_info.hpp index 628c032de..3cc29035c 100644 --- a/include/mapnik/text/glyph_info.hpp +++ b/include/mapnik/text/glyph_info.hpp @@ -23,7 +23,7 @@ #define MAPNIK_GLYPH_INFO_HPP //mapnik -#include +#include #include #include @@ -62,7 +62,7 @@ struct glyph_info double unscaled_line_height; double scale_multiplier; pixel_position offset; - char_properties_ptr format; + evaluated_format_properties_ptr format; double ymin() const { return unscaled_ymin * 64.0 * scale_multiplier; } double ymax() const { return unscaled_ymax * 64.0 * scale_multiplier; } diff --git a/include/mapnik/text/itemizer.hpp b/include/mapnik/text/itemizer.hpp index 3631312fb..ec2f66d89 100644 --- a/include/mapnik/text/itemizer.hpp +++ b/include/mapnik/text/itemizer.hpp @@ -24,7 +24,7 @@ #define MAPNIK_TEXT_ITEMIZER_HPP //mapnik -#include +#include #include // stl @@ -47,7 +47,7 @@ struct text_item unsigned end = 0u; UScriptCode script = USCRIPT_INVALID_CODE; UBiDiDirection rtl = UBIDI_LTR; - char_properties_ptr format; + evaluated_format_properties_ptr format; }; // This class splits text into parts which all have the same @@ -59,7 +59,7 @@ class text_itemizer { public: text_itemizer(); - void add_text(value_unicode_string const& str, char_properties_ptr format); + void add_text(value_unicode_string const& str, evaluated_format_properties_ptr format); std::list const& itemize(unsigned start=0, unsigned end=0); void clear(); value_unicode_string const& text() const { return text_; } @@ -76,7 +76,7 @@ private: unsigned end; T data; }; - using format_run_t = run; + using format_run_t = run; using direction_run_t = run; using script_run_t = run; using format_run_list = std::list; diff --git a/include/mapnik/text/renderer.hpp b/include/mapnik/text/renderer.hpp index 6861cb187..e0961b574 100644 --- a/include/mapnik/text/renderer.hpp +++ b/include/mapnik/text/renderer.hpp @@ -45,9 +45,9 @@ namespace mapnik struct glyph_t { FT_Glyph image; - char_properties const* properties; + detail::evaluated_format_properties const* properties; - glyph_t(FT_Glyph image_, char_properties const* properties_) + glyph_t(FT_Glyph image_, detail::evaluated_format_properties const* properties_) : image(image_), properties(properties_) {} glyph_t( glyph_t && other) noexcept diff --git a/include/mapnik/text/text_layout.hpp b/include/mapnik/text/text_layout.hpp index 34f29ade5..f9e5736cd 100644 --- a/include/mapnik/text/text_layout.hpp +++ b/include/mapnik/text/text_layout.hpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include @@ -51,7 +51,7 @@ public: text_layout(face_manager_freetype & font_manager, double scale_factor, text_layout_properties const& properties); // Adds a new text part. Call this function repeatedly to build the complete text. - void add_text(mapnik::value_unicode_string const& str, char_properties_ptr format); + void add_text(mapnik::value_unicode_string const& str, evaluated_format_properties_ptr format); // Returns the complete text stored in this layout. mapnik::value_unicode_string const& text() const; diff --git a/include/mapnik/text/text_properties.hpp b/include/mapnik/text/text_properties.hpp index 657112d81..b51f86cd5 100644 --- a/include/mapnik/text/text_properties.hpp +++ b/include/mapnik/text/text_properties.hpp @@ -23,7 +23,7 @@ #define MAPNIK_TEXT_PROPERTIES_HPP // mapnik -#include +#include #include #include #include @@ -41,18 +41,15 @@ #include #include -namespace mapnik -{ +namespace mapnik { namespace detail { -using fontset_map = std::map; - -struct MAPNIK_DECL char_properties +struct evaluated_format_properties { std::string face_name; boost::optional fontset; double text_size; double character_spacing; - double line_spacing; //Largest total height (fontsize+line_spacing) per line is chosen + double line_spacing; double text_opacity; double halo_opacity; unsigned wrap_char; @@ -62,6 +59,10 @@ struct MAPNIK_DECL char_properties double halo_radius; }; +} + +using fontset_map = std::map; + struct MAPNIK_DECL format_properties { format_properties(); @@ -168,7 +169,6 @@ struct MAPNIK_DECL text_symbolizer_properties // Default values for text layouts text_layout_properties layout_defaults; // Default values for format_properties. - //char_properties_ptr format; format_properties format_defaults; private: diff --git a/src/cairo/cairo_context.cpp b/src/cairo/cairo_context.cpp index 0bde69457..47f1305fc 100644 --- a/src/cairo/cairo_context.cpp +++ b/src/cairo/cairo_context.cpp @@ -440,7 +440,7 @@ void cairo_context::add_text(glyph_positions_ptr path, //render halo double halo_radius = 0; - char_properties_ptr format; + evaluated_format_properties_ptr format; set_operator(halo_comp_op); for (auto const& glyph_pos : *path) { diff --git a/src/text/formatting/format.cpp b/src/text/formatting/format.cpp index 9919026bf..c67dadcd4 100644 --- a/src/text/formatting/format.cpp +++ b/src/text/formatting/format.cpp @@ -82,9 +82,9 @@ node_ptr format_node::from_xml(xml_node const& xml) } -void format_node::apply(char_properties_ptr p, feature_impl const& feature, attributes const& attrs, text_layout &output) const +void format_node::apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& attrs, text_layout &output) const { - char_properties_ptr new_properties = std::make_shared(*p); + evaluated_format_properties_ptr new_properties = std::make_shared(*p); if (text_size) new_properties->text_size = boost::apply_visitor(extract_value(feature,attrs), *text_size); if (character_spacing) new_properties->character_spacing = boost::apply_visitor(extract_value(feature,attrs), *character_spacing); diff --git a/src/text/formatting/layout.cpp b/src/text/formatting/layout.cpp index cbbbbf270..5852a77b9 100644 --- a/src/text/formatting/layout.cpp +++ b/src/text/formatting/layout.cpp @@ -78,7 +78,7 @@ node_ptr layout_node::from_xml(xml_node const& xml) return n; } -void layout_node::apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const +void layout_node::apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const { text_layout_properties new_properties(output.get_layout_properties()); if (dx) new_properties.dx = *dx; diff --git a/src/text/formatting/list.cpp b/src/text/formatting/list.cpp index e6487d657..66c79f1e7 100644 --- a/src/text/formatting/list.cpp +++ b/src/text/formatting/list.cpp @@ -42,7 +42,7 @@ void list_node::to_xml(boost::property_tree::ptree & xml) const } -void list_node::apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const +void list_node::apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout & output) const { for (node_ptr const& node : children_) { diff --git a/src/text/formatting/text.cpp b/src/text/formatting/text.cpp index bbebad8f3..9ac4e663b 100644 --- a/src/text/formatting/text.cpp +++ b/src/text/formatting/text.cpp @@ -49,7 +49,7 @@ node_ptr text_node::from_xml(xml_node const& xml) return std::make_shared(xml.get_value()); } -void text_node::apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const +void text_node::apply(evaluated_format_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const { mapnik::value_unicode_string text_str = boost::apply_visitor(evaluate(feature,vars), *text_).to_unicode(); if (p->text_transform == UPPERCASE) diff --git a/src/text/itemizer.cpp b/src/text/itemizer.cpp index 1641c0261..29101b893 100644 --- a/src/text/itemizer.cpp +++ b/src/text/itemizer.cpp @@ -37,7 +37,7 @@ text_itemizer::text_itemizer() forced_line_breaks_.push_back(0); } -void text_itemizer::add_text(mapnik::value_unicode_string const& str, char_properties_ptr format) +void text_itemizer::add_text(mapnik::value_unicode_string const& str, evaluated_format_properties_ptr format) { unsigned start = text_.length(); text_ += str; diff --git a/src/text/placements/list.cpp b/src/text/placements/list.cpp index ce54dac2d..56dd4842b 100644 --- a/src/text/placements/list.cpp +++ b/src/text/placements/list.cpp @@ -101,7 +101,7 @@ text_placements_ptr text_placements_list::from_xml(xml_node const& xml, fontset_ { if (itr->is_text() || !itr->is("Placement")) continue; text_symbolizer_properties & p = list->add(); - //p.format = std::make_shared(*(p.format)); //Make a deep copy -- FIXME + //p.format = std::make_shared(*(p.format)); //Make a deep copy -- FIXME //TODO: This needs a real copy constructor for text_symbolizer_properties p.from_xml(*itr, fontsets); //TODO: if (strict_ && !p.format.fontset.size()) diff --git a/src/text/renderer.cpp b/src/text/renderer.cpp index d444fb6fa..233ddc6bf 100644 --- a/src/text/renderer.cpp +++ b/src/text/renderer.cpp @@ -151,8 +151,8 @@ void agg_text_renderer::render(glyph_positions const& pos) matrix.yy = transform_.sy * 0x10000L; matrix.yx = transform_.shy * 0x10000L; - char_properties default_props; - char_properties const* format = &default_props; + detail::evaluated_format_properties default_props; + detail::evaluated_format_properties const* format = &default_props; for (auto const& glyph : glyphs_) { if (glyph.properties) diff --git a/src/text/text_layout.cpp b/src/text/text_layout.cpp index 3eb460872..75c33c92c 100644 --- a/src/text/text_layout.cpp +++ b/src/text/text_layout.cpp @@ -64,7 +64,7 @@ text_layout::text_layout(face_manager_freetype & font_manager, double scale_fact lines_(), properties_(properties) {} -void text_layout::add_text(mapnik::value_unicode_string const& str, char_properties_ptr format) +void text_layout::add_text(mapnik::value_unicode_string const& str, evaluated_format_properties_ptr format) { itemizer_.add_text(str, format); } diff --git a/src/text/text_properties.cpp b/src/text/text_properties.cpp index 9dd6ba2fa..aaed0964e 100644 --- a/src/text/text_properties.cpp +++ b/src/text/text_properties.cpp @@ -62,7 +62,7 @@ void text_symbolizer_properties::process(text_layout & output, feature_impl cons if (tree_) { //evaluate format properties - char_properties_ptr format = std::make_shared(); + evaluated_format_properties_ptr format = std::make_shared(); format->text_size = boost::apply_visitor(extract_value(feature,attrs), format_defaults.text_size); format->character_spacing = boost::apply_visitor(extract_value(feature,attrs), format_defaults.character_spacing);