aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-24 20:08:47 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-24 20:08:47 +0000
commit39a7c7035b2978e2483cca67c2a9f8b201fb5fbb (patch)
tree93e61563310d6ca468b4ade29a7136713470cf47 /src/ports
parentdfc740393e3476905af1964a280cd1e7a0940cc2 (diff)
Use different unique identifier for a fallback family.
BUG=chromium:266412 R=mtklein@google.com, reed@google.com Review URL: https://codereview.chromium.org/24288002 git-svn-id: http://skia.googlecode.com/svn/trunk@11451 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkFontConfigInterface_android.cpp48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/ports/SkFontConfigInterface_android.cpp b/src/ports/SkFontConfigInterface_android.cpp
index 3a4c02e539..7382d00b45 100644
--- a/src/ports/SkFontConfigInterface_android.cpp
+++ b/src/ports/SkFontConfigInterface_android.cpp
@@ -67,6 +67,7 @@ struct FamilyRec {
static const int FONT_STYLE_COUNT = 4;
FontRecID fFontRecID[FONT_STYLE_COUNT];
bool fIsFallbackFont;
+ SkString fFallbackName;
SkPaintOptionsAndroid fPaintOptions;
};
@@ -263,10 +264,6 @@ SkFontConfigInterfaceAndroid::SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*
familyRec->fIsFallbackFont = family->fIsFallbackFont;
familyRec->fPaintOptions = family->fFontFiles[j]->fPaintOptions;
- // if this is a fallback font then add it to the appropriate fallback chains
- if (familyRec->fIsFallbackFont) {
- addFallbackFamily(familyRecID);
- }
} else if (familyRec->fPaintOptions != family->fFontFiles[j]->fPaintOptions) {
SkDebugf("Every font file within a family must have identical"
"language and variant attributes");
@@ -280,28 +277,26 @@ SkFontConfigInterfaceAndroid::SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*
fontRecID));
}
familyRec->fFontRecID[fontRec.fStyle] = fontRecID;
-
- // add the fallback file name to the name dictionary. This is needed
- // by getFallbackFamilyNameForChar() so that fallback families can be
- // requested by the filenames of the fonts they contain.
- if (familyRec && familyRec->fIsFallbackFont) {
- insert_into_name_dict(fFamilyNameDict, fontRec.fFileName.c_str(), familyRecID);
- }
}
- // add the names that map to this family to the dictionary for easy lookup
- if (familyRec && !familyRec->fIsFallbackFont) {
- SkTDArray<const char*> names = family->fNames;
- if (names.isEmpty()) {
- SkDEBUGFAIL("ERROR: non-fallback font with no name");
- continue;
- }
+ if (familyRec) {
+ if (familyRec->fIsFallbackFont) {
+ // add the font to the appropriate fallback chains and also insert a
+ // unique name into the familyNameDict for internal usage
+ addFallbackFamily(familyRecID);
+ } else {
+ // add the names that map to this family to the dictionary for easy lookup
+ const SkTDArray<const char*>& names = family->fNames;
+ if (names.isEmpty()) {
+ SkDEBUGFAIL("ERROR: non-fallback font with no name");
+ continue;
+ }
- for (int i = 0; i < names.count(); i++) {
- insert_into_name_dict(fFamilyNameDict, names[i], familyRecID);
+ for (int i = 0; i < names.count(); i++) {
+ insert_into_name_dict(fFamilyNameDict, names[i], familyRecID);
+ }
}
}
-
}
DEBUG_FONT(("---- We have %d system fonts", fFonts.count()));
@@ -341,9 +336,16 @@ SkFontConfigInterfaceAndroid::~SkFontConfigInterfaceAndroid() {
void SkFontConfigInterfaceAndroid::addFallbackFamily(FamilyRecID familyRecID) {
SkASSERT(familyRecID < fFontFamilies.count());
- const FamilyRec& familyRec = fFontFamilies[familyRecID];
+ FamilyRec& familyRec = fFontFamilies[familyRecID];
SkASSERT(familyRec.fIsFallbackFont);
+ // add the fallback family to the name dictionary. This is
+ // needed by getFallbackFamilyNameForChar() so that fallback
+ // families can be identified by a unique name. The unique
+ // identifier that we've chosen is the familyID in hex (e.g. '0F##fallback').
+ familyRec.fFallbackName.printf("%.2x##fallback", familyRecID);
+ insert_into_name_dict(fFamilyNameDict, familyRec.fFallbackName.c_str(), familyRecID);
+
// add to the default fallback list
fDefaultFallbackList.push(familyRecID);
@@ -529,7 +531,7 @@ bool SkFontConfigInterfaceAndroid::getFallbackFamilyNameForChar(SkUnichar uni,
uint16_t glyphID;
paint.textToGlyphs(&uni, sizeof(uni), &glyphID);
if (glyphID != 0) {
- name->set(fFonts[fontRecID].fFileName);
+ name->set(fFontFamilies[familyRecID].fFallbackName);
return true;
}
}