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

Web fonts are not embedded in PDF on Linux and render as vector outlines

    XMLWordPrintable

Details

    Description

      With the following Web page:

      <html>
      <style>
          @font-face {
              font-family: 'Ubuntu Mono';
              font-style: normal;
              font-weight: 400;
              src: url(http://astefanutti.io/further-cdi/fonts/UbuntuMono-Regular.woff) format('woff');
          }
          body {
              font-family: 'Ubuntu Mono', monospace;
          }
      </style>
      <body>
          <div>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
              tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
              quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
              consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
              cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
              non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
          </div>
      </body>
      </html>
      

      When printing the page to PDF with the following code:

      #include <QApplication>
      
      #include "mywebview.h"
      
      int main(int argc,char** argv)
      {
          QApplication app(argc, argv);
      
          MyWebView view;
          view.load(QUrl(argv[1]));
      
          return app.exec();
      }
      
      #include <QApplication>
      #include <QPrinter>
      
      #if (QT_VERSION < 0x050000)
      #include <QWebView>
      #else
      #include <QtWebKitWidgets/QWebView>
      #endif
      
      class MyWebView:public QWebView
      {
        Q_OBJECT
        public:
          MyWebView()
          {
              m_printer.setPageSize(QPrinter::A4);
              m_printer.setOutputFormat(QPrinter::PdfFormat);
              m_printer.setOutputFileName("test.pdf");
              connect(this,SIGNAL(loadFinished(bool)),this,SLOT(savetoPDF()));
          }
          ~MyWebView(){}
      
      private slots:
          void savetoPDF()
          {
              print(&m_printer);
              QApplication::exit();
          }
      private:
        QPrinter m_printer;
      };
      

      The generated PDF does not embed the Web font with Qt 5 - test-qt5.pdf, 177KB, Qt 5.3.2 - while it works as expected with Qt 4 - test-qt4.pdf, 6.2KB, Qt 4.8.6.

      When the Web font is referenced locally and is present on the local file system, it gets correctly embedded in the generated PDF.

      Attachments

        1. main.cpp
          0.2 kB
        2. mywebview.h
          0.7 kB
        3. test.html
          0.8 kB
        4. test.pro
          0.2 kB
        5. test-qt4.pdf
          6 kB
        6. test-qt5.pdf
          177 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            laknoll Lars Knoll
            astefanutti Antonin Stefanutti
            Votes:
            5 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes