Skip to content
Permalink
Browse files

Fix fontconfig cache failure on MinGW

  • Loading branch information...
trueroad committed Feb 18, 2017
1 parent 481fc4d commit 4092624f4fa85ae8c38fcb87646942f13583b26a
Showing with 65 additions and 0 deletions.
  1. +3 −0 gub/specs/fontconfig.py
  2. +62 −0 patches/fontconfig-2.12.1-fix-cache-mingw.patch
@@ -117,6 +117,9 @@ def install (self):
'%(install_prefix)s/etc/fonts/conf.d/98-gub-fonts-dir.conf')

class Fontconfig__mingw (Fontconfig):
patches = Fontconfig.patches + [
'fontconfig-2.12.1-fix-cache-mingw.patch'
]
def patch (self):
Fontconfig.patch (self)
self.file_sub ([('<cachedir>@FC_CACHEDIR@</cachedir>', '')],
@@ -0,0 +1,62 @@
From 7f420d5e0cbc202885c53b6ce4854984464bf831 Mon Sep 17 00:00:00 2001
From: Masamichi Hosoda <trueroad@trueroad.jp>
Date: Wed, 11 Jan 2017 20:42:56 +0900
Subject: [PATCH v2] Bug 99360 - Fix cache file update on MinGW

On Windows, opened or locked files cannot be removed.
Since fontconfig locked an old cache file while updating the file,
fontconfig failed to replace the file with updated file on Windows.

This patch makes fontconfig does not lock the old cache file
while updating it on Windows.
---
src/fcdir.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/src/fcdir.c b/src/fcdir.c
index fd62a34..c8aaf54 100644
--- a/src/fcdir.c
+++ b/src/fcdir.c
@@ -362,7 +362,9 @@ FcDirCacheScan (const FcChar8 *dir, FcConfig *config)
if (!dirs)
goto bail1;

+#ifndef _WIN32
fd = FcDirCacheLock (dir, config);
+#endif
/*
* Scan the dir
*/
@@ -382,7 +384,9 @@ FcDirCacheScan (const FcChar8 *dir, FcConfig *config)
FcDirCacheWrite (cache, config);

bail2:
+#ifndef _WIN32
FcDirCacheUnlock (fd);
+#endif
FcStrSetDestroy (dirs);
bail1:
FcFontSetDestroy (set);
@@ -417,7 +421,9 @@ FcDirCacheRescan (const FcChar8 *dir, FcConfig *config)
if (!dirs)
goto bail;

+#ifndef _WIN32
fd = FcDirCacheLock (dir, config);
+#endif
/*
* Scan the dir
*/
@@ -436,7 +442,9 @@ FcDirCacheRescan (const FcChar8 *dir, FcConfig *config)
FcDirCacheWrite (new, config);

bail1:
+#ifndef _WIN32
FcDirCacheUnlock (fd);
+#endif
FcStrSetDestroy (dirs);
bail:
if (d)
--
2.8.3

0 comments on commit 4092624

Please sign in to comment.
You can’t perform that action at this time.