Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: src/core/SkTypeface.cpp

Issue 22861017: Add an empty typeface as a default-default. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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];
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698