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

Qt cannot deal with preinstalled Chinese macOS font "GB18030 Bitmap"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.2.2
    • GUI: Font handling
    • None
    • macOS 12.1 Monterey
    • macOS

    Description

      When using the font in QML, it renders outside of the Text component it's used in and yields the following error message:

      Failed to compute left/right minimum bearings for "GB18030 Bitmap"

      QFontMetricsF returns bogus font metrics:

      1. Set pixel size to 12
      2. QFontMetricsF::height() reports 0.109375 pixels
      3. QFontMetricsF::ascent() reports 0.078125 pixels
      4. QFontMetricsF::descent() reports 0.03125 pixels

      Example QML code:

      import QtQuick
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Text {
              anchors.fill: parent
              font.family: "GB18030 Bitmap"
              font.pixelSize: 20
              text: "漢字"
              color: "black"
              
              // Uncomment the following line to move the text into the visible area
              // verticalAlignment: Text.AlignVCenter
          }
      }
      

      Example QFontMetricsF code:

      #include <QGuiApplication>
      #include <QFont>
      #include <QFontMetricsF>
      #include <QDebug>
      
      int main(int argc, char *argv[])
      {
          QGuiApplication a(argc, argv);
      
          QFont font("GB18030 Bitmap");
          font.setPixelSize(12);
      
          QFontMetricsF metrics(font);
      
          qDebug() << metrics.height() << metrics.ascent() << metrics.descent();
      }

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            nikwen Niklas Wenzel
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes