aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontConfigInterface_android.cpp
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-19 18:22:30 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-19 18:22:30 +0000
commit9902c38f4802aad589177c069f792eeeabb1a29b (patch)
treec6b08eaf87693677e67242517de93844697cb2a2 /src/ports/SkFontConfigInterface_android.cpp
parentc1a81ebec52bc5dff8c9461570e1212afe09506f (diff)
Add new entry point that supports fallback font selection based on language.
BUG= chromium:287995 R=reed@google.com, wangxianzhu@chromium.org Review URL: https://codereview.chromium.org/23819067 git-svn-id: http://skia.googlecode.com/svn/trunk@11394 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports/SkFontConfigInterface_android.cpp')
-rw-r--r--src/ports/SkFontConfigInterface_android.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/ports/SkFontConfigInterface_android.cpp b/src/ports/SkFontConfigInterface_android.cpp
index f56308dda9..3a4c02e539 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;
}
@@ -505,10 +505,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);
@@ -663,8 +673,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,