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

Wrong point size of a QFont created without a specified point size

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.0
    • GUI: Font handling
    • None
    • Have tested on:

      1. Arch Linux with KDE Plasma 5.19.1 and Xorg.
      2. Windows 10.
    • Linux/X11, Windows

    Description

      If a QFont is created without explicitly specifying the point size, its actual point size is the same as the system font, but when calling QFont:pointSize, 12 is returned no matter what the size of the system font (i.e. the actual size) is.

      A minimal way to reproduce it:

      #include <QApplication>
      #include <QTextEdit>
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          QTextEdit edit1, edit2;
          QFont font1("monospace"), font2("monospace", 12);
          edit1.setFont(font1);
          edit2.setFont(font2);
          edit1.setPlainText(QString("size of font1: %1\nfont size of edit1: %2").arg(font1.pointSize()).arg(edit1.font().pointSize()));
          edit2.setPlainText(QString("size of font2: %1\nfont size of edit2: %2").arg(font2.pointSize()).arg(edit2.font().pointSize()));
          edit1.show();
          edit2.show();
          return app.exec();
      }
      

      The screenshot of the above code executed on Arch Linux with KDE Plasma is attached.

       

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            ouuan Yufan You
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes