summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2013-08-30 11:01:15 +0100
committerTorne (Richard Coles) <torne@google.com>2013-08-30 11:01:15 +0100
commit100391e7075105c568711ce047e44e811329aabb (patch)
tree4034769967b364bbb5c1b43c62e7d52a6b3f3ca3
parent986f900932d7192ddfdc26564ad55a381022e309 (diff)
parentc8d516621e00993f8fa4c68d93015d67bf6cfa8b (diff)
downloadsrc-100391e7075105c568711ce047e44e811329aabb.tar.gz
Merge from Chromium at DEPS revision 30.0.1599.25
This commit was generated by merge_to_master.py. Change-Id: Id50c4618b6f0764cf4c64ac46efe7ea9fa900f8d
-rw-r--r--ports/SkFontConfigInterface_android.cpp7
-rw-r--r--ports/SkFontConfigParser_android.cpp48
2 files changed, 48 insertions, 7 deletions
diff --git a/ports/SkFontConfigInterface_android.cpp b/ports/SkFontConfigInterface_android.cpp
index e9886188..c9dc944f 100644
--- a/ports/SkFontConfigInterface_android.cpp
+++ b/ports/SkFontConfigInterface_android.cpp
@@ -183,7 +183,12 @@ static void get_path_for_sys_fonts(SkString* full, const char name[]) {
static void insert_into_name_dict(SkTDict<FamilyRecID>& familyNameDict,
const char* name, FamilyRecID familyRecID) {
SkAutoAsciiToLC tolc(name);
- familyNameDict.set(tolc.lc(), familyRecID);
+ if (familyNameDict.find(tolc.lc())) {
+ SkDebugf("---- system font attempting to use a the same name [%s] for"
+ "multiple families. skipping subsequent occurrences", tolc.lc());
+ } else {
+ familyNameDict.set(tolc.lc(), familyRecID);
+ }
}
// Defined in SkFontHost_FreeType.cpp
diff --git a/ports/SkFontConfigParser_android.cpp b/ports/SkFontConfigParser_android.cpp
index b1c81599..e8692e91 100644
--- a/ports/SkFontConfigParser_android.cpp
+++ b/ports/SkFontConfigParser_android.cpp
@@ -163,16 +163,52 @@ static void endElementHandler(void *data, const char *tag) {
* families array.
*/
static void parseConfigFile(const char *filename, SkTDArray<FontFamily*> &families) {
- XML_Parser parser = XML_ParserCreate(NULL);
- FamilyData *familyData = new FamilyData(&parser, families);
- XML_SetUserData(parser, familyData);
- XML_SetElementHandler(parser, startElementHandler, endElementHandler);
- FILE *file = fopen(filename, "r");
+
+ FILE* file = NULL;
+
+#if !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
+ // if we are using a version of Android prior to Android 4.2 (JellyBean MR1
+ // at API Level 17) then we need to look for files with a different suffix.
+ char sdkVersion[PROP_VALUE_MAX];
+ __system_property_get("ro.build.version.sdk", sdkVersion);
+ const int sdkVersionInt = atoi(sdkVersion);
+
+ if (0 != *sdkVersion && sdkVersionInt < 17) {
+ SkString basename;
+ SkString updatedFilename;
+ SkString locale = SkFontConfigParser::GetLocale();
+
+ basename.set(filename);
+ // Remove the .xml suffix. We'll add it back in a moment.
+ if (basename.endsWith(".xml")) {
+ basename.resize(basename.size()-4);
+ }
+ // Try first with language and region
+ updatedFilename.printf("%s-%s.xml", basename.c_str(), locale.c_str());
+ file = fopen(updatedFilename.c_str(), "r");
+ if (!file) {
+ // If not found, try next with just language
+ updatedFilename.printf("%s-%.2s.xml", basename.c_str(), locale.c_str());
+ file = fopen(updatedFilename.c_str(), "r");
+ }
+ }
+#endif
+
+ if (NULL == file) {
+ file = fopen(filename, "r");
+ }
+
// Some of the files we attempt to parse (in particular, /vendor/etc/fallback_fonts.xml)
// are optional - failure here is okay because one of these optional files may not exist.
- if (file == NULL) {
+ if (NULL == file) {
return;
}
+
+ XML_Parser parser = XML_ParserCreate(NULL);
+ FamilyData *familyData = new FamilyData(&parser, families);
+ XML_SetUserData(parser, familyData);
+ XML_SetElementHandler(parser, startElementHandler, endElementHandler);
+
char buffer[512];
bool done = false;
while (!done) {