Do not assume fontconfig will find a font.
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 16 Sep 2008 22:59:59 +0000 (22:59 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 16 Sep 2008 22:59:59 +0000 (22:59 +0000)
If you have no fonts in fontconfig, it returns NULL... believe me, it
does happen.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@36029 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/canvas/evas_font_dir.c

index a46b4d6..c40e7cd 100644 (file)
@@ -322,6 +322,11 @@ evas_font_load(Evas *evas, const char *name, const char *source, int size)
 
        /* do matching */
        set = FcFontSort(NULL, p_nm, FcTrue, NULL, &res);
+       if (!set)
+         {
+            fprintf(stderr, "ERROR: no fontconfig font matches '%s'. It was the last resource, no font found!\n", name);
+            goto fc_end;
+         }
 
        /* Do loading for all in family */
        for (i = 0; i < set->nfont; i++)
@@ -337,6 +342,7 @@ evas_font_load(Evas *evas, const char *name, const char *source, int size)
          }
 
        FcFontSetDestroy(set);
+     fc_end:
        FcPatternDestroy(p_nm);
      }
 #endif