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); |
-} |