changeset 2424:9fadee4a9a23

Combine patches into single file and improve them as per suggestion at https://github.com/mxe/mxe/pull/21#issuecomment-5238769 - The "Qt4 custom global params" patch was dropped as poppler provides the possibility to put poppler-data into share/poppler anyway - The "applications fonts dir" patch was reworked to be more general, and to look for fonts in share/fonts/type1/gsfonts (in analogy to share/poppler and to *nix systems)
author Stefan Löffler <st.loeffler@gmail.com>
date Sat, 21 Apr 2012 13:37:51 +0200
parents 1ef908a16c3d
children 83dc2eed9081
files src/poppler-1-win32.patch src/poppler-application-fonts-dir.patch src/poppler-no-dll-export.patch src/poppler-path-check.patch src/poppler-qt4-globalparams.patch src/poppler-zapf-dingbats.patch
diffstat 6 files changed, 239 insertions(+), 186 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/poppler-1-win32.patch	Sat Apr 21 13:37:51 2012 +0200
@@ -0,0 +1,239 @@
+This file is part of MXE.
+See index.html for further information.
+
+From f084359f36e68aaaede8fed598933156e03ac442 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com>
+Date: Sat, 21 Apr 2012 09:29:25 +0200
+Subject: [PATCH 1/4] Fix Standard-14 fallback fonts
+
+wingding.ttf is totally different from ZapfDingbats. symbol.ttf is only a lousy fallback for Symbol.
+Based on patch provided by Jonathan Kew.
+---
+ poppler/GlobalParamsWin.cc |    6 +++++-
+ 1 files changed, 5 insertions(+), 1 deletions(-)
+
+diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
+index f989fb8..b15773f 100644
+--- a/poppler/GlobalParamsWin.cc
++++ b/poppler/GlobalParamsWin.cc
+@@ -73,13 +73,17 @@ static struct {
+     {"Helvetica-BoldOblique", "n019024l.pfb", "arialbi.ttf"},
+     {"Helvetica-Oblique",     "n019023l.pfb", "ariali.ttf"},
+     // TODO: not sure if "symbol.ttf" is right
++    // "symbol.ttf" can be used as a fallback, but some symbols are differently
++    // encoded (e.g., the glyphs for 'f', 'j', 'v'), while most other glyphs
++    // have a fairly different appearance
+     {"Symbol",                "s050000l.pfb", "symbol.ttf"},
+     {"Times-Bold",            "n021004l.pfb", "timesbd.ttf"},
+     {"Times-BoldItalic",      "n021024l.pfb", "timesbi.ttf"},
+     {"Times-Italic",          "n021023l.pfb", "timesi.ttf"},
+     {"Times-Roman",           "n021003l.pfb", "times.ttf"},
+     // TODO: not sure if "wingding.ttf" is right
+-    {"ZapfDingbats",          "d050000l.pfb", "wingding.ttf"},
++    // No, the symbol sets are totally different
++    {"ZapfDingbats",          "d050000l.pfb", NULL},
+ 
+     // those seem to be frequently accessed by PDF files and I kind of guess
+     // which font file do the refer to
+-- 
+1.7.5.4
+
+
+From 81dd27ef8bd213d8edc3e7983986bc17b6ef1d97 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com>
+Date: Sat, 21 Apr 2012 09:34:46 +0200
+Subject: [PATCH 2/4] Only check for Type1 fonts in custom directory if path
+ is non-NULL
+
+Otherwise, programs using poppler may crash
+---
+ poppler/GlobalParamsWin.cc |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
+index b15773f..f68577f 100644
+--- a/poppler/GlobalParamsWin.cc
++++ b/poppler/GlobalParamsWin.cc
+@@ -243,7 +243,7 @@ void GlobalParams::setupBaseFonts(char * dir)
+         if (displayFonts->lookup(fontName))
+             continue;
+ 
+-        if (dir) {
++        if (dir && displayFontTab[i].t1FileName) {
+             GooString *fontPath = appendToPath(new GooString(dir), displayFontTab[i].t1FileName);
+             if (FileExists(fontPath->getCString())) {
+                 AddFont(displayFonts, fontName, fontPath, displayFontT1);
+-- 
+1.7.5.4
+
+
+From 3ee566eef0bc1e45807de257ea9b914ead61d205 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com>
+Date: Sat, 21 Apr 2012 11:57:02 +0200
+Subject: [PATCH 3/4] Allow custom substitution fonts on Windows
+
+Standard-compliant PDF viewers must be able to handle 14 standard fonts even if they are not embedded. For the Symbol and ZapfDingbats fonts, there is no suitable alternative available on Windows by default, so they must be provided separately (and poppler must find them).
+
+The search path is share/fonts/type1/gsfonts (relative to poppler) similar to *nix systems and the search path for poppler-data.
+---
+ poppler/GlobalParams.cc    |   31 +++++++++++++++++++++++++++++++
+ poppler/GlobalParamsWin.cc |    2 +-
+ 2 files changed, 32 insertions(+), 1 deletions(-)
+
+diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
+index 687fd25..eea60be 100644
+--- a/poppler/GlobalParams.cc
++++ b/poppler/GlobalParams.cc
+@@ -214,6 +214,37 @@ get_poppler_datadir (void)
+ 
+ #ifdef _WIN32
+ 
++static char *
++get_poppler_fontdir (void)
++{
++#if !ENABLE_RELOCATABLE
++  static HMODULE hmodule = 0;
++#endif
++  static char retval[MAX_PATH];
++  static int beenhere = 0;
++
++  unsigned char *p;
++
++  if (beenhere)
++    return retval;
++
++  if (!GetModuleFileName (hmodule, (CHAR *) retval, sizeof(retval) - 32))
++    return NULL;
++
++  p = _mbsrchr ((unsigned char *) retval, '\\');
++  *p = '\0';
++  p = _mbsrchr ((unsigned char *) retval, '\\');
++  if (p) {
++    if (stricmp ((const char *) (p+1), "bin") == 0)
++      *p = '\0';
++  }
++  strcat (retval, "\\share\\fonts\\type1\\gsfonts");
++
++  beenhere = 1;
++
++  return retval;
++}
++
+ //------------------------------------------------------------------------
+ // WinFontInfo
+ //------------------------------------------------------------------------
+diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
+index f68577f..3ee75e4 100644
+--- a/poppler/GlobalParamsWin.cc
++++ b/poppler/GlobalParamsWin.cc
+@@ -281,7 +281,7 @@ DisplayFontParam *GlobalParams::getDisplayFont(GfxFont *font) {
+ 
+     if (!fontName) return NULL;
+     lockGlobalParams;
+-    setupBaseFonts(NULL);
++    setupBaseFonts(get_poppler_fontdir());
+     dfp = (DisplayFontParam *)displayFonts->lookup(fontName);
+     if (!dfp) {
+         substFontName = findSubstituteName(fontName->getCString());
+-- 
+1.7.5.4
+
+
+From 51130351c64db0137795a4f253732a2aac8a4ec2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com>
+Date: Sat, 21 Apr 2012 13:19:54 +0200
+Subject: [PATCH 4/4] Don't use dllimport/dllexport
+
+Otherwise static linking fails
+---
+ cpp/poppler-global.h     |    5 -----
+ poppler/XpdfPluginAPI.h  |   18 ------------------
+ qt4/src/poppler-export.h |    5 -----
+ 3 files changed, 0 insertions(+), 28 deletions(-)
+
+diff --git a/cpp/poppler-global.h b/cpp/poppler-global.h
+index 5650182..6c3e01b 100644
+--- a/cpp/poppler-global.h
++++ b/cpp/poppler-global.h
+@@ -20,13 +20,8 @@
+ #ifndef POPPLER_GLOBAL_H
+ #define POPPLER_GLOBAL_H
+ 
+-#if defined(_WIN32)
+-#  define LIB_EXPORT __declspec(dllexport)
+-#  define LIB_IMPORT __declspec(dllimport)
+-#else
+ #  define LIB_EXPORT
+ #  define LIB_IMPORT
+-#endif
+ 
+ #if defined(poppler_cpp_EXPORTS)
+ #  define POPPLER_CPP_EXPORT LIB_EXPORT
+diff --git a/poppler/XpdfPluginAPI.h b/poppler/XpdfPluginAPI.h
+index 22540f7..290aa63 100644
+--- a/poppler/XpdfPluginAPI.h
++++ b/poppler/XpdfPluginAPI.h
+@@ -28,19 +28,11 @@ extern "C" {
+  */
+ #define xpdfPluginAPIVersion 1
+ 
+-#ifdef _WIN32
+-#  ifdef __cplusplus
+-#    define PLUGINFUNC(retType) extern "C" __declspec(dllexport) retType
+-#  else
+-#    define PLUGINFUNC(retType) extern __declspec(dllexport) retType
+-#  endif
+-#else
+ #  ifdef __cplusplus
+ #    define PLUGINFUNC(retType) extern "C" retType
+ #  else
+ #    define PLUGINFUNC(retType) extern retType
+ #  endif
+-#endif
+ 
+ /*------------------------------------------------------------------------
+  * Plugin setup/cleanup
+@@ -285,22 +277,12 @@ void (*_xpdfRegisterSecurityHandler)(XpdfSecurityHandler *handler);
+ 
+ } XpdfPluginVecTable;
+ 
+-#ifdef _WIN32
+-
+-extern __declspec(dllexport) XpdfPluginVecTable xpdfPluginVecTable;
+-
+-#define xpdfPluginSetup \
+-  extern __declspec(dllexport) \
+-  XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
+-
+-#else
+ 
+ extern XpdfPluginVecTable xpdfPluginVecTable;
+ 
+ #define xpdfPluginSetup \
+   XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
+ 
+-#endif
+ 
+ #define xpdfGetInfoDict (*xpdfPluginVecTable._xpdfGetInfoDict)
+ #define xpdfGetCatalog (*xpdfPluginVecTable._xpdfGetCatalog)
+diff --git a/qt4/src/poppler-export.h b/qt4/src/poppler-export.h
+index 7661fe9..ebb1e18 100644
+--- a/qt4/src/poppler-export.h
++++ b/qt4/src/poppler-export.h
+@@ -2,13 +2,8 @@
+ * This file is used to set the poppler_qt4_EXPORT macros right.
+ * This is needed for setting the visibility on windows, it will have no effect on other platforms.
+ */
+-#if defined(_WIN32)
+-# define LIB_EXPORT __declspec(dllexport)
+-# define LIB_IMPORT __declspec(dllimport)
+-#else
+ # define LIB_EXPORT
+ # define LIB_IMPORT
+-#endif
+ 
+ #ifdef poppler_qt4_EXPORTS
+ # define POPPLER_QT4_EXPORT LIB_EXPORT
+-- 
+1.7.5.4
+
--- a/src/poppler-application-fonts-dir.patch	Tue Apr 17 21:07:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
-index f989fb8..7ec1b8f 100644
---- a/poppler/GlobalParamsWin.cc
-+++ b/poppler/GlobalParamsWin.cc
-@@ -274,10 +280,15 @@ DisplayFontParam *GlobalParams::getDisplayFont(GfxFont *font) {
-     DisplayFontParam *  dfp;
-     GooString *         fontName = font->getName();
-     char *              substFontName = NULL;
-+    char                appDir[MAX_PATH];
- 
-     if (!fontName) return NULL;
-     lockGlobalParams;
--    setupBaseFonts(NULL);
-+    if (::GetModuleFileName(0, appDir, MAX_PATH) > 0)
-+        setupBaseFonts(appendToPath(grabPath(appDir), "fonts")->getCString());
-+    else
-+        setupBaseFonts(NULL);
-+    
-     dfp = (DisplayFontParam *)displayFonts->lookup(fontName);
-     if (!dfp) {
-         substFontName = findSubstituteName(fontName->getCString());
-
--- a/src/poppler-no-dll-export.patch	Tue Apr 17 21:07:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
---- a/qt4/src/poppler-export.h	2010-06-24 18:36:48.918858971 +0200
-+++ b/qt4/src/poppler-export.h	2010-06-24 18:37:05.658857764 +0200
-@@ -2,13 +2,8 @@
- * This file is used to set the poppler_qt4_EXPORT macros right.
- * This is needed for setting the visibility on windows, it will have no effect on other platforms.
- */
--#if defined(_WIN32)
--# define LIB_EXPORT __declspec(dllexport)
--# define LIB_IMPORT __declspec(dllimport)
--#else
- # define LIB_EXPORT
- # define LIB_IMPORT
--#endif
- 
- #ifdef poppler_qt4_EXPORTS
- # define POPPLER_QT4_EXPORT LIB_EXPORT
---- a/cpp/poppler-global.h	2012-04-16 08:02:52.946380873 +0200
-+++ b/cpp/poppler-global.h	2012-04-16 08:03:23.882534269 +0200
-@@ -20,13 +20,8 @@
- #ifndef POPPLER_GLOBAL_H
- #define POPPLER_GLOBAL_H
- 
--#if defined(_WIN32)
--#  define LIB_EXPORT __declspec(dllexport)
--#  define LIB_IMPORT __declspec(dllimport)
--#else
- #  define LIB_EXPORT
- #  define LIB_IMPORT
--#endif
- 
- #if defined(poppler_cpp_EXPORTS)
- #  define POPPLER_CPP_EXPORT LIB_EXPORT
---- a/poppler/XpdfPluginAPI.h	2012-04-16 08:05:16.523092822 +0200
-+++ b/poppler/XpdfPluginAPI.h	2012-04-16 08:05:49.019253960 +0200
-@@ -28,19 +28,11 @@
-  */
- #define xpdfPluginAPIVersion 1
- 
--#ifdef _WIN32
--#  ifdef __cplusplus
--#    define PLUGINFUNC(retType) extern "C" __declspec(dllexport) retType
--#  else
--#    define PLUGINFUNC(retType) extern __declspec(dllexport) retType
--#  endif
--#else
- #  ifdef __cplusplus
- #    define PLUGINFUNC(retType) extern "C" retType
- #  else
- #    define PLUGINFUNC(retType) extern retType
- #  endif
--#endif
- 
- /*------------------------------------------------------------------------
-  * Plugin setup/cleanup
-@@ -285,22 +277,12 @@
- 
- } XpdfPluginVecTable;
- 
--#ifdef _WIN32
--
--extern __declspec(dllexport) XpdfPluginVecTable xpdfPluginVecTable;
--
--#define xpdfPluginSetup \
--  extern __declspec(dllexport) \
--  XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
--
--#else
- 
- extern XpdfPluginVecTable xpdfPluginVecTable;
- 
- #define xpdfPluginSetup \
-   XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
- 
--#endif
- 
- #define xpdfGetInfoDict (*xpdfPluginVecTable._xpdfGetInfoDict)
- #define xpdfGetCatalog (*xpdfPluginVecTable._xpdfGetCatalog)
--- a/src/poppler-path-check.patch	Tue Apr 17 21:07:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
-index f989fb8..7ec1b8f 100644
---- a/poppler/GlobalParamsWin.cc
-+++ b/poppler/GlobalParamsWin.cc
-@@ -239,7 +245,7 @@ void GlobalParams::setupBaseFonts(char * dir)
-         if (displayFonts->lookup(fontName))
-             continue;
- 
--        if (dir) {
-+        if (dir && displayFontTab[i].t1FileName) {
-             GooString *fontPath = appendToPath(new GooString(dir), displayFontTab[i].t1FileName);
-             if (FileExists(fontPath->getCString())) {
-                 AddFont(displayFonts, fontName, fontPath, displayFontT1);
-
--- a/src/poppler-qt4-globalparams.patch	Tue Apr 17 21:07:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc
-index 04c56c6..d1d45d9 100644
---- a/qt4/src/poppler-document.cc
-+++ b/qt4/src/poppler-document.cc
-@@ -46,6 +46,7 @@
- namespace Poppler {
- 
-   int DocumentData::count = 0;
-+  GBool DocumentData::ownGlobalParams = gFalse;
- 
-   Document *Document::load(const QString &filePath, const QByteArray &ownerPassword,
- 			   const QByteArray &userPassword)
-diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
-index d6e3265..075b3fd 100644
---- a/qt4/src/poppler-private.cc
-+++ b/qt4/src/poppler-private.cc
-@@ -234,8 +234,13 @@ namespace Debug {
-         count --;
-         if ( count == 0 )
-         {
--            utf8Map = 0;
--            delete globalParams;
-+            if ( ownGlobalParams )
-+            {
-+                utf8Map = 0;
-+                delete globalParams;
-+                globalParams = NULL;
-+                ownGlobalParams = gFalse;
-+            }
-         }
-       }
-     
-@@ -250,8 +255,12 @@ namespace Debug {
-       
-         if ( count == 0 )
-         {
--            utf8Map = 0;
--            globalParams = new GlobalParams();
-+            if ( !globalParams )
-+            {
-+                utf8Map = 0;
-+                globalParams = new GlobalParams();
-+                ownGlobalParams = gTrue;
-+            }
-             setErrorFunction(qt4ErrorFunction);
-         }
-         count ++;
-diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h
-index 7d0b1a3..9614e38 100644
---- a/qt4/src/poppler-private.h
-+++ b/qt4/src/poppler-private.h
-@@ -197,6 +197,7 @@ namespace Poppler {
- 	QColor paperColor;
- 	int m_hints;
- 	static int count;
-+	static GBool ownGlobalParams;
-     };
- 
-     class FontInfoData
--- a/src/poppler-zapf-dingbats.patch	Tue Apr 17 21:07:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
-index f989fb8..7ec1b8f 100644
---- a/poppler/GlobalParamsWin.cc
-+++ b/poppler/GlobalParamsWin.cc
-@@ -79,7 +79,8 @@ static struct {
-     {"Times-Italic",          "n021023l.pfb", "timesi.ttf"},
-     {"Times-Roman",           "n021003l.pfb", "times.ttf"},
-     // TODO: not sure if "wingding.ttf" is right
--    {"ZapfDingbats",          "d050000l.pfb", "wingding.ttf"},
-+    // no, the symbol sets are quite different
-+    {"ZapfDingbats",          "d050000l.pfb", NULL},
- 
-     // those seem to be frequently accessed by PDF files and I kind of guess
-     // which font file do the refer to