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

Unified Diff: src/core/SkFontHost.cpp

Issue 21149008: refactoring for SK_FONTHOST_USES_FONTMGR option (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 5 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/core/SkTypeface.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkFontHost.cpp
diff --git a/src/core/SkFontHost.cpp b/src/core/SkFontHost.cpp
index 734b3aa1b89e3e6c6f9945501b84db95cd4d09c1..11f681329ac46c8ea95c63badbd050891b07aaed 100644
--- a/src/core/SkFontHost.cpp
+++ b/src/core/SkFontHost.cpp
@@ -68,7 +68,6 @@ SkFontStyle::SkFontStyle(int weight, int width, Slant slant) {
#include "SkFontMgr.h"
-
SK_DEFINE_INST_COUNT(SkFontStyleSet)
class SkEmptyFontStyleSet : public SkFontStyleSet {
@@ -174,6 +173,17 @@ SkTypeface* SkFontMgr::createFromFile(const char path[], int ttcIndex) {
return this->onCreateFromFile(path, ttcIndex);
}
+SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[],
+ unsigned styleBits) {
+ return this->onLegacyCreateTypeface(familyName, styleBits);
+}
+
+SkTypeface* SkFontMgr::onLegacyCreateTypeface(const char familyName[],
+ unsigned styleBits) {
+ SkASSERT(!"unimplemented");
+ return NULL;
+}
+
SkFontMgr* SkFontMgr::RefDefault() {
static SkFontMgr* gFM;
if (NULL == gFM) {
@@ -185,3 +195,43 @@ SkFontMgr* SkFontMgr::RefDefault() {
}
return SkRef(gFM);
}
+
+//////////////////////////////////////////////////////////////////////////
+
+#ifdef SK_FONTHOST_USES_FONTMGR
+
+#if 0
+static SkFontStyle TypefaceStyleBitsToFontStyle(SkTypeface::Style styleBits) {
+ SkFontStyle::Weight weight = (styleBits & SkTypeface::kBold) ?
+ SkFontStyle::kBold_Weight :
+ SkFontStyle::kNormal_Weight;
+ SkFontStyle::Width width = SkFontStyle::kNormal_Width;
+ SkFontStyle::Slant slant = (styleBits & SkTypeface::kItalic) ?
+ SkFontStyle::kUpright_Slant :
+ SkFontStyle::kItalic_Slant;
+ return SkFontStyle(weight, width, slant);
+}
+#endif
+
+SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
+ const char familyName[],
+ SkTypeface::Style style) {
+ if (familyFace) {
+ return familyFace->refMatchingStyle(style);
+ } else {
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->legacyCreateTypeface(familyName, style);
+ }
+}
+
+SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->createFromFile(path);
+}
+
+SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->createFromStream(stream);
+}
+
+#endif
« no previous file with comments | « include/ports/SkFontMgr.h ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698