Index: src/ports/SkFontMgr_android.cpp |
diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp |
index 5e93bf8a6208522c600bedca95d02529a3f7f570..905d33ae0e76d863f0fff47736dd7b47383c2a7d 100644 |
--- a/src/ports/SkFontMgr_android.cpp |
+++ b/src/ports/SkFontMgr_android.cpp |
@@ -346,8 +346,9 @@ protected: |
virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], |
const SkFontStyle& style, |
- const char bpc47[], |
- uint32_t character) const SK_OVERRIDE |
+ const char* bcp47[], |
+ int bcpLength, |
+ SkUnichar character) const SK_OVERRIDE |
{ |
// The variant 'elegant' is 'not squashed', 'compact' is 'stays in ascent/descent'. |
// The variant 'default' means 'compact and elegant'. |
@@ -359,11 +360,13 @@ protected: |
// The first time match anything in the mask, second time anything not in the mask. |
for (bool maskMatches = true; maskMatches != false; maskMatches = false) { |
- SkLanguage lang(bpc47); |
+ int bcpNext = 1; |
+ SkLanguage lang((bcpLength > 0) ? bcp47[0] : NULL); |
// Match against the language, removing a segment each time. |
// The last time through the loop, the language will be empty. |
// The empty language is special, and matches all languages. |
- do { |
+ bool searchComplete = false; |
+ while (!searchComplete) { |
const SkString& langTag = lang.getTag(); |
for (int i = 0; i < fFallbackNameToFamilyMap.count(); ++i) { |
SkFontStyleSet_Android* family = fFallbackNameToFamilyMap[i].styleSet; |
@@ -387,7 +390,18 @@ protected: |
return face.detach(); |
} |
} |
- } while (!lang.getTag().isEmpty() && (lang = lang.getParent(), true)); |
+ |
+ if (!langTag.isEmpty()) { |
+ lang = lang.getParent(); |
+ // move onto the next language tag until we exhaust them and |
+ // only then fall through to the default case (i.e. empty lang). |
+ if (lang.getTag().isEmpty() && bcpNext < bcpLength) { |
+ lang.set(bcp47[bcpNext++]); |
+ } |
+ } else { |
+ searchComplete = true; |
+ } |
+ } |
} |
return NULL; |
} |