diff --git a/include/mapnik/text/layout.hpp b/include/mapnik/text/layout.hpp index 7f8d35fbc..69a4772e6 100644 --- a/include/mapnik/text/layout.hpp +++ b/include/mapnik/text/layout.hpp @@ -51,7 +51,7 @@ public: typedef std::vector glyph_vector; typedef glyph_vector::const_iterator const_iterator; glyph_vector const& get_glyphs() const { return glyphs_; } - void add_glyph(glyph_info const& glyph); + void add_glyph(glyph_info const& glyph, double scale_factor_); void reserve(glyph_vector::size_type length); const_iterator begin() const; diff --git a/src/text/layout.cpp b/src/text/layout.cpp index e1b4d7cd0..a0a568d57 100644 --- a/src/text/layout.cpp +++ b/src/text/layout.cpp @@ -89,7 +89,7 @@ void text_layout::break_line(text_line_ptr line, double wrap_width, unsigned tex unsigned last_break_position = 0; for (unsigned i=line->get_first_char(); iget_last_char(); i++) { - //TODO: Char spacing + //TODO: character_spacing std::map::const_iterator width_itr = width_map_.find(i); if (width_itr != width_map_.end()) { @@ -192,14 +192,15 @@ text_line::text_line(unsigned first_char, unsigned last_char) { } -void text_line::add_glyph(const glyph_info &glyph) +void text_line::add_glyph(const glyph_info &glyph, double scale_factor_) { line_height_ = std::max(line_height_, glyph.line_height + glyph.format->line_spacing); if (glyphs_.empty()) { width_ = glyph.width; - } else { - width_ += glyph.width + glyphs_.back().format->character_spacing; + } else if (glyph.width) { + //Only add character spacing if the character is not a zero-width part of a cluster. + width_ += glyph.width + glyphs_.back().format->character_spacing * scale_factor_; } glyphs_.push_back(glyph); } diff --git a/src/text/layout_shape_dummy.cpp b/src/text/layout_shape_dummy.cpp index 54a715ecc..afbc0902f 100644 --- a/src/text/layout_shape_dummy.cpp +++ b/src/text/layout_shape_dummy.cpp @@ -59,7 +59,7 @@ void text_layout::shape_text(text_line_ptr line) width_map_[i] += tmp.width; - line->add_glyph(tmp); + line->add_glyph(tmp, scale_factor_); } line->update_max_char_height(face->get_char_height()); } diff --git a/src/text/layout_shape_hb.cpp b/src/text/layout_shape_hb.cpp index 8bce35616..45d5b0d5f 100644 --- a/src/text/layout_shape_hb.cpp +++ b/src/text/layout_shape_hb.cpp @@ -73,7 +73,7 @@ void text_layout::shape_text(text_line_ptr line) width_map_[glyphs[i].cluster] += tmp.width; - line->add_glyph(tmp); + line->add_glyph(tmp, scale_factor_); } line->update_max_char_height(face->get_char_height()); break; //When we reach this point the current font had all glyphs.