OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Test.h" | 8 #include "Test.h" |
9 #include "TestClassDef.h" | 9 #include "TestClassDef.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 size_t size = face->getTableSize(kFontTableTag_head); | 39 size_t size = face->getTableSize(kFontTableTag_head); |
40 if (size) { | 40 if (size) { |
41 // unitsPerEm is at offset 18 into the 'head' table. | 41 // unitsPerEm is at offset 18 into the 'head' table. |
42 uint16_t rawUPEM; | 42 uint16_t rawUPEM; |
43 face->getTableData(kFontTableTag_head, 18, sizeof(rawUPEM), &rawUPEM); | 43 face->getTableData(kFontTableTag_head, 18, sizeof(rawUPEM), &rawUPEM); |
44 tableUPEM = SkEndian_SwapBE16(rawUPEM); | 44 tableUPEM = SkEndian_SwapBE16(rawUPEM); |
45 } | 45 } |
46 | 46 |
47 if (tableUPEM >= 0) { | 47 if (tableUPEM >= 0) { |
48 REPORTER_ASSERT(reporter, tableUPEM == nativeUPEM); | 48 REPORTER_ASSERT(reporter, tableUPEM == nativeUPEM); |
49 } else { | |
50 // not sure this is a bug, but lets report it for now as info. | |
51 SkDebugf("--- typeface returned 0 upem [%X]\n", face->uniqueID()); | |
52 } | 49 } |
53 } | 50 } |
54 | 51 |
55 // Test that countGlyphs() agrees with a direct lookup in the 'maxp' table | 52 // Test that countGlyphs() agrees with a direct lookup in the 'maxp' table |
56 // (if that table is available). | 53 // (if that table is available). |
57 static void test_countGlyphs(skiatest::Reporter* reporter, SkTypeface* face) { | 54 static void test_countGlyphs(skiatest::Reporter* reporter, SkTypeface* face) { |
58 int nativeGlyphs = face->countGlyphs(); | 55 int nativeGlyphs = face->countGlyphs(); |
59 | 56 |
60 int tableGlyphs = -1; | 57 int tableGlyphs = -1; |
61 size_t size = face->getTableSize(kFontTableTag_maxp); | 58 size_t size = face->getTableSize(kFontTableTag_maxp); |
62 if (size) { | 59 if (size) { |
63 // glyphs is at offset 4 into the 'maxp' table. | 60 // glyphs is at offset 4 into the 'maxp' table. |
64 uint16_t rawGlyphs; | 61 uint16_t rawGlyphs; |
65 face->getTableData(kFontTableTag_maxp, 4, sizeof(rawGlyphs), &rawGlyphs)
; | 62 face->getTableData(kFontTableTag_maxp, 4, sizeof(rawGlyphs), &rawGlyphs)
; |
66 tableGlyphs = SkEndian_SwapBE16(rawGlyphs); | 63 tableGlyphs = SkEndian_SwapBE16(rawGlyphs); |
67 } | 64 } |
68 | 65 |
69 if (tableGlyphs >= 0) { | 66 if (tableGlyphs >= 0) { |
70 REPORTER_ASSERT(reporter, tableGlyphs == nativeGlyphs); | 67 REPORTER_ASSERT(reporter, tableGlyphs == nativeGlyphs); |
71 } else { | |
72 // not sure this is a bug, but lets report it for now as info. | |
73 SkDebugf("--- typeface returned 0 glyphs [%X]\n", face->uniqueID()); | |
74 } | 68 } |
75 } | 69 } |
76 | 70 |
77 // The following three are all the same code points in various encodings. | 71 // The following three are all the same code points in various encodings. |
78 static uint8_t utf8Chars[] = { 0x61, 0xE4, 0xB8, 0xAD, 0xD0, 0xAF, 0xD7, 0x99, 0
xD7, 0x95, 0xF0, 0x9D, 0x84, 0x9E, 0x61 }; | 72 static uint8_t utf8Chars[] = { 0x61, 0xE4, 0xB8, 0xAD, 0xD0, 0xAF, 0xD7, 0x99, 0
xD7, 0x95, 0xF0, 0x9D, 0x84, 0x9E, 0x61 }; |
79 static uint16_t utf16Chars[] = { 0x0061, 0x4E2D, 0x042F, 0x05D9, 0x05D5, 0xD834,
0xDD1E, 0x0061 }; | 73 static uint16_t utf16Chars[] = { 0x0061, 0x4E2D, 0x042F, 0x05D9, 0x05D5, 0xD834,
0xDD1E, 0x0061 }; |
80 static uint32_t utf32Chars[] = { 0x00000061, 0x00004E2D, 0x0000042F, 0x000005D9,
0x000005D5, 0x0001D11E, 0x00000061 }; | 74 static uint32_t utf32Chars[] = { 0x00000061, 0x00004E2D, 0x0000042F, 0x000005D9,
0x000005D5, 0x0001D11E, 0x00000061 }; |
81 | 75 |
82 struct CharsToGlyphs_TestData { | 76 struct CharsToGlyphs_TestData { |
83 const void* chars; | 77 const void* chars; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 } | 300 } |
307 } | 301 } |
308 | 302 |
309 DEF_TEST(FontHost, reporter) { | 303 DEF_TEST(FontHost, reporter) { |
310 test_tables(reporter); | 304 test_tables(reporter); |
311 test_fontstream(reporter); | 305 test_fontstream(reporter); |
312 test_advances(reporter); | 306 test_advances(reporter); |
313 } | 307 } |
314 | 308 |
315 // need tests for SkStrSearch | 309 // need tests for SkStrSearch |
OLD | NEW |