add impls for createfromstream for fontconfig fontmgr
git-svn-id: http://skia.googlecode.com/svn/trunk@10469 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
cde269a6a6
commit
b6bd24d31f
@ -162,14 +162,23 @@ SkTypeface* SkFontMgr::matchFaceStyle(const SkTypeface* face,
|
||||
}
|
||||
|
||||
SkTypeface* SkFontMgr::createFromData(SkData* data, int ttcIndex) {
|
||||
if (NULL == data) {
|
||||
return NULL;
|
||||
}
|
||||
return this->onCreateFromData(data, ttcIndex);
|
||||
}
|
||||
|
||||
SkTypeface* SkFontMgr::createFromStream(SkStream* stream, int ttcIndex) {
|
||||
if (NULL == stream) {
|
||||
return NULL;
|
||||
}
|
||||
return this->onCreateFromStream(stream, ttcIndex);
|
||||
}
|
||||
|
||||
SkTypeface* SkFontMgr::createFromFile(const char path[], int ttcIndex) {
|
||||
if (NULL == path) {
|
||||
return NULL;
|
||||
}
|
||||
return this->onCreateFromFile(path, ttcIndex);
|
||||
}
|
||||
|
||||
|
@ -262,11 +262,25 @@ protected:
|
||||
const SkFontStyle&) { return NULL; }
|
||||
|
||||
virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) { return NULL; }
|
||||
virtual SkTypeface* onCreateFromStream(SkStream*, int ttcIndex) {
|
||||
return NULL;
|
||||
|
||||
virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) {
|
||||
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.
|
||||
}
|
||||
|
||||
// TODO should the caller give us the style?
|
||||
SkTypeface::Style style = SkTypeface::kNormal;
|
||||
SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, stream));
|
||||
return face;
|
||||
}
|
||||
|
||||
virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) {
|
||||
return NULL;
|
||||
SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
|
||||
return stream.get() ? this->createFromStream(stream, ttcIndex) : NULL;
|
||||
}
|
||||
|
||||
virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
|
||||
|
Loading…
Reference in New Issue
Block a user