CMakeLists.txt | 8 ++++- config.h.cmake | 6 ++++ configure.ac | 65 ++++++++++++++++++++++++++++++++++++++++++- makefile.vc | 2 - poppler/GlobalParams.cc | 67 ++++++++++++++++++++++++++++++++++++++++++--- poppler/GlobalParams.h | 7 ++-- poppler/GlobalParamsWin.cc | 5 +++ 7 files changed, 151 insertions(+), 9 deletions(-)
New commits: commit 350ff407e06a961f2a5b9d203cb8e78ce09313a0 Author: Hib Eris <[email protected]> Date: Wed Jan 13 22:20:41 2010 +0000 Make poppler (optionally) relocatable on Windows diff --git a/configure.ac b/configure.ac index b22f467..dae0a1e 100644 --- a/configure.ac +++ b/configure.ac @@ -76,6 +76,32 @@ AC_ARG_ENABLE(fixedpoint, [ --enable-fixedpoint use fixed point (instead of double precision) arithmetic in the Splash backend], AC_DEFINE(USE_FIXEDPOINT, [1], [Use fixed point arithmetic])) +dnl Relocation support +AC_ARG_ENABLE(relocatable, + AC_HELP_STRING([--disable-relocatable], + [Hardcode the poppler library location (on Windows).]), + enable_relocatable=$enableval, + [if test x$os_win32 = xyes; then + # default to yes on native Windows. + enable_relocatable="yes" + else + # default to no everywhere else. + enable_relocatable="no" + fi + ] +) + +if test x$enable_relocatable = xyes; then + if test x$os_win32 = xyes; then + AC_DEFINE([ENABLE_RELOCATABLE], + [1],[Do not hardcode the library location]) + else + AC_MSG_ERROR( + [Invalid setting for relocatable, only supported on windows]) + + fi +fi + AC_DEFINE_DIR(POPPLER_DATADIR, "{datarootdir}/poppler", [Poppler data dir]) dnl ##### Checks for header files. diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc index a91ecc1..493159d 100644 --- a/poppler/GlobalParams.cc +++ b/poppler/GlobalParams.cc @@ -45,6 +45,7 @@ #endif #ifdef _WIN32 # include <shlobj.h> +# include <mbstring.h> #endif #include "goo/gmem.h" #include "goo/GooString.h" @@ -141,6 +142,62 @@ DisplayFontParam::~DisplayFontParam() { } } +#if ENABLE_RELOCATABLE && defined(_WIN32) + +/* search for data relative to where we are installed */ + +static HMODULE hmodule; + +extern "C" { +BOOL WINAPI +DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + hmodule = hinstDLL; + break; + } + + return TRUE; +} +} + +static char * +get_poppler_datadir (void) +{ + static char retval[_MAX_PATH]; + static int beenhere = 0; + + unsigned char *p; + + if (beenhere) + return retval; + + if (!GetModuleFileName (hmodule, (CHAR *) retval, sizeof(retval) - 20)) + return POPPLER_DATADIR; + + p = _mbsrchr ((const unsigned char *) retval, '\\'); + *p = '\0'; + p = _mbsrchr ((const unsigned char *) retval, '\\'); + if (p) { + if (stricmp ((const char *) (p+1), "bin") == 0) + *p = '\0'; + } + strcat (retval, "\\share\\poppler"); + + beenhere = 1; + + return retval; +} + +#undef POPPLER_DATADIR +#define POPPLER_DATADIR get_poppler_datadir () + +#endif + #ifdef _WIN32 //------------------------------------------------------------------------ commit 36b67b002db802bfad553720e2114b76b07bb614 Author: Hib Eris <[email protected]> Date: Wed Jan 13 22:17:03 2010 +0000 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(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 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 @@ 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 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 @@ 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" @@ -239,7 +240,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], @@ -566,6 +602,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..a91ecc1 100644 --- a/poppler/GlobalParams.cc +++ b/poppler/GlobalParams.cc @@ -22,6 +22,7 @@ // Copyright (C) 2009 Petr Gajdos <[email protected]> // Copyright (C) 2009 William Bader <[email protected]> // Copyright (C) 2009 Kovid Goyal <[email protected]> +// Copyright (C) 2010 Hib Eris <[email protected]> // // 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 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir) UnicodeMap *map; int i; -#ifndef _MSC_VER +#if WITH_FONTCONFIGURATION_FONTCONFIG FcInit(); FCcfg = FcConfigGetCurrent(); #endif @@ -962,7 +963,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 +1111,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 +1171,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..37539a6 100644 --- a/poppler/GlobalParams.h +++ b/poppler/GlobalParams.h @@ -21,6 +21,7 @@ // Copyright (C) 2009 Jonathan Kew <[email protected]> // Copyright (C) 2009 Petr Gajdos <[email protected]> // Copyright (C) 2009 William Bader <[email protected]> +// Copyright (C) 2010 Hib Eris <[email protected]> // // 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 @@ public: void setBaseDir(char *dir); -#ifdef _MSC_VER +#if WITH_FONTCONFIGURATION_WIN32 void setupBaseFonts(char *dir); #endif @@ -352,7 +353,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..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 <[email protected]> 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 @@ description for all fonts available in Windows. That's how MuPDF works. #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> _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
