Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.2.2
-
None
-
macOS 12.1 Monterey
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:
- Set pixel size to 12
- QFontMetricsF::height() reports 0.109375 pixels
- QFontMetricsF::ascent() reports 0.078125 pixels
- 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(); }