Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Copy Markdown
Contributor

@matzf matzf Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary additional variables, just multiply spriteWidth/Height with iconSize at initialization.
(That is, if the logic should actually work like implemented, this seems to break some test cases completely)


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;
}
Expand Down
Loading