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