external/fontconfig/windowsfonts.patch |   40 +++++++++++++++------------------
 1 file changed, 19 insertions(+), 21 deletions(-)

New commits:
commit 859e06502e4fd265ccea70678106e2cafa8fb4d9
Author:     Tor Lillqvist <[email protected]>
AuthorDate: Mon Apr 14 18:54:35 2025 +0300
Commit:     Caolán McNamara <[email protected]>
CommitDate: Tue Dec 2 09:35:35 2025 +0100

    Make the fontconfig Windows patch apply to fontconfig 2.16.1
    
    Note that this patch is for now just a start of work that is paused
    for now. The handling of non-ASCII filenames in the external libraries
    that in the CODA case are now used also on Windows is likely very
    broken, and needs to be carefully checked and modified. The new
    <tools/UnixWrappers.h> thing, with additional work, will probably be
    used.
    
    Change-Id: I30cb09747a8de8716608669a75c872b73812b3f0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194587
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/external/fontconfig/windowsfonts.patch 
b/external/fontconfig/windowsfonts.patch
index feaaf80937c5..dccad99db916 100644
--- a/external/fontconfig/windowsfonts.patch
+++ b/external/fontconfig/windowsfonts.patch
@@ -12,37 +12,35 @@ well.
 @@ -58,6 +58,8 @@
  
  #ifdef _WIN32
- #include <mbstring.h>
-+#include <wchar.h>
-+#include <Shlobj.h>
- extern FcChar8 fontconfig_instprefix[];
+ #  include <mbstring.h>
++#  include <wchar.h>
++#  include <Shlobj.h>
+ extern FcChar8               fontconfig_instprefix[];
  pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory = NULL;
- pfnSHGetFolderPathA pSHGetFolderPathA = NULL;
-@@ -1386,18 +1387,25 @@
-     }
-     else if (strcmp ((const char *) path, "WINDOWSFONTDIR") == 0)
-     {
+ pfnSHGetFolderPathA          pSHGetFolderPathA = NULL;
+@@ -1386,17 +1387,23 @@
+       }
+       strcat ((char *)path, "\Microsoft\Windows\Fonts");
+     } else if (strcmp ((const char *)path, "WINDOWSFONTDIR") == 0) {
 -      int rc;
 -      path = buffer;
 -      _ensureWin32GettersReady();
--      rc = pGetSystemWindowsDirectory ((LPSTR) buffer, sizeof (buffer) - 20);
--      if (rc == 0 || rc > sizeof (buffer) - 20)
+-      rc = pGetSystemWindowsDirectory ((LPSTR)buffer, sizeof (buffer) - 20);
+-      if (rc == 0 || rc > sizeof (buffer) - 20) {
 +      wchar_t *wpath;
 +      int size_needed;
 +      
-+      if (!SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_Fonts, 0, NULL, &wpath)))
-       {
++      if (!SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_Fonts, 0, NULL, &wpath))) 
{
 -          FcConfigMessage (parse, FcSevereError, "GetSystemWindowsDirectory 
failed");
 +          FcConfigMessage (parse, FcSevereError, "SHGetKnownFolderPath for 
FOLDERID_Fonts failed");
            return NULL;
        }
--      if (path [strlen ((const char *) path) - 1] != '\')
--          strcat ((char *) path, "\");
--      strcat ((char *) path, "fonts");
+-      if (path[strlen ((const char *)path) - 1] != '\')
+-          strcat ((char *)path, "\");
+-      strcat ((char *)path, "fonts");
 +      /* We assume that the code using fontconfig handles UTF-8 strings and 
not system codepage */
 +      size_needed = WideCharToMultiByte (CP_UTF8, 0, wpath, wcslen(wpath), 
NULL, 0, NULL, NULL);
-+      if (size_needed <= 0 || size_needed > sizeof(buffer))
-+      {
++      if (size_needed <= 0 || size_needed > sizeof(buffer)) {
 +          FcConfigMessage (parse, FcSevereError, "WideCharToMultiByte 
failed");
 +          CoTaskMemFree (wpath);
 +          return NULL;
@@ -50,6 +48,6 @@ well.
 +      path = buffer;
 +      WideCharToMultiByte(CP_UTF8, 0, wpath, wcslen(wpath), path, 
size_needed, NULL, NULL);
 +      CoTaskMemFree (wpath);
-     }
-     else
-     {
+     } else {
+       if (!prefix) {
+           if (!FcStrIsAbsoluteFilename (path) && path[0] != '~')

Reply via email to