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

SVG rendering loses font styles when local styles applied

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 4.7.0
    • SVG Support
    • None
    • Windows 7

    Description

      Font styles (and perhaps others, I haven't tested beyond fonts) defined in a CSS style section within an SVG document are only applied when no other font styles exist locally on the SVG elements. See example:

      main.cpp
      #include <QtGui>
      #include <QtSvg/QtSvg>
      
      static const QString ns = QLatin1String("http://www.w3.org/2000/svg");
      
      int main(int argc, char **argv) {
        QApplication app(argc, argv);
      
        QByteArray data;
        QXmlStreamWriter writer(&data);
        writer.writeStartDocument();
      
        writer.writeStartElement(ns, "svg");
        writer.writeAttribute("width", "400");
        writer.writeAttribute("height", "400");
        writer.writeAttribute("version", "1.2");
        writer.writeAttribute("baseProfile", "tiny");
      
        writer.writeStartElement(ns, "defs");
        writer.writeStartElement(ns, "style");
        writer.writeAttribute("type", "text/css");
        writer.writeCDATA("text { font-family: Verdana; font-size: 20px; }");
        writer.writeEndElement();  // style
        writer.writeEndElement();  // defs
      
        writer.writeStartElement(ns, "text");
        writer.writeAttribute("x", "10");
        writer.writeAttribute("y", "100");
        writer.writeCharacters("Using style");
        writer.writeEndElement();
      
        writer.writeStartElement(ns, "text");
        writer.writeAttribute("x", "350");
        writer.writeAttribute("y", "200");
        writer.writeAttribute("text-anchor", "end");
        writer.writeCharacters("No style?");
        writer.writeEndElement();
      
        writer.writeStartElement(ns, "text");
        writer.writeAttribute("x", "350");
        writer.writeAttribute("y", "300");
        writer.writeAttribute("style", "text-anchor: end");
        writer.writeCharacters("No style here either?");
        writer.writeEndElement();
      
        writer.writeEndDocument();
      
        QSvgWidget w;
        w.load(data);
        w.show();
      
        return app.exec();
      }
      

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            dmateer Dave Mateer
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes