| Index: src/core/SkTypeface.cpp
|
| ===================================================================
|
| --- src/core/SkTypeface.cpp (revision 10850)
|
| +++ src/core/SkTypeface.cpp (working copy)
|
| @@ -36,6 +36,35 @@
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| +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 @@
|
| 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];
|
| }
|
|
|
|
|