summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtextscriptengine
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2010-03-22 10:46:00 +0100
committerLars Knoll <lars.knoll@nokia.com>2010-03-22 10:46:00 +0100
commit74f5e34979b8a08a91aa3c2fa6d252e68eca7817 (patch)
tree9361f50e54e5b9168fb891012e9c78a67799d1ba /tests/auto/qtextscriptengine
parent572ebf1586f4e995527eee126fcf0bd4fdb18bee (diff)
Add support for polyphonic greek
Merge patch c0006e05f32ecd6f16825b799d2bce345c166433 from harfbuzz and add autotests to QTextScriptEngine. Support for polyphonic greek is implemented by mapping decomposed greek character sequences to their composed characters in the greek extended unicode range (U+1f00 - U+1fff). Task-number: QTBUG-391 Reviewed-By: Simon Hausmann
Diffstat (limited to 'tests/auto/qtextscriptengine')
-rw-r--r--tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
index 6de3f59fdd..841f5b90c7 100644
--- a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
+++ b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
@@ -99,6 +99,7 @@ private slots:
void kannada();
void malayalam();
void sinhala();
+ void greek();
void khmer();
void linearB();
@@ -998,6 +999,80 @@ void tst_QTextScriptEngine::linearB()
#endif
}
+#if defined(Q_WS_X11)
+static bool decomposedShaping( const QFont &f, const QChar &ch)
+{
+ QString str = QString().append(ch);
+ QTextLayout layout(str, f);
+ QTextEngine *e = layout.d;
+ e->itemize();
+ e->shape(0);
+
+ QTextLayout decomposed(str.normalized(QString::NormalizationForm_D), f);
+ QTextEngine *de = decomposed.d;
+ de->itemize();
+ de->shape(0);
+
+ if( e->layoutData->items[0].num_glyphs != de->layoutData->items[0].num_glyphs )
+ goto error;
+
+ for (int i = 0; i < e->layoutData->items[0].num_glyphs; ++i) {
+ if ((e->layoutData->glyphLayout.glyphs[i] & 0xffffff) != (de->layoutData->glyphLayout.glyphs[i] & 0xffffff))
+ goto error;
+ }
+ return true;
+ error:
+ qDebug("%s: decomposedShaping of char %4x failed, nglyphs=%d, decomposed nglyphs %d",
+ f.family().toLatin1().constData(),
+ ch.unicode(),
+ e->layoutData->items[0].num_glyphs,
+ de->layoutData->items[0].num_glyphs);
+
+ str = "";
+ int i = 0;
+ while (i < e->layoutData->items[0].num_glyphs) {
+ str += QString("%1 ").arg(e->layoutData->glyphLayout.glyphs[i], 4, 16);
+ ++i;
+ }
+ qDebug(" composed glyph result = %s", str.toLatin1().constData());
+ str = "";
+ i = 0;
+ while (i < de->layoutData->items[0].num_glyphs) {
+ str += QString("%1 ").arg(de->layoutData->glyphLayout.glyphs[i], 4, 16);
+ ++i;
+ }
+ qDebug(" decomposed glyph result = %s", str.toLatin1().constData());
+ return false;
+}
+#endif
+
+
+void tst_QTextScriptEngine::greek()
+{
+#if defined(Q_WS_X11)
+ {
+ if (QFontDatabase().families(QFontDatabase::Any).contains("DejaVu Sans")) {
+ QFont f("DejaVu Sans");
+ for (int uc = 0x1f00; uc <= 0x1fff; ++uc) {
+ QString str;
+ str.append(uc);
+ if (str.normalized(QString::NormalizationForm_D).normalized(QString::NormalizationForm_C) != str) {
+ //qDebug() << "skipping" << hex << uc;
+ continue;
+ }
+ if (uc == 0x1fc1 || uc == 0x1fed)
+ continue;
+ QVERIFY( decomposedShaping(f, QChar(uc)) );
+ }
+ } else {
+ QSKIP("couln't find DejaVu Sans", SkipAll);
+ }
+ }
+#else
+ QSKIP("X11 specific test", SkipAll);
+#endif
+}
+
QTEST_MAIN(tst_QTextScriptEngine)
#include "tst_qtextscriptengine.moc"