From: Martin Kretzschmar Date: Wed, 22 Dec 2004 11:50:50 +0000 (+0000) Subject: add prototype. X-Git-Tag: EVINCE_0_1_0~91 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=f36af012943a93a0c8e1f2d36c4f5b9e1ac1b8e5;p=evince.git add prototype. * pdf/xpdf/GlobalParams.h (setupBaseFontsFc): add prototype. * pdf/xpdf/GlobalParams.cc (displayFontTabFc): maps base font names to fontconfig patterns. (setupBaseFontsFc): setupBaseFonts reimplemented using fontconfig. * pdf/xpdf/pdf-document.cc (pdf_document_load): use setupBaseFontsFc. --- diff --git a/ChangeLog b/ChangeLog index 3c66429a..3f9b7d8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-12-22 Martin Kretzschmar + + * pdf/xpdf/GlobalParams.h (setupBaseFontsFc): add prototype. + + * pdf/xpdf/GlobalParams.cc (displayFontTabFc): maps base font + names to fontconfig patterns. + (setupBaseFontsFc): setupBaseFonts reimplemented using fontconfig. + + * pdf/xpdf/pdf-document.cc (pdf_document_load): use + setupBaseFontsFc. + 2004-12-22 Marco Pesenti Gritti * Makefile.am: diff --git a/pdf/xpdf/GlobalParams.cc b/pdf/xpdf/GlobalParams.cc index c1254302..c7757644 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,30 @@ static char *displayFontDirs[] = { NULL }; +/* patterns originally from mupdf; added agfa fonts*/ +static struct { + const char *name; + const char *pattern; +} displayFontTabFc[] = { + {"Courier", "Courier,Nimbus Mono L,Courier New,Cumberland AMT,Cumberland:style=Regular,Roman"}, + {"Courier-Bold", "Courier,Nimbus Mono L,Courier New,Cumberland AMT,Cumberland:style=Bold"}, + {"Courier-BoldOblique", "Courier,Nimbus Mono L,Courier New,Cumberland AMT,Cumberland:style=Oblique,Italic"}, + {"Courier-Oblique", "Courier,Nimbus Mono L,Courier New,Cumberland AMT,Cumberland:style=BoldOblique,BoldItalic"}, + {"Helvetica", "Helvetica,Nimbus Sans L,Arial,Albany AMT,Albany:style=Regular,Roman"}, + {"Helvetica-Bold", "Helvetica,Nimbus Sans L,Arial,Albany AMT,Albany:style=Bold"}, + {"Helvetica-BoldOblique", "Helvetica,Nimbus Sans L,Arial,Albany AMT,Albany:style=Oblique,Italic"}, + {"Helvetica-Oblique", "Helvetica,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", "Times,Nimbus Roman No9 L,Times New Roman,Thorndale AMT,Thorndale:style=Bold,Medium"}, + {"Times-BoldItalic", "Times,Nimbus Roman No9 L,Times New Roman,Thorndale AMT,Thorndale:style=BoldItalic,Medium Italic"}, + {"Times-Italic", "Times,Nimbus Roman No9 L,Times New Roman,Thorndale AMT,Thorndale:style=Italic,Regular Italic"}, + {"Times-Roman", "Times,Nimbus Roman No9 L,Times New Roman,Thorndale AMT,Thorndale:style=Regular,Roman"}, + {"ZapfDingbats", "Zapf Dingbats,Dingbats"}, + {NULL} +}; + //------------------------------------------------------------------------ GlobalParams *globalParams = NULL; @@ -936,6 +961,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 //------------------------------------------------------------------------ diff --git a/pdf/xpdf/GlobalParams.h b/pdf/xpdf/GlobalParams.h index 93ec06aa..b0992567 100644 --- a/pdf/xpdf/GlobalParams.h +++ b/pdf/xpdf/GlobalParams.h @@ -16,6 +16,7 @@ #endif #include +#include #include "gtypes.h" #include "CharTypes.h" @@ -116,6 +117,7 @@ public: ~GlobalParams(); void setupBaseFonts(char *dir); + void setupBaseFontsFc(FcConfig *fcConfig); //----- accessors diff --git a/pdf/xpdf/pdf-document.cc b/pdf/xpdf/pdf-document.cc index be15d7ca..fa7c7fcf 100644 --- a/pdf/xpdf/pdf-document.cc +++ b/pdf/xpdf/pdf-document.cc @@ -84,7 +84,7 @@ pdf_document_load (EvDocument *document, if (!globalParams) { globalParams = new GlobalParams("/etc/xpdfrc"); - globalParams->setupBaseFonts(NULL); + globalParams->setupBaseFontsFc(NULL); } filename = g_filename_from_uri (uri, NULL, error);