diff --git a/src/gui/image/qpaintengine_pic.cpp b/src/gui/image/qpaintengine_pic.cpp
index 343c472..46782c0 100644
--- a/src/gui/image/qpaintengine_pic.cpp
+++ b/src/gui/image/qpaintengine_pic.cpp
@@ -56,7 +56,7 @@
 #include "qrect.h"
 #include <private/qtextengine_p.h>
 
-//#define QT_PICTURE_DEBUG
+#define QT_PICTURE_DEBUG
 #include <qdebug.h>
 
 
@@ -480,13 +480,15 @@ void QPicturePaintEngine::drawImage(const QRectF &r, const QImage &image, const
 void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti)
 {
     Q_D(QPicturePaintEngine);
-#ifdef QT_PICTURE_DEBUG
-    qDebug() << " -> drawTextItem():" << p << ti.text();
-#endif
 
     const QTextItemInt &si = static_cast<const QTextItemInt &>(ti);
-    if (si.chars == 0)
+    qDebug() << __FUNCTION__ << p << si.text() << ti
+             <<  ti.font() << "FDPI" <<  ti.font().d->dpi << '>';
+    if (si.chars == 0) {
+        qDebug() << ">Draw as path";
         QPaintEngine::drawTextItem(p, ti); // Draw as path
+        qDebug() << "<Draw as path";
+    }
 
     if (d->pic_d->formatMajor >= 9) {
         int pos;
@@ -515,6 +517,7 @@ void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti)
         d->s << p << ti.text();
         writeCmdLength(pos, QRectF(p, QSizeF(1,1)), true);
     }
+    qDebug() << __FUNCTION__ << '<';
 }
 
 void QPicturePaintEngine::updateState(const QPaintEngineState &state)
diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp
index 6bbfc9f..d30f983 100644
--- a/src/gui/painting/qpaintdevice.cpp
+++ b/src/gui/painting/qpaintdevice.cpp
@@ -40,11 +40,20 @@
 ****************************************************************************/
 
 #include "qpaintdevice.h"
-
+#include <qdebug.h>
 QT_BEGIN_NAMESPACE
 
 extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp
 
+QDebug operator<<(QDebug debug, const QPaintDevice &d)
+{
+    debug << "QPaintDevice(" << &d
+          << "devType=" << d.devType()
+          << "logDPI" << d.logicalDpiX() << d.logicalDpiY()
+          << "physDPI" << d.physicalDpiX() << d.physicalDpiY() << ')';
+    return debug;
+}
+
 QPaintDevice::QPaintDevice()
 {
     painters = 0;
diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h
index f8389da..a2d9890 100644
--- a/src/gui/painting/qpaintdevice.h
+++ b/src/gui/painting/qpaintdevice.h
@@ -56,6 +56,7 @@ class QWSDisplay;
 #endif
 
 class QPaintEngine;
+ class QDebug;
 
 class Q_GUI_EXPORT QPaintDevice                                // device for QPainter
 {
@@ -160,6 +161,8 @@ void bitBlt(QPaintDevice *dst, const QPoint &dp,
             bool ignoreMask=false);
 #endif
 
+Q_GUI_EXPORT QDebug operator<<(QDebug, const QPaintDevice &);
+
 /*****************************************************************************
   Inline functions
  *****************************************************************************/
diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp
index ca63044..d4a9b7d 100644
--- a/src/gui/painting/qpaintengine.cpp
+++ b/src/gui/painting/qpaintengine.cpp
@@ -750,6 +750,7 @@ void QPaintEngine::drawPath(const QPainterPath &)
 void QPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
 {
     const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
+     qDebug() << __FUNCTION__ << p << textItem << '>';
 
     QPainterPath path;
 #ifndef Q_WS_MAC
@@ -757,6 +758,7 @@ void QPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
 #endif
     if (ti.glyphs.numGlyphs)
         ti.fontEngine->addOutlineToPath(0, 0, ti.glyphs, &path, ti.flags);
+     qDebug() << __FUNCTION__ << "path.isEmpty=" << path.isEmpty();
     if (!path.isEmpty()) {
         painter()->save();
         painter()->setRenderHint(QPainter::Antialiasing,
@@ -766,6 +768,7 @@ void QPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
         painter()->fillPath(path, state->pen().brush());
         painter()->restore();
     }
+    qDebug() << __FUNCTION__ << '<';
 }
 
 /*!
diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h
index 27d6ac7..378dd07 100644
--- a/src/gui/painting/qpaintengine.h
+++ b/src/gui/painting/qpaintengine.h
@@ -86,6 +86,7 @@ public:
 };
 Q_DECLARE_TYPEINFO(QTextItem, Q_PRIMITIVE_TYPE);
 
+Q_GUI_EXPORT  QDebug operator<<(QDebug d, const QTextItem &t);
 
 class Q_GUI_EXPORT QPaintEngine
 {
diff --git a/src/gui/painting/qpaintengine_alpha.cpp b/src/gui/painting/qpaintengine_alpha.cpp
index 76362aa..66257a4 100644
--- a/src/gui/painting/qpaintengine_alpha.cpp
+++ b/src/gui/painting/qpaintengine_alpha.cpp
@@ -43,6 +43,7 @@
 
 #ifndef QT_NO_PRINTER
 #include <qdebug.h>
+#include <qpaintdevice.h>
 #include "private/qpaintengine_alpha_p.h"
 
 #include "private/qpicture_p.h"
@@ -65,6 +66,7 @@ QAlphaPaintEngine::~QAlphaPaintEngine()
 bool QAlphaPaintEngine::begin(QPaintDevice *pdev)
 {
     Q_D(QAlphaPaintEngine);
+    qDebug() << __FUNCTION__ << *pdev;
 
     d->m_continueCall = true;
     if (d->m_pass != 0) {
@@ -109,15 +111,20 @@ bool QAlphaPaintEngine::end()
 
 void QAlphaPaintEngine::updateState(const QPaintEngineState &state)
 {
+    qDebug() << __FUNCTION__ << ">";
     Q_D(QAlphaPaintEngine);
 
     DirtyFlags flags = state.state();
     if (flags & QPaintEngine::DirtyTransform) {
+        qDebug() << "DirtyTransform";
         d->m_transform = state.transform();
         d->m_complexTransform = (d->m_transform.type() > QTransform::TxScale);
         d->m_emulateProjectiveTransforms = !(d->m_savedcaps & QPaintEngine::PerspectiveTransform)
                                            && !(d->m_savedcaps & QPaintEngine::AlphaBlend)
                                            && (d->m_transform.type() >= QTransform::TxProject);
+        qDebug() << "resulting d->m_transform=" << d->m_transform
+                 << "d->m_complexTransform=" << d->m_complexTransform
+                 <<  "d->m_emulateProjectiveTransforms" <<  d->m_emulateProjectiveTransforms;
     }
     if (flags & QPaintEngine::DirtyPen) {
         d->m_pen = state.pen();
@@ -155,6 +162,7 @@ void QAlphaPaintEngine::updateState(const QPaintEngineState &state)
 
     if (d->m_picengine)
         d->m_picengine->updateState(state);
+    qDebug() << __FUNCTION__ << "<";
 }
 
 void QAlphaPaintEngine::drawPath(const QPainterPath &path)
@@ -206,6 +214,7 @@ void QAlphaPaintEngine::drawPolygon(const QPointF *points, int pointCount, Polyg
 
 void QAlphaPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
 {
+    qDebug() << __FUNCTION__ << r << pm << sr;
     Q_D(QAlphaPaintEngine);
 
     QRectF tr = d->m_transform.mapRect(r);
@@ -248,6 +257,9 @@ void QAlphaPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem
 
     QRectF tr(p.x(), p.y() - textItem.ascent(), textItem.width() + 5, textItem.ascent() + textItem.descent() + 5);
     tr = d->m_transform.mapRect(tr);
+    qDebug() << __FUNCTION__ << p << textItem.text()
+             << textItem
+             << "tr=" << tr;
 
     if (d->m_pass == 0) {
         d->m_continueCall = false;
@@ -295,6 +307,7 @@ bool QAlphaPaintEngine::continueCall() const
 void QAlphaPaintEngine::flushAndInit(bool init)
 {
     Q_D(QAlphaPaintEngine);
+    qDebug() << __FUNCTION__ << "init=" << init <<"d->m_pic=" << d->m_pic;
     Q_ASSERT(d->m_pass == 0);
 
     if (d->m_pic) {
@@ -327,6 +340,8 @@ void QAlphaPaintEngine::flushAndInit(bool init)
         QTransform mtx;
         mtx.scale(1.0f / (qreal(d->m_pdev->logicalDpiX()) / qreal(qt_defaultDpiX())),
                   1.0f / (qreal(d->m_pdev->logicalDpiY()) / qreal(qt_defaultDpiY())));
+        qDebug() << __FUNCTION__  << "mtx=" << mtx
+                 << "on" << *d->m_pdev << rects;
         painter()->setTransform(mtx);
         painter()->drawPicture(0, 0, *d->m_pic);
 
@@ -352,6 +367,7 @@ void QAlphaPaintEngine::flushAndInit(bool init)
         d->m_pic = new QPicture();
         d->m_pic->d_ptr->in_memory_only = true;
         d->m_picpainter = new QPainter(d->m_pic);
+        qDebug() << __FUNCTION__ << "creating new picture";
         d->m_picengine = d->m_picpainter->paintEngine();
 
         // When newPage() is called and the m_picpainter is recreated
@@ -364,6 +380,7 @@ void QAlphaPaintEngine::flushAndInit(bool init)
         d->m_picpainter->setOpacity(painter()->opacity());
         d->m_picpainter->setTransform(painter()->combinedTransform());
         d->m_picengine->syncState();
+        qDebug() << __FUNCTION__ << "XXXXXXXXXXXXXXX";
     }
 }
 
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 06477be..a2eff4a 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -43,6 +43,7 @@
 #include <qdebug.h>
 #include <qmath.h>
 #include <qmutex.h>
+#include <qdebug.h>
 
 // QtGui
 #include "qbitmap.h"
@@ -1611,6 +1612,7 @@ void QPainter::save()
         return;
     }
 
+    qDebug() << __FUNCTION__ << "d->extended" << d->extended;
     if (d->extended) {
         d->state = d->extended->createState(d->states.back());
         d->extended->setState(d->state);
@@ -1649,6 +1651,7 @@ void QPainter::restore()
     d->state = d->states.back();
     d->txinv = false;
 
+    qDebug() << __FUNCTION__ << "d->extended" << d->extended;
     if (d->extended) {
         d->checkEmulation();
         d->extended->setState(d->state);
@@ -6099,6 +6102,7 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText
 */
 void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justificationPadding)
 {
+//    qDebug() << __FUNCTION__ << p << str << tf << justificationPadding;
 #ifdef QT_DEBUG_DRAW
     if (qt_show_painter_debug_output)
         printf("QPainter::drawText(), pos=[%.2f,%.2f], str='%s'\n", p.x(), p.y(), str.toLatin1().constData());
@@ -6581,6 +6585,7 @@ Q_GUI_EXPORT void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t
 
 void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti)
 {
+//    qDebug() << __FUNCTION__ << p << _ti.text();
 #ifdef QT_DEBUG_DRAW
     if (qt_show_painter_debug_output)
         printf("QPainter::drawTextItem(), pos=[%.f,%.f], str='%s'\n",
@@ -7680,6 +7685,27 @@ QPolygon QPainter::xForm(const QPolygon &av, int index, int npoints) const
     return a * combinedMatrix();
 }
 
+QDebug operator<<(QDebug d, const QPainterState &s)
+{
+    d << "QPainterState clipRegion=" << s.clipRegion
+      << "clipOperation=" <<s.clipOperation
+      << "renderHints=" << s.renderHints
+      << "worldMatrix=" << s.worldMatrix
+      << "matrix=" << s.matrix
+      << "redirectionMatrix=" << s.redirectionMatrix
+      << "Viewport" << s.vx << s.vy << s.vw << s.vh
+      << "Window" << s.wx << s.wy << s.ww << s.wh
+      << "opacity" << s.opacity
+      << "World transform" << s.WxF
+      << "View transform" << s.VxF
+      << "clipEnabled=" << s.clipEnabled
+      << "bgMode=" << s.bgMode
+      << "painter=" << s.painter
+      << "composition_mode=" <<s.composition_mode
+      << "changeFlags=" << s.changeFlags;
+    return d;
+}
+
 /*!
     \fn QPoint QPainter::xFormDev(const QPoint &point) const
     \overload
diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h
index 1395ed0..c501637 100644
--- a/src/gui/painting/qpainter_p.h
+++ b/src/gui/painting/qpainter_p.h
@@ -71,6 +71,7 @@ class QPaintEngine;
 class QEmulationPaintEngine;
 class QPaintEngineEx;
 struct QFixedPoint;
+class QDebug;
 
 struct QTLWExtra;
 
@@ -176,6 +177,8 @@ public:
     uint changeFlags;
 };
 
+Q_GUI_EXPORT QDebug operator<<(QDebug d, const QPainterState &);
+
 struct QPainterDummyState
 {
     QFont font;
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index f4b86b0..263b696 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -55,10 +55,25 @@
 #include "qtextdocument_p.h"
 #include <qapplication.h>
 #include <stdlib.h>
-
+#include <qdebug.h>
 
 QT_BEGIN_NAMESPACE
 
+QDebug operator<<(QDebug d, const QTextItem &t)
+{
+    const QTextItemInt &ti = static_cast<const QTextItemInt &>(t);
+    qDebug() << "descent=" << ti.descent
+            << "ascent=" << ti.ascent
+            << "width=" << ti.width
+            << "flags" << ti.flags
+            <<  "num_chars=" << ti.num_chars
+            << "chars=" << ti.chars
+            << "logClusters=" << ti.logClusters
+            << "font" << ti.f
+            << "QGlyphLayout:" << ti.glyphs.numGlyphs;
+    return d;
+}
+
 namespace {
 // Helper class used in QTextEngine::itemize
 // keep it out here to allow us to keep supporting various compilers.
