Make fontconfig optional with mingw compiler
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 61d5d8a..0cd32df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,6 +30,13 @@
option(USE_EXCEPTIONS "Throw exceptions to deal with not enough memory and similar problems." OFF)
option(USE_FIXEDPOINT "Use fixed point arithmetic in the Splash backend" OFF)
option(USE_FLOAT "Use single precision arithmetic in the Splash backend" OFF)
+if(MSVC)
+ option(WITH_FONTCONFIGURATION_WIN32 "Select win32 font configuration backend" ON)
+ option(WITH_FONTCONFIGURATION_FONTCONFIG "Select fontconfig font configuration backend" OFF)
+else(MSVC)
+ option(WITH_FONTCONFIGURATION_WIN32 "Select win32 font configuration backend" OFF)
+ option(WITH_FONTCONFIGURATION_FONTCONFIG "Select fontconfig font configuration backend" ON)
+endif(MSVC)
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
@@ -271,7 +278,6 @@
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
-set(poppler_SRCS ${poppler_SRCS} poppler/GlobalParamsWin.cc)
add_library(poppler STATIC ${poppler_SRCS})
else(MSVC)
add_library(poppler SHARED ${poppler_SRCS})
diff --git a/config.h.cmake b/config.h.cmake
index 7150789..9527fd5 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -160,6 +160,12 @@
/* Version number of package */
#define VERSION "${POPPLER_VERSION}"
+/* Use fontconfig font configuration backend */
+#cmakedefine WITH_FONTCONFIGURATION_FONTCONFIG 1
+
+/* Use win32 font configuration backend */
+#cmakedefine WITH_FONTCONFIGURATION_WIN32 1
+
/* Define to 1 if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */
diff --git a/configure.ac b/configure.ac
index 29efd70..b22f467 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,7 @@
create_shared_lib="-no-undefined"
;;
mingw*)
+ os_win32=yes
win32_libs="-lgdi32"
create_shared_lib="-no-undefined"
auto_import_flags="-Wl,--enable-auto-import"
@@ -239,7 +240,42 @@
AC_SUBST(FREETYPE_CFLAGS)
AC_SUBST(FREETYPE_LIBS)
-PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.0.0)
+AC_MSG_CHECKING([which font configuration to use])
+AC_ARG_WITH([font_configuration],
+ [AS_HELP_STRING([--with-font-configuration=fontconfig|win32],
+ [Select font configuration backend])],
+ [],
+ [if test x$os_win32 = xyes; then
+ # default to win32 on native Windows.
+ with_font_configuration=win32
+ else
+ # default to fontconig everywhere else.
+ with_font_configuration=fontconfig
+ fi
+ ]
+)
+AC_MSG_RESULT([$with_font_configuration])
+
+case $with_font_configuration in
+ win32)
+ AC_DEFINE([WITH_FONTCONFIGURATION_WIN32],
+ [1],[Use win32 font configuration backend])
+ # Set the minimum required Internet Explorer version to 5.0
+ CPPFLAGS="$CPPFLAGS -D_WIN32_IE=0x0500"
+ ;;
+ fontconfig)
+ AC_DEFINE([WITH_FONTCONFIGURATION_FONTCONFIG],
+ [1],[Use fontconfig font configuration backend])
+ PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.0.0)
+ ;;
+ *)
+ AC_MSG_ERROR(
+ [Invalid font configuration setting: $with_font_configuration])
+ ;;
+esac
+
+AM_CONDITIONAL(BUILD_WITH_WIN32_FONTCONFIGURATION,
+ test x$with_font_configuration = xwin32)
AC_ARG_ENABLE(splash-output,
AC_HELP_STRING([--disable-splash-output],
@@ -566,6 +602,7 @@
echo ""
echo "Building poppler with support for:"
+echo " font configuration: $with_font_configuration"
echo " splash output: $enable_splash_output"
echo " cairo output: $enable_cairo_output"
echo " abiword output: $enable_abiword_output"
diff --git a/makefile.vc b/makefile.vc
index 1cacd2f..9d43828 100644
--- a/makefile.vc
+++ b/makefile.vc
@@ -62,6 +62,7 @@
LDFLAGS = $(LDFLAGS) /nologo /DEBUG
+CFLAGS = $(CFLAGS) /D "WITH_FONTCONFIGURATION_WIN32=1"
#CFLAGS = $(CFLAGS) /D "USE_FIXEDPOINT"
!if "$(TARGET)"=="rel"
@@ -87,7 +88,6 @@
$(O)\Decrypt.obj $(O)\Dict.obj $(O)\Error.obj \
$(O)\FontEncodingTables.obj $(O)\FontInfo.obj $(O)\Form.obj $(O)\Function.obj \
$(O)\Gfx.obj $(O)\GfxFont.obj $(O)\GfxState.obj $(O)\GlobalParams.obj \
- $(O)\GlobalParamsWin.obj \
$(O)\JArithmeticDecoder.obj $(O)\JBIG2Stream.obj $(O)\JPXStream.obj \
$(O)\Lexer.obj $(O)\Link.obj $(O)\NameToCharCode.obj $(O)\Object.obj \
$(O)\Outline.obj $(O)\OutputDev.obj $(O)\PDFDoc.obj $(O)\PDFDocEncoding.obj \
diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 2813b98..a91ecc1 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -22,6 +22,7 @@
// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com>
// Copyright (C) 2009 William Bader <williambader@hotmail.com>
// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
+// Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -557,7 +558,7 @@
UnicodeMap *map;
int i;
-#ifndef _MSC_VER
+#if WITH_FONTCONFIGURATION_FONTCONFIG
FcInit();
FCcfg = FcConfigGetCurrent();
#endif
@@ -962,7 +963,7 @@
}
}
-#ifndef _MSC_VER
+#if WITH_FONTCONFIGURATION_FONTCONFIG
static FcPattern *buildFcPattern(GfxFont *font)
{
int weight = -1,
@@ -1110,7 +1111,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
+#if WITH_FONTCONFIGURATION_FONTCONFIG
DisplayFontParam *GlobalParams::getDisplayFont(GfxFont *font) {
DisplayFontParam *dfp;
FcPattern *p=0;
@@ -1170,6 +1171,9 @@
return dfp;
}
#endif
+#if WITH_FONTCONFIGURATION_WIN32
+#include "GlobalParamsWin.cc"
+#endif
GBool GlobalParams::getPSExpandSmaller() {
GBool f;
diff --git a/poppler/GlobalParams.h b/poppler/GlobalParams.h
index b422e0c..37539a6 100644
--- a/poppler/GlobalParams.h
+++ b/poppler/GlobalParams.h
@@ -21,6 +21,7 @@
// Copyright (C) 2009 Jonathan Kew <jonathan_kew@sil.org>
// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com>
// Copyright (C) 2009 William Bader <williambader@hotmail.com>
+// Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -37,7 +38,7 @@
#include <assert.h>
#include "poppler-config.h"
#include <stdio.h>
-#ifndef _MSC_VER
+#if WITH_FONTCONFIGURATION_FONTCONFIG
#include <fontconfig/fontconfig.h>
#endif
#include "goo/gtypes.h"
@@ -169,7 +170,7 @@
void setBaseDir(char *dir);
-#ifdef _MSC_VER
+#if WITH_FONTCONFIGURATION_WIN32
void setupBaseFonts(char *dir);
#endif
@@ -352,7 +353,7 @@
UnicodeMapCache *unicodeMapCache;
CMapCache *cMapCache;
-#ifndef _MSC_VER
+#if WITH_FONTCONFIGURATION_FONTCONFIG
FcConfig *FCcfg;
#endif
diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
index 19ea546..2333ddb 100644
--- a/poppler/GlobalParamsWin.cc
+++ b/poppler/GlobalParamsWin.cc
@@ -1,5 +1,7 @@
/* Written by Krzysztof Kowalczyk (http://blog.kowalczyk.info)
but mostly based on xpdf code.
+
+ // Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
TODO: instead of a fixed mapping defined in displayFontTab, it could
scan the whole fonts directory, parse TTF files and build font
@@ -13,6 +15,9 @@
#endif
#include <windows.h>
+#if !(_WIN32_IE >= 0x0500)
+#error "_WIN32_IE must be defined >= 0x0500 for SHGFP_TYPE_CURRENT from shlobj.h"
+#endif
#include <shlobj.h>
#include <string.h>
#include <stdio.h>