Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(888)

Unified Diff: src/ports/SkFontConfigParser_android.cpp

Issue 694533006: Allow all font weights on Android and respect overrides. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add expectations. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/ports/SkFontConfigParser_android.cpp
diff --git a/src/ports/SkFontConfigParser_android.cpp b/src/ports/SkFontConfigParser_android.cpp
index 41f5c4aac9e395b6dedf1c7016c08aab3f09f467..a9ce0c9d3131a5cc9d79d87ad7caf3260a9a472b 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)) {
« no previous file with comments | « expectations/gm/Test-Android-Xoom-Tegra2-Arm7-Release/expected-results.json ('k') | src/ports/SkFontMgr_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698