diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index 0116c4d..16eccc3 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -471,16 +471,58 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape } } +QDebug operator<<(QDebug d, const glyph_metrics_t &gm) +{ + if (!gm.isValid()) { + d << "glyph_metrics_t INVALID"; + return d; + } + d << "glyph_metrics_t origin: " << gm.x << ',' << gm.y << " size: " + << gm.width << 'x' << gm.height << " offset: " << gm.xoff << ',' << gm.yoff; + return d; +} + +QDebug operator<<(QDebug d, const ABCFLOAT &gm) +{ + d << "ABCFLOAT " << gm.abcfA << ' ' << gm.abcfB << ' ' << gm.abcfC; + return d; +} + +QDebug operator<<(QDebug d, const FIXED &f) +{ + d.nospace() << f.value << '.' << f.fract; + return d; +} + +QDebug operator<<(QDebug d, const MAT2 &m) +{ + d << "MAT2 {" << m.eM11 << ',' << m.eM12 << ',' << m.eM21 << ',' << m.eM22 << '}'; + return d; +} + +QDebug operator<<(QDebug d, const GLYPHMETRICS &gm) +{ + d.nospace() << "GLYPHMETRICS blackbox: " << gm.gmBlackBoxX << 'x' << gm.gmBlackBoxY + << " origin " << gm.gmptGlyphOrigin.x << ',' < QTransform::TxTranslate) { XFORM xform; @@ -543,16 +592,22 @@ glyph_metrics_t QWindowsFontEngine::boundingBox(glyph_t glyph, const QTransform SelectObject(hdc, hfont); glyph_metrics_t glyphMetrics; + qDebug() << __FUNCTION__ << '1' << _name << glyph << t; bool success = getOutlineMetrics(glyph, t, &glyphMetrics); + qDebug() << __FUNCTION__ << '2' << _name << "SUC=" << success << "TTF" << ttf + << glyphMetrics; if (!ttf && !success) { // Bitmap fonts wchar_t ch = glyph; ABCFLOAT abc; - GetCharABCWidthsFloat(hdc, ch, ch, &abc); + if (!GetCharABCWidthsFloat(hdc, ch, ch, &abc)) + qErrnoWarning("GetCharABCWidthsFloat() failed"); int width = qRound(abc.abcfB); - - return glyph_metrics_t(QFixed::fromReal(abc.abcfA), -tm.tmAscent, width, tm.tmHeight, width, 0).transformed(t); + const glyph_metrics_t ro = glyph_metrics_t(QFixed::fromReal(abc.abcfA), -tm.tmAscent, width, tm.tmHeight, width, 0); + const glyph_metrics_t r =ro.transformed(t); + qDebug() << __FUNCTION__ << '3' << _name << abc << "width=" << width << ro << r; + return r; } return glyphMetrics; @@ -1068,9 +1123,10 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, const QTransform &t, QImage::Format mask_format) { + qDebug() << __FUNCTION__ << QT_VERSION_STR << _name << glyph << t; Q_UNUSED(mask_format) glyph_metrics_t gm = boundingBox(glyph); - + qDebug() << __FUNCTION__ << _name << gm; // printf(" -> for glyph %4x\n", glyph); int gx = gm.x.toInt(); @@ -1078,8 +1134,10 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, int iw = gm.width.toInt(); int ih = gm.height.toInt(); - if (iw <= 0 || iw <= 0) + if (iw <= 0 || iw <= 0) { + qDebug() << __FUNCTION__ << _name << "bailing out " << iw; return 0; + } bool has_transformation = t.type() > QTransform::TxTranslate; @@ -1087,6 +1145,8 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, unsigned int options = ttf ? ETO_GLYPH_INDEX : 0; XFORM xform; + qDebug() << "hastransform" << has_transformation << t; + if (has_transformation) { xform.eM11 = t.m11(); xform.eM12 = t.m12(); @@ -1107,8 +1167,12 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, memset(&mat, 0, sizeof(mat)); mat.eM11.value = mat.eM22.value = 1; + qDebug() << "GF" << _name + << glyph << "op" << ggo_options << mat << "ttf=" << ttf; const DWORD result = GetGlyphOutline(hdc, glyph, ggo_options, &tgm, 0, 0, &mat); + + XFORM identity = {1, 0, 0, 1, 0, 0}; SetWorldTransform(hdc, &identity); SetGraphicsMode(hdc, GM_COMPATIBLE); @@ -1119,6 +1183,7 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, qErrnoWarning(errorCode, "QWinFontEngine: unable to query transformed glyph metrics (GetGlyphOutline() failed, error %d)...", errorCode); return 0; } + qDebug() << tgm; iw = tgm.gmBlackBoxX; ih = tgm.gmBlackBoxY; @@ -1234,7 +1299,7 @@ QImage QWindowsFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed, const QTra SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &contrast, 0); SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) 1000, 0); - int margin = glyphMargin(QFontEngineGlyphCache::Raster_RGBMask); + int margin = glyphMargin(QFontEngineGlyphCache::Raster_RGBMask); QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, margin, t, QImage::Format_RGB32); SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) quintptr(contrast), 0); diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp index 46f9784..6ff4c2a 100644 --- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp @@ -49,7 +49,7 @@ #include -// #define DEBUG_SAVE_IMAGE +#define DEBUG_SAVE_IMAGE class tst_QStaticText: public QObject { @@ -727,12 +727,16 @@ void tst_QStaticText::drawStruckOutText() p.drawStaticText(QPointF(50, 50 - QFontMetricsF(p.font()).ascent()), text); } -#if defined(DEBUG_SAVE_IMAGE) - imageDrawText.save("drawStruckOutText_imageDrawText.png"); - imageDrawStaticText.save("drawStruckOutText_imageDrawStaticText.png"); -#endif + + + imageDrawText.save("drawStruckOutText_imageDrawText.png"); + imageDrawStaticText.save("drawStruckOutText_imageDrawStaticText.png"); + imageDrawText.save("drawStruckOutText_imageDrawText.xpm"); + imageDrawStaticText.save("drawStruckOutText_imageDrawStaticText.xpm"); + QVERIFY(imageDrawText.toImage() != m_whiteSquare); + QCOMPARE(imageDrawText, imageDrawStaticText); }