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
This commit is contained in:
reed@google.com 2013-07-31 17:37:31 +00:00
parent caacc8f4e1
commit e027a6ed9b
4 changed files with 34 additions and 5 deletions

View File

@ -18,6 +18,7 @@
'../include/xml',
'../src/core',
'../src/lazy',
'../src/ports',
'../src/sfnt',
'../src/utils',
],

View File

@ -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() {

View File

@ -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;

View File

@ -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);
}