From 7c93514fbc8498ac56ee7f6effa3d11b742c7c4f Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 28 Feb 2017 15:01:46 +0100 Subject: [PATCH] avoid division by zero (units_per_EM is set to 0 for bitmap fonts) --- include/mapnik/text/harfbuzz_shaper.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/mapnik/text/harfbuzz_shaper.hpp b/include/mapnik/text/harfbuzz_shaper.hpp index c1544179c..2752af964 100644 --- a/include/mapnik/text/harfbuzz_shaper.hpp +++ b/include/mapnik/text/harfbuzz_shaper.hpp @@ -199,11 +199,16 @@ static void shape_text(text_line & line, if (theface->glyph_dimensions(g)) { g.face = theface; - g.scale_multiplier = size / theface->get_face()->units_per_EM; + g.scale_multiplier = theface->get_face()->units_per_EM > 0 ? + (size / theface->get_face()->units_per_EM) : (size / 2048.0) ; //Overwrite default advance with better value provided by HarfBuzz g.unscaled_advance = gpos.x_advance; g.offset.set(gpos.x_offset * g.scale_multiplier, gpos.y_offset * g.scale_multiplier); double tmp_height = g.height(); + if (theface->is_color()) + { + tmp_height = size; + } if (tmp_height > max_glyph_height) max_glyph_height = tmp_height; width_map[char_index] += g.advance(); line.add_glyph(std::move(g), scale_factor);