From fd19eb79056b8e62f037c0ae4532f4f7cc970580 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Thu, 28 May 2015 19:15:56 -0400 Subject: [PATCH] fix shaped icon box sizes --- src/mbgl/text/quads.cpp | 13 +++++++++---- src/mbgl/text/shaping.cpp | 5 ++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 6c517bab2..9835a488a 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -13,10 +13,15 @@ SymbolQuads getIconQuads(Anchor &anchor, const PositionedIcon &shapedIcon, const std::vector &line, const StyleLayoutSymbol &layout, const bool alongLine) { - vec2 tl{shapedIcon.left, shapedIcon.top}; - vec2 tr{shapedIcon.right, shapedIcon.top}; - vec2 br{shapedIcon.right, shapedIcon.bottom}; - vec2 bl{shapedIcon.left, shapedIcon.bottom}; + const float border = 1.0; + auto left = shapedIcon.left - border; + auto right = left + shapedIcon.image.w; + auto top = shapedIcon.top - border; + auto bottom = top + shapedIcon.image.h; + vec2 tl{left, top}; + vec2 tr{right, top}; + vec2 br{right, bottom}; + vec2 bl{left, bottom}; float angle = layout.icon.rotate * M_PI / 180.0f; diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index 971b695e4..35fe5dc24 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -6,11 +6,10 @@ namespace mbgl { PositionedIcon shapeIcon(const Rect &image, const StyleLayoutSymbol &layout) { float dx = layout.icon.offset[0]; float dy = layout.icon.offset[1]; - // TODO, this is image.image.width in -js float x1 = dx - image.originalW / 2.0f; - float x2 = x1 + image.w; + float x2 = x1 + image.originalW; float y1 = dy - image.originalH / 2.0f; - float y2 = y1 + image.h; + float y2 = y1 + image.originalH; return PositionedIcon(image, y1, y2, x1, x2); }