summaryrefslogtreecommitdiff
path: root/poppler
diff options
context:
space:
mode:
authorJeff Muizelaar <jeff@infidigm.net>2006-02-04 20:48:25 +0000
committerJeff Muizelaar <jeff@infidigm.net>2006-02-04 20:48:25 +0000
commitb4e34d905cd0ca5815a450de35b4c2774f4887c9 (patch)
treed04a7eb5c62d072041f402f819344ca2ba9c1ec5 /poppler
parentfd85a0afdd7b4cafc68df400d4f94fccaea18c76 (diff)
2006-02-04 Jeff Muizelaar <jeff@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.
Diffstat (limited to 'poppler')
-rw-r--r--poppler/GlobalParams.cc51
1 files changed, 28 insertions, 23 deletions
diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 45f2b6d7..cfc3805a 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -1247,7 +1247,7 @@ static FcPattern *buildFcPattern(GfxFont *font)
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 @@ DisplayFontParam *GlobalParams::getDisplayFont(GfxFont *font) {
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))
+ for (i = 0; i < set->nfont; ++i)
{
- 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))
- {
- 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);