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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 face->getFamilyName(&name); | 105 face->getFamilyName(&name); |
106 SkString a; | 106 SkString a; |
107 a.appendf("%s, paintGlyphIds[%d] = %d, faceGlyphIds[%d] = %d, face =
%s", | 107 a.appendf("%s, paintGlyphIds[%d] = %d, faceGlyphIds[%d] = %d, face =
%s", |
108 test.name, i, (int)paintGlyphIds[i], i, (int)faceGlyphIds[
i], name.c_str()); | 108 test.name, i, (int)paintGlyphIds[i], i, (int)faceGlyphIds[
i], name.c_str()); |
109 REPORTER_ASSERT_MESSAGE(reporter, paintGlyphIds[i] == faceGlyphIds[i
], a.c_str()); | 109 REPORTER_ASSERT_MESSAGE(reporter, paintGlyphIds[i] == faceGlyphIds[i
], a.c_str()); |
110 } | 110 } |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 static void test_fontstream(skiatest::Reporter* reporter, SkStream* stream, int
ttcIndex) { | 114 static void test_fontstream(skiatest::Reporter* reporter, SkStream* stream, int
ttcIndex) { |
115 int n = SkFontStream::GetTableTags(stream, ttcIndex, NULL); | 115 int n = SkFontStream::GetTableTags(stream, ttcIndex, nullptr); |
116 SkAutoTArray<SkFontTableTag> array(n); | 116 SkAutoTArray<SkFontTableTag> array(n); |
117 | 117 |
118 int n2 = SkFontStream::GetTableTags(stream, ttcIndex, array.get()); | 118 int n2 = SkFontStream::GetTableTags(stream, ttcIndex, array.get()); |
119 REPORTER_ASSERT(reporter, n == n2); | 119 REPORTER_ASSERT(reporter, n == n2); |
120 | 120 |
121 for (int i = 0; i < n; ++i) { | 121 for (int i = 0; i < n; ++i) { |
122 #ifdef DUMP_TTC_TABLES | 122 #ifdef DUMP_TTC_TABLES |
123 SkString str; | 123 SkString str; |
124 SkFontTableTag t = array[i]; | 124 SkFontTableTag t = array[i]; |
125 str.appendUnichar((t >> 24) & 0xFF); | 125 str.appendUnichar((t >> 24) & 0xFF); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 { | 207 { |
208 SkAutoMalloc data(size); | 208 SkAutoMalloc data(size); |
209 size_t size2 = face->getTableData(tags[i], 0, size, data.get()); | 209 size_t size2 = face->getTableData(tags[i], 0, size, data.get()); |
210 REPORTER_ASSERT(reporter, size2 == size); | 210 REPORTER_ASSERT(reporter, size2 == size); |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 static void test_tables(skiatest::Reporter* reporter) { | 215 static void test_tables(skiatest::Reporter* reporter) { |
216 static const char* const gNames[] = { | 216 static const char* const gNames[] = { |
217 NULL, // default font | 217 nullptr, // default font |
218 "Helvetica", "Arial", | 218 "Helvetica", "Arial", |
219 "Times", "Times New Roman", | 219 "Times", "Times New Roman", |
220 "Courier", "Courier New", | 220 "Courier", "Courier New", |
221 "Terminal", "MS Sans Serif", | 221 "Terminal", "MS Sans Serif", |
222 "Hiragino Mincho ProN", "MS PGothic", | 222 "Hiragino Mincho ProN", "MS PGothic", |
223 }; | 223 }; |
224 | 224 |
225 for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); ++i) { | 225 for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); ++i) { |
226 SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(gNames[i], SkTy
peface::kNormal)); | 226 SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(gNames[i], SkTy
peface::kNormal)); |
227 if (face) { | 227 if (face) { |
228 #ifdef DUMP_TABLES | 228 #ifdef DUMP_TABLES |
229 SkDebugf("%s\n", gNames[i]); | 229 SkDebugf("%s\n", gNames[i]); |
230 #endif | 230 #endif |
231 test_tables(reporter, face); | 231 test_tables(reporter, face); |
232 test_unitsPerEm(reporter, face); | 232 test_unitsPerEm(reporter, face); |
233 test_countGlyphs(reporter, face); | 233 test_countGlyphs(reporter, face); |
234 test_charsToGlyphs(reporter, face); | 234 test_charsToGlyphs(reporter, face); |
235 } | 235 } |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 /* | 239 /* |
240 * Verifies that the advance values returned by generateAdvance and | 240 * Verifies that the advance values returned by generateAdvance and |
241 * generateMetrics match. | 241 * generateMetrics match. |
242 */ | 242 */ |
243 static void test_advances(skiatest::Reporter* reporter) { | 243 static void test_advances(skiatest::Reporter* reporter) { |
244 static const char* const faces[] = { | 244 static const char* const faces[] = { |
245 NULL, // default font | 245 nullptr, // default font |
246 "Arial", "Times", "Times New Roman", "Helvetica", "Courier", | 246 "Arial", "Times", "Times New Roman", "Helvetica", "Courier", |
247 "Courier New", "Verdana", "monospace", | 247 "Courier New", "Verdana", "monospace", |
248 }; | 248 }; |
249 | 249 |
250 static const struct { | 250 static const struct { |
251 SkPaint::Hinting hinting; | 251 SkPaint::Hinting hinting; |
252 unsigned flags; | 252 unsigned flags; |
253 } settings[] = { | 253 } settings[] = { |
254 { SkPaint::kNo_Hinting, 0 }, | 254 { SkPaint::kNo_Hinting, 0 }, |
255 { SkPaint::kNo_Hinting, SkPaint::kLinearText_Flag }, | 255 { SkPaint::kNo_Hinting, SkPaint::kLinearText_Flag }, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } | 308 } |
309 | 309 |
310 DEF_TEST(FontHost, reporter) { | 310 DEF_TEST(FontHost, reporter) { |
311 test_tables(reporter); | 311 test_tables(reporter); |
312 test_fontstream(reporter); | 312 test_fontstream(reporter); |
313 test_advances(reporter); | 313 test_advances(reporter); |
314 test_symbolfont(reporter); | 314 test_symbolfont(reporter); |
315 } | 315 } |
316 | 316 |
317 // need tests for SkStrSearch | 317 // need tests for SkStrSearch |
OLD | NEW |