Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes 16707, export of hairline results in a different visual thickness
  • Loading branch information
aaime committed Jun 15, 2017
1 parent 7aec4d1 commit b64f256
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/symbology-ng/qgssymbollayerutils.cpp
Expand Up @@ -1845,7 +1845,14 @@ void QgsSymbolLayerUtils::lineToSld( QDomDocument &doc, QDomElement &element,
element.appendChild( createSvgParameterElement( doc, QStringLiteral( "stroke-opacity" ), encodeSldAlpha( color.alpha() ) ) );
}
if ( width > 0 )
{
element.appendChild( createSvgParameterElement( doc, QStringLiteral( "stroke-width" ), qgsDoubleToString( width ) ) );
}
else if ( width == 0 )
{
// hairline, yet not zero. it's actually painted in qgis
element.appendChild( createSvgParameterElement( doc, QStringLiteral( "stroke-width" ), QStringLiteral( "0.5" ) ) );
}
if ( penJoinStyle )
element.appendChild( createSvgParameterElement( doc, QStringLiteral( "stroke-linejoin" ), encodeSldLineJoinStyle( *penJoinStyle ) ) );
if ( penCapStyle )
Expand Down
9 changes: 9 additions & 0 deletions tests/src/python/test_qgssymbollayer_createsld.py
Expand Up @@ -231,6 +231,15 @@ def testEllipseMarkerUnitPixel(self):
self.assertStrokeWidth(root, 2, 1)
self.assertStaticDisplacement(root, 5, 10)

def testSimpleLineHairline(self):
symbol = QgsSimpleLineSymbolLayer(QColor("black"), 0)
dom, root = self.symbolToSld(symbol)

# print ("Simple line px: \n" + dom.toString())

# Hairline is turned into 0.5px
self.assertStrokeWidth(root, 1, 0.5)

def testSimpleLineUnitDefault(self):
symbol = QgsSimpleLineSymbolLayer(QColor("black"), 1)
symbol.setCustomDashVector([10, 10])
Expand Down
1 change: 1 addition & 0 deletions tests/testdata/qgis_server/getstyles.txt
Expand Up @@ -19,6 +19,7 @@ Content-Type: text/xml; charset=utf-8
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">0.5</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>7</se:Size>
Expand Down

0 comments on commit b64f256

Please sign in to comment.