diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-18 13:45:58 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-18 13:45:58 +0000 |
commit | d074c3709afa6ea70888262a402603197d71dd11 (patch) | |
tree | dab56a5a4417f1b4203d108b745154bc5f73813c /tests/FontHostTest.cpp | |
parent | ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8d (diff) |
Need to apply matrix to advance in generateAdvance (as we already were in generateMetrics)
Fixes b/6833339
Expand existing unittest to detect this (we needed to set both scale and skew on the paint)
git-svn-id: http://skia.googlecode.com/svn/trunk@4647 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/FontHostTest.cpp')
-rw-r--r-- | tests/FontHostTest.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp index e35e73f58b..260956fe57 100644 --- a/tests/FontHostTest.cpp +++ b/tests/FontHostTest.cpp @@ -113,6 +113,17 @@ static void test_advances(skiatest::Reporter* reporter) { { SkPaint::kNormal_Hinting, SkPaint::kSubpixelText_Flag }, }; + static const struct { + SkScalar fScaleX; + SkScalar fSkewX; + } gScaleRec[] = { + { SK_Scalar1, 0 }, + { SK_Scalar1/2, 0 }, + // these two exercise obliquing (skew) + { SK_Scalar1, -SK_Scalar1/4 }, + { SK_Scalar1/2, -SK_Scalar1/4 }, + }; + SkPaint paint; char txt[] = "long.text.with.lots.of.dots."; @@ -121,23 +132,28 @@ static void test_advances(skiatest::Reporter* reporter) { paint.setTypeface(face); for (size_t j = 0; j < SK_ARRAY_COUNT(settings); j++) { - paint.setHinting(settings[j].hinting); - paint.setLinearText((settings[j].flags & SkPaint::kLinearText_Flag) != 0); - paint.setSubpixelText((settings[j].flags & SkPaint::kSubpixelText_Flag) != 0); + paint.setHinting(settings[j].hinting); + paint.setLinearText((settings[j].flags & SkPaint::kLinearText_Flag) != 0); + paint.setSubpixelText((settings[j].flags & SkPaint::kSubpixelText_Flag) != 0); - SkRect bounds; + for (size_t k = 0; k < SK_ARRAY_COUNT(gScaleRec); ++k) { + paint.setTextScaleX(gScaleRec[k].fScaleX); + paint.setTextSkewX(gScaleRec[k].fSkewX); - // For no hinting and light hinting this should take the - // optimized generateAdvance path. - SkScalar width1 = paint.measureText(txt, strlen(txt)); + SkRect bounds; - // Requesting the bounds forces a generateMetrics call. - SkScalar width2 = paint.measureText(txt, strlen(txt), &bounds); + // For no hinting and light hinting this should take the + // optimized generateAdvance path. + SkScalar width1 = paint.measureText(txt, strlen(txt)); - // SkDebugf("Font: %s, generateAdvance: %f, generateMetrics: %f\n", - // faces[i], SkScalarToFloat(width1), SkScalarToFloat(width2)); + // Requesting the bounds forces a generateMetrics call. + SkScalar width2 = paint.measureText(txt, strlen(txt), &bounds); - REPORTER_ASSERT(reporter, width1 == width2); + // SkDebugf("Font: %s, generateAdvance: %f, generateMetrics: %f\n", + // faces[i], SkScalarToFloat(width1), SkScalarToFloat(width2)); + + REPORTER_ASSERT(reporter, width1 == width2); + } } } } |