Remove a layer of indirection and code from SkFontHost.
R=mtklein@google.com, tomhudson@google.com, djsollen@google.com Author: bungeman@google.com Review URL: https://codereview.chromium.org/105223006
This commit is contained in:
parent
77cd8b0ba2
commit
f91c47d91d
@ -90,42 +90,6 @@ public:
|
||||
static void SetSubpixelOrder(LCDOrder order);
|
||||
/** @deprecated get from Device. */
|
||||
static LCDOrder GetSubpixelOrder();
|
||||
|
||||
private:
|
||||
/** Return a new, closest matching typeface given either an existing family
|
||||
(specified by a typeface in that family) or by a familyName and a
|
||||
requested style.
|
||||
1) If familyFace is null, use familyName.
|
||||
2) If familyName is null, use data (UTF-16 to cover).
|
||||
3) If all are null, return the default font that best matches style
|
||||
*/
|
||||
static SkTypeface* CreateTypeface(const SkTypeface* familyFace,
|
||||
const char familyName[],
|
||||
SkTypeface::Style style);
|
||||
|
||||
/** Return a new typeface given the data buffer. If the data does not
|
||||
represent a valid font, returns null.
|
||||
|
||||
If a typeface instance is returned, the caller is responsible for
|
||||
calling unref() on the typeface when they are finished with it.
|
||||
|
||||
The returned typeface may or may not have called ref() on the stream
|
||||
parameter. If the typeface has not called ref(), then it may have made
|
||||
a copy of the releveant data. In either case, the caller is still
|
||||
responsible for its refcnt ownership of the stream.
|
||||
*/
|
||||
static SkTypeface* CreateTypefaceFromStream(SkStream*);
|
||||
|
||||
/** Return a new typeface from the specified file path. If the file does not
|
||||
represent a valid font, this returns null. If a typeface is returned,
|
||||
the caller is responsible for calling unref() when it is no longer used.
|
||||
*/
|
||||
static SkTypeface* CreateTypefaceFromFile(const char path[]);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
friend class SkScalerContext;
|
||||
friend class SkTypeface;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -207,33 +207,3 @@ SkFontMgr* SkFontMgr::RefDefault() {
|
||||
SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, CreateDefault);
|
||||
return SkRef(singleton.get());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
|
||||
const char familyName[],
|
||||
SkTypeface::Style style) {
|
||||
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
if (familyFace) {
|
||||
bool bold = style & SkTypeface::kBold;
|
||||
bool italic = style & SkTypeface::kItalic;
|
||||
SkFontStyle newStyle = SkFontStyle(bold ? SkFontStyle::kBold_Weight
|
||||
: SkFontStyle::kNormal_Weight,
|
||||
SkFontStyle::kNormal_Width,
|
||||
italic ? SkFontStyle::kItalic_Slant
|
||||
: SkFontStyle::kUpright_Slant);
|
||||
return fm->matchFaceStyle(familyFace, newStyle);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "SkAdvancedTypefaceMetrics.h"
|
||||
#include "SkEndian.h"
|
||||
#include "SkFontDescriptor.h"
|
||||
#include "SkFontHost.h"
|
||||
#include "SkFontMgr.h"
|
||||
#include "SkLazyPtr.h"
|
||||
#include "SkOTTable_OS_2.h"
|
||||
#include "SkStream.h"
|
||||
@ -84,7 +84,8 @@ SkTypeface* SkTypeface::CreateDefault(int style) {
|
||||
// TODO(bungeman, mtklein): This is sad. Make our fontconfig code safe?
|
||||
SkAutoMutexAcquire lock(&gCreateDefaultMutex);
|
||||
|
||||
SkTypeface* t = SkFontHost::CreateTypeface(NULL, NULL, (Style)style);
|
||||
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
SkTypeface* t = fm->legacyCreateTypeface(NULL, style);;
|
||||
return t ? t : SkEmptyTypeface::Create();
|
||||
}
|
||||
|
||||
@ -123,7 +124,8 @@ SkTypeface* SkTypeface::CreateFromName(const char name[], Style style) {
|
||||
if (NULL == name) {
|
||||
return RefDefault(style);
|
||||
}
|
||||
return SkFontHost::CreateTypeface(NULL, name, style);
|
||||
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
return fm->legacyCreateTypeface(name, style);
|
||||
}
|
||||
|
||||
SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) {
|
||||
@ -131,15 +133,25 @@ SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) {
|
||||
family->ref();
|
||||
return const_cast<SkTypeface*>(family);
|
||||
}
|
||||
return SkFontHost::CreateTypeface(family, NULL, s);
|
||||
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
bool bold = s & SkTypeface::kBold;
|
||||
bool italic = s & SkTypeface::kItalic;
|
||||
SkFontStyle newStyle = SkFontStyle(bold ? SkFontStyle::kBold_Weight
|
||||
: SkFontStyle::kNormal_Weight,
|
||||
SkFontStyle::kNormal_Width,
|
||||
italic ? SkFontStyle::kItalic_Slant
|
||||
: SkFontStyle::kUpright_Slant);
|
||||
return fm->matchFaceStyle(family, newStyle);
|
||||
}
|
||||
|
||||
SkTypeface* SkTypeface::CreateFromStream(SkStream* stream) {
|
||||
return SkFontHost::CreateTypefaceFromStream(stream);
|
||||
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
return fm->createFromStream(stream);
|
||||
}
|
||||
|
||||
SkTypeface* SkTypeface::CreateFromFile(const char path[]) {
|
||||
return SkFontHost::CreateTypefaceFromFile(path);
|
||||
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
return fm->createFromFile(path);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user