From e5b17bdcfaa269766dde499a15ae54718334337d Mon Sep 17 00:00:00 2001 From: Marco Zimmermann Date: Mon, 16 Mar 2026 16:11:01 +0100 Subject: [PATCH] fixes scaled sprite width / height --- .../vector/symbol/Tiled2dMapVectorSymbolObject.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.cpp b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.cpp index 447438ef4..1a8a54223 100644 --- a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.cpp +++ b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.cpp @@ -706,15 +706,21 @@ void Tiled2dMapVectorSymbolObject::updateStretchIconProperties(VectorModificatio bottomPadding = (spriteDesc.height - contentBox[3]) * scale; } + const auto scaledBaseSpriteWidth = spriteWidth * iconSize.value; + const auto scaledBaseSpriteHeight = spriteHeight * iconSize.value; + auto scaleX = 1.0; auto scaleY = 1.0; - if (labelObject) { + if (labelObject && scaledBaseSpriteWidth > 0.0 && scaledBaseSpriteHeight > 0.0) { const double textWidth = labelObject->dimensions.x + (leftPadding + rightPadding); const double textHeight = labelObject->dimensions.y + (topPadding + bottomPadding); - scaleX = std::max(1.0, textWidth / (spriteWidth * iconSize.value)); - scaleY = std::max(1.0, textHeight / (spriteHeight * iconSize.value)); + scaleX = std::max(1.0, textWidth / scaledBaseSpriteWidth); + scaleY = std::max(1.0, textHeight / scaledBaseSpriteHeight); } + spriteWidth = scaledBaseSpriteWidth; + spriteHeight = scaledBaseSpriteHeight; + if (iconTextFit == IconTextFit::WIDTH || iconTextFit == IconTextFit::BOTH) { spriteWidth *= scaleX; }