diff --git a/include/mapnik/text/dummy_shaper.hpp b/include/mapnik/text/dummy_shaper.hpp index 15551f418..874f0d0db 100644 --- a/include/mapnik/text/dummy_shaper.hpp +++ b/include/mapnik/text/dummy_shaper.hpp @@ -82,7 +82,7 @@ static void shape_text(text_line & line, width_map[i] += tmp.advance(); line.add_glyph(tmp, scale_factor); } - line.update_max_char_height(face->get_char_height()); + line.update_max_char_height(face->get_char_height(size)); } } diff --git a/include/mapnik/text/face.hpp b/include/mapnik/text/face.hpp index bc4ecff36..a0d807fa3 100644 --- a/include/mapnik/text/face.hpp +++ b/include/mapnik/text/face.hpp @@ -64,7 +64,7 @@ public: return face_; } - double get_char_height() const; + double get_char_height(double size) const; bool set_character_sizes(double size); bool set_unscaled_character_sizes(); diff --git a/include/mapnik/text/glyph_info.hpp b/include/mapnik/text/glyph_info.hpp index ce59d5424..a8dc611c3 100644 --- a/include/mapnik/text/glyph_info.hpp +++ b/include/mapnik/text/glyph_info.hpp @@ -49,7 +49,7 @@ struct glyph_info unscaled_ymax(0.0), unscaled_advance(0.0), unscaled_line_height(0.0), - scale_multiplier(0.0), + scale_multiplier(1.0), offset(), format() {} glyph_index_t glyph_index; @@ -68,8 +68,8 @@ struct glyph_info pixel_position offset; char_properties_ptr format; - double ymin() const { return floor(unscaled_ymin * scale_multiplier / y_scale); } - double ymax() const { return ceil(unscaled_ymax * scale_multiplier / y_scale); } + double ymin() const { return floor(unscaled_ymin * 64.0 * scale_multiplier / y_scale); } + double ymax() const { return ceil(unscaled_ymax * 64.0 * scale_multiplier / y_scale); } double height() const { return ymax() - ymin(); }; double advance() const { return floor(unscaled_advance * scale_multiplier / x_scale); }; double line_height() const { return floor(unscaled_line_height * scale_multiplier / y_scale); }; diff --git a/include/mapnik/text/harfbuzz_shaper.hpp b/include/mapnik/text/harfbuzz_shaper.hpp index d607d2eef..cfdc8c6c8 100644 --- a/include/mapnik/text/harfbuzz_shaper.hpp +++ b/include/mapnik/text/harfbuzz_shaper.hpp @@ -110,14 +110,11 @@ static void shape_text(text_line & line, //Overwrite default advance with better value provided by HarfBuzz tmp.unscaled_advance = positions[i].x_advance * tmp.x_scale; - std::cerr << tmp.line_height() << ' ' << - tmp.advance() << '\n'; - tmp.offset.set(positions[i].x_offset * tmp.scale_multiplier, positions[i].y_offset * tmp.scale_multiplier); width_map[glyphs[i].cluster] += tmp.advance(); line.add_glyph(tmp, scale_factor); } - line.update_max_char_height(face->get_char_height()); + line.update_max_char_height(face->get_char_height(size)); break; //When we reach this point the current font had all glyphs. } } diff --git a/include/mapnik/text/icu_shaper.hpp b/include/mapnik/text/icu_shaper.hpp index 816ea4773..92df713e1 100644 --- a/include/mapnik/text/icu_shaper.hpp +++ b/include/mapnik/text/icu_shaper.hpp @@ -112,7 +112,7 @@ static void shape_text(text_line & line, } } if (!shaped_status) continue; - line.update_max_char_height(face->get_char_height()); + line.update_max_char_height(face->get_char_height(size)); return; } } diff --git a/src/text/face.cpp b/src/text/face.cpp index 257c25616..05db9410e 100644 --- a/src/text/face.cpp +++ b/src/text/face.cpp @@ -36,12 +36,13 @@ font_face::font_face(FT_Face face) { } -double font_face::get_char_height() const +double font_face::get_char_height(double size) const { if (char_height_ != 0.0) return char_height_; glyph_info tmp; tmp.glyph_index = FT_Get_Char_Index(face_, 'X'); glyph_dimensions(tmp); + tmp.scale_multiplier = size / face_->units_per_EM; char_height_ = tmp.height(); return char_height_; } @@ -96,7 +97,7 @@ void font_face::glyph_dimensions(glyph_info & glyph) const glyph.unscaled_ymin = glyph_bbox.yMin * glyph.y_scale; glyph.unscaled_ymax = glyph_bbox.yMax * glyph.y_scale; - glyph.unscaled_advance = face_->glyph->metrics.horiAdvance * glyph.x_scale; + glyph.unscaled_advance = face_->glyph->advance.x * glyph.x_scale; glyph.unscaled_line_height = face_->size->metrics.height * glyph.y_scale; //TODO: dimension_cache_.insert(std::pair(c, dim));