Android FontHost cannot use FontMgr yet.

git-svn-id: http://skia.googlecode.com/svn/trunk@12221 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bungeman@google.com 2013-11-11 18:36:46 +00:00
parent e0f04689c8
commit 451b5962c9
4 changed files with 45 additions and 2 deletions

View File

@ -446,6 +446,7 @@
{
'defines': [
'SK_BUILD_FOR_ANDROID',
'SK_FONTHOST_DOES_NOT_USE_FONTMGR',
],
'configurations': {
'Debug': {

View File

@ -208,6 +208,8 @@ SkFontMgr* SkFontMgr::RefDefault() {
//////////////////////////////////////////////////////////////////////////
#ifndef SK_FONTHOST_DOES_NOT_USE_FONTMGR
#if 0
static SkFontStyle TypefaceStyleBitsToFontStyle(SkTypeface::Style styleBits) {
SkFontStyle::Weight weight = (styleBits & SkTypeface::kBold) ?
@ -248,3 +250,5 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
return fm->createFromStream(stream);
}
#endif

View File

@ -930,6 +930,5 @@ SkTypeface* SkCreateTypefaceForScript(HB_Script script, SkTypeface::Style style,
///////////////////////////////////////////////////////////////////////////////
SkFontMgr* SkFontMgr::Factory() {
SkFontConfigInterface* fci = SkFontConfigInterface::GetSingletonDirectInterface();
return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL;
return NULL;
}

View File

@ -124,6 +124,45 @@ SkTypeface* FontConfigTypeface::LegacyCreateTypeface(
return face;
}
#ifdef SK_FONTHOST_DOES_NOT_USE_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;
}
const size_t length = stream->getLength();
if (!length) {
return NULL;
}
if (length >= 1024 * 1024 * 1024) {
return NULL; // don't accept too large fonts (>= 1GB) for safety.
}
// ask freetype for reported style and if it is a fixed width font
SkTypeface::Style style = SkTypeface::kNormal;
bool isFixedWidth = false;
if (!find_name_and_attributes(stream, NULL, &style, &isFixedWidth)) {
return NULL;
}
SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, isFixedWidth, stream));
return face;
}
SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
return stream.get() ? CreateTypefaceFromStream(stream) : NULL;
}
#endif
///////////////////////////////////////////////////////////////////////////////
SkStream* FontConfigTypeface::onOpenStream(int* ttcIndex) const {