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 "SkCommandLineFlags.h" | 8 #include "SkCommandLineFlags.h" |
9 #include "SkFontMgr.h" | 9 #include "SkFontMgr.h" |
10 #include "SkOTTable_name.h" | 10 #include "SkOTTable_name.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); | 145 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
146 int count = SkMin32(fm->countFamilies(), MAX_FAMILIES); | 146 int count = SkMin32(fm->countFamilies(), MAX_FAMILIES); |
147 for (int i = 0; i < count; ++i) { | 147 for (int i = 0; i < count; ++i) { |
148 SkAutoTUnref<SkFontStyleSet> set(fm->createStyleSet(i)); | 148 SkAutoTUnref<SkFontStyleSet> set(fm->createStyleSet(i)); |
149 for (int j = 0; j < set->count(); ++j) { | 149 for (int j = 0; j < set->count(); ++j) { |
150 SkString sname; | 150 SkString sname; |
151 SkFontStyle fs; | 151 SkFontStyle fs; |
152 set->getStyle(j, &fs, &sname); | 152 set->getStyle(j, &fs, &sname); |
153 | 153 |
154 SkAutoTUnref<SkTypeface> typeface(set->createTypeface(j)); | 154 SkAutoTUnref<SkTypeface> typeface(set->createTypeface(j)); |
155 if (NULL == typeface.get()) { | |
156 //TODO: SkFontMgr_fontconfig always returns NULL? | |
157 continue; | |
158 } | |
159 | 155 |
160 SkString familyName; | 156 SkString familyName; |
161 typeface->getFamilyName(&familyName); | 157 typeface->getFamilyName(&familyName); |
162 if (verbose) { | 158 if (verbose) { |
163 SkDebugf("[%s]\n", familyName.c_str()); | 159 SkDebugf("[%s]\n", familyName.c_str()); |
164 } | 160 } |
165 | 161 |
166 SkAutoTUnref<SkTypeface::LocalizedStrings> familyNamesIter( | 162 SkAutoTUnref<SkTypeface::LocalizedStrings> familyNamesIter( |
167 typeface->createFamilyNameIterator()); | 163 typeface->createFamilyNameIterator()); |
168 SkTypeface::LocalizedString familyNameLocalized; | 164 SkTypeface::LocalizedString familyNameLocalized; |
169 while (familyNamesIter->next(&familyNameLocalized)) { | 165 while (familyNamesIter->next(&familyNameLocalized)) { |
170 if (verbose) { | 166 if (verbose) { |
171 SkDebugf("(%s) <%s>\n", familyNameLocalized.fString.c_str(), | 167 SkDebugf("(%s) <%s>\n", familyNameLocalized.fString.c_str(), |
172 familyNameLocalized.fLanguage.c_str())
; | 168 familyNameLocalized.fLanguage.c_str(
)); |
173 } | 169 } |
174 } | 170 } |
175 | 171 |
176 size_t nameTableSize = typeface->getTableSize(nameTag); | 172 size_t nameTableSize = typeface->getTableSize(nameTag); |
177 if (0 == nameTableSize) { | 173 if (0 == nameTableSize) { |
178 continue; | 174 continue; |
179 } | 175 } |
180 SkAutoTMalloc<uint8_t> nameTableData(nameTableSize); | 176 SkAutoTMalloc<uint8_t> nameTableData(nameTableSize); |
181 size_t copied = typeface->getTableData(nameTag, 0, nameTableSize, na
meTableData.get()); | 177 size_t copied = typeface->getTableData(nameTag, 0, nameTableSize, na
meTableData.get()); |
182 if (copied != nameTableSize) { | 178 if (copied != nameTableSize) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 210 } |
215 } | 211 } |
216 } | 212 } |
217 | 213 |
218 DEFINE_bool(verboseFontNames, false, "verbose FontNames test."); | 214 DEFINE_bool(verboseFontNames, false, "verbose FontNames test."); |
219 | 215 |
220 DEF_TEST(FontNames, reporter) { | 216 DEF_TEST(FontNames, reporter) { |
221 test_synthetic(reporter, FLAGS_verboseFontNames); | 217 test_synthetic(reporter, FLAGS_verboseFontNames); |
222 test_systemfonts(reporter, FLAGS_verboseFontNames); | 218 test_systemfonts(reporter, FLAGS_verboseFontNames); |
223 } | 219 } |
OLD | NEW |