aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-11 18:36:46 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-11 18:36:46 +0000
commit451b5962c906be9517cc99b80deecf525e85ee89 (patch)
tree8b8b46fcbe78d4d7f12e17bc2d66e58e07a5720c /src
parente0f04689c8ae098a5244a17bc9b364fb5003f797 (diff)
Android FontHost cannot use FontMgr yet.
git-svn-id: http://skia.googlecode.com/svn/trunk@12221 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkFontHost.cpp4
-rw-r--r--src/ports/SkFontConfigInterface_android.cpp3
-rw-r--r--src/ports/SkFontHost_fontconfig.cpp39
3 files changed, 44 insertions, 2 deletions
diff --git a/src/core/SkFontHost.cpp b/src/core/SkFontHost.cpp
index c09739d02f..f3d30e8591 100644
--- a/src/core/SkFontHost.cpp
+++ b/src/core/SkFontHost.cpp
@@ -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
diff --git a/src/ports/SkFontConfigInterface_android.cpp b/src/ports/SkFontConfigInterface_android.cpp
index 6c3e8d5625..6f9ed3a93b 100644
--- a/src/ports/SkFontConfigInterface_android.cpp
+++ b/src/ports/SkFontConfigInterface_android.cpp
@@ -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;
}
diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp
index de766dfefe..3700ed1e97 100644
--- a/src/ports/SkFontHost_fontconfig.cpp
+++ b/src/ports/SkFontHost_fontconfig.cpp
@@ -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 {