diff options
11 files changed, 34 insertions, 89 deletions
diff --git a/expectations/gm/Test-Android-Nexus10-MaliT604-Arm7-Debug/expected-results.json b/expectations/gm/Test-Android-Nexus10-MaliT604-Arm7-Debug/expected-results.json index 0cfeaf8278..fc509921fe 100644 --- a/expectations/gm/Test-Android-Nexus10-MaliT604-Arm7-Debug/expected-results.json +++ b/expectations/gm/Test-Android-Nexus10-MaliT604-Arm7-Debug/expected-results.json @@ -6209,7 +6209,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 17276962213970077366 + 15535368433031718847 ] ], "reviewed-by-human": true @@ -6218,7 +6218,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 8694218356938189525 + 17714223495513615914 ] ], "reviewed-by-human": true diff --git a/expectations/gm/Test-Android-Nexus10-MaliT604-Arm7-Release/expected-results.json b/expectations/gm/Test-Android-Nexus10-MaliT604-Arm7-Release/expected-results.json index a9fccd4053..e69c884aef 100644 --- a/expectations/gm/Test-Android-Nexus10-MaliT604-Arm7-Release/expected-results.json +++ b/expectations/gm/Test-Android-Nexus10-MaliT604-Arm7-Release/expected-results.json @@ -6209,7 +6209,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 17276962213970077366 + 15535368433031718847 ] ], "reviewed-by-human": true @@ -6218,7 +6218,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 8694218356938189525 + 17714223495513615914 ] ], "reviewed-by-human": true diff --git a/expectations/gm/Test-Android-Nexus5-Adreno330-Arm7-Debug/expected-results.json b/expectations/gm/Test-Android-Nexus5-Adreno330-Arm7-Debug/expected-results.json index 9b639b0d95..d0f266c05d 100644 --- a/expectations/gm/Test-Android-Nexus5-Adreno330-Arm7-Debug/expected-results.json +++ b/expectations/gm/Test-Android-Nexus5-Adreno330-Arm7-Debug/expected-results.json @@ -4853,7 +4853,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 5363798543478698363 + 17992956605548700079 ] ], "reviewed-by-human": true @@ -4862,7 +4862,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 8694218356938189525 + 17714223495513615914 ] ], "reviewed-by-human": true diff --git a/expectations/gm/Test-Android-Nexus5-Adreno330-Arm7-Release/expected-results.json b/expectations/gm/Test-Android-Nexus5-Adreno330-Arm7-Release/expected-results.json index 9b639b0d95..d0f266c05d 100644 --- a/expectations/gm/Test-Android-Nexus5-Adreno330-Arm7-Release/expected-results.json +++ b/expectations/gm/Test-Android-Nexus5-Adreno330-Arm7-Release/expected-results.json @@ -4853,7 +4853,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 5363798543478698363 + 17992956605548700079 ] ], "reviewed-by-human": true @@ -4862,7 +4862,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 8694218356938189525 + 17714223495513615914 ] ], "reviewed-by-human": true diff --git a/expectations/gm/Test-Android-Nexus7-Tegra3-Arm7-Debug/expected-results.json b/expectations/gm/Test-Android-Nexus7-Tegra3-Arm7-Debug/expected-results.json index b780887164..c6124cd686 100644 --- a/expectations/gm/Test-Android-Nexus7-Tegra3-Arm7-Debug/expected-results.json +++ b/expectations/gm/Test-Android-Nexus7-Tegra3-Arm7-Debug/expected-results.json @@ -4647,7 +4647,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 17276962213970077366 + 15535368433031718847 ] ], "reviewed-by-human": true @@ -4656,7 +4656,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 8694218356938189525 + 17714223495513615914 ] ], "reviewed-by-human": true diff --git a/expectations/gm/Test-Android-Nexus7-Tegra3-Arm7-Release/expected-results.json b/expectations/gm/Test-Android-Nexus7-Tegra3-Arm7-Release/expected-results.json index b780887164..c6124cd686 100644 --- a/expectations/gm/Test-Android-Nexus7-Tegra3-Arm7-Release/expected-results.json +++ b/expectations/gm/Test-Android-Nexus7-Tegra3-Arm7-Release/expected-results.json @@ -4647,7 +4647,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 17276962213970077366 + 15535368433031718847 ] ], "reviewed-by-human": true @@ -4656,7 +4656,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 8694218356938189525 + 17714223495513615914 ] ], "reviewed-by-human": true diff --git a/expectations/gm/Test-Android-Xoom-Tegra2-Arm7-Debug/expected-results.json b/expectations/gm/Test-Android-Xoom-Tegra2-Arm7-Debug/expected-results.json index 483b7a1d6a..aa0df8f5eb 100644 --- a/expectations/gm/Test-Android-Xoom-Tegra2-Arm7-Debug/expected-results.json +++ b/expectations/gm/Test-Android-Xoom-Tegra2-Arm7-Debug/expected-results.json @@ -4687,7 +4687,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 1821325695757397620 + 6653149078790784803 ] ], "reviewed-by-human": true @@ -4696,7 +4696,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 13605807214433697 + 7308045438196578573 ] ], "reviewed-by-human": true @@ -4705,7 +4705,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 13605807214433697 + 7308045438196578573 ] ], "reviewed-by-human": true diff --git a/expectations/gm/Test-Android-Xoom-Tegra2-Arm7-Release/expected-results.json b/expectations/gm/Test-Android-Xoom-Tegra2-Arm7-Release/expected-results.json index 63551c6712..e1d77a1a1f 100644 --- a/expectations/gm/Test-Android-Xoom-Tegra2-Arm7-Release/expected-results.json +++ b/expectations/gm/Test-Android-Xoom-Tegra2-Arm7-Release/expected-results.json @@ -4687,7 +4687,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 1821325695757397620 + 6653149078790784803 ] ], "reviewed-by-human": true @@ -4696,7 +4696,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 13605807214433697 + 7308045438196578573 ] ], "reviewed-by-human": true @@ -4705,7 +4705,7 @@ "allowed-digests": [ [ "bitmap-64bitMD5", - 13605807214433697 + 7308045438196578573 ] ], "reviewed-by-human": true diff --git a/src/ports/SkFontConfigParser_android.cpp b/src/ports/SkFontConfigParser_android.cpp index 41f5c4aac9..a9ce0c9d31 100644 --- a/src/ports/SkFontConfigParser_android.cpp +++ b/src/ports/SkFontConfigParser_android.cpp @@ -203,54 +203,7 @@ void aliasElementHandler(FamilyData* familyData, const char** attributes) { } } -bool findWeight400(FontFamily* family) { - for (int i = 0; i < family->fFonts.count(); i++) { - if (family->fFonts[i].fWeight == 400) { - return true; - } - } - return false; -} - -bool desiredWeight(int weight) { - return (weight == 400 || weight == 700); -} - -int countDesiredWeight(FontFamily* family) { - int count = 0; - for (int i = 0; i < family->fFonts.count(); i++) { - if (desiredWeight(family->fFonts[i].fWeight)) { - count++; - } - } - return count; -} - -// To meet Skia's expectations, any family that contains weight=400 -// fonts should *only* contain {400,700} -void purgeUndesiredWeights(FontFamily* family) { - int count = countDesiredWeight(family); - for (int i = 1, j = 0; i < family->fFonts.count(); i++) { - if (desiredWeight(family->fFonts[j].fWeight)) { - j++; - } - if ((i != j) && desiredWeight(family->fFonts[i].fWeight)) { - family->fFonts[j] = family->fFonts[i]; - } - } - family->fFonts.resize_back(count); -} - -void familysetElementEndHandler(FamilyData* familyData) { - for (int i = 0; i < familyData->families.count(); i++) { - if (findWeight400(familyData->families[i])) { - purgeUndesiredWeights(familyData->families[i]); - } - } -} - -void startElementHandler(void* data, const char* tag, - const char** attributes) { +void startElementHandler(void* data, const char* tag, const char** attributes) { FamilyData* familyData = (FamilyData*) data; size_t len = strlen(tag); if (len == 6 && !strncmp(tag, "family", len)) { @@ -268,9 +221,7 @@ void startElementHandler(void* data, const char* tag, void endElementHandler(void* data, const char* tag) { FamilyData* familyData = (FamilyData*) data; size_t len = strlen(tag); - if (len == 9 && strncmp(tag, "familyset", len) == 0) { - familysetElementEndHandler(familyData); - } else if (len == 6 && strncmp(tag, "family", len) == 0) { + if (len == 6 && strncmp(tag, "family", len) == 0) { *familyData->families.append() = familyData->currentFamily; familyData->currentFamily = NULL; } else if (len == 4 && !strncmp(tag, "font", len)) { diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp index 4677a1f86d..508ad4c9c1 100644 --- a/src/ports/SkFontMgr_android.cpp +++ b/src/ports/SkFontMgr_android.cpp @@ -44,7 +44,7 @@ public: SkTypeface_Android(int index, const SkFontStyle& style, bool isFixedPitch, - const SkString familyName) + const SkString& familyName) : INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch) , fIndex(index) , fFamilyName(familyName) { } @@ -63,11 +63,11 @@ private: class SkTypeface_AndroidSystem : public SkTypeface_Android { public: - SkTypeface_AndroidSystem(const SkString pathName, + SkTypeface_AndroidSystem(const SkString& pathName, int index, const SkFontStyle& style, bool isFixedPitch, - const SkString familyName, + const SkString& familyName, const SkLanguage& lang, FontVariant variantStyle) : INHERITED(index, style, isFixedPitch, familyName) @@ -102,7 +102,7 @@ public: int index, const SkFontStyle& style, bool isFixedPitch, - const SkString familyName) + const SkString& familyName) : INHERITED(index, style, isFixedPitch, familyName) , fStream(SkRef(stream)) { } @@ -167,6 +167,10 @@ public: continue; } + if (fontFile.fWeight != 0) { + style = SkFontStyle(fontFile.fWeight, style.width(), style.slant()); + } + const SkLanguage& lang = family.fLanguage; uint32_t variant = family.fVariant; if (kDefault_FontVariant == variant) { @@ -231,16 +235,7 @@ public: private: SkFontStyle style(int index) { - return SkFontStyle(this->weight(index), SkFontStyle::kNormal_Width, - this->slant(index)); - } - SkFontStyle::Weight weight(int index) { - if (fStyles[index]->isBold()) return SkFontStyle::kBold_Weight; - return SkFontStyle::kNormal_Weight; - } - SkFontStyle::Slant slant(int index) { - if (fStyles[index]->isItalic()) return SkFontStyle::kItalic_Slant; - return SkFontStyle::kUpright_Slant; + return fStyles[index]->fontStyle(); } static int match_score(const SkFontStyle& pattern, const SkFontStyle& candidate) { int score = 0; diff --git a/tests/FontConfigParser.cpp b/tests/FontConfigParser.cpp index 86b2b1db90..4273b5eeab 100644 --- a/tests/FontConfigParser.cpp +++ b/tests/FontConfigParser.cpp @@ -19,13 +19,12 @@ int CountFallbacks(SkTDArray<FontFamily*> fontFamilies) { return countOfFallbackFonts; } -void ValidateLoadedFonts(SkTDArray<FontFamily*> fontFamilies, +void ValidateLoadedFonts(SkTDArray<FontFamily*> fontFamilies, const char* firstExpectedFile, skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, fontFamilies[0]->fNames.count() == 5); REPORTER_ASSERT(reporter, !strcmp(fontFamilies[0]->fNames[0].c_str(), "sans-serif")); REPORTER_ASSERT(reporter, - !strcmp(fontFamilies[0]->fFonts[0].fFileName.c_str(), - "Roboto-Regular.ttf")); + !strcmp(fontFamilies[0]->fFonts[0].fFileName.c_str(), firstExpectedFile)); REPORTER_ASSERT(reporter, !fontFamilies[0]->fIsFallbackFont); } @@ -71,7 +70,7 @@ DEF_TEST(FontConfigParserAndroid, reporter) { REPORTER_ASSERT(reporter, CountFallbacks(preV17FontFamilies) == 10); DumpLoadedFonts(preV17FontFamilies); - ValidateLoadedFonts(preV17FontFamilies, reporter); + ValidateLoadedFonts(preV17FontFamilies, "Roboto-Regular.ttf", reporter); } else { resourcesMissing = true; } @@ -87,7 +86,7 @@ DEF_TEST(FontConfigParserAndroid, reporter) { REPORTER_ASSERT(reporter, CountFallbacks(v17FontFamilies) == 31); DumpLoadedFonts(v17FontFamilies); - ValidateLoadedFonts(v17FontFamilies, reporter); + ValidateLoadedFonts(v17FontFamilies, "Roboto-Regular.ttf", reporter); } else { resourcesMissing = true; } @@ -103,7 +102,7 @@ DEF_TEST(FontConfigParserAndroid, reporter) { REPORTER_ASSERT(reporter, CountFallbacks(v22FontFamilies) == 42); DumpLoadedFonts(v22FontFamilies); - ValidateLoadedFonts(v22FontFamilies, reporter); + ValidateLoadedFonts(v22FontFamilies, "Roboto-Thin.ttf", reporter); } else { resourcesMissing = true; } |