| Index: src/ports/SkFontHost_fontconfig.cpp
|
| diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp
|
| index b3a893e53687a1c8597a542406414b2c1131ef2a..32e9f80560cefe0ad6c31cee45ae44a3184b564a 100644
|
| --- a/src/ports/SkFontHost_fontconfig.cpp
|
| +++ b/src/ports/SkFontHost_fontconfig.cpp
|
| @@ -60,19 +60,20 @@ SkFontConfigInterface* SkFontHost_fontconfig_ref_global() {
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| struct FindRec {
|
| - FindRec(const char* name, SkTypeface::Style style)
|
| + FindRec(const char* name, const SkFontStyle& style)
|
| : fFamilyName(name) // don't need to make a deep copy
|
| , fStyle(style) {}
|
|
|
| const char* fFamilyName;
|
| - SkTypeface::Style fStyle;
|
| + SkFontStyle fStyle;
|
| };
|
|
|
| -static bool find_proc(SkTypeface* face, SkTypeface::Style style, void* ctx) {
|
| - FontConfigTypeface* fci = (FontConfigTypeface*)face;
|
| - const FindRec* rec = (const FindRec*)ctx;
|
| +static bool find_proc(SkTypeface* cachedTypeface, const SkFontStyle& cachedStyle, void* ctx) {
|
| + FontConfigTypeface* cachedFCTypeface = (FontConfigTypeface*)cachedTypeface;
|
| + const FindRec* rec = static_cast<const FindRec*>(ctx);
|
|
|
| - return rec->fStyle == style && fci->isFamilyName(rec->fFamilyName);
|
| + return rec->fStyle == cachedStyle &&
|
| + cachedFCTypeface->isFamilyName(rec->fFamilyName);
|
| }
|
|
|
| SkTypeface* FontConfigTypeface::LegacyCreateTypeface(
|
| @@ -89,34 +90,37 @@ SkTypeface* FontConfigTypeface::LegacyCreateTypeface(
|
| familyName = fct->getFamilyName();
|
| }
|
|
|
| - FindRec rec(familyName, style);
|
| + SkFontStyle requestedStyle(style);
|
| + FindRec rec(familyName, requestedStyle);
|
| SkTypeface* face = SkTypefaceCache::FindByProcAndRef(find_proc, &rec);
|
| if (face) {
|
| -// SkDebugf("found cached face <%s> <%s> %p [%d]\n", familyName, ((FontConfigTypeface*)face)->getFamilyName(), face, face->getRefCnt());
|
| + //SkDebugf("found cached face <%s> <%s> %p [%d]\n",
|
| + // familyName, ((FontConfigTypeface*)face)->getFamilyName(),
|
| + // face, face->getRefCnt());
|
| return face;
|
| }
|
|
|
| SkFontConfigInterface::FontIdentity indentity;
|
| - SkString outFamilyName;
|
| - SkTypeface::Style outStyle;
|
| -
|
| - if (!fci->matchFamilyName(familyName, style,
|
| - &indentity, &outFamilyName, &outStyle)) {
|
| + SkString outFamilyName;
|
| + SkTypeface::Style outStyle;
|
| + if (!fci->matchFamilyName(familyName, style, &indentity, &outFamilyName, &outStyle)) {
|
| return NULL;
|
| }
|
|
|
| // check if we, in fact, already have this. perhaps fontconfig aliased the
|
| // requested name to some other name we actually have...
|
| rec.fFamilyName = outFamilyName.c_str();
|
| - rec.fStyle = outStyle;
|
| + rec.fStyle = SkFontStyle(outStyle);
|
| face = SkTypefaceCache::FindByProcAndRef(find_proc, &rec);
|
| if (face) {
|
| return face;
|
| }
|
|
|
| - face = FontConfigTypeface::Create(outStyle, indentity, outFamilyName);
|
| - SkTypefaceCache::Add(face, style);
|
| -// SkDebugf("add face <%s> <%s> %p [%d]\n", familyName, outFamilyName.c_str(), face, face->getRefCnt());
|
| + face = FontConfigTypeface::Create(SkFontStyle(outStyle), indentity, outFamilyName);
|
| + SkTypefaceCache::Add(face, requestedStyle);
|
| + //SkDebugf("add face <%s> <%s> %p [%d]\n",
|
| + // familyName, outFamilyName.c_str(),
|
| + // face, face->getRefCnt());
|
| return face;
|
| }
|
|
|
|
|