diff options
author | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-05 15:07:25 +0000 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2012-09-12 02:44:36 -0700 |
commit | ef9e72cd106361d2bd4df3e8a8b6fec05f1332c1 (patch) | |
tree | 2a8a8dcaa9fba8f883685cee9411896bed89613a /tests | |
parent | 0a58de2a1de572bb48f9e4027b53820f5c6ada52 (diff) | |
download | external_skia-ef9e72cd106361d2bd4df3e8a8b6fec05f1332c1.zip external_skia-ef9e72cd106361d2bd4df3e8a8b6fec05f1332c1.tar.gz external_skia-ef9e72cd106361d2bd4df3e8a8b6fec05f1332c1.tar.bz2 |
Squashed commit of font rendering fixes from Skia master
When guessing at the dest, use linear space instead of color space.
http://codereview.appspot.com/5732044/
--this line, and those below, will be ignored--
M src/ports/SkFontHost_FreeType.cpp
git-svn-id: http://skia.googlecode.com/svn/trunk@3313 2bbb7eff-a529-9590-31e7-b0007b416f81
Don't override the user's hinting level.
http://codereview.appspot.com/5792049/
git-svn-id: http://skia.googlecode.com/svn/trunk@3344 2bbb7eff-a529-9590-31e7-b0007b416f81
Use default lcd filter until we have the means to specify one.
git-svn-id: http://skia.googlecode.com/svn/trunk@3358 2bbb7eff-a529-9590-31e7-b0007b416f81
Use floats for mask table for accuracy.
http://codereview.appspot.com/5783099/
git-svn-id: http://skia.googlecode.com/svn/trunk@3374 2bbb7eff-a529-9590-31e7-b0007b416f81
Glyph advances from generateAdvance do not always match generateMetrics results.
http://codereview.appspot.com/5841071/
git-svn-id: http://skia.googlecode.com/svn/trunk@3480 2bbb7eff-a529-9590-31e7-b0007b416f81
Temp fix for very large text sizes.
http://codereview.appspot.com/5970065/
git-svn-id: http://skia.googlecode.com/svn/trunk@3569 2bbb7eff-a529-9590-31e7-b0007b416f81
Compare scalars to scalars (fixes fixed point).
git-svn-id: http://skia.googlecode.com/svn/trunk@3570 2bbb7eff-a529-9590-31e7-b0007b416f81
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')
-rw-r--r-- | tests/FontHostTest.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp index 8ab7ad3..82cd9af 100644 --- a/tests/FontHostTest.cpp +++ b/tests/FontHostTest.cpp @@ -85,8 +85,80 @@ static void test_tables(skiatest::Reporter* reporter) { } } +/* + * Verifies that the advance values returned by generateAdvance and + * generateMetrics match. + */ +static void test_advances(skiatest::Reporter* reporter) { + static const char* const faces[] = { + NULL, // default font + "Arial", "Times", "Times New Roman", "Helvetica", "Courier", + "Courier New", "Verdana", "monospace", + }; + + static const struct { + SkPaint::Hinting hinting; + unsigned flags; + } settings[] = { + { SkPaint::kNo_Hinting, 0 }, + { SkPaint::kNo_Hinting, SkPaint::kLinearText_Flag }, + { SkPaint::kNo_Hinting, SkPaint::kSubpixelText_Flag }, + { SkPaint::kSlight_Hinting, 0 }, + { SkPaint::kSlight_Hinting, SkPaint::kLinearText_Flag }, + { SkPaint::kSlight_Hinting, SkPaint::kSubpixelText_Flag }, + { SkPaint::kNormal_Hinting, 0 }, + { SkPaint::kNormal_Hinting, SkPaint::kLinearText_Flag }, + { 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."; + + for (size_t i = 0; i < SK_ARRAY_COUNT(faces); i++) { + SkTypeface* face = SkTypeface::CreateFromName(faces[i], SkTypeface::kNormal); + 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); + + for (size_t k = 0; k < SK_ARRAY_COUNT(gScaleRec); ++k) { + paint.setTextScaleX(gScaleRec[k].fScaleX); + paint.setTextSkewX(gScaleRec[k].fSkewX); + + SkRect bounds; + + // For no hinting and light hinting this should take the + // optimized generateAdvance path. + SkScalar width1 = paint.measureText(txt, strlen(txt)); + + // Requesting the bounds forces a generateMetrics call. + SkScalar width2 = paint.measureText(txt, strlen(txt), &bounds); + + // SkDebugf("Font: %s, generateAdvance: %f, generateMetrics: %f\n", + // faces[i], SkScalarToFloat(width1), SkScalarToFloat(width2)); + + REPORTER_ASSERT(reporter, width1 == width2); + } + } + } +} + static void TestFontHost(skiatest::Reporter* reporter) { test_tables(reporter); + test_advances(reporter); } // need tests for SkStrSearch |