summaryrefslogtreecommitdiff
path: root/src/mbgl/layout
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-10-14 15:16:14 +0200
committerKonstantin Käfer <mail@kkaefer.com>2019-10-14 18:46:12 +0200
commit2187980a871cc22f59c1078a949e42db0ab7c1a2 (patch)
treeaf86f66a8c3aa45b0b5b967867431a50e9df264c /src/mbgl/layout
parent9cac122c5cf6404b9c8cdb52f130f7386a273241 (diff)
downloadqtlocation-mapboxgl-2187980a871cc22f59c1078a949e42db0ab7c1a2.tar.gz
[core] fix icon-text-fit
This fixes rendering by account for the 1px texture padding around icons that were stretched with icon-text-fit. We've added the 1px padding before, but didn't scale it accordingly when we are resizing the icon when it is stretched to fit the text. Adjusts the code to match the logic in GL JS.
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r--src/mbgl/layout/symbol_layout.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 81d1d9a5b6..d0227c36c5 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -121,7 +121,7 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters,
allowVerticalPlacement = allowVerticalPlacement || placementMode == style::TextWritingModeType::Vertical;
return !seen.insert(placementMode).second;
});
- modes.erase(end, modes.end());
+ modes.erase(end, modes.end());
placementModes = std::move(modes);
}
@@ -525,21 +525,22 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex,
const float textRepeatDistance = symbolSpacing / 2;
const auto evaluatedLayoutProperties = layout->evaluate(zoom, feature);
IndexedSubfeature indexedFeature(feature.index, sourceLayer->getName(), bucketLeaderID, symbolInstances.size());
- const bool hasIconTextFit = evaluatedLayoutProperties.get<style::IconTextFit>() != IconTextFitType::None;
+ const auto iconTextFit = evaluatedLayoutProperties.get<style::IconTextFit>();
// Adjust shaped icon size when icon-text-fit is used.
optional<PositionedIcon> verticallyShapedIcon;
- if (shapedIcon && hasIconTextFit) {
+ if (shapedIcon && iconTextFit != IconTextFitType::None) {
// Create vertically shaped icon for vertical writing mode if needed.
if (allowVerticalPlacement && shapedTextOrientations.vertical) {
verticallyShapedIcon = shapedIcon;
- verticallyShapedIcon->fitIconToText(evaluatedLayoutProperties,
- shapedTextOrientations.vertical,
- layoutTextSize);
+ verticallyShapedIcon->fitIconToText(
+ shapedTextOrientations.vertical, iconTextFit, layout->get<IconTextFitPadding>(), iconOffset, fontScale);
+ }
+ const auto shapedText = getDefaultHorizontalShaping(shapedTextOrientations);
+ if (shapedText) {
+ shapedIcon->fitIconToText(
+ shapedText, iconTextFit, layout->get<IconTextFitPadding>(), iconOffset, fontScale);
}
- shapedIcon->fitIconToText(evaluatedLayoutProperties,
- getDefaultHorizontalShaping(shapedTextOrientations),
- layoutTextSize);
}
auto addSymbolInstance = [&] (Anchor& anchor, std::shared_ptr<SymbolInstanceSharedData> sharedData) {