[poppler] Fontconfig dependency for pdftops?

Peter Åstrand astrand at cendio.se
Tue Feb 19 03:42:43 PST 2008


On Sun, 10 Feb 2008, Peter Åstrand wrote:

> We are updating our "pdftops" from the one shipped with xpdf-2.02pl1 to 
> the latest poppler version. Is fontconfig a hard dependency nowadays, even 
> for tools like pdftops?

I think I can answer this myself. Yes, it's a hard dependency, but it's 
easy to get rid of. pdftops seems to work perfectly fine without 
fontconfig, and the size of the resulting binary is greatly reduced. 
Another great advantage is that the binary will be self contained and does 
not require a fontconfig configuration. 

In GlobalParams.cc, there's a comment:

 /* if you can't or don't want to use Fontconfig, you need to implement
    this function for your platform. For Windows, it's in GlobalParamsWin.cc
 */

However, the code in question is surrounded by "#ifndef _MSC_VER", which 
is not very generic. The attached patch generalizes this and depends on 
the define "DISABLE_FONTCONFIG" instead. Additionally, it provides a stub 
implementation of getDisplayFont on UNIX, when fontconfig is not used. 

Any chance this patch can be accepted? In addition to making it possible 
to build Poppler without fontconfig on UNIX, it also makes it possible to 
build Poppler for Windows with MinGW, without Fontconfig. 

Best regards, 
---
Peter Åstrand		ThinLinc Chief Developer
Cendio AB		http://www.cendio.se
Wallenbergs gata 4
583 30 Linköping	Phone: +46-13-21 46 00
-------------- next part --------------
Index: poppler/GlobalParams.h
===================================================================
--- poppler/GlobalParams.h	(revision 14451)
+++ poppler/GlobalParams.h	(working copy)
@@ -16,7 +16,10 @@
 #include <assert.h>
 #include "poppler-config.h"
 #include <stdio.h>
-#ifndef _MSC_VER
+#ifdef _MSC_VER
+#define DISABLE_FONTCONFIG 1
+#endif
+#ifndef DISABLE_FONTCONFIG
 #include <fontconfig/fontconfig.h>
 #endif
 #include "goo/gtypes.h"
@@ -324,7 +327,7 @@
   UnicodeMapCache *unicodeMapCache;
   CMapCache *cMapCache;
   
-#ifndef _MSC_VER
+#ifndef DISABLE_FONTCONFIG
   FcConfig *FCcfg;
 #endif
 
Index: poppler/GlobalParams.cc
===================================================================
--- poppler/GlobalParams.cc	(revision 14452)
+++ poppler/GlobalParams.cc	(working copy)
@@ -533,7 +533,7 @@
   UnicodeMap *map;
   int i;
 
-#ifndef _MSC_VER  
+#ifndef DISABLE_FONTCONFIG  
   FcInit();
   FCcfg = FcConfigGetCurrent();
 #endif
@@ -925,7 +925,7 @@
   }
 }
 
-#ifndef _MSC_VER
+#ifndef DISABLE_FONTCONFIG
 static FcPattern *buildFcPattern(GfxFont *font)
 {
   int weight = FC_WEIGHT_NORMAL,
@@ -1072,7 +1072,7 @@
 /* if you can't or don't want to use Fontconfig, you need to implement
    this function for your platform. For Windows, it's in GlobalParamsWin.cc
 */
-#ifndef _MSC_VER
+#ifndef DISABLE_FONTCONFIG
 DisplayFontParam *GlobalParams::getDisplayFont(GfxFont *font) {
   DisplayFontParam *dfp;
   FcPattern *p=0;
@@ -1131,6 +1131,15 @@
   unlockGlobalParams;
   return dfp;
 }
+#else
+/* Dummy implementation on non-windows */
+#ifndef _MSC_VER
+DisplayFontParam *GlobalParams::getDisplayFont(GfxFont *font) {
+    warning("No FontConfig - No getDisplayFont implementation on this platform\n");
+    return NULL;
+}
+
+#endif // _MSC_VER
 #endif
 
 GBool GlobalParams::getPSExpandSmaller() {
Index: poppler/PreScanOutputDev.cc
===================================================================
--- poppler/PreScanOutputDev.cc	(revision 14451)
+++ poppler/PreScanOutputDev.cc	(working copy)
@@ -6,6 +6,8 @@
 //
 //========================================================================
 
+#include <config.h>
+
 #ifdef USE_GCC_PRAGMAS
 #pragma implementation
 #endif
Index: configure.ac
===================================================================
--- configure.ac	(revision 14455)
+++ configure.ac	(working copy)
@@ -154,7 +154,17 @@
 AC_SUBST(FREETYPE_CFLAGS)
 AC_SUBST(FREETYPE_LIBS)
 
-PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.0.0)
+AC_ARG_ENABLE(fontconfig,
+              AC_HELP_STRING([--disable-fontconfig],
+                             [Disable FontConfig support.]),
+              enable_fontconfig=$enableval,
+              enable_fontconfig="yes")
+AH_TEMPLATE([DISABLE_FONTCONFIG], [Disable FontConfig support.])
+if test x$enable_fontconfig = xyes; then
+    PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.0.0)
+else
+    AC_DEFINE(DISABLE_FONTCONFIG)
+fi
 
 AC_ARG_ENABLE(splash-output,
               AC_HELP_STRING([--disable-splash-output],
Index: utils/HtmlFonts.cc
===================================================================
--- utils/HtmlFonts.cc	(revision 14451)
+++ utils/HtmlFonts.cc	(working copy)
@@ -1,3 +1,4 @@
+#include "config.h"
 #include "HtmlFonts.h"
 #include "GlobalParams.h"
 #include "UnicodeMap.h"


More information about the poppler mailing list