(fc_list): If FcFontList finds no font, try
authorhanda <handa>
Fri, 25 Jun 2004 11:57:20 +0000 (11:57 +0000)
committerhanda <handa>
Fri, 25 Jun 2004 11:57:20 +0000 (11:57 +0000)
FcFontMatch.

src/font-ft.c

index e398e85..0f6a451 100644 (file)
@@ -304,12 +304,27 @@ fc_list (MSymbol family)
   fs = FcFontList (fc_config, pattern, os);
   if (fs)
     {
-      for (i = 0; i < fs->nfont; i++)
-       {
-         char *filename;
+      char *filename;
 
-         FcPatternGetString (fs->fonts[i], FC_FILE, 0, (FcChar8 **) &filename);
-         add_font_info (filename, family);
+      if (fs->nfont > 0)
+       for (i = 0; i < fs->nfont; i++)
+         {
+           FcPatternGetString (fs->fonts[i], FC_FILE, 0, 
+                               (FcChar8 **) &filename);
+           add_font_info (filename, family);
+         }
+      else
+       {
+         FcPattern *match;
+         FcResult result;
+
+         FcConfigSubstitute (fc_config, pattern, FcMatchPattern);
+         FcDefaultSubstitute (pattern);
+         match = FcFontMatch (fc_config, pattern, &result);
+         if (FcPatternGetString (match, FC_FILE, 0, (FcChar8 **) &filename)
+             == FcResultMatch)
+           add_font_info (filename, family);
+         FcPatternDestroy (match);
        }
       FcFontSetDestroy (fs);
     }