aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/FontHostTest.cpp
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-15 19:42:57 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-15 19:42:57 +0000
commit7bdd614a1940935d3badeb54f7aae75d76ea830d (patch)
treeaeb3d7e8d8b68cb9d1fb77a0def97f689a2876d7 /tests/FontHostTest.cpp
parent78b38b130deb8bcfa41611039875ce0162542ac1 (diff)
Implement onCountGlyphs and onGetUPEM on Windows.
R=vandebo@chromium.org Review URL: https://codereview.chromium.org/19231003 git-svn-id: http://skia.googlecode.com/svn/trunk@10089 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/FontHostTest.cpp')
-rw-r--r--tests/FontHostTest.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp
index 9a186dd57d..7358b1089a 100644
--- a/tests/FontHostTest.cpp
+++ b/tests/FontHostTest.cpp
@@ -29,20 +29,18 @@ static const struct TagSize {
};
// 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 @@ static void test_unitsPerEm(skiatest::Reporter* reporter, SkTypeface* face) {
}
}
+// 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 @@ static void test_tables(skiatest::Reporter* reporter) {
#endif
test_tables(reporter, face);
test_unitsPerEm(reporter, face);
+ test_countGlyphs(reporter, face);
face->unref();
}
}