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

Unified Diff: src/ports/SkFontHost_fontconfig.cpp

Issue 838743002: Cache SkTypeface for alternative family name (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_fontconfig.cpp
diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp
index 2fdb16e3645b8f288de28b2ea46788e8780ec491..f43c01b95778d73aeffc432922b4c56ae79d442f 100644
--- a/src/ports/SkFontHost_fontconfig.cpp
+++ b/src/ports/SkFontHost_fontconfig.cpp
@@ -105,17 +105,17 @@ SkTypeface* FontConfigTypeface::LegacyCreateTypeface(const char familyName[],
return face;
}
- SkFontConfigInterface::FontIdentity indentity;
+ SkFontConfigInterface::FontIdentity identity;
SkString outFamilyName;
SkTypeface::Style outStyle;
- if (!fci->matchFamilyName(familyName, style, &indentity, &outFamilyName, &outStyle)) {
+ if (!fci->matchFamilyName(familyName, style, &identity, &outFamilyName, &outStyle)) {
return NULL;
}
- // Check if a typeface with this FontIdentity is already in the FontIdentity cache.
- face = SkTypefaceCache::FindByProcAndRef(find_by_FontIdentity, &indentity);
+ // Check if a typeface with this outFamily is already in the FontIdentity cache.
+ face = SkTypefaceCache::FindByProcAndRef(find_by_FontIdentity, &identity);
if (!face) {
- face = FontConfigTypeface::Create(SkFontStyle(outStyle), indentity, outFamilyName);
+ face = FontConfigTypeface::Create(SkFontStyle(outStyle), identity, outFamilyName);
// Add this FontIdentity to the FontIdentity cache.
SkTypefaceCache::Add(face, requestedStyle);
}
@@ -124,6 +124,16 @@ SkTypeface* FontConfigTypeface::LegacyCreateTypeface(const char familyName[],
//SkDebugf("add face <%s> <%s> %p [%d]\n",
// familyName, outFamilyName.c_str(),
// face, face->getRefCnt());
+
+ // If any aliased name is returned for the requested family, cache SkTypeface
+ // with the original family name so the following lookups will hit the cache.
+ if (!outFamilyName.equals(familyName)) {
+ SkTypeface* face_orig =
+ FontConfigTypeface::Create(SkFontStyle(outStyle), identity, SkString(familyName));
+ SkTypefaceCache::Add(face_orig, requestedStyle);
+ //SkDebugf("add face <%s> %p [%d]\n",
+ // familyName, face_orig, face_orig->getRefCnt());
+ }
return face;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698