[QGIS-Developer] Issue with determining Symbol size - Bug?

C Hamilton adenaculture at gmail.com
Tue Sep 1 10:39:13 PDT 2020


I am trying to calculate the size of a single symbol in pixels using:

canvas = iface.mapCanvas()
context = QgsRenderContext.fromMapSettings(canvas.mapSettings())
layer = iface.activeLayer()
rnd = layer.renderer()
sym = rnd.symbol()
scaled_size_in_pixels = context.convertToPainterUnits(
    sym.size(),
    sym.sizeUnit(),
    sym.sizeMapUnitScale() )

The last line can also be calculated by:

  scaled_size_in_pixels = sym.size(context)

I am finding that this is returning the size of the filled area of the
symbol, but it does not include the border. Is this a bug or do I need to
add something additional to include the border?

Thanks,

Calvin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20200901/c08f5eb1/attachment-0001.html>


More information about the QGIS-Developer mailing list