aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkFontHost.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-30 17:47:39 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-30 17:47:39 +0000
commit30ddd615c447fed73286151b463af20d309c85f1 (patch)
tree03f06598408958e47d01a638db285546cd122a29 /src/core/SkFontHost.cpp
parent2d859346dd4c583cae84e485bfa87ef97ffaebc1 (diff)
refactoring for SK_FONTHOST_USES_FONTMGR option
BUG= R=bungeman@google.com Review URL: https://codereview.chromium.org/21149008 git-svn-id: http://skia.googlecode.com/svn/trunk@10440 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkFontHost.cpp')
-rw-r--r--src/core/SkFontHost.cpp52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/core/SkFontHost.cpp b/src/core/SkFontHost.cpp
index 734b3aa1b8..11f681329a 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