Some Chinese characters' strokes may be missing when I use QPainter.drawText under Windows platform.It happens when the size of font is within a range, usaually smaller.It seems like that it doesn't happen on English character.Only in Chinese does this happen.
Code:
void MainWindow::paintEvent(QPaintEvent*)
{
const QString content = "宝贝盖房子啊"; // What I'm going to draw
QFont font;
font.setFamily("Arial");
// font.setPixelSize(50);
font.setPointSize(20); // fontsize.If it's too small, it won't draw properly
QFontMetrics fm(font);
QRect contentRect = fm.boundingRect(content);
int width = (contentRect.width());
int height = (contentRect.height());
QImage pix(width, height, QImage::Format_MonoLSB); // It only happens when using this format
pix.fill(Qt::black);
QPainter p(&pix);
p.setFont(font);
p.drawText(pix.rect(), Qt::AlignLeft | Qt::AlignVCenter, content);
p.end();
pix.save("D:\\pix.bmp");
}
Here's a picture of the results:
Why does this happen?