aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-31 17:37:31 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-31 17:37:31 +0000
commite027a6ed9b9e2a96be846ddefb2b06e350858eed (patch)
tree5bcc3580a1e462ad720a4767eb45256e30ff3d31 /src/ports
parentcaacc8f4e1ff69d545fb55c2a0a1d46e5cdbae3f (diff)
adapt FontConfig to use SK_FONTHOST_USES_FONTMGR
BUG= Review URL: https://codereview.chromium.org/21331003 git-svn-id: http://skia.googlecode.com/svn/trunk@10463 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkFontConfigTypeface.h7
-rw-r--r--src/ports/SkFontHost_fontconfig.cpp24
2 files changed, 26 insertions, 5 deletions
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);
+}
+
+