diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-03-11 10:37:52 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-03-11 11:02:34 (GMT) |
commit | 86e7893c2c1a4c316a1db510ab6abeafa7267c3d (patch) | |
tree | 9d7af495b124edd89c0701adf67eb4685b0215c9 | |
parent | bb8c150241ead7fe86d2c02e4a789c3ac4db81a8 (diff) | |
download | Qt-86e7893c2c1a4c316a1db510ab6abeafa7267c3d.zip Qt-86e7893c2c1a4c316a1db510ab6abeafa7267c3d.tar.gz Qt-86e7893c2c1a4c316a1db510ab6abeafa7267c3d.tar.bz2 |
Fix combining marks handling in Core Text shaper
For fonts without combined glyph for combinations like U+0062 U+0300,
Core Text will return glyph sequences like <b> <`>, the latter will
have advance_x = 0, advance_y = <positive value> to keep it above
the previous glyph. To get correct positioning in flipped coordinate,
we need to store the negative y advance in Qt.
Task-number: QTBUG-15675
Reviewed-by: Eskil
-rw-r--r-- | src/gui/text/qfontengine_coretext.mm | 3 | ||||
-rw-r--r-- | tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp | 25 |
2 files changed, 26 insertions, 2 deletions
diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm index 2ae60b1..0209689 100644 --- a/src/gui/text/qfontengine_coretext.mm +++ b/src/gui/text/qfontengine_coretext.mm @@ -234,7 +234,8 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay int idx = rtlOffset + rtlSign * i; outGlyphs[idx] = tmpGlyphs[i] | fontIndex; outAdvances_x[idx] = QFixed::fromReal(tmpPoints[i + 1].x - tmpPoints[i].x); - outAdvances_y[idx] = QFixed::fromReal(tmpPoints[i + 1].y - tmpPoints[i].y); + // Use negative y advance for flipped coordinate system + outAdvances_y[idx] = QFixed::fromReal(tmpPoints[i].y - tmpPoints[i + 1].y); if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) { outAdvances_x[idx] = outAdvances_x[idx].round(); diff --git a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp index 91d0f3f..4f4e706a 100644 --- a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp @@ -56,7 +56,7 @@ -#if defined(Q_WS_X11) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) #define private public #include <private/qtextengine_p.h> #include <qtextlayout.h> @@ -104,6 +104,7 @@ private slots: void khmer(); void linearB(); void controlInSyllable_qtbug14204(); + void combiningMarks_qtbug15675(); }; tst_QTextScriptEngine::tst_QTextScriptEngine() @@ -1133,5 +1134,27 @@ void tst_QTextScriptEngine::controlInSyllable_qtbug14204() #endif } +void tst_QTextScriptEngine::combiningMarks_qtbug15675() +{ +#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) + QString s; + s.append(QChar(0x0061)); + s.append(QChar(0x0062)); + s.append(QChar(0x0300)); + s.append(QChar(0x0063)); + + QFont font("Monaco"); + QTextLayout layout(s, font); + QTextEngine *e = layout.d; + e->itemize(); + e->shape(0); + + QVERIFY(e->layoutData->items[0].num_glyphs == 4); + QVERIFY(e->layoutData->glyphLayout.advances_y[2] > 0); +#else + QSKIP("Mac specific test", SkipAll); +#endif +} + QTEST_MAIN(tst_QTextScriptEngine) #include "tst_qtextscriptengine.moc" |