diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 7c22bde..b9d42a7 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -8039,12 +8039,16 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,
                     tabstops, ta, tabarraylen,
                     painter);
 }
+
+QString debugHieroglyph(const QStringRef &r);
+
 void qt_format_text(const QFont &fnt, const QRectF &_r,
                     int tf, const QTextOption *option, const QString& str, QRectF *brect,
                     int tabstops, int *ta, int tabarraylen,
                     QPainter *painter)
 {
 
+    qDebug() << __FUNCTION__ << fnt.family() << debugHieroglyph(str.midRef(0, str.size()));
     Q_ASSERT( !((tf & ~Qt::TextDontPrint)!=0 && option!=0) ); // we either have an option or flags
 
     if (option) {
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 1ca28fa..00f1ccd 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -293,6 +293,7 @@ extern QMutex *qt_fontdatabase_mutex();
 
 QFontEngine *QFontPrivate::engineForScript(int script) const
 {
+    qDebug() << __FUNCTION__ <<script;
     QMutexLocker locker(qt_fontdatabase_mutex());
     if (script >= QUnicodeTables::Inherited)
         script = QUnicodeTables::Common;
@@ -2920,9 +2921,13 @@ void QFontCache::insertEngineData(const Key &key, QFontEngineData *engineData)
 
 QFontEngine *QFontCache::findEngine(const Key &key)
 {
+    qDebug() << __FUNCTION__ << key.def.family << "script: "<<key.script;
     EngineCache::Iterator it = engineCache.find(key),
                          end = engineCache.end();
-    if (it == end) return 0;
+    if (it == end) {
+        qDebug() << __FUNCTION__ << "not found";
+        return 0;
+    }
 
     // found... update the hitcount and timestamp
     it.value().hits++;
@@ -2933,7 +2938,7 @@ QFontEngine *QFontCache::findEngine(const Key &key)
              it.value().data, it.value().timestamp, it.value().hits,
              int(it.value().data->ref), it.value().data->cache_count,
              it.value().data->name());
-
+    qDebug() << __FUNCTION__ << "found" << it.value().data;
     return it.value().data;
 }
 
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 5e971ea..0940622 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -67,14 +67,14 @@
 #  include FT_TRUETYPE_TABLES_H
 #endif
 
-// #define QFONTDATABASE_DEBUG
+#define QFONTDATABASE_DEBUG
 #ifdef QFONTDATABASE_DEBUG
 #  define FD_DEBUG qDebug
 #else
 #  define FD_DEBUG if (false) qDebug
 #endif
 
-// #define FONT_MATCH_DEBUG
+#define FONT_MATCH_DEBUG
 #ifdef FONT_MATCH_DEBUG
 #  define FM_DEBUG qDebug
 #else
@@ -937,7 +937,10 @@ static const int scriptForWritingSystem[] = {
 
 int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem)
 {
-    return scriptForWritingSystem[writingSystem];
+    int r =scriptForWritingSystem[writingSystem];
+    if (writingSystem)
+        qDebug() << __FUNCTION__ << "returns " << r << "for" << writingSystem;
+    return r;
 }
 
 
@@ -1083,6 +1086,7 @@ static QStringList familyList(const QFontDef &req)
 //         qDebug() << "adding substs: " << subs_list;
 
     family_list += subs_list;
+    qDebug() << __FUNCTION__ << req.family << "returns " <<  family_list;
 
     return family_list;
 }
@@ -1214,6 +1218,11 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
                          QtFontStyle::Key styleKey, int pixelSize, char pitch,
                          QtFontDesc *desc, int force_encoding_id)
 {
+    qDebug() << __FUNCTION__ << "script" <<script << score << family->name
+#ifdef Q_OS_WIN
+                <<family->english_name
+#endif
+              << foundry_name;
     Q_UNUSED(force_encoding_id);
     Q_UNUSED(script);
     Q_UNUSED(pitch);
@@ -1393,11 +1402,13 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
     \internal
 
     Tries to find the best match for a given request and family/foundry
-*/
+match */
 static void match(int script, const QFontDef &request,
                   const QString &family_name, const QString &foundry_name, int force_encoding_id,
                   QtFontDesc *desc, const QList<int> &blacklistedFamilies, bool forceXLFD)
 {
+    qDebug() << __FUNCTION__ << ">script=" << script << request.family <<
+                "family_name" << family_name << foundry_name << "blacklisted" << blacklistedFamilies;
     Q_UNUSED(force_encoding_id);
 
     QtFontStyle::Key styleKey;
@@ -1464,14 +1475,24 @@ static void match(int script, const QFontDef &request,
         for (int ws = 1; !supported && ws < QFontDatabase::WritingSystemsCount; ++ws) {
             if (scriptForWritingSystem[ws] != script)
                 continue;
-            if (test.family->writingSystems[ws] & QtFontFamily::Supported)
+            if (test.family->writingSystems[ws] & QtFontFamily::Supported) {
                 supported = true;
+//                qDebug() << __FUNCTION__ << "script="<< script << "ws" << ws << "supported!";
+            } else {
+//                qDebug() << __FUNCTION__ << "script="<< script << "ws" << ws << "unsupported!";
+            }
         }
         if (!supported) {
             // family not supported in the script we want
             continue;
         }
 
+        qDebug() << __FUNCTION__ << "x="<< x << test.family->name
+#ifdef Q_OS_WIN
+                            <<test.family->english_name
+#endif
+                    << "supported";
+
         // as we know the script is supported, we can be sure
         // to find a matching font here.
         unsigned int newscore =
@@ -1494,6 +1515,11 @@ static void match(int script, const QFontDef &request,
         if (newscore < 10) // xlfd instead of FT... just accept it
             break;
     }
+    if (desc && desc->family) {
+        qDebug() << __FUNCTION__ << "<script=" << script << request.family << "MATCH"<< desc->family->name;
+    } else {
+        qDebug() << __FUNCTION__ << "<script=" << script << request.family << "NOMATCH";
+    }
 }
 #endif
 
@@ -2001,6 +2027,7 @@ QFont QFontDatabase::font(const QString &family, const QString &style,
 {
     QString familyName, foundryName;
     parseFontName(family, foundryName, familyName);
+    qDebug() << __FUNCTION__ << family <<  foundryName<<style << pointSize;
 
     QMutexLocker locker(fontDatabaseMutex());
 
diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp
index 6f5321b..8416aa9 100644
--- a/src/gui/text/qfontdatabase_win.cpp
+++ b/src/gui/text/qfontdatabase_win.cpp
@@ -677,6 +677,7 @@ static QFontEngine *loadEngine(int script, const QFontDef &request,
                                const QtFontDesc *desc,
                                const QStringList &family_list)
 {
+    qDebug() << __FUNCTION__ << script << family_list;
     LOGFONT lf;
     memset(&lf, 0, sizeof(LOGFONT));
 
@@ -727,6 +728,7 @@ static QFontEngine *loadEngine(int script, const QFontDef &request,
             f = fam.right(fam.length()-1).toInt();
         else
             f = deffnt;
+        qDebug() << __FUNCTION__ << "rawMode" <<f;
         hfont = (HFONT)GetStockObject(f);
         if (!hfont) {
             qErrnoWarning("QFontEngine::loadEngine: GetStockObject failed");
@@ -837,6 +839,7 @@ static QFontEngine *loadEngine(int script, const QFontDef &request,
         ttf = tm.tmPitchAndFamily & TMPF_TRUETYPE;
         SelectObject(hdc, oldObj);
 
+        qDebug() << __FUNCTION__ << '3' <<fam << "tt=" << ttf << "directw"<< useDirectWrite;
         if (!ttf || !useDirectWrite) {
             useDirectWrite = false;
 
@@ -920,17 +923,20 @@ static QFontEngine *loadEngine(int script, const QFontDef &request,
         // ### TODO: This only works for scripts that require OpenType. More generally
         // for scripts that do not require OpenType we should just look at the list of
         // supported writing systems in the font's OS/2 table.
+        qDebug() << "checking open type"<< script << font_name;
         if (scriptRequiresOpenType(script)) {
             HB_Face hbFace = few->harfbuzzFace();
             if (!hbFace || !hbFace->supported_scripts[script]) {
-                FM_DEBUG("  OpenType support missing for script\n");
+                qDebug() << "  OpenType support missing for script" << script;
                 delete few;
+                qDebug() << __FUNCTION__ << "returning 0 due to OpenType support missing";
                 return 0;
             }
         }
 
         initFontInfo(few, request, fontHdc, dpi);
         fe = few;
+        qDebug() << __FUNCTION__ << fe << " for request " << request.family;
     }
 
 #if !defined(QT_NO_DIRECTWRITE)
@@ -979,6 +985,7 @@ static QFontEngine *loadEngine(int script, const QFontDef &request,
                 tryFonts = other_tryFonts;
                 break;
             }
+            qDebug() << __FUNCTION__ << '4' <<*tryFonts;
         }
         QStringList fm = QFontDatabase().families();
         QStringList list = family_list;
@@ -988,6 +995,7 @@ static QFontEngine *loadEngine(int script, const QFontDef &request,
                 list << QLatin1String(*tf);
             ++tf;
         }
+        qDebug() << __FUNCTION__ << '5' <<list;
         QFontEngine *mfe = new QFontEngineMultiWin(fe, list);
         mfe->fontDef = fe->fontDef;
         fe = mfe;
@@ -997,11 +1005,13 @@ static QFontEngine *loadEngine(int script, const QFontDef &request,
 
 QFontEngine *qt_load_font_engine_win(const QFontDef &request)
 {
+    qDebug() << __FUNCTION__ << request.family;
     // From qfont.cpp
     extern int qt_defaultDpi();
 
     QFontCache::Key key(request, QUnicodeTables::Common);
     QFontEngine *fe = QFontCache::instance()->findEngine(key);
+    qDebug() << __FUNCTION__ << "found in cache: " << fe;
     if (fe != 0)
         return fe;
     else
@@ -1032,8 +1042,10 @@ const char *styleHint(const QFontDef &request)
 
 static QFontEngine *loadWin(const QFontPrivate *d, int script, const QFontDef &req)
 {
+    qDebug() << __FUNCTION__ << '>'<< "script="<< script <<req.family;
     // list of families to try
     QStringList family_list = familyList(req);
+    qDebug() << __FUNCTION__ << family_list;
 
     const char *stylehint = styleHint(d->request);
     if (stylehint)
@@ -1044,6 +1056,7 @@ static QFontEngine *loadWin(const QFontPrivate *d, int script, const QFontDef &r
 
     // add the default family
     QString defaultFamily = QApplication::font().family();
+    qDebug() << __FUNCTION__ << "Checking QApplication::font() families: " << defaultFamily << QApplication::font().defaultFamily();
     if (! family_list.contains(defaultFamily))
         family_list << defaultFamily;
 
@@ -1051,7 +1064,7 @@ static QFontEngine *loadWin(const QFontPrivate *d, int script, const QFontDef &r
     // previous versions
     family_list << QApplication::font().defaultFamily();
 
-    // null family means find the first font matching the specified script
+    // null family means find the first font matching the specified script!
     family_list << QString();
 
     QtFontDesc desc;
@@ -1063,7 +1076,8 @@ static QFontEngine *loadWin(const QFontPrivate *d, int script, const QFontDef &r
             QString family, foundry;
             parseFontName(family_list.at(i), foundry, family);
             FM_DEBUG("loadWin: >>>>>>>>>>>>>>trying to match '%s'", family.toLatin1().data());
-            QT_PREPEND_NAMESPACE(match)(script, req, family, foundry, -1, &desc, blacklistedFamilies);
+            qDebug() <<__FUNCTION__ << "looping family" << i <<"of" << family_list.size() << family;
+            match(script, req, family, foundry, -1, &desc, blacklistedFamilies);
             if (desc.family)
                 break;
         }
@@ -1073,6 +1087,7 @@ static QFontEngine *loadWin(const QFontPrivate *d, int script, const QFontDef &r
         if (!fe)
             blacklistedFamilies.append(desc.familyIndex);
     }
+    qDebug() << __FUNCTION__ << '<'<< fe;
     return fe;
 }
 
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp
index 59b1807..b754877 100644
--- a/src/gui/text/qfontdatabase_x11.cpp
+++ b/src/gui/text/qfontdatabase_x11.cpp
@@ -1261,7 +1261,7 @@ static void load(const QString &family = QString(), int script = -1, bool forceX
 
 #ifdef QFONTDATABASE_DEBUG
     FD_DEBUG("QFontDatabase: load(%s, %d) took %d ms",
-             family.toLatin1().constData(), script, t.elapsed());
+             family.toLatin1().constData(), script, int(t.elapsed()));
 #endif
 }
 
@@ -1656,7 +1656,7 @@ static QFontEngine *tryPatternLoad(FcPattern *match, int screen,
     } else if (scriptRequiresOpenType(script)) {
         HB_Face hbFace = engine->harfbuzzFace();
         if (!hbFace || !hbFace->supported_scripts[script]) {
-            FM_DEBUG("  OpenType support missing for script\n");
+            qDebug() << "  OpenType support missing for script"<< script;
             delete engine;
             engine = 0;
         }
@@ -1732,7 +1732,7 @@ static QFontEngine *loadFc(const QFontPrivate *fp, int script, const QFontDef &r
             }
             FcFontSetDestroy(fs);
         }
-        FM_DEBUG("engine for script %d is %s\n", script, fe ? fe->fontDef.family.toLatin1().data(): "(null)");
+        FM_DEBUG("loadFc: engine for script %d is %s\n", script, fe ? fe->fontDef.family.toLatin1().data(): "(null)");
     }
     if (fe
         && script == QUnicodeTables::Common
@@ -1743,6 +1743,7 @@ static QFontEngine *loadFc(const QFontPrivate *fp, int script, const QFontDef &r
     }
     if (match)
         FcPatternDestroy(match);
+    qDebug() << __FUNCTION__ << " returns " << fe;
     return fe;
 }
 
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 1fb18d6..084eefb 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1317,6 +1317,7 @@ static inline glyph_t stripped(glyph_t glyph)
 
 QFontEngineMulti::QFontEngineMulti(int engineCount)
 {
+    setObjectName("QFontEngineMulti"+ QString::number(engineCount));
     engines.fill(0, engineCount);
     cache_cost = 0;
 }
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index 7e0a337..2eea22c 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -312,7 +312,10 @@ int QFontEngineWin::getGlyphIndexes(const QChar *str, int numChars, QGlyphLayout
 
 
 QFontEngineWin::QFontEngineWin(const QString &name, HFONT _hfont, bool stockFont, LOGFONT lf)
+
 {
+    setObjectName(name);
+    qDebug() << __FUNCTION__ << name;
     //qDebug("regular windows font engine created: font='%s', size=%d", name, lf.lfHeight);
 
     _name = name;
@@ -1315,6 +1318,7 @@ QFontEngineMultiWin::QFontEngineMultiWin(QFontEngine *first, const QStringList &
 
 void QFontEngineMultiWin::loadEngine(int at)
 {
+    qDebug() << __FUNCTION__ << at;
     Q_ASSERT(at < engines.size());
     Q_ASSERT(engines.at(at) == 0);
 
diff --git a/src/gui/text/qfontengine_x11.cpp b/src/gui/text/qfontengine_x11.cpp
index e2dd349..f599a77 100644
--- a/src/gui/text/qfontengine_x11.cpp
+++ b/src/gui/text/qfontengine_x11.cpp
@@ -971,6 +971,7 @@ Q_GUI_EXPORT void qt_x11ft_convert_pattern(FcPattern *pattern, QByteArray *file_
 QFontEngineX11FT::QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int screen)
     : QFontEngineFT(fd)
 {
+    setObjectName("QFontEngineX11FT" + fd.family);
 //     FcPatternPrint(pattern);
 
     bool antialias = X11->fc_antialias;
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 4d080b7..e36020c 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -2190,8 +2190,10 @@ void QScriptLine::setDefaultHeight(QTextEngine *eng)
         QPaintDevice *pdev = eng->block.docHandle()->layout()->paintDevice();
         if (pdev)
             f = QFont(f, pdev);
+        qDebug() << __FUNCTION__ <<'1' <<  f.family();
         e = f.d->engineForScript(QUnicodeTables::Common);
     } else {
+        qDebug() << __FUNCTION__ << '2' << f.family();
         e = eng->fnt.d->engineForScript(QUnicodeTables::Common);
     }
 
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 8d652ea..81f7ac5 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -800,6 +800,21 @@ bool QTextLayout::isValidCursorPosition(int pos) const
     inserted into the layout, the QTextLine returned will not be valid
     (isValid() will return false).
 */
+
+QString debugHieroglyph(const QStringRef &r)
+{
+    QString s ;
+    QTextStream str(&s);
+    for (int i = 0; i < r.size(); ++i) {
+        const QChar c = r.at(i);
+        const ushort  u = c.unicode();
+        str << hex << showbase << r.at(i).unicode() << dec << ' ';
+        if (u >= 32 && u < 128)
+            str << '\'' << char(u) << "' ";
+    }
+    return s;
+}
+
 QTextLine QTextLayout::createLine()
 {
 #ifndef QT_NO_DEBUG
@@ -821,6 +836,7 @@ QTextLine QTextLayout::createLine()
         if (!d->lines.at(l-1).length || d->layoutData->string.at(strlen - 1) != QChar::LineSeparator)
             return QTextLine();
     }
+    qDebug() << __FUNCTION__  << from << strlen << d->layoutData->string.size() << debugHieroglyph(d->layoutData->string.midRef(from, strlen));
 
     QScriptLine line;
     line.from = from;
