fix null fFontRef in GetDefaultFont()
http://codereview.appspot.com/4662041/ git-svn-id: http://skia.googlecode.com/svn/trunk@1709 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
6f2b44d2ff
commit
b80255700e
@ -75,8 +75,13 @@ static SkTypeface::Style computeStyleBits(CTFontRef font, bool* isMonospace) {
|
||||
|
||||
class SkTypeface_Mac : public SkTypeface {
|
||||
public:
|
||||
SkTypeface_Mac(SkTypeface::Style style, SkFontID fontID, bool isMonospace)
|
||||
: SkTypeface(style, fontID, isMonospace), fFontRef(0) {}
|
||||
SkTypeface_Mac(SkTypeface::Style style, SkFontID fontID, bool isMonospace,
|
||||
CTFontRef fontRef, const char name[])
|
||||
: SkTypeface(style, fontID, isMonospace) {
|
||||
SkASSERT(fontRef);
|
||||
fFontRef = fontRef; // we take over ownership
|
||||
fName.set(name);
|
||||
}
|
||||
|
||||
virtual ~SkTypeface_Mac() { CFRelease(fFontRef); }
|
||||
|
||||
@ -85,14 +90,11 @@ public:
|
||||
};
|
||||
|
||||
static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[]) {
|
||||
SkASSERT(fontRef);
|
||||
bool isMonospace;
|
||||
SkTypeface::Style style = computeStyleBits(fontRef, &isMonospace);
|
||||
SkTypeface_Mac* face = new SkTypeface_Mac(style,
|
||||
SkTypefaceCache::NewFontID(),
|
||||
isMonospace);
|
||||
face->fFontRef = fontRef; // we take over ownership of fontRef
|
||||
face->fName.set(name);
|
||||
return face;
|
||||
return new SkTypeface_Mac(style, SkTypefaceCache::NewFontID(),
|
||||
isMonospace, fontRef, name);
|
||||
}
|
||||
|
||||
static SkTypeface* NewFromName(const char familyName[],
|
||||
@ -156,8 +158,7 @@ static SkTypeface* GetDefaultFace() {
|
||||
static SkTypeface* gDefaultFace;
|
||||
|
||||
if (NULL == gDefaultFace) {
|
||||
gDefaultFace = new SkTypeface_Mac(SkTypeface::kNormal,
|
||||
SkTypefaceCache::NewFontID(), false);
|
||||
gDefaultFace = NewFromName(FONT_DEFAULT_NAME, SkTypeface::kNormal);
|
||||
}
|
||||
return gDefaultFace;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user