From 09ea6bebb4cb2ffe50aaa9374e552801c6d200e2 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 14 Sep 2020 13:33:04 +1000 Subject: [PATCH] Scale up buffer sizes when converting, in order to better match actual MapBox rendering --- src/core/vectortile/qgsmapboxglstyleconverter.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/vectortile/qgsmapboxglstyleconverter.cpp b/src/core/vectortile/qgsmapboxglstyleconverter.cpp index d94b1df659d..d46a1d3ad5c 100644 --- a/src/core/vectortile/qgsmapboxglstyleconverter.cpp +++ b/src/core/vectortile/qgsmapboxglstyleconverter.cpp @@ -859,6 +859,10 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, } double bufferSize = 0.0; + // the pixel based text buffers appear larger when rendered on the web - so automatically scale + // them up when converting to a QGIS style + // (this number is based on trial-and-error comparisons only!) + constexpr double BUFFER_SIZE_SCALE = 2.0; if ( jsonPaint.contains( QStringLiteral( "text-halo-width" ) ) ) { const QVariant jsonHaloWidth = jsonPaint.value( QStringLiteral( "text-halo-width" ) ); @@ -866,18 +870,18 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, { case QVariant::Int: case QVariant::Double: - bufferSize = jsonHaloWidth.toDouble() * context.pixelSizeConversionFactor(); + bufferSize = jsonHaloWidth.toDouble() * context.pixelSizeConversionFactor() * BUFFER_SIZE_SCALE; break; case QVariant::Map: bufferSize = 1; - ddLabelProperties.setProperty( QgsPalLayerSettings::BufferSize, parseInterpolateByZoom( jsonHaloWidth.toMap(), context, context.pixelSizeConversionFactor(), &bufferSize ) ); + ddLabelProperties.setProperty( QgsPalLayerSettings::BufferSize, parseInterpolateByZoom( jsonHaloWidth.toMap(), context, context.pixelSizeConversionFactor() * BUFFER_SIZE_SCALE, &bufferSize ) ); break; case QVariant::List: case QVariant::StringList: bufferSize = 1; - ddLabelProperties.setProperty( QgsPalLayerSettings::BufferSize, parseValueList( jsonHaloWidth.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor(), 255, nullptr, &bufferSize ) ); + ddLabelProperties.setProperty( QgsPalLayerSettings::BufferSize, parseValueList( jsonHaloWidth.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor() * BUFFER_SIZE_SCALE, 255, nullptr, &bufferSize ) ); break; default: