Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12.9, 5.15.2, 6.0.1
-
None
Description
See the below sample code:
#include <QtGui> int main(int argc, char **argv) { QGuiApplication app(argc, argv); QImage img(1, 1, QImage::Format_ARGB32); img.setDotsPerMeterX(56692); img.setDotsPerMeterY(56692); QFont font(QFont("SimSun", 36), &img); QFontMetrics fm(font); #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) qDebug() << "fontDpi: " << fm.fontDpi(); #endif qDebug() << "width: " << fm.horizontalAdvance(QChar(L',')); return 0; }
Run on Linux platform it prints:
fontDpi: 1440
width: -304
The width should be 720 but got -304.
While debugging the horizontalAdvance, I found that the QFontEngineFT::loadGlyph internal assign an int to short:
g = new Glyph;
g->data = nullptr;
g->linearAdvance = info.linearAdvance;
The info.linearAdvance value is 46080 (0xB400), but g->linearAdvance is short!!!