From: djsollen@google.com Date: Fri, 6 Sep 2013 18:00:04 +0000 (+0000) Subject: Update the freetype backed fonthost to keep the style and fixed width attributes... X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~10931 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d2fef9834531ea0e400b6d57a9619f77ca1962b;p=platform%2Fupstream%2FlibSkiaSharp.git 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 --- diff --git a/src/fonts/SkFontMgr_fontconfig.cpp b/src/fonts/SkFontMgr_fontconfig.cpp index 367faf8..0b4accd 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 e1b6c18..744c84b 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 1625b8a..012ce90 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; }