reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
tfarina | bcbc178 | 2014-06-18 14:32:48 -0700 | [diff] [blame] | 8 | #include "Resources.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 9 | #include "SkEndian.h" |
reed@google.com | ed268bf | 2013-03-11 20:13:36 +0000 | [diff] [blame] | 10 | #include "SkFontStream.h" |
bungeman@google.com | 3c996f8 | 2013-10-24 21:39:35 +0000 | [diff] [blame] | 11 | #include "SkOSFile.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 12 | #include "SkPaint.h" |
reed@google.com | ed268bf | 2013-03-11 20:13:36 +0000 | [diff] [blame] | 13 | #include "SkStream.h" |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 14 | #include "SkTypeface.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 15 | #include "Test.h" |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 16 | |
| 17 | //#define DUMP_TABLES |
reed@google.com | ed268bf | 2013-03-11 20:13:36 +0000 | [diff] [blame] | 18 | //#define DUMP_TTC_TABLES |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 19 | |
| 20 | #define kFontTableTag_head SkSetFourByteTag('h', 'e', 'a', 'd') |
| 21 | #define kFontTableTag_hhea SkSetFourByteTag('h', 'h', 'e', 'a') |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 22 | #define kFontTableTag_maxp SkSetFourByteTag('m', 'a', 'x', 'p') |
| 23 | |
| 24 | static const struct TagSize { |
| 25 | SkFontTableTag fTag; |
| 26 | size_t fSize; |
| 27 | } gKnownTableSizes[] = { |
| 28 | { kFontTableTag_head, 54 }, |
| 29 | { kFontTableTag_hhea, 36 }, |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 30 | }; |
| 31 | |
reed@google.com | a262eea | 2013-03-21 15:20:00 +0000 | [diff] [blame] | 32 | // Test that getUnitsPerEm() agrees with a direct lookup in the 'head' table |
bungeman@google.com | 7bdd614 | 2013-07-15 19:42:57 +0000 | [diff] [blame] | 33 | // (if that table is available). |
reed@google.com | 4b2af9c | 2012-07-31 17:24:44 +0000 | [diff] [blame] | 34 | static void test_unitsPerEm(skiatest::Reporter* reporter, SkTypeface* face) { |
bungeman@google.com | 7bdd614 | 2013-07-15 19:42:57 +0000 | [diff] [blame] | 35 | int nativeUPEM = face->getUnitsPerEm(); |
reed@google.com | 4b2af9c | 2012-07-31 17:24:44 +0000 | [diff] [blame] | 36 | |
reed@google.com | a262eea | 2013-03-21 15:20:00 +0000 | [diff] [blame] | 37 | int tableUPEM = -1; |
reed@google.com | 4b2af9c | 2012-07-31 17:24:44 +0000 | [diff] [blame] | 38 | size_t size = face->getTableSize(kFontTableTag_head); |
| 39 | if (size) { |
reed@google.com | 4b2af9c | 2012-07-31 17:24:44 +0000 | [diff] [blame] | 40 | // unitsPerEm is at offset 18 into the 'head' table. |
bungeman@google.com | 7bdd614 | 2013-07-15 19:42:57 +0000 | [diff] [blame] | 41 | uint16_t rawUPEM; |
| 42 | face->getTableData(kFontTableTag_head, 18, sizeof(rawUPEM), &rawUPEM); |
| 43 | tableUPEM = SkEndian_SwapBE16(rawUPEM); |
reed@google.com | a262eea | 2013-03-21 15:20:00 +0000 | [diff] [blame] | 44 | } |
reed@google.com | a262eea | 2013-03-21 15:20:00 +0000 | [diff] [blame] | 45 | |
| 46 | if (tableUPEM >= 0) { |
| 47 | REPORTER_ASSERT(reporter, tableUPEM == nativeUPEM); |
reed@google.com | 4b2af9c | 2012-07-31 17:24:44 +0000 | [diff] [blame] | 48 | } |
| 49 | } |
| 50 | |
bungeman@google.com | 7bdd614 | 2013-07-15 19:42:57 +0000 | [diff] [blame] | 51 | // Test that countGlyphs() agrees with a direct lookup in the 'maxp' table |
| 52 | // (if that table is available). |
| 53 | static void test_countGlyphs(skiatest::Reporter* reporter, SkTypeface* face) { |
| 54 | int nativeGlyphs = face->countGlyphs(); |
| 55 | |
| 56 | int tableGlyphs = -1; |
| 57 | size_t size = face->getTableSize(kFontTableTag_maxp); |
| 58 | if (size) { |
| 59 | // glyphs is at offset 4 into the 'maxp' table. |
| 60 | uint16_t rawGlyphs; |
| 61 | face->getTableData(kFontTableTag_maxp, 4, sizeof(rawGlyphs), &rawGlyphs); |
| 62 | tableGlyphs = SkEndian_SwapBE16(rawGlyphs); |
| 63 | } |
| 64 | |
| 65 | if (tableGlyphs >= 0) { |
| 66 | REPORTER_ASSERT(reporter, tableGlyphs == nativeGlyphs); |
bungeman@google.com | 7bdd614 | 2013-07-15 19:42:57 +0000 | [diff] [blame] | 67 | } |
| 68 | } |
bungeman@google.com | 72b8cb2 | 2013-10-25 17:49:08 +0000 | [diff] [blame] | 69 | |
bungeman@google.com | 3c996f8 | 2013-10-24 21:39:35 +0000 | [diff] [blame] | 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, 0xD7, 0x95, 0xF0, 0x9D, 0x84, 0x9E, 0x61 }; |
| 72 | static uint16_t utf16Chars[] = { 0x0061, 0x4E2D, 0x042F, 0x05D9, 0x05D5, 0xD834, 0xDD1E, 0x0061 }; |
| 73 | static uint32_t utf32Chars[] = { 0x00000061, 0x00004E2D, 0x0000042F, 0x000005D9, 0x000005D5, 0x0001D11E, 0x00000061 }; |
| 74 | |
| 75 | struct CharsToGlyphs_TestData { |
| 76 | const void* chars; |
| 77 | int charCount; |
| 78 | size_t charsByteLength; |
| 79 | SkTypeface::Encoding typefaceEncoding; |
| 80 | const char* name; |
| 81 | } static charsToGlyphs_TestData[] = { |
| 82 | { utf8Chars, 7, sizeof(utf8Chars), SkTypeface::kUTF8_Encoding, "Simple UTF-8" }, |
| 83 | { utf16Chars, 7, sizeof(utf16Chars), SkTypeface::kUTF16_Encoding, "Simple UTF-16" }, |
| 84 | { utf32Chars, 7, sizeof(utf32Chars), SkTypeface::kUTF32_Encoding, "Simple UTF-32" }, |
| 85 | }; |
| 86 | |
| 87 | // Test that SkPaint::textToGlyphs agrees with SkTypeface::charsToGlyphs. |
| 88 | static void test_charsToGlyphs(skiatest::Reporter* reporter, SkTypeface* face) { |
| 89 | uint16_t paintGlyphIds[256]; |
| 90 | uint16_t faceGlyphIds[256]; |
| 91 | |
| 92 | for (size_t testIndex = 0; testIndex < SK_ARRAY_COUNT(charsToGlyphs_TestData); ++testIndex) { |
| 93 | CharsToGlyphs_TestData& test = charsToGlyphs_TestData[testIndex]; |
| 94 | |
| 95 | SkPaint paint; |
| 96 | paint.setTypeface(face); |
| 97 | paint.setTextEncoding((SkPaint::TextEncoding)test.typefaceEncoding); |
| 98 | paint.textToGlyphs(test.chars, test.charsByteLength, paintGlyphIds); |
| 99 | |
| 100 | face->charsToGlyphs(test.chars, test.typefaceEncoding, faceGlyphIds, test.charCount); |
| 101 | |
| 102 | for (int i = 0; i < test.charCount; ++i) { |
| 103 | SkString name; |
| 104 | face->getFamilyName(&name); |
| 105 | SkString a; |
skia.committer@gmail.com | 7dc4fd0 | 2013-10-25 07:02:14 +0000 | [diff] [blame] | 106 | a.appendf("%s, paintGlyphIds[%d] = %d, faceGlyphIds[%d] = %d, face = %s", |
bungeman@google.com | 3c996f8 | 2013-10-24 21:39:35 +0000 | [diff] [blame] | 107 | test.name, i, (int)paintGlyphIds[i], i, (int)faceGlyphIds[i], name.c_str()); |
| 108 | REPORTER_ASSERT_MESSAGE(reporter, paintGlyphIds[i] == faceGlyphIds[i], a.c_str()); |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
reed@google.com | ed268bf | 2013-03-11 20:13:36 +0000 | [diff] [blame] | 113 | static void test_fontstream(skiatest::Reporter* reporter, |
| 114 | SkStream* stream, int ttcIndex) { |
| 115 | int n = SkFontStream::GetTableTags(stream, ttcIndex, NULL); |
| 116 | SkAutoTArray<SkFontTableTag> array(n); |
skia.committer@gmail.com | 2e71f16 | 2013-03-12 07:12:32 +0000 | [diff] [blame] | 117 | |
reed@google.com | ed268bf | 2013-03-11 20:13:36 +0000 | [diff] [blame] | 118 | int n2 = SkFontStream::GetTableTags(stream, ttcIndex, array.get()); |
| 119 | REPORTER_ASSERT(reporter, n == n2); |
skia.committer@gmail.com | 2e71f16 | 2013-03-12 07:12:32 +0000 | [diff] [blame] | 120 | |
reed@google.com | ed268bf | 2013-03-11 20:13:36 +0000 | [diff] [blame] | 121 | for (int i = 0; i < n; ++i) { |
| 122 | #ifdef DUMP_TTC_TABLES |
| 123 | SkString str; |
| 124 | SkFontTableTag t = array[i]; |
| 125 | str.appendUnichar((t >> 24) & 0xFF); |
| 126 | str.appendUnichar((t >> 16) & 0xFF); |
| 127 | str.appendUnichar((t >> 8) & 0xFF); |
| 128 | str.appendUnichar((t >> 0) & 0xFF); |
| 129 | SkDebugf("[%d:%d] '%s'\n", ttcIndex, i, str.c_str()); |
| 130 | #endif |
| 131 | size_t size = SkFontStream::GetTableSize(stream, ttcIndex, array[i]); |
| 132 | for (size_t j = 0; j < SK_ARRAY_COUNT(gKnownTableSizes); ++j) { |
| 133 | if (gKnownTableSizes[j].fTag == array[i]) { |
| 134 | REPORTER_ASSERT(reporter, gKnownTableSizes[j].fSize == size); |
| 135 | } |
skia.committer@gmail.com | 2e71f16 | 2013-03-12 07:12:32 +0000 | [diff] [blame] | 136 | } |
reed@google.com | ed268bf | 2013-03-11 20:13:36 +0000 | [diff] [blame] | 137 | } |
| 138 | } |
| 139 | |
| 140 | static void test_fontstream(skiatest::Reporter* reporter, SkStream* stream) { |
| 141 | int count = SkFontStream::CountTTCEntries(stream); |
| 142 | #ifdef DUMP_TTC_TABLES |
| 143 | SkDebugf("CountTTCEntries %d\n", count); |
| 144 | #endif |
| 145 | for (int i = 0; i < count; ++i) { |
| 146 | test_fontstream(reporter, stream, i); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | static void test_fontstream(skiatest::Reporter* reporter) { |
bungeman@google.com | 3c996f8 | 2013-10-24 21:39:35 +0000 | [diff] [blame] | 151 | // This test cannot run if there is no resource path. |
tfarina | bcbc178 | 2014-06-18 14:32:48 -0700 | [diff] [blame] | 152 | SkString resourcePath = GetResourcePath(); |
bungeman@google.com | 3c996f8 | 2013-10-24 21:39:35 +0000 | [diff] [blame] | 153 | if (resourcePath.isEmpty()) { |
| 154 | SkDebugf("Could not run fontstream test because resourcePath not specified."); |
| 155 | return; |
| 156 | } |
tfarina | a8e2e15 | 2014-07-28 19:26:58 -0700 | [diff] [blame] | 157 | SkString filename = SkOSPath::Join(resourcePath.c_str(), "test.ttc"); |
bungeman@google.com | 3c996f8 | 2013-10-24 21:39:35 +0000 | [diff] [blame] | 158 | |
| 159 | SkFILEStream stream(filename.c_str()); |
reed@google.com | ed268bf | 2013-03-11 20:13:36 +0000 | [diff] [blame] | 160 | if (stream.isValid()) { |
| 161 | test_fontstream(reporter, &stream); |
bungeman@google.com | 3c996f8 | 2013-10-24 21:39:35 +0000 | [diff] [blame] | 162 | } else { |
| 163 | SkDebugf("Could not run fontstream test because test.ttc not found."); |
reed@google.com | ed268bf | 2013-03-11 20:13:36 +0000 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 167 | static void test_tables(skiatest::Reporter* reporter, SkTypeface* face) { |
caryclark@google.com | 42639cd | 2012-06-06 12:03:39 +0000 | [diff] [blame] | 168 | if (false) { // avoid bit rot, suppress warning |
robertphillips@google.com | 5b33211 | 2013-01-30 20:33:12 +0000 | [diff] [blame] | 169 | SkFontID fontID = face->uniqueID(); |
caryclark@google.com | 42639cd | 2012-06-06 12:03:39 +0000 | [diff] [blame] | 170 | REPORTER_ASSERT(reporter, fontID); |
| 171 | } |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 172 | |
reed@google.com | 8b0a335 | 2012-04-19 18:52:39 +0000 | [diff] [blame] | 173 | int count = face->countTables(); |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 174 | |
| 175 | SkAutoTMalloc<SkFontTableTag> storage(count); |
| 176 | SkFontTableTag* tags = storage.get(); |
reed@google.com | fbd033d | 2012-02-23 16:15:58 +0000 | [diff] [blame] | 177 | |
reed@google.com | 8b0a335 | 2012-04-19 18:52:39 +0000 | [diff] [blame] | 178 | int count2 = face->getTableTags(tags); |
reed@google.com | fbd033d | 2012-02-23 16:15:58 +0000 | [diff] [blame] | 179 | REPORTER_ASSERT(reporter, count2 == count); |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 180 | |
| 181 | for (int i = 0; i < count; ++i) { |
reed@google.com | 8b0a335 | 2012-04-19 18:52:39 +0000 | [diff] [blame] | 182 | size_t size = face->getTableSize(tags[i]); |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 183 | REPORTER_ASSERT(reporter, size > 0); |
| 184 | |
| 185 | #ifdef DUMP_TABLES |
| 186 | char name[5]; |
| 187 | name[0] = (tags[i] >> 24) & 0xFF; |
| 188 | name[1] = (tags[i] >> 16) & 0xFF; |
| 189 | name[2] = (tags[i] >> 8) & 0xFF; |
| 190 | name[3] = (tags[i] >> 0) & 0xFF; |
| 191 | name[4] = 0; |
| 192 | SkDebugf("%s %d\n", name, size); |
| 193 | #endif |
| 194 | |
| 195 | for (size_t j = 0; j < SK_ARRAY_COUNT(gKnownTableSizes); ++j) { |
| 196 | if (gKnownTableSizes[j].fTag == tags[i]) { |
| 197 | REPORTER_ASSERT(reporter, gKnownTableSizes[j].fSize == size); |
| 198 | } |
| 199 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 200 | |
reed@google.com | fbd033d | 2012-02-23 16:15:58 +0000 | [diff] [blame] | 201 | // do we get the same size from GetTableData and GetTableSize |
| 202 | { |
| 203 | SkAutoMalloc data(size); |
reed@google.com | 8b0a335 | 2012-04-19 18:52:39 +0000 | [diff] [blame] | 204 | size_t size2 = face->getTableData(tags[i], 0, size, data.get()); |
reed@google.com | fbd033d | 2012-02-23 16:15:58 +0000 | [diff] [blame] | 205 | REPORTER_ASSERT(reporter, size2 == size); |
| 206 | } |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 207 | } |
| 208 | } |
| 209 | |
| 210 | static void test_tables(skiatest::Reporter* reporter) { |
| 211 | static const char* const gNames[] = { |
| 212 | NULL, // default font |
| 213 | "Arial", "Times", "Times New Roman", "Helvetica", "Courier", |
bungeman@google.com | c0d3f2f | 2012-07-31 21:39:05 +0000 | [diff] [blame] | 214 | "Courier New", "Terminal", "MS Sans Serif", |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 215 | }; |
| 216 | |
| 217 | for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); ++i) { |
bungeman@google.com | 3c996f8 | 2013-10-24 21:39:35 +0000 | [diff] [blame] | 218 | SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(gNames[i], SkTypeface::kNormal)); |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 219 | if (face) { |
| 220 | #ifdef DUMP_TABLES |
| 221 | SkDebugf("%s\n", gNames[i]); |
| 222 | #endif |
| 223 | test_tables(reporter, face); |
reed@google.com | 4b2af9c | 2012-07-31 17:24:44 +0000 | [diff] [blame] | 224 | test_unitsPerEm(reporter, face); |
bungeman@google.com | 7bdd614 | 2013-07-15 19:42:57 +0000 | [diff] [blame] | 225 | test_countGlyphs(reporter, face); |
bungeman@google.com | 72b8cb2 | 2013-10-25 17:49:08 +0000 | [diff] [blame] | 226 | test_charsToGlyphs(reporter, face); |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 227 | } |
| 228 | } |
| 229 | } |
| 230 | |
bungeman@google.com | 34f1026 | 2012-03-23 18:11:47 +0000 | [diff] [blame] | 231 | /* |
| 232 | * Verifies that the advance values returned by generateAdvance and |
| 233 | * generateMetrics match. |
| 234 | */ |
| 235 | static void test_advances(skiatest::Reporter* reporter) { |
| 236 | static const char* const faces[] = { |
| 237 | NULL, // default font |
| 238 | "Arial", "Times", "Times New Roman", "Helvetica", "Courier", |
| 239 | "Courier New", "Verdana", "monospace", |
| 240 | }; |
| 241 | |
| 242 | static const struct { |
| 243 | SkPaint::Hinting hinting; |
| 244 | unsigned flags; |
| 245 | } settings[] = { |
| 246 | { SkPaint::kNo_Hinting, 0 }, |
| 247 | { SkPaint::kNo_Hinting, SkPaint::kLinearText_Flag }, |
| 248 | { SkPaint::kNo_Hinting, SkPaint::kSubpixelText_Flag }, |
| 249 | { SkPaint::kSlight_Hinting, 0 }, |
| 250 | { SkPaint::kSlight_Hinting, SkPaint::kLinearText_Flag }, |
| 251 | { SkPaint::kSlight_Hinting, SkPaint::kSubpixelText_Flag }, |
| 252 | { SkPaint::kNormal_Hinting, 0 }, |
| 253 | { SkPaint::kNormal_Hinting, SkPaint::kLinearText_Flag }, |
| 254 | { SkPaint::kNormal_Hinting, SkPaint::kSubpixelText_Flag }, |
| 255 | }; |
| 256 | |
reed@google.com | d074c37 | 2012-07-18 13:45:58 +0000 | [diff] [blame] | 257 | static const struct { |
| 258 | SkScalar fScaleX; |
| 259 | SkScalar fSkewX; |
| 260 | } gScaleRec[] = { |
| 261 | { SK_Scalar1, 0 }, |
| 262 | { SK_Scalar1/2, 0 }, |
| 263 | // these two exercise obliquing (skew) |
| 264 | { SK_Scalar1, -SK_Scalar1/4 }, |
| 265 | { SK_Scalar1/2, -SK_Scalar1/4 }, |
| 266 | }; |
| 267 | |
bungeman@google.com | 34f1026 | 2012-03-23 18:11:47 +0000 | [diff] [blame] | 268 | SkPaint paint; |
| 269 | char txt[] = "long.text.with.lots.of.dots."; |
| 270 | |
| 271 | for (size_t i = 0; i < SK_ARRAY_COUNT(faces); i++) { |
bungeman@google.com | 9447103 | 2013-02-25 15:55:13 +0000 | [diff] [blame] | 272 | SkAutoTUnref<SkTypeface> face(SkTypeface::CreateFromName(faces[i], SkTypeface::kNormal)); |
bungeman@google.com | 34f1026 | 2012-03-23 18:11:47 +0000 | [diff] [blame] | 273 | paint.setTypeface(face); |
| 274 | |
| 275 | for (size_t j = 0; j < SK_ARRAY_COUNT(settings); j++) { |
reed@google.com | d074c37 | 2012-07-18 13:45:58 +0000 | [diff] [blame] | 276 | paint.setHinting(settings[j].hinting); |
| 277 | paint.setLinearText((settings[j].flags & SkPaint::kLinearText_Flag) != 0); |
| 278 | paint.setSubpixelText((settings[j].flags & SkPaint::kSubpixelText_Flag) != 0); |
bungeman@google.com | 34f1026 | 2012-03-23 18:11:47 +0000 | [diff] [blame] | 279 | |
reed@google.com | d074c37 | 2012-07-18 13:45:58 +0000 | [diff] [blame] | 280 | for (size_t k = 0; k < SK_ARRAY_COUNT(gScaleRec); ++k) { |
| 281 | paint.setTextScaleX(gScaleRec[k].fScaleX); |
| 282 | paint.setTextSkewX(gScaleRec[k].fSkewX); |
bungeman@google.com | 34f1026 | 2012-03-23 18:11:47 +0000 | [diff] [blame] | 283 | |
reed@google.com | d074c37 | 2012-07-18 13:45:58 +0000 | [diff] [blame] | 284 | SkRect bounds; |
bungeman@google.com | 34f1026 | 2012-03-23 18:11:47 +0000 | [diff] [blame] | 285 | |
reed@google.com | d074c37 | 2012-07-18 13:45:58 +0000 | [diff] [blame] | 286 | // For no hinting and light hinting this should take the |
| 287 | // optimized generateAdvance path. |
| 288 | SkScalar width1 = paint.measureText(txt, strlen(txt)); |
bungeman@google.com | 34f1026 | 2012-03-23 18:11:47 +0000 | [diff] [blame] | 289 | |
reed@google.com | d074c37 | 2012-07-18 13:45:58 +0000 | [diff] [blame] | 290 | // Requesting the bounds forces a generateMetrics call. |
| 291 | SkScalar width2 = paint.measureText(txt, strlen(txt), &bounds); |
bungeman@google.com | 34f1026 | 2012-03-23 18:11:47 +0000 | [diff] [blame] | 292 | |
reed@google.com | d074c37 | 2012-07-18 13:45:58 +0000 | [diff] [blame] | 293 | // SkDebugf("Font: %s, generateAdvance: %f, generateMetrics: %f\n", |
| 294 | // faces[i], SkScalarToFloat(width1), SkScalarToFloat(width2)); |
| 295 | |
| 296 | REPORTER_ASSERT(reporter, width1 == width2); |
| 297 | } |
bungeman@google.com | 34f1026 | 2012-03-23 18:11:47 +0000 | [diff] [blame] | 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 302 | DEF_TEST(FontHost, reporter) { |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 303 | test_tables(reporter); |
reed@google.com | ed268bf | 2013-03-11 20:13:36 +0000 | [diff] [blame] | 304 | test_fontstream(reporter); |
bungeman@google.com | 34f1026 | 2012-03-23 18:11:47 +0000 | [diff] [blame] | 305 | test_advances(reporter); |
reed@google.com | 17aa07d | 2012-02-23 14:51:10 +0000 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | // need tests for SkStrSearch |