diff --git a/src/core/symbology-ng/qgsfillsymbollayerv2.cpp b/src/core/symbology-ng/qgsfillsymbollayerv2.cpp index f4ed270d4ffd..addb453be41b 100644 --- a/src/core/symbology-ng/qgsfillsymbollayerv2.cpp +++ b/src/core/symbology-ng/qgsfillsymbollayerv2.cpp @@ -2569,6 +2569,15 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolV2RenderContext double outputPixelDist = distance * QgsSymbolLayerV2Utils::pixelSizeScaleFactor( ctx, mDistanceUnit, mDistanceMapUnitScale ); double outputPixelOffset = mOffset * QgsSymbolLayerV2Utils::pixelSizeScaleFactor( ctx, mOffsetUnit, mOffsetMapUnitScale ); + // NOTE: this may need to be modified if we ever change from a forced rasterized/brush approach, + // because potentially we may want to allow vector based line pattern fills where the first line + // is offset by a large distance + + // fix truncated pattern with larger offsets + outputPixelOffset = fmod( outputPixelOffset, outputPixelDist ); + if ( outputPixelOffset > outputPixelDist / 2.0 ) + outputPixelOffset -= outputPixelDist; + // To get all patterns into image, we have to consider symbols size (estimateMaxBleed()). // For marker lines we have to get markers interval. double outputPixelBleed = 0; diff --git a/tests/src/core/testqgslinefillsymbol.cpp b/tests/src/core/testqgslinefillsymbol.cpp index 4d95570ddf30..c33e5b46e723 100644 --- a/tests/src/core/testqgslinefillsymbol.cpp +++ b/tests/src/core/testqgslinefillsymbol.cpp @@ -61,6 +61,7 @@ class TestQgsLineFillSymbol : public QObject void lineFillSymbol(); void lineFillSymbolOffset(); + void lineFillLargeOffset(); void dataDefinedSubSymbol(); @@ -161,6 +162,17 @@ void TestQgsLineFillSymbol::lineFillSymbolOffset() mLineFill->setOffset( 0 ); } +void TestQgsLineFillSymbol::lineFillLargeOffset() +{ + // test line fill with large offset compared to line distance + mLineFill->setOffset( 8 ); + QVERIFY( imageCheck( "symbol_linefill_large_posoffset" ) ); + + mLineFill->setOffset( -8 ); + QVERIFY( imageCheck( "symbol_linefill_large_negoffset" ) ); + mLineFill->setOffset( 0 ); +} + void TestQgsLineFillSymbol::dataDefinedSubSymbol() { mReport += "

Line fill symbol data defined sub symbol test

\n";