Add an empty typeface as a default-default.
R=reed@google.com Review URL: https://codereview.chromium.org/22861017 git-svn-id: http://skia.googlecode.com/svn/trunk@10857 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
ab17a4fa1f
commit
5c1d88dca0
@ -36,6 +36,35 @@ SkTypeface::~SkTypeface() {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class SkEmptyTypeface : public SkTypeface {
|
||||
public:
|
||||
SkEmptyTypeface() : SkTypeface(SkTypeface::kNormal, 0, true) { }
|
||||
protected:
|
||||
virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { return NULL; }
|
||||
virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRIDE {
|
||||
return NULL;
|
||||
}
|
||||
virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE { }
|
||||
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
|
||||
SkAdvancedTypefaceMetrics::PerGlyphInfo,
|
||||
const uint32_t*, uint32_t) const SK_OVERRIDE { return NULL; }
|
||||
virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE { }
|
||||
virtual int onCountGlyphs() const SK_OVERRIDE { return 0; };
|
||||
virtual int onGetUPEM() const SK_OVERRIDE { return 0; };
|
||||
class EmptyLocalizedStrings : public SkTypeface::LocalizedStrings {
|
||||
public:
|
||||
virtual bool next(SkTypeface::LocalizedString*) SK_OVERRIDE { return false; }
|
||||
};
|
||||
virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_OVERRIDE {
|
||||
return SkNEW(EmptyLocalizedStrings);
|
||||
};
|
||||
virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE { return 0; }
|
||||
virtual size_t onGetTableData(SkFontTableTag, size_t, size_t, void*) const SK_OVERRIDE {
|
||||
return 0;
|
||||
}
|
||||
virtual SkTypeface* onRefMatchingStyle(Style) const SK_OVERRIDE { return NULL; }
|
||||
};
|
||||
|
||||
SkTypeface* SkTypeface::GetDefaultTypeface(Style style) {
|
||||
// we keep a reference to this guy for all time, since if we return its
|
||||
// fontID, the font cache may later on ask to resolve that back into a
|
||||
@ -48,9 +77,12 @@ SkTypeface* SkTypeface::GetDefaultTypeface(Style style) {
|
||||
style = (Style)(style & 0x03);
|
||||
|
||||
if (NULL == gDefaultTypefaces[style]) {
|
||||
gDefaultTypefaces[style] =
|
||||
SkFontHost::CreateTypeface(NULL, NULL, style);
|
||||
gDefaultTypefaces[style] = SkFontHost::CreateTypeface(NULL, NULL, style);
|
||||
}
|
||||
if (NULL == gDefaultTypefaces[style]) {
|
||||
gDefaultTypefaces[style] = SkNEW(SkEmptyTypeface);
|
||||
}
|
||||
|
||||
return gDefaultTypefaces[style];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user