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

QFont::defaultFamily() returns an empty string on Linux

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.6.2, 5.7.1
    • 5.7.0
    • GUI: Font handling
    • None
    • Linux x64

      The following code snippet results an empty string:

      QFont font;
      font.setStyleHint(QFont::Serif);
      qDebug() << font.defaultFamily();

      The issue seems to be Linux specific. I tested it on Windows where QFont::defaultFamily() works as expected. During debugging I found that QGuiApplicationPrivate::platformIntegration()>fontDatabase()>fallbacksForFamily() call always returns an empty list.

      As a workaround QFontDatabase can be instantiated before the QFont::setStyleHint() call. That's why the corresponding auto test (tst_QFont::defaultFamily() in tests/auto/gui/text/qfont/tst_qfont.cpp) doesn't detect this issue.

      This feature must have worked before because QtWebKit had an auto test which tested this. Currently this test is skipped in QtWebEngine.

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

            allan.jensen Allan Sandfeld Jensen
            pvarga Peter Varga
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes