diff --git a/include/mapnik/text/placement_finder_ng.hpp b/include/mapnik/text/placement_finder_ng.hpp index 27326400b..f25d685b1 100644 --- a/include/mapnik/text/placement_finder_ng.hpp +++ b/include/mapnik/text/placement_finder_ng.hpp @@ -101,6 +101,7 @@ public: bool next_position(); private: + void init_alignment(); Feature const& feature_; DetectorType const& detector_; box2d const& extent_; @@ -108,6 +109,10 @@ private: text_layout layout_; text_placement_info_ptr info_; bool valid_; + + vertical_alignment_e valign_; + horizontal_alignment_e halign_; + justify_alignment_e jalign_; }; typedef boost::shared_ptr placement_finder_ng_ptr; diff --git a/src/text/placement_finder_ng.cpp b/src/text/placement_finder_ng.cpp index fc3cf25c4..183e82f85 100644 --- a/src/text/placement_finder_ng.cpp +++ b/src/text/placement_finder_ng.cpp @@ -68,10 +68,60 @@ bool placement_finder_ng::next_position() } else { angle_ = 0.0; } + init_alignment(); return true; } +void placement_finder_ng::init_alignment() +{ + text_symbolizer_properties const& p = info_->properties; + valign_ = p.valign; + if (valign_ == V_AUTO) + { + if (p.displacement.second > 0.0) + { + valign_ = V_BOTTOM; + } else if (p.displacement.second < 0.0) + { + valign_ = V_TOP; + } else + { + valign_ = V_MIDDLE; + } + } + + halign_ = p.halign; + if (halign_ == H_AUTO) + { + if (p.displacement.first > 0.0) + { + halign_ = H_RIGHT; + } else if (p.displacement.first < 0.0) + { + halign_ = H_LEFT; + } else + { + halign_ = H_MIDDLE; + } + } + + jalign_ = p.jalign; + if (jalign_ == J_AUTO) + { + if (p.displacement.first > 0.0) + { + jalign_ = J_LEFT; + } else if (p.displacement.first < 0.0) + { + jalign_ = J_RIGHT; + } else { + jalign_ = J_MIDDLE; + } + } +} + + glyph_positions::glyph_positions() : base_point_(), const_angle_(true) {