Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-79692

QSvgGenerator ignores QPen's MiterJoin joinStyle

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.9.5, 5.12.3
    • SVG Support
    • None
    • Ubuntu 18.04.2 LTS
    • Linux/X11

    Description

      Consider the following test code:

      #include <QPainter>
      #include <QSvgGenerator>
      
      const int w=100, h=100;
      void test(QPaintDevice& dev)
      {
          QPainter painter(&dev);
          painter.setBrush(Qt::darkGreen);
          painter.drawRect(0,0,w,h);
      
          auto pen=QPen(Qt::white,w/36.*4/w);
          pen.setJoinStyle(Qt::MiterJoin); // QSvgGenerator ignores this
          painter.setPen(pen);
      
          painter.scale(w,w);
          const QVector<QPointF> points={{0.4,0.6},{0.6,0.5},{0.4,0.4}};
          painter.drawPolyline(points.data(), points.size());
      }
      
      int main()
      {
          QSvgGenerator generator;
          generator.setFileName("test.svg");
          generator.setViewBox(QRect(0,0,w,h));
          test(generator);
          QImage img(w,h,QImage::Format_RGBA8888);
          test(img);
          img.save("test.png");
      }
      

      If you run it, you'll get two output files in current directory: test.png and test.svg. In the PNG one there's an arrow-like acute angle, while in the SVG file the arrow is chopped: join style is BevelJoin, the default.

      The expected result is that SVG file looks the same as the PNG one (up to antialiasing).

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            10110111 Ruslan Kabatsayev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes