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

Unified Diff: src/core/SkFontHost.cpp

Issue 13312002: add matcher to fontstyleset (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 | « include/ports/SkFontMgr.h ('k') | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkFontHost.cpp
===================================================================
--- src/core/SkFontHost.cpp (revision 8442)
+++ src/core/SkFontHost.cpp (working copy)
@@ -50,8 +50,45 @@
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
+#include "SkFontStyle.h"
+
+SkFontStyle::SkFontStyle() {
+ fUnion.fU32 = 0;
+ fUnion.fR.fWeight = kNormal_Weight;
+ fUnion.fR.fWidth = kNormal_Width;
+ fUnion.fR.fSlant = kUpright_Slant;
+}
+
+SkFontStyle::SkFontStyle(int weight, int width, Slant slant) {
+ fUnion.fU32 = 0;
+ fUnion.fR.fWeight = SkPin32(weight, kThin_Weight, kBlack_Weight);
+ fUnion.fR.fWidth = SkPin32(width, kUltraCondensed_Width, kUltaExpanded_Width);
+ fUnion.fR.fSlant = SkPin32(slant, kUpright_Slant, kItalic_Slant);
+}
+
#include "SkFontMgr.h"
+class SkEmptyFontStyleSet : public SkFontStyleSet {
+public:
+ virtual int count() SK_OVERRIDE { return 0; }
+ virtual void getStyle(int, SkFontStyle*, SkString*) SK_OVERRIDE {
+ SkASSERT(!"SkFontStyleSet::getStyle called on empty set");
+ }
+ virtual SkTypeface* createTypeface(int index) SK_OVERRIDE {
+ SkASSERT(!"SkFontStyleSet::createTypeface called on empty set");
+ return NULL;
+ }
+ virtual SkTypeface* matchStyle(const SkFontStyle&) SK_OVERRIDE {
+ return NULL;
+ }
+};
+
+SkFontStyleSet* SkFontStyleSet::CreateEmpty() {
+ return SkNEW(SkEmptyFontStyleSet);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
class SkEmptyFontMgr : public SkFontMgr {
protected:
virtual int onCountFamilies() SK_OVERRIDE {
@@ -64,6 +101,10 @@
SkASSERT(!"onCreateStyleSet called with bad index");
return NULL;
}
+ virtual SkFontStyleSet* onMatchFamily(const char[]) SK_OVERRIDE {
+ return SkFontStyleSet::CreateEmpty();
+ }
+
virtual SkTypeface* onMatchFamilyStyle(const char[],
const SkFontStyle&) SK_OVERRIDE {
return NULL;
@@ -83,20 +124,6 @@
}
};
-SkFontStyle::SkFontStyle() {
- fUnion.fU32 = 0;
- fUnion.fR.fWeight = kNormal_Weight;
- fUnion.fR.fWidth = kNormal_Width;
- fUnion.fR.fSlant = kUpright_Slant;
-}
-
-SkFontStyle::SkFontStyle(int weight, int width, Slant slant) {
- fUnion.fU32 = 0;
- fUnion.fR.fWeight = SkPin32(weight, kThin_Weight, kBlack_Weight);
- fUnion.fR.fWidth = SkPin32(width, kUltraCondensed_Width, kUltaExpanded_Width);
- fUnion.fR.fSlant = SkPin32(slant, kUpright_Slant, kItalic_Slant);
-}
-
int SkFontMgr::countFamilies() {
return this->onCountFamilies();
}
@@ -109,6 +136,10 @@
return this->onCreateStyleSet(index);
}
+SkFontStyleSet* SkFontMgr::matchFamily(const char familyName[]) {
+ return this->onMatchFamily(familyName);
+}
+
SkTypeface* SkFontMgr::matchFamilyStyle(const char familyName[],
const SkFontStyle& fs) {
return this->onMatchFamilyStyle(familyName, fs);
« no previous file with comments | « include/ports/SkFontMgr.h ('k') | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698