aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gyp/ports.gyp1
-rw-r--r--src/fonts/SkFontMgr_fontconfig.cpp7
-rw-r--r--src/ports/SkFontConfigTypeface.h7
-rw-r--r--src/ports/SkFontHost_fontconfig.cpp24
4 files changed, 34 insertions, 5 deletions
diff --git a/gyp/ports.gyp b/gyp/ports.gyp
index fa717e14bb..fff368df6a 100644
--- a/gyp/ports.gyp
+++ b/gyp/ports.gyp
@@ -18,6 +18,7 @@
'../include/xml',
'../src/core',
'../src/lazy',
+ '../src/ports',
'../src/sfnt',
'../src/utils',
],
diff --git a/src/fonts/SkFontMgr_fontconfig.cpp b/src/fonts/SkFontMgr_fontconfig.cpp
index a78575262f..1c87a72f06 100644
--- a/src/fonts/SkFontMgr_fontconfig.cpp
+++ b/src/fonts/SkFontMgr_fontconfig.cpp
@@ -8,6 +8,7 @@
#include "SkFontMgr.h"
#include "SkFontStyle.h"
#include "SkFontConfigInterface.h"
+#include "SkFontConfigTypeface.h"
#include "SkMath.h"
#include "SkString.h"
#include "SkTDArray.h"
@@ -267,6 +268,12 @@ protected:
virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) {
return NULL;
}
+
+ virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
+ unsigned styleBits) SK_OVERRIDE {
+ return FontConfigTypeface::LegacyCreateTypeface(NULL, familyName,
+ (SkTypeface::Style)styleBits);
+ }
};
SkFontMgr* SkFontMgr::Factory() {
diff --git a/src/ports/SkFontConfigTypeface.h b/src/ports/SkFontConfigTypeface.h
index 549e02f826..e9f9a13c1e 100644
--- a/src/ports/SkFontConfigTypeface.h
+++ b/src/ports/SkFontConfigTypeface.h
@@ -7,10 +7,10 @@
#include "SkFontConfigInterface.h"
#include "SkFontHost_FreeType_common.h"
+#include "SkStream.h"
#include "SkTypefaceCache.h"
class SkFontDescriptor;
-class SkStream;
class FontConfigTypeface : public SkTypeface_FreeType {
SkFontConfigInterface::FontIdentity fIdentity;
@@ -48,6 +48,10 @@ public:
return fFamilyName.equals(name);
}
+ static SkTypeface* LegacyCreateTypeface(const SkTypeface* family,
+ const char familyName[],
+ SkTypeface::Style);
+
protected:
friend class SkFontHost; // hack until we can make public versions
@@ -56,6 +60,7 @@ protected:
size_t length, void* data) const SK_OVERRIDE;
virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE;
virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE;
+ virtual SkTypeface* onRefMatchingStyle(Style) const SK_OVERRIDE;
private:
typedef SkTypeface_FreeType INHERITED;
diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp
index c53328b89b..75c21c243b 100644
--- a/src/ports/SkFontHost_fontconfig.cpp
+++ b/src/ports/SkFontHost_fontconfig.cpp
@@ -72,9 +72,10 @@ static bool find_proc(SkTypeface* face, SkTypeface::Style style, void* ctx) {
return rec->fStyle == style && fci->isFamilyName(rec->fFamilyName);
}
-SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
- const char familyName[],
- SkTypeface::Style style) {
+SkTypeface* FontConfigTypeface::LegacyCreateTypeface(
+ const SkTypeface* familyFace,
+ const char familyName[],
+ SkTypeface::Style style) {
SkAutoTUnref<SkFontConfigInterface> fci(RefFCI());
if (NULL == fci.get()) {
return NULL;
@@ -107,6 +108,15 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
return face;
}
+#ifndef SK_FONTHOST_USES_FONTMGR
+
+SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
+ const char familyName[],
+ SkTypeface::Style style) {
+ return FontConfigTypeface::LegacyCreateTypeface(familyFace, familyName,
+ style);
+}
+
SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
if (!stream) {
return NULL;
@@ -130,6 +140,8 @@ SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
return stream.get() ? CreateTypefaceFromStream(stream) : NULL;
}
+#endif
+
///////////////////////////////////////////////////////////////////////////////
SkStream* FontConfigTypeface::onOpenStream(int* ttcIndex) const {
@@ -196,4 +208,8 @@ void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc,
*isLocalStream = SkToBool(this->getLocalStream());
}
-///////////////////////////////////////////////////////////////////////////////
+SkTypeface* FontConfigTypeface::onRefMatchingStyle(Style style) const {
+ return LegacyCreateTypeface(this, NULL, style);
+}
+
+