Details
-
Bug
-
Resolution: Done
-
P2: Important
-
6.2.4
-
macOS 12
-
-
cdd7163c60 (qt/qtbase/dev) cdd7163c60 (qt/tqtc-qtbase/dev)
Description
The text is drawn corrupted in certain circumstance.
It appears the problem occurs when:
- QTextDocument based text
- The font is styled as bold
- The font has no explicit bold typeface installed (for example Geneva)
- The painter drawing the font is scaled smaller (less than 1.0 scale)
- macOS (Windows is fine)
Here's part of code
QTextDocument doc; { QTextCursor cursor(&doc); QTextCharFormat qtf; QFont myFont("Geneva"); myFont.setPixelSize(200); myFont.setStyleStrategy(QFont::NoAntiali qtf.setForeground(QColor(0, 0, 0)); myFont.setBold(true); qtf.setFont(myFont); cursor.insertText("Bold Geneva\n", qtf); .... } QImage pic(600, 400, QImage::Format_ARGB32_Premultiplied); pic.fill(QColor(255, 255, 255)); { // approx 100% size QPainter painter(&pic); painter.translate(0, 50); painter.scale(0.25, 0.25); doc.drawContents(&painter); } pic.save("/Users/qtsupport/test_scaled.png");
How to reproduce
1. Use attached project qtbug103215.zip
2. Modify the file path to your own in main.cpp
pic.save("/Users/qtsupport/test_scaled.png");
3. Build and run the application
4. Open the created "test_scaled.png"
If the font has no installed bold typeface, it may not expect bold to appear perfectly.
However, it should not draw corrupted.