| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkFontConfigParser_android.h" | 9 #include "SkFontConfigParser_android.h" |
| 10 #include "Test.h" | 10 #include "Test.h" |
| 11 | 11 |
| 12 void ValidateLoadedFonts(SkTDArray<FontFamily*> fontFamilies, | 12 void ValidateLoadedFonts(SkTDArray<FontFamily*> fontFamilies, |
| 13 skiatest::Reporter* reporter) { | 13 skiatest::Reporter* reporter) { |
| 14 REPORTER_ASSERT(reporter, fontFamilies[0]->fNames.count() == 5); | 14 REPORTER_ASSERT(reporter, fontFamilies[0]->fNames.count() == 5); |
| 15 REPORTER_ASSERT(reporter, !strcmp(fontFamilies[0]->fNames[0].c_str(), "sans-
serif")); | 15 REPORTER_ASSERT(reporter, !strcmp(fontFamilies[0]->fNames[0].c_str(), "sans-
serif")); |
| 16 REPORTER_ASSERT(reporter, | 16 REPORTER_ASSERT(reporter, |
| 17 !strcmp(fontFamilies[0]->fFontFiles[0].fFileName.c_str(), | 17 !strcmp(fontFamilies[0]->fFonts[0].fFileName.c_str(), |
| 18 "Roboto-Regular.ttf")); | 18 "Roboto-Regular.ttf")); |
| 19 REPORTER_ASSERT(reporter, !fontFamilies[0]->fIsFallbackFont); | 19 REPORTER_ASSERT(reporter, !fontFamilies[0]->fIsFallbackFont); |
| 20 | 20 |
| 21 } | 21 } |
| 22 | 22 |
| 23 void DumpLoadedFonts(SkTDArray<FontFamily*> fontFamilies) { | 23 void DumpLoadedFonts(SkTDArray<FontFamily*> fontFamilies) { |
| 24 #if SK_DEBUG_FONTS | 24 #if SK_DEBUG_FONTS |
| 25 for (int i = 0; i < fontFamilies.count(); ++i) { | 25 for (int i = 0; i < fontFamilies.count(); ++i) { |
| 26 SkDebugf("Family %d:\n", i); | 26 SkDebugf("Family %d:\n", i); |
| 27 switch(fontFamilies[i]->fVariant) { | 27 switch(fontFamilies[i]->fVariant) { |
| 28 case SkPaintOptionsAndroid::kElegant_Variant: SkDebugf(" elegant");
break; | 28 case SkPaintOptionsAndroid::kElegant_Variant: SkDebugf(" elegant");
break; |
| 29 case SkPaintOptionsAndroid::kCompact_Variant: SkDebugf(" compact");
break; | 29 case SkPaintOptionsAndroid::kCompact_Variant: SkDebugf(" compact");
break; |
| 30 default: break; | 30 default: break; |
| 31 } | 31 } |
| 32 if (!fontFamilies[i]->fLanguage.getTag().isEmpty()) { | 32 if (!fontFamilies[i]->fLanguage.getTag().isEmpty()) { |
| 33 SkDebugf(" language: %s", fontFamilies[i]->fLanguage.getTag().c_str
()); | 33 SkDebugf(" language: %s", fontFamilies[i]->fLanguage.getTag().c_str
()); |
| 34 } | 34 } |
| 35 for (int j = 0; j < fontFamilies[i]->fNames.count(); ++j) { | 35 for (int j = 0; j < fontFamilies[i]->fNames.count(); ++j) { |
| 36 SkDebugf(" name %s\n", fontFamilies[i]->fNames[j].c_str()); | 36 SkDebugf(" name %s\n", fontFamilies[i]->fNames[j].c_str()); |
| 37 } | 37 } |
| 38 for (int j = 0; j < fontFamilies[i]->fFontFiles.count(); ++j) { | 38 for (int j = 0; j < fontFamilies[i]->fFonts.count(); ++j) { |
| 39 const FontFileInfo& ffi = fontFamilies[i]->fFontFiles[j]; | 39 const FontFileInfo& ffi = fontFamilies[i]->fFonts[j]; |
| 40 SkDebugf(" file (%d %s %d) %s\n", | 40 SkDebugf(" file (%d %s %d) %s\n", |
| 41 ffi.fWeight, | 41 ffi.fWeight, |
| 42 ffi.fPaintOptions.getLanguage().getTag().isEmpty() ? "" : | 42 ffi.fPaintOptions.getLanguage().getTag().isEmpty() ? "" : |
| 43 ffi.fPaintOptions.getLanguage().getTag().c_str(), | 43 ffi.fPaintOptions.getLanguage().getTag().c_str(), |
| 44 ffi.fPaintOptions.getFontVariant(), | 44 ffi.fPaintOptions.getFontVariant(), |
| 45 ffi.fFileName.c_str()); | 45 ffi.fFileName.c_str()); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 #endif // SK_DEBUG_FONTS | 48 #endif // SK_DEBUG_FONTS |
| 49 } | 49 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 ValidateLoadedFonts(v22FontFamilies, reporter); | 94 ValidateLoadedFonts(v22FontFamilies, reporter); |
| 95 } else { | 95 } else { |
| 96 resourcesMissing = true; | 96 resourcesMissing = true; |
| 97 } | 97 } |
| 98 | 98 |
| 99 if (resourcesMissing) { | 99 if (resourcesMissing) { |
| 100 SkDebugf("---- Resource files missing for FontConfigParser test\n"); | 100 SkDebugf("---- Resource files missing for FontConfigParser test\n"); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| OLD | NEW |