aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-06 18:00:04 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-06 18:00:04 +0000
commit6d2fef9834531ea0e400b6d57a9619f77ca1962b (patch)
treefdb069af0cdc80d9ead1d1695da7c7d07e6f9ac7 /src
parent80f9cf18cc665f57834ee9989ce495cda067313e (diff)
Update the freetype backed fonthost to keep the style and fixed width attributes for a font stream.
This fixes a regression in Android when switching from FontHost_android R=reed@google.com Review URL: https://codereview.chromium.org/23966003 git-svn-id: http://skia.googlecode.com/svn/trunk@11134 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/fonts/SkFontMgr_fontconfig.cpp4
-rw-r--r--src/ports/SkFontConfigTypeface.h4
-rw-r--r--src/ports/SkFontHost_fontconfig.cpp16
3 files changed, 18 insertions, 6 deletions
diff --git a/src/fonts/SkFontMgr_fontconfig.cpp b/src/fonts/SkFontMgr_fontconfig.cpp
index 367faf8528..0b4accd254 100644
--- a/src/fonts/SkFontMgr_fontconfig.cpp
+++ b/src/fonts/SkFontMgr_fontconfig.cpp
@@ -272,9 +272,9 @@ protected:
return NULL; // don't accept too large fonts (>= 1GB) for safety.
}
- // TODO should the caller give us the style?
+ // TODO should the caller give us the style or should we get it from freetype?
SkTypeface::Style style = SkTypeface::kNormal;
- SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, stream));
+ SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, false, stream));
return face;
}
diff --git a/src/ports/SkFontConfigTypeface.h b/src/ports/SkFontConfigTypeface.h
index e1b6c18227..744c84b098 100644
--- a/src/ports/SkFontConfigTypeface.h
+++ b/src/ports/SkFontConfigTypeface.h
@@ -26,8 +26,8 @@ public:
, fFamilyName(familyName)
, fLocalStream(NULL) {}
- FontConfigTypeface(Style style, SkStream* localStream)
- : INHERITED(style, SkTypefaceCache::NewFontID(), false) {
+ FontConfigTypeface(Style style, bool fixedWidth, SkStream* localStream)
+ : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) {
// we default to empty fFamilyName and fIdentity
fLocalStream = localStream;
SkSafeRef(localStream);
diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp
index 1625b8aa81..012ce90c8c 100644
--- a/src/ports/SkFontHost_fontconfig.cpp
+++ b/src/ports/SkFontHost_fontconfig.cpp
@@ -15,6 +15,13 @@
#include "SkTypeface.h"
#include "SkTypefaceCache.h"
+// Defined in SkFontHost_FreeType.cpp
+bool find_name_and_attributes(SkStream* stream, SkString* name,
+ SkTypeface::Style* style, bool* isFixedWidth);
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex);
static SkFontConfigInterface* gFontConfigInterface;
@@ -129,9 +136,14 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
return NULL; // don't accept too large fonts (>= 1GB) for safety.
}
- // TODO should the caller give us the style?
+ // ask freetype for reported style and if it is a fixed width font
SkTypeface::Style style = SkTypeface::kNormal;
- SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, stream));
+ bool isFixedWidth = false;
+ if (!find_name_and_attributes(stream, NULL, &style, &isFixedWidth)) {
+ return NULL;
+ }
+
+ SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, isFixedWidth, stream));
return face;
}