1From 18f3a255561c2fe4cf93a4c0114550b8712e4494 Mon Sep 17 00:00:00 2001 2From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com> 3Date: Mon, 6 Nov 2017 06:59:37 +0100 4Subject: [PATCH] Use a custom font directory on Windows 5 6Uses the share/fonts directory alongside the application/poppler library 7--- 8 poppler/GlobalParams.cc | 32 +++++++++++++++++++++++++++++++- 9 poppler/GlobalParamsWin.cc | 2 +- 10 2 files changed, 32 insertions(+), 2 deletions(-) 11 12diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc 13index 4e46c183..dbd16c14 100644 14--- a/poppler/GlobalParams.cc 15+++ b/poppler/GlobalParams.cc 16@@ -152,6 +152,36 @@ static const char *get_poppler_datadir(void) 17 # undef POPPLER_DATADIR 18 # define POPPLER_DATADIR get_poppler_datadir() 19 20+static const char * 21+get_poppler_fontsdir (void) 22+{ 23+ static char retval[MAX_PATH]; 24+ static int beenhere = 0; 25+ 26+ unsigned char *p; 27+ 28+ if (beenhere) 29+ return retval; 30+ 31+ if (!GetModuleFileName (hmodule, (CHAR *) retval, sizeof(retval) - 20)) 32+ return POPPLER_DATADIR; 33+ 34+ p = _mbsrchr ((unsigned char *) retval, '\\'); 35+ *p = '\0'; 36+ p = _mbsrchr ((unsigned char *) retval, '\\'); 37+ if (p) { 38+ if (stricmp ((const char *) (p+1), "bin") == 0) 39+ *p = '\0'; 40+ } 41+ strcat (retval, "\\share\\fonts"); 42+ 43+ beenhere = 1; 44+ 45+ return retval; 46+} 47+#undef POPPLER_FONTSDIR 48+#define POPPLER_FONTSDIR get_poppler_fontsdir () 49+ 50 #endif 51 52 //------------------------------------------------------------------------ 53@@ -848,7 +878,7 @@ GooString *GlobalParams::findFontFile(const GooString *fontName) 54 { 55 GooString *path = nullptr; 56 57- setupBaseFonts(nullptr); 58+ setupBaseFonts(POPPLER_FONTSDIR); 59 globalParamsLocker(); 60 const auto fontFile = fontFiles.find(fontName->toStr()); 61 if (fontFile != fontFiles.end()) { 62diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc 63index 2056df18..c0f760e8 100644 64--- a/poppler/GlobalParamsWin.cc 65+++ b/poppler/GlobalParamsWin.cc 66@@ -504,7 +504,7 @@ GooString *GlobalParams::findSystemFontFile(const GfxFont *font, SysFontType *ty 67 if (!fontName) 68 return nullptr; 69 std::unique_lock<std::recursive_mutex> locker(mutex); 70- setupBaseFonts(nullptr); 71+ setupBaseFonts(POPPLER_FONTSDIR); 72 73 // TODO: base14Name should be changed? 74 // In the system using FontConfig, findSystemFontFile() uses 75-- 762.25.1 77 78