6

I'm a bit confused about SVG graphics! I'm trying to build a script that creates a "north reference" in SVG, and it renders fine when viewed in Firefox. In Inkscape there's some issues with text orientation (the "GN" marker, but I can fix that), but in QGIS it renders really bad.

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="5cm" height="5cm" viewBox="0 0 400 400"
     xmlns="http://www.w3.org/2000/svg" version="1.1">
  <title>North Arrows</title>
  <defs
    id="arrowheads">
    <marker
     style="overflow:visible"
     id="magnetic"
     refX="0.0"
     refY="0.0"
     orient="auto">
     <path d="M 5 0 L 40 0 L 5 7 z"
        stroke="#000" stroke-width="1" fill="#000" />
    </marker>
    <marker
     style="overflow:visible"
     id="true"
     refX="0.0"
     refY="0.0"
     orient="auto">
     <path
        transform="scale(0.8)"
        d="M 0 -10 L 35 0 L 0 10 L 22 -18 L 22 18 z"
        stroke="#000" stroke-width="1" fill="#000" />
    </marker>
    <marker
     style="overflow:visible"
     id="grid"
     refX="0.0"
     refY="0.0"
     orient="auto">
     <text
        style="font-size:20px;font-family:sans-serif;writing-mode: tb;"
        >
         <tspan
         y="-15"
         x="10"
         id="grid_text">GN</tspan> 
        </text>
    </marker>
  </defs>
  <path d="M 200 380 L 230 90"
        stroke="#000" stroke-width="1" 
        style="marker-end:url(#magnetic)" />
  <path d="M 200 380 L 180 60"
        stroke="#000" stroke-width="1"
        style="marker-end:url(#true)" />
  <path d="M 200 380 L 200 30"
        stroke="#000" stroke-width="1"
        style="marker-end:url(#grid)" />
  <text y="395" style="font-size:15px;font-family:sans-serif;" >
        <tspan x="220" dy="-15">GN = 0</tspan>
        <tspan x="220" dy="-15" >Magnetic Dev. 20</tspan>
        <tspan x="220" dy="-15" >True North = 10</tspan>
  </text>
</svg>

When I preview or open in Firefox it looks like this: Firefox preview

But when I add the image in QGIS (Composer) it looks like this: QGIS image in composer

Does QGIS have a limited SVG rendering capability, or is it Qt that has limitations? Isn't my SVG in a "valid" format/syntax?

[Edit] I'm leaning towards a Qt problem, since "karbon" (Qt vector application) previews the file fine, but when opening it, it displays the same as in QGIS. When creating a line with arrow markers in karbon and saving as SVG, markers are lost! Is Qt really this bad at rendering SVG??

1 Answer 1

8

Well. It turns out QtSvg (and thereby QGIS) only supports SVG "Tiny" 1.2. Description for Tiny

One of the things that "Tiny" doesn't support is "markers"...

I need to generate my "arrowheads" as separate polygons, place and rotate them manually...

Work is on the way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.