Permalink
Browse files

Use double instead of unsigned while parsing XML.

Closes #1469.
  • Loading branch information...
1 parent 59129a7 commit 786f798cabe65470e57f0a52d225fe52af05c5b9 @herm herm committed Sep 5, 2012
@@ -131,7 +131,7 @@ class font_face : boost::noncopyable
return false;
}
- bool set_character_sizes(float size)
+ bool set_character_sizes(double size)
{
if ( !FT_Set_Char_Size(face_,0,(FT_F26Dot6)(size * (1<<6)),0,0))
return true;
@@ -191,7 +191,7 @@ class MAPNIK_DECL font_face_set : private boost::noncopyable
}
}
- void set_character_sizes(float size)
+ void set_character_sizes(double size)
{
BOOST_FOREACH ( face_ptr const& face, faces_)
{
@@ -59,7 +59,7 @@ struct char_properties
void to_xml(boost::property_tree::ptree &node, bool explicit_defaults, char_properties const& dfl=char_properties()) const;
std::string face_name;
font_set fontset;
- float text_size;
+ double text_size;
double character_spacing;
double line_spacing; //Largest total height (fontsize+line_spacing) per line is chosen
double text_opacity;
@@ -151,7 +151,7 @@ struct text_symbolizer_properties
justify_alignment_e jalign;
vertical_alignment_e valign;
/** distance between repeated labels on a single geometry */
- unsigned label_spacing;
+ double label_spacing;
/** distance the label can be moved on the line to fit, if 0 the default is used */
unsigned label_position_tolerance;
bool avoid_edges;
@@ -164,8 +164,8 @@ struct text_symbolizer_properties
bool allow_overlap;
/** Only consider geometry with largest bbox (polygons) */
bool largest_bbox_only;
- unsigned text_ratio;
- unsigned wrap_width;
+ double text_ratio;
+ double wrap_width;
/** Default values for char_properties. */
char_properties format;
private:
@@ -66,30 +66,30 @@ struct MAPNIK_DECL text_symbolizer : public symbolizer_base
expression_ptr get_orientation() const func_deprecated; // orienation (rotation angle atm)
void set_orientation(expression_ptr expr);
- unsigned get_text_ratio() const func_deprecated; // target ratio for text bounding box in pixels
- void set_text_ratio(unsigned ratio);
- unsigned get_wrap_width() const func_deprecated; // width to wrap text at, or trigger ratio
- void set_wrap_width(unsigned ratio);
+ double get_text_ratio() const func_deprecated; // target ratio for text bounding box in pixels
+ void set_text_ratio(double ratio);
+ double get_wrap_width() const func_deprecated; // width to wrap text at, or trigger ratio
+ void set_wrap_width(double width);
unsigned char get_wrap_char() const func_deprecated; // character used to wrap lines
std::string get_wrap_char_string() const func_deprecated; // character used to wrap lines as std::string
void set_wrap_char(unsigned char character);
void set_wrap_char_from_string(std::string const& character);
text_transform_e get_text_transform() const func_deprecated; // text conversion on strings before display
void set_text_transform(text_transform_e convert);
- unsigned get_line_spacing() const func_deprecated; // spacing between lines of text
- void set_line_spacing(unsigned spacing);
- unsigned get_character_spacing() const func_deprecated; // spacing between characters in text
- void set_character_spacing(unsigned spacing);
- unsigned get_label_spacing() const func_deprecated; // spacing between repeated labels on lines
- void set_label_spacing(unsigned spacing);
+ double get_line_spacing() const func_deprecated; // spacing between lines of text
+ void set_line_spacing(double spacing);
+ double get_character_spacing() const func_deprecated; // spacing between characters in text
+ void set_character_spacing(double spacing);
+ double get_label_spacing() const func_deprecated; // spacing between repeated labels on lines
+ void set_label_spacing(double spacing);
unsigned get_label_position_tolerance() const func_deprecated; //distance the label can be moved on the line to fit, if 0 the default is used
void set_label_position_tolerance(unsigned tolerance);
bool get_force_odd_labels() const func_deprecated; // try render an odd amount of labels
void set_force_odd_labels(bool force);
double get_max_char_angle_delta() const func_deprecated; // maximum change in angle between adjacent characters
void set_max_char_angle_delta(double angle);
- float get_text_size() const func_deprecated;
- void set_text_size(float size);
+ double get_text_size() const func_deprecated;
+ void set_text_size(double size);
std::string const& get_face_name() const func_deprecated;
void set_face_name(std::string face_name);
font_set const& get_fontset() const func_deprecated;
View
@@ -724,7 +724,7 @@ class cairo_context : private boost::noncopyable
path.vertex(&c, &x, &y, &angle);
face_set_ptr faces = font_manager.get_face_set(c->format->face_name, c->format->fontset);
- float text_size = c->format->text_size * scale_factor;
+ double text_size = c->format->text_size * scale_factor;
faces->set_character_sizes(text_size);
glyph_ptr glyph = faces->get_glyph(c->c);
@@ -59,9 +59,9 @@ node_ptr format_node::from_xml(xml_node const& xml)
n->face_name = xml.get_opt_attr<std::string>("face-name");
/*TODO: Fontset is problematic. We don't have the fontsets pointer here... */
- n->text_size = xml.get_opt_attr<unsigned>("size");
- n->character_spacing = xml.get_opt_attr<unsigned>("character-spacing");
- n->line_spacing = xml.get_opt_attr<unsigned>("line-spacing");
+ n->text_size = xml.get_opt_attr<double>("size");
+ n->character_spacing = xml.get_opt_attr<double>("character-spacing");
+ n->line_spacing = xml.get_opt_attr<double>("line-spacing");
n->text_opacity = xml.get_opt_attr<double>("opacity");
boost::optional<boolean> wrap = xml.get_opt_attr<boolean>("wrap-before");
if (wrap) n->wrap_before = *wrap;
View
@@ -86,24 +86,24 @@ void text_symbolizer_properties::from_xml(xml_node const &sym, fontset_map const
if (placement_) label_placement = *placement_;
optional<vertical_alignment_e> valign_ = sym.get_opt_attr<vertical_alignment_e>("vertical-alignment");
if (valign_) valign = *valign_;
- optional<unsigned> text_ratio_ = sym.get_opt_attr<unsigned>("text-ratio");
+ optional<double> text_ratio_ = sym.get_opt_attr<double>("text-ratio");
if (text_ratio_) text_ratio = *text_ratio_;
- optional<unsigned> wrap_width_ = sym.get_opt_attr<unsigned>("wrap-width");
+ optional<double> wrap_width_ = sym.get_opt_attr<double>("wrap-width");
if (wrap_width_) wrap_width = *wrap_width_;
optional<unsigned> label_position_tolerance_ = sym.get_opt_attr<unsigned>("label-position-tolerance");
if (label_position_tolerance_) label_position_tolerance = *label_position_tolerance_;
- optional<unsigned> spacing_ = sym.get_opt_attr<unsigned>("spacing");
+ optional<double> spacing_ = sym.get_opt_attr<double>("spacing");
if (spacing_) label_spacing = *spacing_;
else {
// https://github.com/mapnik/mapnik/issues/1427
- spacing_ = sym.get_opt_attr<unsigned>("label-spacing");
+ spacing_ = sym.get_opt_attr<double>("label-spacing");
if (spacing_) label_spacing = *spacing_;
}
- optional<unsigned> minimum_distance_ = sym.get_opt_attr<unsigned>("minimum-distance");
+ optional<double> minimum_distance_ = sym.get_opt_attr<double>("minimum-distance");
if (minimum_distance_) minimum_distance = *minimum_distance_;
- optional<unsigned> min_padding_ = sym.get_opt_attr<unsigned>("minimum-padding");
+ optional<double> min_padding_ = sym.get_opt_attr<double>("minimum-padding");
if (min_padding_) minimum_padding = *min_padding_;
- optional<unsigned> min_path_length_ = sym.get_opt_attr<unsigned>("minimum-path-length");
+ optional<double> min_path_length_ = sym.get_opt_attr<double>("minimum-path-length");
if (min_path_length_) minimum_path_length = *min_path_length_;
optional<boolean> avoid_edges_ = sym.get_opt_attr<boolean>("avoid-edges");
if (avoid_edges_) avoid_edges = *avoid_edges_;
@@ -256,7 +256,7 @@ char_properties::char_properties() :
void char_properties::from_xml(xml_node const& sym, fontset_map const& fontsets)
{
- optional<float> text_size_ = sym.get_opt_attr<float>("size");
+ optional<double> text_size_ = sym.get_opt_attr<double>("size");
if (text_size_) text_size = *text_size_;
optional<double> character_spacing_ = sym.get_opt_attr<double>("character-spacing");
if (character_spacing_) character_spacing = *character_spacing_;
View
@@ -178,22 +178,22 @@ font_set const& text_symbolizer::get_fontset() const
return placement_options_->defaults.format.fontset;
}
-unsigned text_symbolizer::get_text_ratio() const
+double text_symbolizer::get_text_ratio() const
{
return placement_options_->defaults.text_ratio;
}
-void text_symbolizer::set_text_ratio(unsigned ratio)
+void text_symbolizer::set_text_ratio(double ratio)
{
placement_options_->defaults.text_ratio = ratio;
}
-unsigned text_symbolizer::get_wrap_width() const
+double text_symbolizer::get_wrap_width() const
{
return placement_options_->defaults.wrap_width;
}
-void text_symbolizer::set_wrap_width(unsigned width)
+void text_symbolizer::set_wrap_width(double width)
{
placement_options_->defaults.wrap_width = width;
}
@@ -238,32 +238,32 @@ void text_symbolizer::set_text_transform(text_transform_e convert)
placement_options_->defaults.format.text_transform = convert;
}
-unsigned text_symbolizer::get_line_spacing() const
+double text_symbolizer::get_line_spacing() const
{
return placement_options_->defaults.format.line_spacing;
}
-void text_symbolizer::set_line_spacing(unsigned spacing)
+void text_symbolizer::set_line_spacing(double spacing)
{
placement_options_->defaults.format.line_spacing = spacing;
}
-unsigned text_symbolizer::get_character_spacing() const
+double text_symbolizer::get_character_spacing() const
{
return placement_options_->defaults.format.character_spacing;
}
-void text_symbolizer::set_character_spacing(unsigned spacing)
+void text_symbolizer::set_character_spacing(double spacing)
{
placement_options_->defaults.format.character_spacing = spacing;
}
-unsigned text_symbolizer::get_label_spacing() const
+double text_symbolizer::get_label_spacing() const
{
return placement_options_->defaults.label_spacing;
}
-void text_symbolizer::set_label_spacing(unsigned spacing)
+void text_symbolizer::set_label_spacing(double spacing)
{
placement_options_->defaults.label_spacing = spacing;
}
@@ -298,12 +298,12 @@ void text_symbolizer::set_max_char_angle_delta(double angle)
placement_options_->defaults.max_char_angle_delta = angle;
}
-void text_symbolizer::set_text_size(float size)
+void text_symbolizer::set_text_size(double size)
{
placement_options_->defaults.format.text_size = size;
}
-float text_symbolizer::get_text_size() const
+double text_symbolizer::get_text_size() const
{
return placement_options_->defaults.format.text_size;
}

0 comments on commit 786f798

Please sign in to comment.