Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSvgRenderer incorrectly renders text
Forum Updated to NodeBB v4.3 + New Features

QSvgRenderer incorrectly renders text

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 6 Posters 887 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FredJupiter
    wrote on last edited by
    #1

    Hi, I'm trying to draw SVG files from different programs and even with simple examples the text in a SVG does not be placed correctly, this is my drawing:

    c179d71d-a312-4dde-bb39-d88847859b3a-grafik.png

    And this is the result:
    26265b69-47c9-4f8d-8754-bb06f6f8918b-grafik.png

    Any idea?
    Best and Thanks a lot.

    jsulmJ 1 Reply Last reply
    0
    • F FredJupiter

      Hi, I'm trying to draw SVG files from different programs and even with simple examples the text in a SVG does not be placed correctly, this is my drawing:

      c179d71d-a312-4dde-bb39-d88847859b3a-grafik.png

      And this is the result:
      26265b69-47c9-4f8d-8754-bb06f6f8918b-grafik.png

      Any idea?
      Best and Thanks a lot.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @FredJupiter Not sure how this is related to Qt?
      Do you mean the SVG image is shown wrongly in Qt application?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Offline
        F Offline
        FredJupiter
        wrote on last edited by
        #3

        Yes, this happens with the QSvgRenderer and when I use the SVG in a QML Image....

        jsulmJ 1 Reply Last reply
        0
        • B Offline
          B Offline
          Bonnie
          wrote on last edited by Bonnie
          #4

          According to https://doc.qt.io/qt-6/svgrendering.html

          Qt supports the static features of SVG 1.2 Tiny. ECMA scripts and DOM manipulation are currently not supported.

          I'm not sure but perhaps there's some unsupported feature in your svg?

          1 Reply Last reply
          0
          • F FredJupiter

            Yes, this happens with the QSvgRenderer and when I use the SVG in a QML Image....

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @FredJupiter Does the SVG image work properly in an image viewer?
            Also see comment from @Bonnie - it could be that your SVG image uses features not supported by Qt.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • F Offline
              F Offline
              FredJupiter
              wrote on last edited by
              #6

              Hm, it looks like if a <tspan> comes into play the text is not aligned accordingly...

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                tspan should be supported - what Qt version do you use and please post a small svg to reproduce the problem.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  FredJupiter
                  wrote on last edited by
                  #8

                  I've tested Qt 6.3, 6.7 and the latest 6.8.1.

                  The QML is quite simple:

                  <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
                  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
                  <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1080" height="1080" viewBox="0 0 1080 1080" xml:space="preserve">
                  <desc>Created with Fabric.js 5.2.4</desc>
                  <defs>
                  </defs>
                  <g transform="matrix(1 0 0 1 540 540)" id="dd1d958a-c7e5-4f47-b3e5-f1d714fce3fa"  >
                  <rect style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(255,255,255); fill-rule: nonzero; opacity: 1; visibility: hidden;" vector-effect="non-scaling-stroke"  x="-540" y="-540" rx="0" ry="0" width="1080" height="1080" />
                  </g>
                  <g transform="matrix(1 0 0 1 540 540)" id="f0933fe9-3676-43bc-9a55-ce012bd5ed79"  >
                  </g>
                  <g transform="matrix(3.83 0 0 3.83 342.3 366.29)" id="4807f659-641c-43ea-840b-e5cf5559004c"  >
                  <path style="stroke: rgb(0,0,0); stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(101,101,101); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke"  transform=" translate(-50, -50)" d="M 94.75 50 C 94.75 56.213 89.514 61.25 83.054 61.25 L 16.946 61.25 C 10.486 61.25 5.25 56.213 5.25 50 L 5.25 50 C 5.25 43.787 10.486 38.75 16.945999999999998 38.75 L 83.053 38.75 C 89.514 38.75 94.75 43.787 94.75 50 L 94.75 50 z" stroke-linecap="round" />
                  </g>
                  <g transform="matrix(0.58 0 0 0.58 351.28 266.75)" style="" id="f015080a-ab49-42d6-ab91-8903fc060bf3"  >
                  		<text xml:space="preserve" font-family="Lato" font-size="100" font-style="normal" font-weight="400" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1; white-space: pre;" ><tspan x="-210.55" y="31.41" >Body text</tspan></text>
                  </g>
                  </svg>
                  

                  The output should be:

                  ed60d00b-3956-4722-b5b1-c351498d11d6-grafik.png

                  but it is:

                  e2366b95-2d5b-453a-bf04-04a1c815bcd5-grafik.png

                  So, the text is somehow misaligned....

                  JoeCFDJ 1 Reply Last reply
                  0
                  • F FredJupiter

                    I've tested Qt 6.3, 6.7 and the latest 6.8.1.

                    The QML is quite simple:

                    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
                    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
                    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1080" height="1080" viewBox="0 0 1080 1080" xml:space="preserve">
                    <desc>Created with Fabric.js 5.2.4</desc>
                    <defs>
                    </defs>
                    <g transform="matrix(1 0 0 1 540 540)" id="dd1d958a-c7e5-4f47-b3e5-f1d714fce3fa"  >
                    <rect style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(255,255,255); fill-rule: nonzero; opacity: 1; visibility: hidden;" vector-effect="non-scaling-stroke"  x="-540" y="-540" rx="0" ry="0" width="1080" height="1080" />
                    </g>
                    <g transform="matrix(1 0 0 1 540 540)" id="f0933fe9-3676-43bc-9a55-ce012bd5ed79"  >
                    </g>
                    <g transform="matrix(3.83 0 0 3.83 342.3 366.29)" id="4807f659-641c-43ea-840b-e5cf5559004c"  >
                    <path style="stroke: rgb(0,0,0); stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(101,101,101); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke"  transform=" translate(-50, -50)" d="M 94.75 50 C 94.75 56.213 89.514 61.25 83.054 61.25 L 16.946 61.25 C 10.486 61.25 5.25 56.213 5.25 50 L 5.25 50 C 5.25 43.787 10.486 38.75 16.945999999999998 38.75 L 83.053 38.75 C 89.514 38.75 94.75 43.787 94.75 50 L 94.75 50 z" stroke-linecap="round" />
                    </g>
                    <g transform="matrix(0.58 0 0 0.58 351.28 266.75)" style="" id="f015080a-ab49-42d6-ab91-8903fc060bf3"  >
                    		<text xml:space="preserve" font-family="Lato" font-size="100" font-style="normal" font-weight="400" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1; white-space: pre;" ><tspan x="-210.55" y="31.41" >Body text</tspan></text>
                    </g>
                    </svg>
                    

                    The output should be:

                    ed60d00b-3956-4722-b5b1-c351498d11d6-grafik.png

                    but it is:

                    e2366b95-2d5b-453a-bf04-04a1c815bcd5-grafik.png

                    So, the text is somehow misaligned....

                    JoeCFDJ Offline
                    JoeCFDJ Offline
                    JoeCFD
                    wrote on last edited by
                    #9

                    @FredJupiter Tested your SVG file with Qt 5.15.2 on Yocto. Same issue. I guess you can file a bug report.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      CPPUIX
                      wrote on last edited by
                      #10

                      See if this helps:

                      • https://stackoverflow.com/questions/79035683/svg-text-is-incorrectly-overlapping
                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved