Handle NULL typeface in SkFontMgr_fontconfig::onMatchFaceStyle.
authorbungeman <bungeman@google.com>
Fri, 12 Sep 2014 19:14:14 +0000 (12:14 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 12 Sep 2014 19:14:14 +0000 (12:14 -0700)
SampleApp does this, and it needs to be handled properly.

R=mtklein@google.com

Author: bungeman@google.com

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

src/ports/SkFontMgr_fontconfig.cpp

index 782fb268ccc7e18b2c320b45f3365c3895bb305a..b8a3fe5b0d232de1c0c21c74c6613c1965445e25 100644 (file)
@@ -798,9 +798,13 @@ protected:
                                          const SkFontStyle& style) const SK_OVERRIDE
     {
         //TODO: should the SkTypeface_fontconfig know its family?
-        const SkTypeface_fontconfig* fcTypeface =
-            static_cast<const SkTypeface_fontconfig*>(typeface);
-        return this->matchFamilyStyle(get_string(fcTypeface->fPattern, FC_FAMILY), style);
+        const char* name = NULL;
+        if (typeface) {
+            const SkTypeface_fontconfig* fcTypeface =
+                static_cast<const SkTypeface_fontconfig*>(typeface);
+            name = get_string(fcTypeface->fPattern, FC_FAMILY);
+        }
+        return this->matchFamilyStyle(name, style);
     }
 
     /** @param stream does not take ownership of the reference. */