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

Unified Diff: src/ports/SkFontConfigParser_android.cpp

Issue 473543004: Revert of Remove SkPaintOptionsAndroid (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 months 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
« no previous file with comments | « src/ports/SkFontConfigParser_android.h ('k') | src/ports/SkFontMgr_android.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontConfigParser_android.cpp
diff --git a/src/ports/SkFontConfigParser_android.cpp b/src/ports/SkFontConfigParser_android.cpp
index bc4bca21594966718666f3709606c4ff5ac56d66..e9c912f4b012e0e9608eab2cf5d7713d6cc48d49 100644
--- a/src/ports/SkFontConfigParser_android.cpp
+++ b/src/ports/SkFontConfigParser_android.cpp
@@ -109,9 +109,9 @@
} else if (nameLen == 7 && !strncmp("variant", name, nameLen)) {
// Value should be either elegant or compact.
if (valueLen == 7 && !strncmp("elegant", value, valueLen)) {
- family->fVariant = kElegant_FontVariant;
+ family->fVariant = SkPaintOptionsAndroid::kElegant_Variant;
} else if (valueLen == 7 && !strncmp("compact", value, valueLen)) {
- family->fVariant = kCompact_FontVariant;
+ family->fVariant = SkPaintOptionsAndroid::kCompact_Variant;
}
}
}
@@ -120,6 +120,13 @@
void fontFileNameHandler(void* data, const char* s, int len) {
FamilyData* familyData = (FamilyData*) data;
familyData->currentFontInfo->fFileName.set(s, len);
+}
+
+void familyElementEndHandler(FontFamily* family) {
+ for (int i = 0; i < family->fFonts.count(); i++) {
+ family->fFonts[i].fPaintOptions.setLanguage(family->fLanguage);
+ family->fFonts[i].fPaintOptions.setFontVariant(family->fVariant);
+ }
}
void fontElementHandler(XML_Parser* parser, FontFileInfo* file, const char** attributes) {
@@ -271,6 +278,7 @@
if (len == 9 && strncmp(tag, "familyset", len) == 0) {
familysetElementEndHandler(familyData);
} else if (len == 6 && strncmp(tag, "family", len) == 0) {
+ familyElementEndHandler(familyData->currentFamily);
*familyData->families.append() = familyData->currentFamily;
familyData->currentFamily = NULL;
} else if (len == 4 && !strncmp(tag, "font", len)) {
@@ -324,27 +332,14 @@
size_t nameLength = strlen(attributeName);
size_t valueLength = strlen(attributeValue);
if (nameLength == 7 && strncmp(attributeName, "variant", nameLength) == 0) {
- const FontVariant prevVariant = familyData->currentFamily->fVariant;
if (valueLength == 7 && strncmp(attributeValue, "elegant", valueLength) == 0) {
- familyData->currentFamily->fVariant = kElegant_FontVariant;
+ newFileInfo.fPaintOptions.setFontVariant(SkPaintOptionsAndroid::kElegant_Variant);
} else if (valueLength == 7 &&
strncmp(attributeValue, "compact", valueLength) == 0) {
- familyData->currentFamily->fVariant = kCompact_FontVariant;
+ newFileInfo.fPaintOptions.setFontVariant(SkPaintOptionsAndroid::kCompact_Variant);
}
- if (familyData->currentFamily->fFonts.count() > 1 &&
- familyData->currentFamily->fVariant != prevVariant) {
- SkDebugf("Every font file within a family must have identical variants");
- sk_throw();
- }
-
} else if (nameLength == 4 && strncmp(attributeName, "lang", nameLength) == 0) {
- SkLanguage prevLang = familyData->currentFamily->fLanguage;
- familyData->currentFamily->fLanguage = SkLanguage(attributeValue);
- if (familyData->currentFamily->fFonts.count() > 1 &&
- familyData->currentFamily->fLanguage != prevLang) {
- SkDebugf("Every font file within a family must have identical languages");
- sk_throw();
- }
+ newFileInfo.fPaintOptions.setLanguage(attributeValue);
} else if (nameLength == 5 && strncmp(attributeName, "index", nameLength) == 0) {
int value;
if (parseNonNegativeInteger(attributeValue, &value)) {
@@ -518,7 +513,9 @@
for (int i = 0; i < langSpecificFonts.count(); ++i) {
FontFamily* family = langSpecificFonts[i];
- family->fLanguage = SkLanguage(locale);
+ for (int j = 0; j < family->fFonts.count(); ++j) {
+ family->fFonts[j].fPaintOptions.setLanguage(locale);
+ }
*fallbackFonts.append() = family;
}
}
@@ -596,16 +593,3 @@
*fontFamilies.append() = fallbackFonts[i];
}
}
-
-SkLanguage SkLanguage::getParent() const {
- SkASSERT(!fTag.isEmpty());
- const char* tag = fTag.c_str();
-
- // strip off the rightmost "-.*"
- const char* parentTagEnd = strrchr(tag, '-');
- if (parentTagEnd == NULL) {
- return SkLanguage();
- }
- size_t parentTagLen = parentTagEnd - tag;
- return SkLanguage(tag, parentTagLen);
-}
« no previous file with comments | « src/ports/SkFontConfigParser_android.h ('k') | src/ports/SkFontMgr_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698