aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontHost_fontconfig.cpp
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2014-10-20 13:33:19 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-20 13:33:19 -0700
commita4c4a2d8cd65abb1e5ac20813831cdb9ace6c7ee (patch)
treecf64b94cb51a6316cf89080697cdd5d54e459ecc /src/ports/SkFontHost_fontconfig.cpp
parentfca302ccf464933e44e00255654d27a7705abb7f (diff)
Replace SkTypeface::Style with SkFontStyle.
Diffstat (limited to 'src/ports/SkFontHost_fontconfig.cpp')
-rw-r--r--src/ports/SkFontHost_fontconfig.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp
index b3a893e536..32e9f80560 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;
}