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

Unified Diff: src/ports/SkFontConfigInterface_android.cpp

Issue 17691002: Ensure we use the current locale when looking up fallback fonts per character (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove mutex Created 7 years, 6 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 | « no previous file | src/ports/SkFontConfigParser_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontConfigInterface_android.cpp
diff --git a/src/ports/SkFontConfigInterface_android.cpp b/src/ports/SkFontConfigInterface_android.cpp
index 2e2d88d689bbdfaf80cb4d6e221ac5ab291012e5..738b11434e348953f27dc9b86a570e8cd6407e8b 100644
--- a/src/ports/SkFontConfigInterface_android.cpp
+++ b/src/ports/SkFontConfigInterface_android.cpp
@@ -107,6 +107,7 @@ public:
private:
void addFallbackFont(FontRecID fontRecID);
SkTypeface* getTypefaceForFontRec(FontRecID fontRecID);
+ FallbackFontList* getCurrentLocaleFallbackFontList();
FallbackFontList* findFallbackFontList(const SkLanguage& lang, bool isOriginal = true);
SkTArray<FontRec> fFonts;
@@ -118,6 +119,10 @@ private:
SkTDict<FallbackFontList*> fFallbackFontDict;
SkTDict<FallbackFontList*> fFallbackFontAliasDict;
FallbackFontList fDefaultFallbackList;
+
+ // fallback info for current locale
+ SkString fCachedLocale;
+ FallbackFontList* fLocaleFallbackFontList;
};
///////////////////////////////////////////////////////////////////////////////
@@ -193,7 +198,8 @@ SkFontConfigInterfaceAndroid::SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*
fFamilyNameDict(1024),
fDefaultFamilyRecID(INVALID_FAMILY_REC_ID),
fFallbackFontDict(128),
- fFallbackFontAliasDict(128) {
+ fFallbackFontAliasDict(128),
+ fLocaleFallbackFontList(NULL) {
for (int i = 0; i < fontFamilies.count(); ++i) {
FontFamily* family = fontFamilies[i];
@@ -489,8 +495,9 @@ SkTypeface* SkFontConfigInterfaceAndroid::getTypefaceForFontRec(FontRecID fontRe
}
bool SkFontConfigInterfaceAndroid::getFallbackFamilyNameForChar(SkUnichar uni, SkString* name) {
- for (int i = 0; i < fDefaultFallbackList.count(); i++) {
- FontRecID fontRecID = fDefaultFallbackList[i];
+ FallbackFontList* fallbackFontList = this->getCurrentLocaleFallbackFontList();
+ for (int i = 0; i < fallbackFontList->count(); i++) {
+ FontRecID fontRecID = fallbackFontList->getAt(i);
SkTypeface* face = this->getTypefaceForFontRec(fontRecID);
SkPaint paint;
@@ -533,6 +540,15 @@ SkTypeface* SkFontConfigInterfaceAndroid::getTypefaceForChar(SkUnichar uni,
return NULL;
}
+FallbackFontList* SkFontConfigInterfaceAndroid::getCurrentLocaleFallbackFontList() {
+ SkString locale = SkFontConfigParser::GetLocale();
+ if (NULL == fLocaleFallbackFontList || locale != fCachedLocale) {
+ fCachedLocale = locale;
+ fLocaleFallbackFontList = this->findFallbackFontList(locale);
+ }
+ return fLocaleFallbackFontList;
+}
+
FallbackFontList* SkFontConfigInterfaceAndroid::findFallbackFontList(const SkLanguage& lang,
bool isOriginal) {
const SkString& langTag = lang.getTag();
« no previous file with comments | « no previous file | src/ports/SkFontConfigParser_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698