| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 | 9 |
| 10 #include "SkCommandLineFlags.h" | 10 #include "SkCommandLineFlags.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 SkAutoTUnref<SkTypeface> typeface(set->createTypeface(j)); | 155 SkAutoTUnref<SkTypeface> typeface(set->createTypeface(j)); |
| 156 if (NULL == typeface.get()) { | 156 if (NULL == typeface.get()) { |
| 157 //TODO: SkFontMgr_fontconfig always returns NULL? | 157 //TODO: SkFontMgr_fontconfig always returns NULL? |
| 158 continue; | 158 continue; |
| 159 } | 159 } |
| 160 | 160 |
| 161 SkString familyName; | 161 SkString familyName; |
| 162 typeface->getFamilyName(&familyName); | 162 typeface->getFamilyName(&familyName); |
| 163 if (verbose) { | 163 if (verbose) { |
| 164 printf("[%s]\n", familyName.c_str()); | 164 SkDebugf("[%s]\n", familyName.c_str()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 SkAutoTUnref<SkTypeface::LocalizedStrings> familyNamesIter( | 167 SkAutoTUnref<SkTypeface::LocalizedStrings> familyNamesIter( |
| 168 typeface->createFamilyNameIterator()); | 168 typeface->createFamilyNameIterator()); |
| 169 SkTypeface::LocalizedString familyNameLocalized; | 169 SkTypeface::LocalizedString familyNameLocalized; |
| 170 while (familyNamesIter->next(&familyNameLocalized)) { | 170 while (familyNamesIter->next(&familyNameLocalized)) { |
| 171 if (verbose) { | 171 if (verbose) { |
| 172 printf("(%s) <%s>\n", familyNameLocalized.fString.c_str(), | 172 SkDebugf("(%s) <%s>\n", familyNameLocalized.fString.c_str(), |
| 173 familyNameLocalized.fLanguage.c_str())
; | 173 familyNameLocalized.fLanguage.c_str())
; |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 | 176 |
| 177 size_t nameTableSize = typeface->getTableSize(nameTag); | 177 size_t nameTableSize = typeface->getTableSize(nameTag); |
| 178 if (0 == nameTableSize) { | 178 if (0 == nameTableSize) { |
| 179 continue; | 179 continue; |
| 180 } | 180 } |
| 181 SkAutoTMalloc<uint8_t> nameTableData(nameTableSize); | 181 SkAutoTMalloc<uint8_t> nameTableData(nameTableSize); |
| 182 size_t copied = typeface->getTableData(nameTag, 0, nameTableSize, na
meTableData.get()); | 182 size_t copied = typeface->getTableData(nameTag, 0, nameTableSize, na
meTableData.get()); |
| 183 if (copied != nameTableSize) { | 183 if (copied != nameTableSize) { |
| 184 continue; | 184 continue; |
| 185 } | 185 } |
| 186 | 186 |
| 187 SkOTTableName::Iterator::Record record; | 187 SkOTTableName::Iterator::Record record; |
| 188 SkOTTableName::Iterator familyNameIter(*((SkOTTableName*)nameTableDa
ta.get()), | 188 SkOTTableName::Iterator familyNameIter(*((SkOTTableName*)nameTableDa
ta.get()), |
| 189 SkOTTableName::Record::NameID::Predefined::FontFamilyName); | 189 SkOTTableName::Record::NameID::Predefined::FontFamilyName); |
| 190 while (familyNameIter.next(record)) { | 190 while (familyNameIter.next(record)) { |
| 191 REPORTER_ASSERT_MESSAGE(reporter, | 191 REPORTER_ASSERT_MESSAGE(reporter, |
| 192 SkOTTableName::Record::NameID::Predefined::FontFamilyName ==
record.type, | 192 SkOTTableName::Record::NameID::Predefined::FontFamilyName ==
record.type, |
| 193 "Requested family name, got something else." | 193 "Requested family name, got something else." |
| 194 ); | 194 ); |
| 195 if (verbose) { | 195 if (verbose) { |
| 196 printf("{%s} <%s>\n", record.name.c_str(), record.language.c
_str()); | 196 SkDebugf("{%s} <%s>\n", record.name.c_str(), record.language
.c_str()); |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 SkOTTableName::Iterator styleNameIter(*((SkOTTableName*)nameTableDat
a.get()), | 200 SkOTTableName::Iterator styleNameIter(*((SkOTTableName*)nameTableDat
a.get()), |
| 201 SkOTTableName::Record::NameID::Predefined::FontSubfamilyName); | 201 SkOTTableName::Record::NameID::Predefined::FontSubfamilyName); |
| 202 while (styleNameIter.next(record)) { | 202 while (styleNameIter.next(record)) { |
| 203 REPORTER_ASSERT_MESSAGE(reporter, | 203 REPORTER_ASSERT_MESSAGE(reporter, |
| 204 SkOTTableName::Record::NameID::Predefined::FontSubfamilyName
== record.type, | 204 SkOTTableName::Record::NameID::Predefined::FontSubfamilyName
== record.type, |
| 205 "Requested subfamily name, got something else." | 205 "Requested subfamily name, got something else." |
| 206 ); | 206 ); |
| 207 if (verbose) { | 207 if (verbose) { |
| 208 printf("{{%s}} <%s>\n", record.name.c_str(), record.language
.c_str()); | 208 SkDebugf("{{%s}} <%s>\n", record.name.c_str(), record.langua
ge.c_str()); |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 | 211 |
| 212 if (verbose) { | 212 if (verbose) { |
| 213 printf("\n"); | 213 SkDebugf("\n"); |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 DEFINE_bool(verboseFontNames, false, "verbose FontNames test."); | 219 DEFINE_bool(verboseFontNames, false, "verbose FontNames test."); |
| 220 | 220 |
| 221 static void TestFontNames(skiatest::Reporter* reporter) { | 221 static void TestFontNames(skiatest::Reporter* reporter) { |
| 222 test_synthetic(reporter, FLAGS_verboseFontNames); | 222 test_synthetic(reporter, FLAGS_verboseFontNames); |
| 223 test_systemfonts(reporter, FLAGS_verboseFontNames); | 223 test_systemfonts(reporter, FLAGS_verboseFontNames); |
| 224 } | 224 } |
| 225 | 225 |
| 226 #include "TestClassDef.h" | 226 #include "TestClassDef.h" |
| 227 DEFINE_TESTCLASS("FontNames", FontNamesTestClass, TestFontNames) | 227 DEFINE_TESTCLASS("FontNames", FontNamesTestClass, TestFontNames) |
| OLD | NEW |