Bug report #6861
SVG symbol scaling and ouput incorrect
|Affected QGIS version:
|Pull Request or Patch supplied:
|Crashes QGIS or corrupts data:
|Copied to github as #:
This issue is to describe several SVG rendering issues currently present in 1.8 and master. I have a pull request in to fix these:
The three related issues are:
A) When SVG symbol is set to map units and rendered using QPicture (e.g. when symbol is rotated) the symbol does not scale with the map item when zooming the page in or out in Print Composer. It will scale with the map item zoom, but not whole page zooming. ( see svg-sym_zoomout-of-rotated.png and svg-sym_zoomin-of-rotated.png )
I have fixed this by adding a screen-only caching of the QPicture in the same way as a QImage is cached. On output to print/image, dpi, etc. is considered as before.
B) When SVG symbol is set to map units and rendered using QPicture and the SVG viewport is not square, the symbol would be stretched to fit a square. ( see svg-sym_closeup.png and svg-sym_closeup_w-fix.png note the orange square in back is a separate layer whose non-SVG symbols are correctly sized for reference) Fixed with cached QPicture support for non-square symbols, as was already done with QImage caching.
C) Once A & B were fixed, the SVG symbol on output to print or image at a specific dpi was slightly smaller than on screen. This was more pronounced when the symbol was output at a smaller size, causing significant registration issues for symbols with overlapping labels (e.g. road shields). I fixed this by keeping the 'size' of the symbol as a double, then only casting to an integer when constructing a QImage for caching. This allowed for the output SVG (always a QPicture, using the 'size' as a double) to reasonably match what was rendered on the screen at various output zoom levels, page sizes and dpi.
Draw SVG symbol from cached QImage unless it exceeds half of cache size, then use QPicture
- Fix #6855, SVG markers/fills larger than half cache (559^2 X 32 + SVG) are drawn with QPicture
- Fix #6861, make QPicture SVG symbols scale with Composer page zoom
- Fix #6861, make SVG symbol output to print/image more accurate by setting 'size' to double
- Update/add support for non-squared SVG via QImage and QPicture, on screen and in output to print/image
- Non-squared SVG QImage/QPicture can now be used in pattern fill, without excess space