diff --git a/include/mapnik/text/glyph_info.hpp b/include/mapnik/text/glyph_info.hpp index 3cc29035c..f8b7559e0 100644 --- a/include/mapnik/text/glyph_info.hpp +++ b/include/mapnik/text/glyph_info.hpp @@ -35,14 +35,12 @@ namespace mapnik class font_face; using face_ptr = std::shared_ptr; -using glyph_index_t = unsigned; - struct glyph_info { - glyph_info() - : glyph_index(0), + glyph_info(unsigned g_index, unsigned c_index) + : glyph_index(g_index), + char_index(c_index), face(nullptr), - char_index(0), unscaled_ymin(0.0), unscaled_ymax(0.0), unscaled_advance(0.0), @@ -50,10 +48,10 @@ struct glyph_info scale_multiplier(1.0), offset(), format() {} - glyph_index_t glyph_index; - face_ptr face; + unsigned glyph_index; // Position in the string of all characters i.e. before itemizing unsigned char_index; + face_ptr face; double unscaled_ymin; double unscaled_ymax; double unscaled_advance; diff --git a/include/mapnik/text/harfbuzz_shaper.hpp b/include/mapnik/text/harfbuzz_shaper.hpp index 31e714fe6..c78974b5c 100644 --- a/include/mapnik/text/harfbuzz_shaper.hpp +++ b/include/mapnik/text/harfbuzz_shaper.hpp @@ -120,21 +120,22 @@ static void shape_text(text_line & line, double max_glyph_height = 0; for (unsigned i=0; iglyph_dimensions(tmp)) + auto const& pos = positions[i]; + auto const& glyph = glyphs[i]; + unsigned char_index = glyph.cluster; + glyph_info g(glyph.codepoint,char_index); + if (face->glyph_dimensions(g)) { - tmp.char_index = glyphs[i].cluster; - tmp.face = face; - tmp.format = text_item.format; - tmp.scale_multiplier = size / face->get_face()->units_per_EM; - double tmp_height = tmp.height(); - if (tmp_height > max_glyph_height) max_glyph_height = tmp_height; + g.face = face; + g.format = text_item.format; + g.scale_multiplier = size / face->get_face()->units_per_EM; //Overwrite default advance with better value provided by HarfBuzz - tmp.unscaled_advance = positions[i].x_advance; - 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); + g.unscaled_advance = pos.x_advance; + g.offset.set(pos.x_offset * g.scale_multiplier, pos.y_offset * g.scale_multiplier); + double tmp_height = g.height(); + if (tmp_height > max_glyph_height) max_glyph_height = tmp_height; + width_map[char_index] += g.advance(); + line.add_glyph(g, scale_factor); } } line.update_max_char_height(max_glyph_height);