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

QWebView: font size set by QWebSettings gets rendered too small

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 4.8.5
    • WebKit
    • None
    • linux (debian, ubuntu, fedora), libqtwebkit4 2.3.2, qt: 4.8.5

    Description

      Setting the default font size of QWebView via QWebSettings results in a smaller font size as compared to specifying the size explicitly in a html string.

      Not sure, if thats a bug or a misconception on my part. Shouldn't the following two code examples render the same font size?

      A) font size via qwebsettings:

      #include <QtGui>
      #include <QWebView>
      
      int main(int argc, char** argv) {
      
        QApplication app(argc, argv);
      
        QWebView* view = new QWebView;
      
        QWebSettings* websettings = QWebSettings::globalSettings();
        websettings->setFontSize(QWebSettings::DefaultFontSize, 10);
        websettings->setFontFamily(QWebSettings::StandardFont, "Droid Sans");
        view->setHtml("<html><body>Hello, just some text.</body></html>");
      
        view->show();
        return app.exec();
      }
      

      B) font size set in html string:

      #include <QtGui>
      #include <QWebView>
      
      int main(int argc, char** argv) {
      
        QApplication app(argc, argv);
      
        QWebView* view = new QWebView;
      
        view->setHtml("<html><body style='font-size:10pt; font-family:\"Droid Sans\"'>Hello, just some text.</body></html>");
        
        view->show();
        return app.exec();
      }
      

      Independently of the font I use, the font size I get, if set by QWebSettings, is always 3pt smaller than in B) or other qt widgets like menu bars.

      Attachments

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

        Activity

          People

            allan.jensen Allan Sandfeld Jensen
            b3nmore b3nmore
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes