| 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 "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
| 10 #include "SkFontConfigParser_android.h" | 10 #include "SkFontConfigParser_android.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 SkDebugf(" language %s\n", fontFamilies[i]->fLanguage.getTag().c_st
r()); | 48 SkDebugf(" language %s\n", fontFamilies[i]->fLanguage.getTag().c_st
r()); |
| 49 } | 49 } |
| 50 for (int j = 0; j < fontFamilies[i]->fNames.count(); ++j) { | 50 for (int j = 0; j < fontFamilies[i]->fNames.count(); ++j) { |
| 51 SkDebugf(" name %s\n", fontFamilies[i]->fNames[j].c_str()); | 51 SkDebugf(" name %s\n", fontFamilies[i]->fNames[j].c_str()); |
| 52 } | 52 } |
| 53 for (int j = 0; j < fontFamilies[i]->fFonts.count(); ++j) { | 53 for (int j = 0; j < fontFamilies[i]->fFonts.count(); ++j) { |
| 54 const FontFileInfo& ffi = fontFamilies[i]->fFonts[j]; | 54 const FontFileInfo& ffi = fontFamilies[i]->fFonts[j]; |
| 55 SkDebugf(" file (%d) %s#%d\n", ffi.fWeight, ffi.fFileName.c_str(),
ffi.fIndex); | 55 SkDebugf(" file (%d) %s#%d\n", ffi.fWeight, ffi.fFileName.c_str(),
ffi.fIndex); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 SkDebugf("\n\n"); |
| 58 } | 59 } |
| 59 | 60 |
| 60 DEF_TEST(FontConfigParserAndroid, reporter) { | 61 DEF_TEST(FontConfigParserAndroid, reporter) { |
| 61 | 62 |
| 62 bool resourcesMissing = false; | 63 bool resourcesMissing = false; |
| 63 | 64 |
| 64 SkTDArray<FontFamily*> preV17FontFamilies; | 65 SkTDArray<FontFamily*> preV17FontFamilies; |
| 65 SkFontConfigParser::GetCustomFontFamilies(preV17FontFamilies, | 66 SkFontConfigParser::GetCustomFontFamilies(preV17FontFamilies, |
| 66 SkString("/custom/font/path/"), | 67 SkString("/custom/font/path/"), |
| 67 GetResourcePath("android_fonts/pre_v17/system_fonts.xml").c_str(), | 68 GetResourcePath("android_fonts/pre_v17/system_fonts.xml").c_str(), |
| 68 GetResourcePath("android_fonts/pre_v17/fallback_fonts.xml").c_str()); | 69 GetResourcePath("android_fonts/pre_v17/fallback_fonts.xml").c_str(), |
| 70 NULL); |
| 69 | 71 |
| 70 if (preV17FontFamilies.count() > 0) { | 72 if (preV17FontFamilies.count() > 0) { |
| 71 REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14); | 73 REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14); |
| 72 REPORTER_ASSERT(reporter, CountFallbacks(preV17FontFamilies) == 10); | 74 REPORTER_ASSERT(reporter, CountFallbacks(preV17FontFamilies) == 10); |
| 73 | 75 |
| 74 DumpLoadedFonts(preV17FontFamilies); | 76 DumpLoadedFonts(preV17FontFamilies); |
| 75 ValidateLoadedFonts(preV17FontFamilies, "Roboto-Regular.ttf", reporter); | 77 ValidateLoadedFonts(preV17FontFamilies, "Roboto-Regular.ttf", reporter); |
| 76 } else { | 78 } else { |
| 77 resourcesMissing = true; | 79 resourcesMissing = true; |
| 78 } | 80 } |
| 79 | 81 |
| 80 | 82 |
| 81 SkTDArray<FontFamily*> v17FontFamilies; | 83 SkTDArray<FontFamily*> v17FontFamilies; |
| 82 SkFontConfigParser::GetCustomFontFamilies(v17FontFamilies, | 84 SkFontConfigParser::GetCustomFontFamilies(v17FontFamilies, |
| 83 SkString("/custom/font/path/"), | 85 SkString("/custom/font/path/"), |
| 84 GetResourcePath("android_fonts/v17/system_fonts.xml").c_str(), | 86 GetResourcePath("android_fonts/v17/system_fonts.xml").c_str(), |
| 85 GetResourcePath("android_fonts/v17/fallback_fonts.xml").c_str()); | 87 GetResourcePath("android_fonts/v17/fallback_fonts.xml").c_str(), |
| 88 GetResourcePath("android_fonts/v17").c_str()); |
| 86 | 89 |
| 87 if (v17FontFamilies.count() > 0) { | 90 if (v17FontFamilies.count() > 0) { |
| 88 REPORTER_ASSERT(reporter, v17FontFamilies.count() == 41); | 91 REPORTER_ASSERT(reporter, v17FontFamilies.count() == 56); |
| 89 REPORTER_ASSERT(reporter, CountFallbacks(v17FontFamilies) == 31); | 92 REPORTER_ASSERT(reporter, CountFallbacks(v17FontFamilies) == 46); |
| 90 | 93 |
| 91 DumpLoadedFonts(v17FontFamilies); | 94 DumpLoadedFonts(v17FontFamilies); |
| 92 ValidateLoadedFonts(v17FontFamilies, "Roboto-Regular.ttf", reporter); | 95 ValidateLoadedFonts(v17FontFamilies, "Roboto-Regular.ttf", reporter); |
| 93 } else { | 96 } else { |
| 94 resourcesMissing = true; | 97 resourcesMissing = true; |
| 95 } | 98 } |
| 96 | 99 |
| 97 | 100 |
| 98 SkTDArray<FontFamily*> v22FontFamilies; | 101 SkTDArray<FontFamily*> v22FontFamilies; |
| 99 SkFontConfigParser::GetCustomFontFamilies(v22FontFamilies, | 102 SkFontConfigParser::GetCustomFontFamilies(v22FontFamilies, |
| 100 SkString("/custom/font/path/"), | 103 SkString("/custom/font/path/"), |
| 101 GetResourcePath("android_fonts/v22/fonts.xml").c_str(), | 104 GetResourcePath("android_fonts/v22/fonts.xml").c_str(), |
| 105 NULL, |
| 102 NULL); | 106 NULL); |
| 103 | 107 |
| 104 if (v22FontFamilies.count() > 0) { | 108 if (v22FontFamilies.count() > 0) { |
| 105 REPORTER_ASSERT(reporter, v22FontFamilies.count() == 53); | 109 REPORTER_ASSERT(reporter, v22FontFamilies.count() == 53); |
| 106 REPORTER_ASSERT(reporter, CountFallbacks(v22FontFamilies) == 42); | 110 REPORTER_ASSERT(reporter, CountFallbacks(v22FontFamilies) == 42); |
| 107 | 111 |
| 108 DumpLoadedFonts(v22FontFamilies); | 112 DumpLoadedFonts(v22FontFamilies); |
| 109 ValidateLoadedFonts(v22FontFamilies, "Roboto-Thin.ttf", reporter); | 113 ValidateLoadedFonts(v22FontFamilies, "Roboto-Thin.ttf", reporter); |
| 110 } else { | 114 } else { |
| 111 resourcesMissing = true; | 115 resourcesMissing = true; |
| 112 } | 116 } |
| 113 | 117 |
| 114 if (resourcesMissing) { | 118 if (resourcesMissing) { |
| 115 SkDebugf("---- Resource files missing for FontConfigParser test\n"); | 119 SkDebugf("---- Resource files missing for FontConfigParser test\n"); |
| 116 } | 120 } |
| 117 } | 121 } |
| 118 | 122 |
| OLD | NEW |