]> www.fi.muni.cz Git - evince.git/commitdiff
add prototype.
authorMartin Kretzschmar <martink@src.gnome.org>
Wed, 22 Dec 2004 11:50:50 +0000 (11:50 +0000)
committerMartin Kretzschmar <martink@src.gnome.org>
Wed, 22 Dec 2004 11:50:50 +0000 (11:50 +0000)
* 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.

ChangeLog
pdf/xpdf/GlobalParams.cc
pdf/xpdf/GlobalParams.h
pdf/xpdf/pdf-document.cc

index 3c66429a146544cd4a158407b0aef737e769d169..3f9b7d8a30277bfe8e18e69e2c7ba71c4bba5997 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2004-12-22  Martin Kretzschmar  <martink@gnome.org>
+
+       * 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  <marco@gnome.org>
 
        * Makefile.am:
index c125430200d7d39251a754852c7265ee5ea24cdc..c77576444f5cb2cf8f213067f1ff398316407ce1 100644 (file)
@@ -18,6 +18,7 @@
 #if HAVE_PAPER_H
 #include <paper.h>
 #endif
+#include <fontconfig/fontconfig.h>
 #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
 //------------------------------------------------------------------------
index 93ec06aa7d77041d90b44a47a0a3df929ad3a672..b09925677510e8cf5ead42d1354b92ccb93a750d 100644 (file)
@@ -16,6 +16,7 @@
 #endif
 
 #include <stdio.h>
+#include <fontconfig/fontconfig.h>
 #include "gtypes.h"
 #include "CharTypes.h"
 
@@ -116,6 +117,7 @@ public:
   ~GlobalParams();
 
   void setupBaseFonts(char *dir);
+  void setupBaseFontsFc(FcConfig *fcConfig);
 
   //----- accessors
 
index be15d7caf2e8c04e4de310ca957f8cd8d9b856c5..fa7c7fcfa4dd380718e47aa77e0b6b04d56283f3 100644 (file)
@@ -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);