aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/FontHostTest.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-31 17:24:44 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-31 17:24:44 +0000
commit4b2af9c91d39c2176a32e7ba42a0276dca68034a (patch)
treee8173fa9f93220566ee18ea0fcd395e548652585 /tests/FontHostTest.cpp
parent777e7890935b831174bcd64a86391d166a505ab4 (diff)
add getUnitsPerEm() to SkTypeface
git-svn-id: http://skia.googlecode.com/svn/trunk@4863 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/FontHostTest.cpp')
-rw-r--r--tests/FontHostTest.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp
index 260956fe57..fcdeaba1a5 100644
--- a/tests/FontHostTest.cpp
+++ b/tests/FontHostTest.cpp
@@ -8,6 +8,7 @@
#include "Test.h"
#include "SkPaint.h"
#include "SkTypeface.h"
+#include "SkEndian.h"
//#define DUMP_TABLES
@@ -24,6 +25,21 @@ static const struct TagSize {
{ kFontTableTag_maxp, 32 },
};
+static void test_unitsPerEm(skiatest::Reporter* reporter, SkTypeface* face) {
+ int upem = face->getUnitsPerEm();
+ REPORTER_ASSERT(reporter, upem > 0);
+
+ 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);
+ }
+}
+
static void test_tables(skiatest::Reporter* reporter, SkTypeface* face) {
SkFontID fontID = face->uniqueID();
if (false) { // avoid bit rot, suppress warning
@@ -82,6 +98,7 @@ static void test_tables(skiatest::Reporter* reporter) {
SkDebugf("%s\n", gNames[i]);
#endif
test_tables(reporter, face);
+ test_unitsPerEm(reporter, face);
face->unref();
}
}