Chromium Code Reviews| Index: tests/FontHostTest.cpp |
| =================================================================== |
| --- tests/FontHostTest.cpp (revision 10083) |
| +++ tests/FontHostTest.cpp (working copy) |
| @@ -29,20 +29,18 @@ |
| }; |
| // Test that getUnitsPerEm() agrees with a direct lookup in the 'head' table |
| -// (if that table is available. |
| +// (if that table is available). |
| static void test_unitsPerEm(skiatest::Reporter* reporter, SkTypeface* face) { |
| - int nativeUPEM = face->getUnitsPerEm();; |
| + int nativeUPEM = face->getUnitsPerEm(); |
| int tableUPEM = -1; |
| size_t size = face->getTableSize(kFontTableTag_head); |
| if (size) { |
|
vandebo (ex-Chrome)
2013/07/15 17:32:56
Do you want to check that size >= 20 ?
bungeman-skia
2013/07/15 18:21:36
Already did that in test_tables.
|
| - SkAutoMalloc storage(size); |
| - char* ptr = (char*)storage.get(); |
| - face->getTableData(kFontTableTag_head, 0, size, ptr); |
| // unitsPerEm is at offset 18 into the 'head' table. |
| - tableUPEM = SkEndian_SwapBE16(*(uint16_t*)&ptr[18]); |
| + uint16_t rawUPEM; |
| + face->getTableData(kFontTableTag_head, 18, sizeof(rawUPEM), &rawUPEM); |
| + tableUPEM = SkEndian_SwapBE16(rawUPEM); |
| } |
| -// SkDebugf("--- typeface returned %d upem [%X]\n", nativeUPEM, face->uniqueID()); |
| if (tableUPEM >= 0) { |
| REPORTER_ASSERT(reporter, tableUPEM == nativeUPEM); |
| @@ -52,6 +50,28 @@ |
| } |
| } |
| +// Test that countGlyphs() agrees with a direct lookup in the 'maxp' table |
| +// (if that table is available). |
| +static void test_countGlyphs(skiatest::Reporter* reporter, SkTypeface* face) { |
| + int nativeGlyphs = face->countGlyphs(); |
| + |
| + int tableGlyphs = -1; |
| + size_t size = face->getTableSize(kFontTableTag_maxp); |
| + if (size) { |
|
vandebo (ex-Chrome)
2013/07/15 17:32:56
size >= 6 ?
bungeman-skia
2013/07/15 18:21:36
Already did that in test_tables.
|
| + // glyphs is at offset 4 into the 'maxp' table. |
| + uint16_t rawGlyphs; |
| + face->getTableData(kFontTableTag_maxp, 4, sizeof(rawGlyphs), &rawGlyphs); |
| + tableGlyphs = SkEndian_SwapBE16(rawGlyphs); |
| + } |
| + |
| + if (tableGlyphs >= 0) { |
| + REPORTER_ASSERT(reporter, tableGlyphs == nativeGlyphs); |
| + } else { |
| + // not sure this is a bug, but lets report it for now as info. |
| + SkDebugf("--- typeface returned 0 glyphs [%X]\n", face->uniqueID()); |
| + } |
| +} |
| + |
| static void test_fontstream(skiatest::Reporter* reporter, |
| SkStream* stream, int ttcIndex) { |
| int n = SkFontStream::GetTableTags(stream, ttcIndex, NULL); |
| @@ -157,6 +177,7 @@ |
| #endif |
| test_tables(reporter, face); |
| test_unitsPerEm(reporter, face); |
| + test_countGlyphs(reporter, face); |
| face->unref(); |
| } |
| } |