From 1cb4cae22140822b5ff4f2bbe3dbc779885bba9c Mon Sep 17 00:00:00 2001 From: Hib Eris Date: Tue, 29 Dec 2009 22:28:43 +0100 Subject: [PATCH] Make fontconfig optional with mingw compiler --- CMakeLists.txt | 8 +++++++- config.h.cmake | 6 ++++++ configure.ac | 39 ++++++++++++++++++++++++++++++++++++++- makefile.vc | 2 +- poppler/GlobalParams.cc | 9 ++++++--- poppler/GlobalParams.h | 6 +++--- poppler/GlobalParamsWin.cc | 3 +++ 7 files changed, 64 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae5f8d6..a0fd3f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,13 @@ option(ENABLE_LCMS "Use liblcms for color management." ON) option(ENABLE_ZLIB "TODO" OFF) option(USE_EXCEPTIONS "Throw exceptions to deal with not enough memory and similar problems." OFF) option(USE_FIXEDPOINT "Use fixed point arithmetic" 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)") @@ -270,7 +277,6 @@ endif(PNG_FOUND) 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 7145e6a..1f4f636 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -157,6 +157,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 7a8ca19..d3b82ec 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,7 @@ case "$host_os" in create_shared_lib="-no-undefined" ;; mingw*) + os_win32=yes win32_libs="-lgdi32" create_shared_lib="-no-undefined" auto_import_flags="-Wl,--enable-auto-import" @@ -235,7 +236,42 @@ fi 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], @@ -562,6 +598,7 @@ poppler-qt4.pc]) 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 @@ LIBS = $(LIBS) kernel32.lib advapi32.lib user32.lib gdi32.lib LDFLAGS = $(LDFLAGS) /nologo /DEBUG +CFLAGS = $(CFLAGS) /D "WITH_FONTCONFIGURATION_WIN32=1" #CFLAGS = $(CFLAGS) /D "USE_FIXEDPOINT" !if "$(TARGET)"=="rel" @@ -87,7 +88,6 @@ POPPLER_OBJS=$(O)\Annot.obj $(O)\Array.obj $(O)\BuiltinFont.obj $(O)\BuiltinFont $(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..eda0a34 100644 --- a/poppler/GlobalParams.cc +++ b/poppler/GlobalParams.cc @@ -557,7 +557,7 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir) UnicodeMap *map; int i; -#ifndef _MSC_VER +#if WITH_FONTCONFIGURATION_FONTCONFIG FcInit(); FCcfg = FcConfigGetCurrent(); #endif @@ -962,7 +962,7 @@ static GBool findModifier(const char *name, const char *modifier, const char **s } } -#ifndef _MSC_VER +#if WITH_FONTCONFIGURATION_FONTCONFIG static FcPattern *buildFcPattern(GfxFont *font) { int weight = -1, @@ -1110,7 +1110,7 @@ static FcPattern *buildFcPattern(GfxFont *font) /* 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 +1170,9 @@ fin: 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..c6373b1 100644 --- a/poppler/GlobalParams.h +++ b/poppler/GlobalParams.h @@ -37,7 +37,7 @@ #include #include "poppler-config.h" #include -#ifndef _MSC_VER +#if WITH_FONTCONFIGURATION_FONTCONFIG #include #endif #include "goo/gtypes.h" @@ -169,7 +169,7 @@ public: void setBaseDir(char *dir); -#ifdef _MSC_VER +#if WITH_FONTCONFIGURATION_WIN32 void setupBaseFonts(char *dir); #endif @@ -352,7 +352,7 @@ private: 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..54113a6 100644 --- a/poppler/GlobalParamsWin.cc +++ b/poppler/GlobalParamsWin.cc @@ -13,6 +13,9 @@ description for all fonts available in Windows. That's how MuPDF works. #endif #include +#if !(_WIN32_IE >= 0x0500) +#error "_WIN32_IE must be defined >= 0x0500 for SHGFP_TYPE_CURRENT from shlobj.h" +#endif #include #include #include -- 1.6.0.4