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

Unified Diff: src/ports/SkFontMgr_android.cpp

Issue 673443003: Update fontMgr to take list of bcp47 language tags. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nits and loop fix Created 6 years, 2 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_fontconfig.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « src/ports/SkFontConfigParser_android.h ('k') | src/ports/SkFontMgr_fontconfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698