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

Unified Diff: src/ports/SkFontConfigParser_android.cpp

Issue 450513002: Revert "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 58aec2d01f6b1756fa5b7c36c0c9c98a09f818da..10212e8a07e7fdc420da6c51d4fe5c2a2812fffc 100644
--- a/src/ports/SkFontConfigParser_android.cpp
+++ b/src/ports/SkFontConfigParser_android.cpp
@@ -97,9 +97,9 @@ void familyElementHandler(FontFamily* family, const char** attributes) {
} 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;
}
}
}
@@ -110,6 +110,13 @@ void fontFileNameHandler(void *data, const char *s, int len) {
familyData->currentFontInfo->fFileName.set(s, len);
}
+void familyElementEndHandler(FontFamily* family) {
+ for (int i = 0; i < family->fFontFiles.count(); i++) {
+ family->fFontFiles[i].fPaintOptions.setLanguage(family->fLanguage);
+ family->fFontFiles[i].fPaintOptions.setFontVariant(family->fVariant);
+ }
+}
+
void fontElementHandler(XML_Parser* parser, FontFileInfo* file, const char** attributes) {
// A <font> should have weight (integer) and style (normal, italic) attributes.
// NOTE: we ignore the style.
@@ -253,6 +260,7 @@ void endElementHandler(void* data, const char* tag) {
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)) {
@@ -305,27 +313,14 @@ static void fontFileElementHandler(FamilyData *familyData, const char **attribut
int nameLength = strlen(attributeName);
int 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;
- }
- if (familyData->currentFamily->fFontFiles.count() > 1 &&
- familyData->currentFamily->fVariant != prevVariant) {
- SkDebugf("Every font file within a family must have identical variants");
- sk_throw();
+ newFileInfo.fPaintOptions.setFontVariant(SkPaintOptionsAndroid::kCompact_Variant);
}
-
} else if (nameLength == 4 && strncmp(attributeName, "lang", nameLength) == 0) {
- SkLanguage prevLang = familyData->currentFamily->fLanguage;
- familyData->currentFamily->fLanguage = SkLanguage(attributeValue);
- if (familyData->currentFamily->fFontFiles.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)) {
@@ -494,7 +489,9 @@ static void getFallbackFontFamiliesForLocale(SkTDArray<FontFamily*> &fallbackFon
for (int i = 0; i < langSpecificFonts.count(); ++i) {
FontFamily* family = langSpecificFonts[i];
- family->fLanguage = SkLanguage(locale);
+ for (int j = 0; j < family->fFontFiles.count(); ++j) {
+ family->fFontFiles[j].fPaintOptions.setLanguage(locale);
+ }
*fallbackFonts.append() = family;
}
}
@@ -572,16 +569,3 @@ void SkFontConfigParser::GetTestFontFamilies(SkTDArray<FontFamily*> &fontFamilie
*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