diff options
author | Albert Astals Cid <aacid@kde.org> | 2022-04-22 17:50:04 +0200 |
---|---|---|
committer | Albert Astals Cid <tsdgeos@yahoo.es> | 2022-05-09 21:34:30 +0000 |
commit | 5b476757e70c79e8dca5fe2a3fb69cbbbfe710a9 (patch) | |
tree | 28f296000044d6e59db5d939fb868d5d44e87bb7 | |
parent | 29f32a477f0f75ee44df890acac377a2eed314c6 (diff) |
GetWindowsFontDir: Simply call SHGetFolderPathA
Instead of all the dance with loading various different dlls
We don't support terribly old Windows that don't even have SHGetFolderPathA
-rw-r--r-- | poppler/GlobalParamsWin.cc | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc index a22bbf79..d33c09bd 100644 --- a/poppler/GlobalParamsWin.cc +++ b/poppler/GlobalParamsWin.cc @@ -26,9 +26,7 @@ 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 <cstring> #include <cstdio> @@ -163,37 +161,11 @@ static std::string GetWindowsFontDir() char winFontDir[MAX_PATH]; winFontDir[0] = '\0'; - // SHGetSpecialFolderPath isn't available in older versions of shell32.dll (Win95 and - // WinNT4), so do a dynamic load of ANSI versions. - HMODULE hLib = LoadLibraryA("shell32.dll"); - if (hLib) { - auto SHGetFolderPathFunc = reinterpret_cast<HRESULT(__stdcall *)(HWND, int, HANDLE, DWORD, LPSTR)>(GetProcAddress(hLib, "SHGetFolderPathA")); - if (SHGetFolderPathFunc) - (*SHGetFolderPathFunc)(nullptr, CSIDL_FONTS, nullptr, SHGFP_TYPE_CURRENT, winFontDir); - - if (!winFontDir[0]) { - // Try an older function - auto SHGetSpecialFolderPathFunc = reinterpret_cast<BOOL(__stdcall *)(HWND, LPSTR, int, BOOL)>(GetProcAddress(hLib, "SHGetSpecialFolderPathA")); - if (SHGetSpecialFolderPathFunc) - (*SHGetSpecialFolderPathFunc)(nullptr, winFontDir, CSIDL_FONTS, FALSE); - } - FreeLibrary(hLib); - } - if (winFontDir[0]) + if (SHGetFolderPathA(nullptr, CSIDL_FONTS, nullptr, SHGFP_TYPE_CURRENT, winFontDir) == S_OK) { return winFontDir; - - // Try older DLL - hLib = LoadLibraryA("SHFolder.dll"); - if (hLib) { - auto SHGetFolderPathFunc = reinterpret_cast<HRESULT(__stdcall *)(HWND, int, HANDLE, DWORD, LPSTR)>(GetProcAddress(hLib, "SHGetFolderPathA")); - if (SHGetFolderPathFunc) - (*SHGetFolderPathFunc)(nullptr, CSIDL_FONTS, nullptr, SHGFP_TYPE_CURRENT, winFontDir); - FreeLibrary(hLib); } - if (winFontDir[0]) - return winFontDir; - // Everything else failed so the standard fonts directory. + // return the windows directory + fonts GetWindowsDirectoryA(winFontDir, MAX_PATH); if (winFontDir[0]) { return std::string(winFontDir) + "\\fonts"; |