[poppler] poppler/poppler: GlobalParams.cc,1.16,1.17

Jeff Muizelaar jrmuizel at freedesktop.org
Sat Feb 4 12:48:27 PST 2006


Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv30124/poppler

Modified Files:
	GlobalParams.cc 
Log Message:
2006-02-04  Jeff Muizelaar  <jeff at infidigm.net>

	* poppler/GlobalParams.cc: Check all fonts returned by fontconfig.
	Discard the ones that are not truetype or type1. Fixes #5758.
	Patch by Ed Catmur.


Index: GlobalParams.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GlobalParams.cc,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- GlobalParams.cc	2 Feb 2006 22:50:01 -0000	1.16
+++ GlobalParams.cc	4 Feb 2006 20:48:25 -0000	1.17
@@ -1247,7 +1247,7 @@
 
 DisplayFontParam *GlobalParams::getDisplayFont(GfxFont *font) {
   DisplayFontParam *dfp;
-  FcPattern *p=0,*m=0;
+  FcPattern *p=0;
 
   GooString *fontName = font->getName();
   if (!fontName) return NULL;
@@ -1259,39 +1259,44 @@
     FcChar8* s;
     char * ext;
     FcResult res;
+    FcFontSet *set;
+    int i;
     p = buildFcPattern(font);
 
     if (!p)
       goto fin;
     FcConfigSubstitute(FCcfg, p, FcMatchPattern);
     FcDefaultSubstitute(p);
-    m = FcFontMatch(FCcfg,p,&res);
-    if (!m)
-      goto fin; 
-    res = FcPatternGetString(m, FC_FILE, 0, &s);
-    if (res != FcResultMatch || !s)
-      goto fin; 
-    ext = strrchr((char*)s,'.');
-    if (!ext)
+    set = FcFontSort(FCcfg, p, FcFalse, NULL, &res);
+    if (!set)
       goto fin;
-    if (!strncasecmp(ext,".ttf",4) || !strncasecmp(ext,".ttc",4))
-    {
-      dfp = new DisplayFontParam(fontName->copy(), displayFontTT);  
-      dfp->tt.fileName = new GooString((char*)s);
-      FcPatternGetInteger(m, FC_INDEX, 0, &(dfp->tt.faceIndex));
-    }
-    else if (!strncasecmp(ext,".pfa",4) || !strncasecmp(ext,".pfb",4)) 
+    for (i = 0; i < set->nfont; ++i)
     {
-      dfp = new DisplayFontParam(fontName->copy(), displayFontT1);  
-      dfp->t1.fileName = new GooString((char*)s);
+      res = FcPatternGetString(set->fonts[i], FC_FILE, 0, &s);
+      if (res != FcResultMatch || !s)
+        continue;
+      ext = strrchr((char*)s,'.');
+      if (!ext)
+        continue;
+      if (!strncasecmp(ext,".ttf",4) || !strncasecmp(ext, ".ttc", 4))
+      {
+        dfp = new DisplayFontParam(fontName->copy(), displayFontTT);  
+        dfp->tt.fileName = new GooString((char*)s);
+        FcPatternGetInteger(set->fonts[i], FC_INDEX, 0, &(dfp->tt.faceIndex));
+      }
+      else if (!strncasecmp(ext,".pfa",4) || !strncasecmp(ext,".pfb",4)) 
+      {
+        dfp = new DisplayFontParam(fontName->copy(), displayFontT1);  
+        dfp->t1.fileName = new GooString((char*)s);
+      }
+      else
+        continue;
+      displayFonts->add(dfp->name,dfp);
+      break;
     }
-    else
-      goto fin;
-    displayFonts->add(dfp->name,dfp);
+    FcFontSetDestroy(set);
   }
 fin:
-  if (m)
-    FcPatternDestroy(m);
   if (p)
     FcPatternDestroy(p);
 



More information about the poppler mailing list