diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index 2623bc137..f7b359a10 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -289,7 +289,6 @@ struct evaluate_expression_wrapper mapnik::color operator() (T1 const& expr, T2 const& feature, T3 const& vars) const { mapnik::value_type val = util::apply_visitor(mapnik::evaluate(feature,vars), expr); - // FIXME - throw instead? if (val.is_null()) return mapnik::color(255,192,203); // pink return mapnik::color(val.to_string()); } @@ -314,7 +313,6 @@ struct evaluate_expression_wrapper mapnik::dash_array operator() (T1 const& expr, T2 const& feature, T3 const& vars) const { mapnik::value_type val = util::apply_visitor(mapnik::evaluate(feature,vars), expr); - // FIXME - throw? if (val.is_null()) return dash_array(); dash_array dash; std::vector buf; @@ -327,17 +325,16 @@ struct evaluate_expression_wrapper } }; -// mapnik::font_feature_settings_ptr +// mapnik::font_feature_settings template <> -struct evaluate_expression_wrapper +struct evaluate_expression_wrapper { template - mapnik::font_feature_settings_ptr operator() (T1 const& expr, T2 const& feature, T3 const& vars) const + mapnik::font_feature_settings operator() (T1 const& expr, T2 const& feature, T3 const& vars) const { mapnik::value_type val = util::apply_visitor(mapnik::evaluate(feature, vars), expr); - // FIXME - throw instead? - if (val.is_null()) return std::make_shared(); - return std::make_shared(val.to_string()); + if (val.is_null()) return mapnik::font_feature_settings(); + return mapnik::font_feature_settings(val.to_string()); } }; diff --git a/include/mapnik/symbolizer_base.hpp b/include/mapnik/symbolizer_base.hpp index 4b8cd724d..55472fa97 100644 --- a/include/mapnik/symbolizer_base.hpp +++ b/include/mapnik/symbolizer_base.hpp @@ -94,7 +94,7 @@ using value_base_type = util::variant; + font_feature_settings>; struct strict_value : value_base_type { diff --git a/include/mapnik/text/font_feature_settings.hpp b/include/mapnik/text/font_feature_settings.hpp index ba8b2c4e6..03cfa5e0e 100644 --- a/include/mapnik/text/font_feature_settings.hpp +++ b/include/mapnik/text/font_feature_settings.hpp @@ -52,12 +52,16 @@ public: const font_feature* get_features() const { return features_.data(); } feature_vector::size_type count() const { return features_.size(); } + feature_vector const& features() const { return features_; } private: feature_vector features_; }; -using font_feature_settings_ptr = std::shared_ptr; +inline bool operator==(font_feature_settings const& lhs, font_feature_settings const& rhs) +{ + return (lhs.features() == rhs.features()); +} constexpr unsigned int font_feature_range_global_start = 0u; static const unsigned int font_feature_range_global_end = std::numeric_limits::max(); diff --git a/include/mapnik/text/harfbuzz_shaper.hpp b/include/mapnik/text/harfbuzz_shaper.hpp index 888a0b0ec..055910bb7 100644 --- a/include/mapnik/text/harfbuzz_shaper.hpp +++ b/include/mapnik/text/harfbuzz_shaper.hpp @@ -76,7 +76,7 @@ static void shape_text(text_line & line, hb_buffer_pre_allocate(buffer.get(), length); mapnik::value_unicode_string const& text = itemizer.text(); - font_feature_settings_ptr features = list.front().format->font_feature_settings; + font_feature_settings features = list.front().format->font_feature_settings; for (auto const& text_item : list) { @@ -93,7 +93,7 @@ static void shape_text(text_line & line, hb_buffer_set_direction(buffer.get(), (text_item.rtl == UBIDI_RTL)?HB_DIRECTION_RTL:HB_DIRECTION_LTR); hb_buffer_set_script(buffer.get(), _icu_script_to_script(text_item.script)); hb_font_t *font(hb_ft_font_create(face->get_face(), nullptr)); - hb_shape(font, buffer.get(), features->get_features(), features->count()); + hb_shape(font, buffer.get(), features.get_features(), features.count()); hb_font_destroy(font); unsigned num_glyphs = hb_buffer_get_length(buffer.get()); diff --git a/include/mapnik/text/text_properties.hpp b/include/mapnik/text/text_properties.hpp index a8ff014c3..fc66ae04c 100644 --- a/include/mapnik/text/text_properties.hpp +++ b/include/mapnik/text/text_properties.hpp @@ -60,7 +60,7 @@ struct evaluated_format_properties fill(0,0,0), halo_fill(0,0,0), halo_radius(0.0), - font_feature_settings(std::make_shared()) {} + font_feature_settings() {} std::string face_name; boost::optional fontset; double text_size; @@ -72,7 +72,7 @@ struct evaluated_format_properties color fill; color halo_fill; double halo_radius; - font_feature_settings_ptr font_feature_settings; + font_feature_settings font_feature_settings; }; } diff --git a/include/mapnik/xml_attribute_cast.hpp b/include/mapnik/xml_attribute_cast.hpp index 95880e03f..40bf9de27 100644 --- a/include/mapnik/xml_attribute_cast.hpp +++ b/include/mapnik/xml_attribute_cast.hpp @@ -201,13 +201,13 @@ struct do_xml_attribute_cast } }; -// specialization for mapnik::font_feature_settings_ptr +// specialization for mapnik::font_feature_settings template <> -struct do_xml_attribute_cast +struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& tree, std::string const& source) + static inline boost::optional xml_attribute_cast_impl(xml_tree const& tree, std::string const& source) { - return std::make_shared(source); + return font_feature_settings(source); } }; diff --git a/src/text/formatting/format.cpp b/src/text/formatting/format.cpp index 75374c28c..0c7789917 100644 --- a/src/text/formatting/format.cpp +++ b/src/text/formatting/format.cpp @@ -75,7 +75,7 @@ node_ptr format_node::from_xml(xml_node const& xml, fontset_map const& fontsets) set_property_from_xml(n->fill, "fill", xml); set_property_from_xml(n->halo_fill, "halo-fill", xml); set_property_from_xml(n->text_transform, "text-transform", xml); - set_property_from_xml(n->font_feature_settings, "font-feature-settings", xml); + set_property_from_xml(n->font_feature_settings, "font-feature-settings", xml); boost::optional face_name = xml.get_opt_attr("face-name"); if (face_name) @@ -115,7 +115,7 @@ void format_node::apply(evaluated_format_properties_ptr p, feature_impl const& f if (fill) new_properties->fill = util::apply_visitor(extract_value(feature,attrs), *fill); if (halo_fill) new_properties->halo_fill = util::apply_visitor(extract_value(feature,attrs), *halo_fill); if (text_transform) new_properties->text_transform = util::apply_visitor(extract_value(feature,attrs), *text_transform); - if (font_feature_settings) new_properties->font_feature_settings = util::apply_visitor(extract_value(feature,attrs), *font_feature_settings); + if (font_feature_settings) new_properties->font_feature_settings = util::apply_visitor(extract_value(feature,attrs), *font_feature_settings); if (fontset) { diff --git a/src/text/properties_util.cpp b/src/text/properties_util.cpp index ba0620167..41e5d6093 100644 --- a/src/text/properties_util.cpp +++ b/src/text/properties_util.cpp @@ -70,7 +70,7 @@ struct property_serializer : public util::static_visitor<> node_.put("." + name_, str); } - void operator() (font_feature_settings_ptr const& val) const + void operator() (font_feature_settings const& val) const { std::string str = val->to_string(); node_.put("." + name_, str); diff --git a/src/text/text_properties.cpp b/src/text/text_properties.cpp index 7e88fecc8..57eeb7168 100644 --- a/src/text/text_properties.cpp +++ b/src/text/text_properties.cpp @@ -98,7 +98,7 @@ void text_symbolizer_properties::process(text_layout & output, feature_impl cons format->face_name = format_defaults.face_name; format->fontset = format_defaults.fontset; - format->font_feature_settings = util::apply_visitor(extract_value(feature,attrs), format_defaults.font_feature_settings); + format->font_feature_settings = util::apply_visitor(extract_value(feature,attrs), format_defaults.font_feature_settings); // Turn off ligatures if character_spacing > 0. if (format->character_spacing > .0 && format->font_feature_settings->count() == 0) { @@ -345,7 +345,7 @@ void format_properties::from_xml(xml_node const& node, fontset_map const& fontse set_property_from_xml(fill, "fill", node); set_property_from_xml(halo_fill, "halo-fill", node); set_property_from_xml(text_transform,"text-transform", node); - set_property_from_xml(font_feature_settings, "font-feature-settings", node); + set_property_from_xml(font_feature_settings, "font-feature-settings", node); optional face_name_ = node.get_opt_attr("face-name"); if (face_name_) face_name = *face_name_; diff --git a/src/xml_tree.cpp b/src/xml_tree.cpp index 9583247d3..b03dd915a 100644 --- a/src/xml_tree.cpp +++ b/src/xml_tree.cpp @@ -77,7 +77,7 @@ DEFINE_NAME_TRAIT( mapnik::value_integer, "int" ) DEFINE_NAME_TRAIT( std::string, "string" ) DEFINE_NAME_TRAIT( color, "color" ) DEFINE_NAME_TRAIT( expression_ptr, "expression_ptr" ) -DEFINE_NAME_TRAIT( font_feature_settings_ptr, "font-feature-settings" ) +DEFINE_NAME_TRAIT( font_feature_settings, "font-feature-settings" ) template struct name_trait< mapnik::enumeration > @@ -429,7 +429,7 @@ compile_get_opt_attr(justify_alignment_e); compile_get_opt_attr(text_upright_e); compile_get_opt_attr(halo_rasterizer_e); compile_get_opt_attr(expression_ptr); -compile_get_opt_attr(font_feature_settings_ptr); +compile_get_opt_attr(font_feature_settings); compile_get_attr(std::string); compile_get_attr(filter_mode_e); compile_get_attr(point_placement_e);