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

QFont does not match fixed width fonts (when not using family name)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 4.7.3, 4.8.1, 5.1.1, 5.2.0
    • GUI: Font handling
    • None
    • OSX 10.8.5 Win7
    • macOS

      This might be two bugs. First, unless QFont is passed an empty string, "", to its constructor, then the TypeWriter and Monospace hints as well as the setFixedPitch(true) method are ignored.

      Second, 5.1.1, actually performs worse returning variable width fonts in all but one case.

      I've run the following code snippet using the listed Qt versions on OSX 10.8.5 and received the output below.

      Expected result: I think every font returned should have been a fixed-width font.

          qDebug() << qVersion() << QT_VERSION_STR;
          {   QFont f;
              f.setStyleHint(QFont::TypeWriter);
              qDebug("%-15s %-15s %-20s %s", "QFont()", "TypeWriter", qPrintable(QFontInfo(f).family()), QFontInfo(f).fixedPitch() ? "fixed-width" : "variable");
          }
          {   QFont f("");
              f.setStyleHint(QFont::TypeWriter);
              qDebug("%-15s %-15s %-20s %s", "QFont(\"\")", "TypeWriter", qPrintable(QFontInfo(f).family()), QFontInfo(f).fixedPitch() ? "fixed-width" : "variable");
          }
          {   QFont f;
              f.setStyleHint(QFont::Monospace);
              qDebug("%-15s %-15s %-20s %s", "QFont()", "Monospace", qPrintable(QFontInfo(f).family()), QFontInfo(f).fixedPitch() ? "fixed-width" : "variable");
          }
          {   QFont f("");
              f.setStyleHint(QFont::Monospace);
              qDebug("%-15s %-15s %-20s %s", "QFont(\"\")", "Monospace", qPrintable(QFontInfo(f).family()), QFontInfo(f).fixedPitch() ? "fixed-width" : "variable");
          }
          {   QFont f;
              f.setFixedPitch(true);
              qDebug("%-15s %-15s %-20s %s", "QFont()", "setFixedPitch", qPrintable(QFontInfo(f).family()), QFontInfo(f).fixedPitch() ? "fixed-width" : "variable");
          }
          {   QFont f("");
              f.setFixedPitch(true);
              qDebug("%-15s %-15s %-20s %s", "QFont(\"\")", "setFixedPitch", qPrintable(QFontInfo(f).family()), QFontInfo(f).fixedPitch() ? "fixed-width" : "variable");
          }
      }
      
      // 4.7.3 4.7.3
      // QFont()         TypeWriter      Lucida Grande        variable
      // QFont("")       TypeWriter      Courier New          fixed-width
      // QFont()         Monospace       Lucida Grande        variable
      // QFont("")       Monospace       Helvetica            variable
      // QFont()         setFixedPitch   Lucida Grande        variable
      // QFont("")       setFixedPitch   Courier New          fixed-width
      
      // 4.8.1 4.8.1 
      // QFont()         TypeWriter      Lucida Grande        variable
      // QFont("")       TypeWriter      Courier New          fixed-width
      // QFont()         Monospace       Lucida Grande        variable
      // QFont("")       Monospace       Helvetica            variable
      // QFont()         setFixedPitch   Lucida Grande        variable
      // QFont("")       setFixedPitch   Courier New          fixed-width
      
      // 5.1.1 5.1.1
      // QFont()         TypeWriter      Lucida Grande        variable
      // QFont("")       TypeWriter      Academy Engraved LET variable
      // QFont()         Monospace       Lucida Grande        variable
      // QFont("")       Monospace       Academy Engraved LET variable
      // QFont()         setFixedPitch   Lucida Grande        variable
      // QFont("")       setFixedPitch   Andale Mono          fixed-width
      
      

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

            Unassigned Unassigned
            hchapman Harvey Chapman
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes