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

Unified Diff: src/ports/SkFontHost_fontconfig.cpp

Issue 16439004: Fix issues related to resolving fonts based on name. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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
« src/core/SkTypeface.cpp ('K') | « src/core/SkTypeface.cpp ('k') | 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 a5aef56f1c9099fe4690acd8e478a3e668ccd3ce..12ff90683fdbf06b0ce624c8170844305b54ebbf 100644
--- a/src/ports/SkFontHost_fontconfig.cpp
+++ b/src/ports/SkFontHost_fontconfig.cpp
@@ -72,6 +72,12 @@ static bool find_proc(SkTypeface* face, SkTypeface::Style style, void* ctx) {
return rec->fStyle == style && fci->isFamilyName(rec->fFamilyName);
}
+static bool find_proc_by_id(SkTypeface* face, SkTypeface::Style style, void* ctx) {
+ const uint32_t* fontID = (const uint32_t*)ctx;
+ uint32_t currFontID = ((FontConfigTypeface*)face)->getIdentity().fID;
+ return currFontID == *fontID;
+}
+
SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
const char familyName[],
SkTypeface::Style style) {
@@ -92,16 +98,21 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
return face;
}
- SkFontConfigInterface::FontIdentity indentity;
+ SkFontConfigInterface::FontIdentity identity;
SkString outFamilyName;
SkTypeface::Style outStyle;
if (!fci->matchFamilyName(familyName, style,
- &indentity, &outFamilyName, &outStyle)) {
+ &identity, &outFamilyName, &outStyle)) {
return NULL;
}
- face = SkNEW_ARGS(FontConfigTypeface, (outStyle, indentity, outFamilyName));
+ face = SkTypefaceCache::FindByProcAndRef(find_proc_by_id, &identity.fID);
reed1 2013/06/05 13:23:57 this may be correct, but is it strictly needed for
djsollen 2013/06/05 13:51:59 No this is still needed. If an app asks for a font
+ if (face) {
+ return face;
+ }
+
+ face = SkNEW_ARGS(FontConfigTypeface, (outStyle, identity, outFamilyName));
SkTypefaceCache::Add(face, style);
// SkDebugf("add face <%s> <%s> %p [%d]\n", familyName, outFamilyName.c_str(), face, face->getRefCnt());
return face;
@@ -122,7 +133,6 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
// TODO should the caller give us the style?
SkTypeface::Style style = SkTypeface::kNormal;
SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, stream));
- SkTypefaceCache::Add(face, style);
return face;
}
« src/core/SkTypeface.cpp ('K') | « src/core/SkTypeface.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698