Skip to content
Permalink
Browse files

Merge pull request #4727 from aaime/stroke_hairline

Fixes 16707, export of hairline results in a different visual thickness
  • Loading branch information
nyalldawson committed Jun 26, 2017
2 parents 32dd2b6 + b64f256 commit 65a5669b255cbfce16cb268f1e9562f0e7271ec3
@@ -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 )
@@ -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])
@@ -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>

0 comments on commit 65a5669

Please sign in to comment.
You can’t perform that action at this time.