Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1867)

Unified Diff: tests/FontHostTest.cpp

Issue 19231003: Implement onCountGlyphs and onGetUPEM on Windows. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ports/SkFontHost_win_dw.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
- 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) {
+ // 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();
}
}
« no previous file with comments | « src/ports/SkFontHost_win_dw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698