summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfontmetrics
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@nokia.com>2010-05-25 20:19:14 +0200
committerJocelyn Turcotte <jocelyn.turcotte@nokia.com>2010-05-31 18:23:05 +0200
commit032fb3d54eaaa1fa36ec45b37f5f7356b1137830 (patch)
tree127dc0c3555003432aaa8add2b73385b24c74c4d /tests/auto/qfontmetrics
parent33fddc2adf95b56d8309ef9bc11408252140a085 (diff)
Add the Qt::TextBypassShaping flag.
This allows quick layouting especially with Windows fonts which contain heavy OpenType logic. On regular latin text the visual compromize is the loss of kerning, justification, capitalization, word spacing and letter spacing support. Reviewed-by: Simon Hausmann Reviewed-by: Eskil
Diffstat (limited to 'tests/auto/qfontmetrics')
-rw-r--r--tests/auto/qfontmetrics/tst_qfontmetrics.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
index 5d73764dbb..81e064e84e 100644
--- a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
+++ b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
@@ -71,6 +71,7 @@ private slots:
void elidedText();
void veryNarrowElidedText();
void averageCharWidth();
+ void bypassShaping();
void elidedMultiLength();
void elidedMultiLengthF();
void bearingIncludedInBoundingRect();
@@ -219,6 +220,20 @@ void tst_QFontMetrics::averageCharWidth()
QVERIFY(fmf.averageCharWidth() != 0);
}
+void tst_QFontMetrics::bypassShaping()
+{
+ QFont f;
+ QFontMetrics fm(f);
+ QString text = " A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z";
+ int textWidth = fm.width(text, -1, Qt::TextBypassShaping);
+ QVERIFY(textWidth != 0);
+ int charsWidth = 0;
+ for (int i = 0; i < text.size(); ++i)
+ charsWidth += fm.width(text[i]);
+ // This assertion is needed in QtWebKit's WebCore::Font::offsetForPositionForSimpleText
+ QCOMPARE(textWidth, charsWidth);
+}
+
template<class FontMetrics> void elidedMultiLength_helper()
{
QString text1 = "Long Text 1\x9cShorter\x9csmall";