From a262eea230a69cce309191bfdc8a19fe8737a152 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Thu, 21 Mar 2013 15:20:00 +0000 Subject: [PATCH] beef-up upem test for fonts git-svn-id: http://skia.googlecode.com/svn/trunk@8293 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tests/FontHostTest.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp index e9961551e1..9a186dd57d 100644 --- a/tests/FontHostTest.cpp +++ b/tests/FontHostTest.cpp @@ -28,18 +28,27 @@ static const struct TagSize { { kFontTableTag_maxp, 32 }, }; +// Test that getUnitsPerEm() agrees with a direct lookup in the 'head' table +// (if that table is available. static void test_unitsPerEm(skiatest::Reporter* reporter, SkTypeface* face) { - int upem = face->getUnitsPerEm(); - if (0 == upem) return; + int nativeUPEM = face->getUnitsPerEm();; + int tableUPEM = -1; size_t size = face->getTableSize(kFontTableTag_head); if (size) { SkAutoMalloc storage(size); char* ptr = (char*)storage.get(); face->getTableData(kFontTableTag_head, 0, size, ptr); // unitsPerEm is at offset 18 into the 'head' table. - int upem2 = SkEndian_SwapBE16(*(uint16_t*)&ptr[18]); - REPORTER_ASSERT(reporter, upem2 == upem); + tableUPEM = SkEndian_SwapBE16(*(uint16_t*)&ptr[18]); + } +// SkDebugf("--- typeface returned %d upem [%X]\n", nativeUPEM, face->uniqueID()); + + if (tableUPEM >= 0) { + REPORTER_ASSERT(reporter, tableUPEM == nativeUPEM); + } else { + // not sure this is a bug, but lets report it for now as info. + SkDebugf("--- typeface returned 0 upem [%X]\n", face->uniqueID()); } } -- 2.34.1