don't rely on fonts having a stream
authorcaryclark <caryclark@google.com>
Mon, 15 Jun 2015 15:05:06 +0000 (08:05 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 15 Jun 2015 15:05:06 +0000 (08:05 -0700)
Portable fonts don't have streams, so expect the stream open
to fail.

R=bungeman@google.com
TBR=cdalton@nvidia.com

Review URL: https://codereview.chromium.org/1185803003

src/fonts/SkTestScalerContext.h
src/gpu/gl/GrGLPathRendering.cpp

index 1d4b89ae17eb49107d54612393c0d638af12195c..5838c801c53a8f156e4e09922359f09a238e2f31 100644 (file)
@@ -74,7 +74,6 @@ protected:
         uint32_t glyphIDsCount) const override;
 
     SkStreamAsset* onOpenStream(int* ttcIndex) const override {
-        SkASSERT(0);  // don't expect to get here
         return NULL;
     }
 
index ae833957405a3dbbd868f0a2d5ab0ad19b49f1ba..e81d54c338250fa16a4331d4a90055bfbfd723ea 100644 (file)
@@ -113,7 +113,11 @@ GrPathRange* GrGLPathRendering::createGlyphs(const SkTypeface* typeface,
     }
 
     int faceIndex;
-    SkAutoTDelete<SkStream> fontStream(typeface->openStream(&faceIndex));
+    SkStreamAsset* asset = typeface->openStream(&faceIndex);
+    if (!asset) {
+        return GrPathRendering::createGlyphs(typeface, NULL, stroke);
+    }
+    SkAutoTDelete<SkStream> fontStream(asset);
 
     const size_t fontDataLength = fontStream->getLength();
     if (0 == fontDataLength) {