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

Unified Diff: src/ports/SkFontConfigInterface_android.cpp

Issue 23819067: Add new entry point that supports fallback font selection based on language. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: improvements Created 7 years, 3 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 | « include/ports/SkTypeface_android.h ('k') | no next file » | 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 9a38261e80262789788e545dd9d86cbb5d1d9825..4baa755a4d25aff5bbe6da763face95abbe47084 100644
--- a/src/ports/SkFontConfigInterface_android.cpp
+++ b/src/ports/SkFontConfigInterface_android.cpp
@@ -95,7 +95,7 @@ public:
* Get the family name of the font in the default fallback font list that
* contains the specified chararacter. if no font is found, returns false.
*/
- bool getFallbackFamilyNameForChar(SkUnichar uni, SkString* name);
+ bool getFallbackFamilyNameForChar(SkUnichar uni, const char* lang, SkString* name);
/**
*
*/
@@ -246,10 +246,10 @@ SkFontConfigInterfaceAndroid::SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*
if (fontRec.fIsValid) {
DEBUG_FONT(("---- SystemFonts[%d][%d] fallback=%d file=%s",
- i, fFonts.count() - 1, fontRec.fIsFallbackFont, filename.c_str()));
+ i, fFonts.count() - 1, family->fIsFallbackFont, filename.c_str()));
} else {
DEBUG_FONT(("---- SystemFonts[%d][%d] fallback=%d file=%s (INVALID)",
- i, fFonts.count() - 1, fontRec.fIsFallbackFont, filename.c_str()));
+ i, fFonts.count() - 1, family->fIsFallbackFont, filename.c_str()));
continue;
}
@@ -504,10 +504,20 @@ SkTypeface* SkFontConfigInterfaceAndroid::getTypefaceForFontRec(FontRecID fontRe
return face;
}
-bool SkFontConfigInterfaceAndroid::getFallbackFamilyNameForChar(SkUnichar uni, SkString* name) {
- FallbackFontList* fallbackFontList = this->getCurrentLocaleFallbackFontList();
+bool SkFontConfigInterfaceAndroid::getFallbackFamilyNameForChar(SkUnichar uni,
+ const char* lang,
+ SkString* name) {
+ FallbackFontList* fallbackFontList = this->findFallbackFontList(lang);
for (int i = 0; i < fallbackFontList->count(); i++) {
FamilyRecID familyRecID = fallbackFontList->getAt(i);
+
+ // if it is not one of the accepted variants then move to the next family
+ int32_t acceptedVariants = SkPaintOptionsAndroid::kDefault_Variant |
+ SkPaintOptionsAndroid::kElegant_Variant;
+ if (!(fFontFamilies[familyRecID].fPaintOptions.getFontVariant() & acceptedVariants)) {
+ continue;
+ }
+
FontRecID fontRecID = find_best_style(fFontFamilies[familyRecID], SkTypeface::kNormal);
SkTypeface* face = this->getTypefaceForFontRec(fontRecID);
@@ -662,8 +672,14 @@ SkTypeface* SkFontConfigInterfaceAndroid::nextLogicalTypeface(SkFontID currFontI
///////////////////////////////////////////////////////////////////////////////
bool SkGetFallbackFamilyNameForChar(SkUnichar uni, SkString* name) {
+ SkString locale = SkFontConfigParser::GetLocale();
+ SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
+ return fontConfig->getFallbackFamilyNameForChar(uni, locale.c_str(), name);
+}
+
+bool SkGetFallbackFamilyNameForChar(SkUnichar uni, const char* lang, SkString* name) {
SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
- return fontConfig->getFallbackFamilyNameForChar(uni, name);
+ return fontConfig->getFallbackFamilyNameForChar(uni, lang, name);
}
void SkUseTestFontConfigFile(const char* mainconf, const char* fallbackconf,
« no previous file with comments | « include/ports/SkTypeface_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698