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 "Resources.h" | 8 #include "Resources.h" |
9 #include "SkEndian.h" | 9 #include "SkEndian.h" |
10 #include "SkFontStream.h" | 10 #include "SkFontStream.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 face->getTableData(kFontTableTag_maxp, 4, sizeof(rawGlyphs), &rawGlyphs)
; | 61 face->getTableData(kFontTableTag_maxp, 4, sizeof(rawGlyphs), &rawGlyphs)
; |
62 tableGlyphs = SkEndian_SwapBE16(rawGlyphs); | 62 tableGlyphs = SkEndian_SwapBE16(rawGlyphs); |
63 } | 63 } |
64 | 64 |
65 if (tableGlyphs >= 0) { | 65 if (tableGlyphs >= 0) { |
66 REPORTER_ASSERT(reporter, tableGlyphs == nativeGlyphs); | 66 REPORTER_ASSERT(reporter, tableGlyphs == nativeGlyphs); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 // The following three are all the same code points in various encodings. | 70 // The following three are all the same code points in various encodings. |
71 static uint8_t utf8Chars[] = { 0x61, 0xE4, 0xB8, 0xAD, 0xD0, 0xAF, 0xD7, 0x99, 0
xD7, 0x95, 0xF0, 0x9D, 0x84, 0x9E, 0x61 }; | 71 // a中Яיו𝄞a𠮟 |
72 static uint16_t utf16Chars[] = { 0x0061, 0x4E2D, 0x042F, 0x05D9, 0x05D5, 0xD834,
0xDD1E, 0x0061 }; | 72 static uint8_t utf8Chars[] = { 0x61, 0xE4,0xB8,0xAD, 0xD0,0xAF, 0xD7,0x99, 0xD7,
0x95, 0xF0,0x9D,0x84,0x9E, 0x61, 0xF0,0xA0,0xAE,0x9F }; |
73 static uint32_t utf32Chars[] = { 0x00000061, 0x00004E2D, 0x0000042F, 0x000005D9,
0x000005D5, 0x0001D11E, 0x00000061 }; | 73 static uint16_t utf16Chars[] = { 0x0061, 0x4E2D, 0x042F, 0x05D9, 0x05D5, 0xD834,
0xDD1E, 0x0061, 0xD842,0xDF9F }; |
| 74 static uint32_t utf32Chars[] = { 0x00000061, 0x00004E2D, 0x0000042F, 0x000005D9,
0x000005D5, 0x0001D11E, 0x00000061, 0x00020B9F }; |
74 | 75 |
75 struct CharsToGlyphs_TestData { | 76 struct CharsToGlyphs_TestData { |
76 const void* chars; | 77 const void* chars; |
77 int charCount; | 78 int charCount; |
78 size_t charsByteLength; | 79 size_t charsByteLength; |
79 SkTypeface::Encoding typefaceEncoding; | 80 SkTypeface::Encoding typefaceEncoding; |
80 const char* name; | 81 const char* name; |
81 } static charsToGlyphs_TestData[] = { | 82 } static charsToGlyphs_TestData[] = { |
82 { utf8Chars, 7, sizeof(utf8Chars), SkTypeface::kUTF8_Encoding, "Simple UTF-8
" }, | 83 { utf8Chars, 8, sizeof(utf8Chars), SkTypeface::kUTF8_Encoding, "Simple UTF-8
" }, |
83 { utf16Chars, 7, sizeof(utf16Chars), SkTypeface::kUTF16_Encoding, "Simple UT
F-16" }, | 84 { utf16Chars, 8, sizeof(utf16Chars), SkTypeface::kUTF16_Encoding, "Simple UT
F-16" }, |
84 { utf32Chars, 7, sizeof(utf32Chars), SkTypeface::kUTF32_Encoding, "Simple UT
F-32" }, | 85 { utf32Chars, 8, sizeof(utf32Chars), SkTypeface::kUTF32_Encoding, "Simple UT
F-32" }, |
85 }; | 86 }; |
86 | 87 |
87 // Test that SkPaint::textToGlyphs agrees with SkTypeface::charsToGlyphs. | 88 // Test that SkPaint::textToGlyphs agrees with SkTypeface::charsToGlyphs. |
88 static void test_charsToGlyphs(skiatest::Reporter* reporter, SkTypeface* face) { | 89 static void test_charsToGlyphs(skiatest::Reporter* reporter, SkTypeface* face) { |
89 uint16_t paintGlyphIds[256]; | 90 uint16_t paintGlyphIds[256]; |
90 uint16_t faceGlyphIds[256]; | 91 uint16_t faceGlyphIds[256]; |
91 | 92 |
92 for (size_t testIndex = 0; testIndex < SK_ARRAY_COUNT(charsToGlyphs_TestData
); ++testIndex) { | 93 for (size_t testIndex = 0; testIndex < SK_ARRAY_COUNT(charsToGlyphs_TestData
); ++testIndex) { |
93 CharsToGlyphs_TestData& test = charsToGlyphs_TestData[testIndex]; | 94 CharsToGlyphs_TestData& test = charsToGlyphs_TestData[testIndex]; |
94 | 95 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 SkAutoMalloc data(size); | 204 SkAutoMalloc data(size); |
204 size_t size2 = face->getTableData(tags[i], 0, size, data.get()); | 205 size_t size2 = face->getTableData(tags[i], 0, size, data.get()); |
205 REPORTER_ASSERT(reporter, size2 == size); | 206 REPORTER_ASSERT(reporter, size2 == size); |
206 } | 207 } |
207 } | 208 } |
208 } | 209 } |
209 | 210 |
210 static void test_tables(skiatest::Reporter* reporter) { | 211 static void test_tables(skiatest::Reporter* reporter) { |
211 static const char* const gNames[] = { | 212 static const char* const gNames[] = { |
212 NULL, // default font | 213 NULL, // default font |
213 "Arial", "Times", "Times New Roman", "Helvetica", "Courier", | 214 "Helvetica", "Arial", |
214 "Courier New", "Terminal", "MS Sans Serif", | 215 "Times", "Times New Roman", |
| 216 "Courier", "Courier New", |
| 217 "Terminal", "MS Sans Serif", |
| 218 "Hiragino Mincho ProN", "MS PGothic", |
215 }; | 219 }; |
216 | 220 |
217 for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); ++i) { | 221 for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); ++i) { |
218 SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(gNames[i], SkTy
peface::kNormal)); | 222 SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(gNames[i], SkTy
peface::kNormal)); |
219 if (face) { | 223 if (face) { |
220 #ifdef DUMP_TABLES | 224 #ifdef DUMP_TABLES |
221 SkDebugf("%s\n", gNames[i]); | 225 SkDebugf("%s\n", gNames[i]); |
222 #endif | 226 #endif |
223 test_tables(reporter, face); | 227 test_tables(reporter, face); |
224 test_unitsPerEm(reporter, face); | 228 test_unitsPerEm(reporter, face); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 303 } |
300 } | 304 } |
301 | 305 |
302 DEF_TEST(FontHost, reporter) { | 306 DEF_TEST(FontHost, reporter) { |
303 test_tables(reporter); | 307 test_tables(reporter); |
304 test_fontstream(reporter); | 308 test_fontstream(reporter); |
305 test_advances(reporter); | 309 test_advances(reporter); |
306 } | 310 } |
307 | 311 |
308 // need tests for SkStrSearch | 312 // need tests for SkStrSearch |
OLD | NEW |