Update the freetype backed fonthost to keep the style and fixed width attributes...
authordjsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 6 Sep 2013 18:00:04 +0000 (18:00 +0000)
committerdjsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 6 Sep 2013 18:00:04 +0000 (18:00 +0000)
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

src/fonts/SkFontMgr_fontconfig.cpp
src/ports/SkFontConfigTypeface.h
src/ports/SkFontHost_fontconfig.cpp

index 367faf8..0b4accd 100644 (file)
@@ -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;
     }
 
index e1b6c18..744c84b 100644 (file)
@@ -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);
index 1625b8a..012ce90 100644 (file)
 #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;
 }