[poppler] Fontconfig patch

Martin Kretzschmar m_kretzschmar at gmx.net
Wed Jul 20 20:02:07 EST 2005


Hi,

Albert Astals Cid schrieb:
> Ok, here it goes again the patch with the fixes from Jeff about styling and 
> the h - name thing, the fix for Brad if BOOK is not defined and the fix for 
> Stefan so he can define and extern fontconfig configuration object.
> 
> More comments?

>>Index: poppler/GlobalParams.cc
>>===================================================================
>>RCS file: /cvs/poppler/poppler/poppler/GlobalParams.cc,v
>>retrieving revision 1.2
>>diff -u -r1.2 GlobalParams.cc
>>--- poppler/GlobalParams.cc	28 Apr 2005 23:03:06 -0000	1.2
>>+++ poppler/GlobalParams.cc	18 Jul 2005 16:14:09 -0000
>>@@ -32,6 +32,7 @@
>> #include "BuiltinFontTables.h"
>> #include "FontEncodingTables.h"
>> #include "GlobalParams.h"
>>+#include "GfxFont.h"
>> 
>> #if MULTITHREADED
>> #  define lockGlobalParams            gLockMutex(&mutex)
>>@@ -49,6 +50,10 @@
>> #  define unlockCMapCache
>> #endif
>> 
>>+#ifndef FC_WEIGHT_BOOK
>>+#define FC_WEIGHT_BOOK 75
>>+#endif
>>+
>> #include "NameToUnicodeTable.h"
>> #include "UnicodeMapTables.h"
>> #include "UTF8.h"
>>@@ -60,62 +65,6 @@
>> 
>> //------------------------------------------------------------------------
>> 
>>-static struct {
>>-  char *name;
>>-  char *fileName;
>>-} displayFontTab[] = {
>>-  {"Courier",               "n022003l.pfb"},
>>-  {"Courier-Bold",          "n022004l.pfb"},
>>-  {"Courier-BoldOblique",   "n022024l.pfb"},
>>-  {"Courier-Oblique",       "n022023l.pfb"},
>>-  {"Helvetica",             "n019003l.pfb"},
>>-  {"Helvetica-Bold",        "n019004l.pfb"},
>>-  {"Helvetica-BoldOblique", "n019024l.pfb"},
>>-  {"Helvetica-Oblique",     "n019023l.pfb"},
>>-  {"Symbol",                "s050000l.pfb"},
>>-  {"Times-Bold",            "n021004l.pfb"},
>>-  {"Times-BoldItalic",      "n021024l.pfb"},
>>-  {"Times-Italic",          "n021023l.pfb"},
>>-  {"Times-Roman",           "n021003l.pfb"},
>>-  {"ZapfDingbats",          "d050000l.pfb"},
>>-  {NULL}
>>-};
>>-
>>-static char *displayFontDirs[] = {
>>-  "/usr/share/ghostscript/fonts",
>>-  "/usr/local/share/ghostscript/fonts",
>>-  "/usr/share/fonts/default/Type1",
>>-  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"},

We should test if we need a special workaround for the "Symbol" font in
the new fontconfig code too. As written in the comment, I had just
stolen the patterns from mupdf. I never tested the old code with the
Symbol font.

>>-  {"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;
>> 
>> //------------------------------------------------------------------------
>>@@ -181,6 +130,9 @@
>>   GooString *fileName;
>>   FILE *f;
>>   int i;
>>+  
>>+  FcInit();
>>+  FCcfg = FcConfigGetCurrent();
>> 
>> #if MULTITHREADED
>>   gInitMutex(&mutex);
>>@@ -207,8 +159,6 @@
>>   cMapDirs = new GooHash(gTrue);
>>   toUnicodeDirs = new GooList();
>>   displayFonts = new GooHash();
>>-  displayCIDFonts = new GooHash();
>>-  displayNamedCIDFonts = new GooHash();
>> #if HAVE_PAPER_H
>>   char *paperName;
>>   const struct paper *paperType;
>>@@ -394,21 +344,21 @@
>>       } else if (!cmd->cmp("toUnicodeDir")) {
>> 	parseToUnicodeDir(tokens, fileName, line);
>>       } else if (!cmd->cmp("displayFontT1")) {
>>-	parseDisplayFont(tokens, displayFonts, displayFontT1, fileName, line);
>>+// 	parseDisplayFont(tokens, displayFonts, displayFontT1, fileName, line);
>>       } else if (!cmd->cmp("displayFontTT")) {
>>-	parseDisplayFont(tokens, displayFonts, displayFontTT, fileName, line);
>>+// 	parseDisplayFont(tokens, displayFonts, displayFontTT, fileName, line);
>>       } else if (!cmd->cmp("displayNamedCIDFontT1")) {
>>-	parseDisplayFont(tokens, displayNamedCIDFonts,
>>-			 displayFontT1, fileName, line);
>>+// 	parseDisplayFont(tokens, displayNamedCIDFonts,
>>+// 			 displayFontT1, fileName, line);
>>       } else if (!cmd->cmp("displayCIDFontT1")) {
>>-	parseDisplayFont(tokens, displayCIDFonts,
>>-			 displayFontT1, fileName, line);
>>+// 	parseDisplayFont(tokens, displayCIDFonts,
>>+// 			 displayFontT1, fileName, line);
>>       } else if (!cmd->cmp("displayNamedCIDFontTT")) {
>>-	parseDisplayFont(tokens, displayNamedCIDFonts,
>>-			 displayFontTT, fileName, line);
>>+// 	parseDisplayFont(tokens, displayNamedCIDFonts,
>>+// 			 displayFontTT, fileName, line);
>>       } else if (!cmd->cmp("displayCIDFontTT")) {
>>-	parseDisplayFont(tokens, displayCIDFonts,
>>-			 displayFontTT, fileName, line);
>>+// 	parseDisplayFont(tokens, displayCIDFonts,
>>+// 			 displayFontTT, fileName, line);
>>       } else if (!cmd->cmp("psFile")) {
>> 	parsePSFile(tokens, fileName, line);
>>       } else if (!cmd->cmp("psFont")) {

Why do you leave the comments? After all the parseDisplayFont function
exists no longer. Maybe just a "// deprecated" comment.

>>+FcPattern *buildFcPattern(GfxFont *font)
>>+{
>>+  int weight = FC_WEIGHT_NORMAL,
>>+      slant = FC_SLANT_ROMAN,
>>+      width = FC_WIDTH_NORMAL,
>>+      spacing = FC_PROPORTIONAL;
>>+  bool deleteFamily = false;
>>+  char *family, *name, *lang, *aux = NULL;
>>+  const char *h = NULL;
>>+  FcPattern *p;
>> 
>>-  lockGlobalParams;
>>-  dfp = (DisplayFontParam *)displayFonts->lookup(fontName);
>>-  unlockGlobalParams;
>>-  return dfp;
>>+  // this is all heuristics will be overwritten if font had proper info
>>+  name = font->getName()->getCString();

Can getName() return NULL?


>>+  // find the language we want the font to support
>>+  if (font->isCIDFont())
>>+  {
>>+    GooString *collection = ((GfxCIDFont *)font)->getCollection();
>>+    if (collection)
>>+    {
>>+      if (strcmp(collection->getCString(), "Adobe-GB1") == 0)
>>+        lang = "zh-cn"; // Simplified Chinese
>>+      else if (strcmp(collection->getCString(), "Adobe-CNS1") == 0)
>>+        lang = "zh-tw"; // Traditional Chinese
>>+      else if (strcmp(collection->getCString(), "Adobe-Japan1") == 0)
>>+        lang = "ja"; // Japanese
>>+      else if (strcmp(collection->getCString(), "Adobe-Japan2") == 0)
>>+        lang = "ja"; // Japanese
>>+      else if (strcmp(collection->getCString(), "Adobe-Korea1") == 0)
>>+        lang = "ko"; // Korean
>>+      else

Can "Adobe-Identity" or "Adobe-UCS" happen here? If so, I guess they
should be lang = "xx", without the error.

Regards,

Martin


More information about the poppler mailing list