X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=pdf%2Fxpdf%2FGlobalParams.cc;h=2bc997ffafb3c6530b27cd251d5b719882ab6f63;hb=5932479cc8c371a385616b5909df558a091b7111;hp=c125430200d7d39251a754852c7265ee5ea24cdc;hpb=6c85243ff859071be4fd2a3847b0fc2086206d31;p=evince.git diff --git a/pdf/xpdf/GlobalParams.cc b/pdf/xpdf/GlobalParams.cc index c1254302..2bc997ff 100644 --- a/pdf/xpdf/GlobalParams.cc +++ b/pdf/xpdf/GlobalParams.cc @@ -18,6 +18,7 @@ #if HAVE_PAPER_H #include #endif +#include #include "gmem.h" #include "GString.h" #include "GList.h" @@ -87,6 +88,32 @@ static char *displayFontDirs[] = { NULL }; +/* patterns originally from mupdf; added agfa fonts*/ +static struct { + const char *name; + const char *pattern; +} displayFontTabFc[] = { + /* FIXME Adobe fonts should be here, but that breaks down if + fontconfig returns pcf fonts */ + {"Courier", "Nimbus Mono L,Courier New,Cumberland AMT,Cumberland:style=Regular,Roman"}, + {"Courier-Bold", "Nimbus Mono L,Courier New,Cumberland AMT,Cumberland:style=Bold"}, + {"Courier-BoldOblique", "Nimbus Mono L,Courier New,Cumberland AMT,Cumberland:style=Oblique,Italic"}, + {"Courier-Oblique", "Nimbus Mono L,Courier New,Cumberland AMT,Cumberland:style=BoldOblique,BoldItalic"}, + {"Helvetica", "Nimbus Sans L,Arial,Albany AMT,Albany:style=Regular,Roman"}, + {"Helvetica-Bold", "Nimbus Sans L,Arial,Albany AMT,Albany:style=Bold"}, + {"Helvetica-BoldOblique", "Nimbus Sans L,Arial,Albany AMT,Albany:style=Oblique,Italic"}, + {"Helvetica-Oblique", "Nimbus Sans L,Arial,Albany AMT,Albany:style=BoldOblique,BoldItalic"}, + /* FIXME Symbol should be first, + but that matches windows ttf which gets wrong encoding */ + {"Symbol", "Standard Symbols L,Symbol"}, + {"Times-Bold", "Nimbus Roman No9 L,Times New Roman,Thorndale AMT,Thorndale:style=Bold,Medium"}, + {"Times-BoldItalic", "Nimbus Roman No9 L,Times New Roman,Thorndale AMT,Thorndale:style=BoldItalic,Medium Italic"}, + {"Times-Italic", "Nimbus Roman No9 L,Times New Roman,Thorndale AMT,Thorndale:style=Italic,Regular Italic"}, + {"Times-Roman", "Nimbus Roman No9 L,Times New Roman,Thorndale AMT,Thorndale:style=Regular,Roman"}, + {"ZapfDingbats", "Dingbats:outline=true"}, + {NULL} +}; + //------------------------------------------------------------------------ GlobalParams *globalParams = NULL; @@ -936,6 +963,83 @@ void GlobalParams::setupBaseFonts(char *dir) { } } +//------------------------------------------------------------------------ + +void GlobalParams::setupBaseFontsFc(FcConfig *fcConfig) { + GString *fontName; + GString *fileName; + DisplayFontParam *dfp; + FcPattern *namePat, *matchPat; + FcResult result; + FcChar8 *fcFileName; + int i; + DisplayFontParamKind kind; + + for (i = 0; displayFontTabFc[i].name; ++i) { + fontName = new GString(displayFontTabFc[i].name); + if (getDisplayFont(fontName)) { + delete fontName; + continue; + } + fileName = NULL; + result = FcResultMatch; + namePat = FcNameParse((const FcChar8 *)displayFontTabFc[i].pattern); + FcConfigSubstitute(fcConfig, namePat, FcMatchPattern); + FcDefaultSubstitute(namePat); + matchPat = FcFontMatch(fcConfig, namePat, &result); + + if (result == FcResultMatch) { + result = FcPatternGetString(matchPat, "file", 0, &fcFileName); + if (result == FcResultMatch) + fileName = new GString((const char *)fcFileName); + } + + FcPatternDestroy(matchPat); + FcPatternDestroy(namePat); + + if (fileName) { + char *ext; + + /* FIXME */ + ext = strrchr(fileName->getCString(), '.'); + if (ext) { + if (strcasecmp (ext, ".pfb") == 0) + kind = displayFontT1; + else if (strcasecmp (ext, ".pfa") == 0) + kind = displayFontT1; + else if (strcasecmp (ext, ".ttf") == 0) + kind = displayFontTT; + else if (strcasecmp (ext, ".ttc") == 0) + kind = displayFontTT; + else { + delete fileName; + fileName = NULL; + } + } else { + delete fileName; + fileName = NULL; + } + } + + if (!fileName) { + error(-1, "No display font for '%s'", displayFontTabFc[i].name); + delete fontName; + continue; + } + + dfp = new DisplayFontParam(fontName, kind); + switch (kind) { + case displayFontT1: + dfp->t1.fileName = fileName; + break; + case displayFontTT: + dfp->tt.fileName = fileName; + } + + globalParams->addDisplayFont(dfp); + } +} + //------------------------------------------------------------------------ // accessors //------------------------------------------------------------------------