[Fontconfig] fontconfig: Branch 'master'

Akira TAGOH tagoh at kemper.freedesktop.org
Wed Apr 8 23:19:50 PDT 2015


 src/fccfg.c |    2 ++
 src/fcxml.c |   21 ++++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit f6e6a8a22b9d775fff117d65016b5e85233a7293
Author: Руслан Ижбулатов <lrn1986 at gmail.com>
Date:   Wed Apr 8 08:41:25 2015 +0000

    W32: Support cache paths relative to the root directory
    
    Paths starting with '/' don't make sense on W32 as-is,
    prepend the installation root directory to them.
    
    This allows the cache to be contained within a particular
    fontconfig installation (as long as the default
    --with-cache-dir= is overriden at configure time).

diff --git a/src/fccfg.c b/src/fccfg.c
index 5467493..cc2d9ee 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -1843,6 +1843,7 @@ FcConfigSubstitute (FcConfig	*config,
 #if defined (_WIN32)
 
 static FcChar8 fontconfig_path[1000] = ""; /* MT-dontcare */
+FcChar8 fontconfig_instprefix[1000] = ""; /* MT-dontcare */
 
 #  if (defined (PIC) || defined (DLL_EXPORT))
 
@@ -1877,6 +1878,7 @@ DllMain (HINSTANCE hinstDLL,
 	  if (p && (FcStrCmpIgnoreCase (p + 1, (const FcChar8 *) "bin") == 0 ||
 		    FcStrCmpIgnoreCase (p + 1, (const FcChar8 *) "lib") == 0))
 	      *p = '\0';
+	  strcat ((char *) fontconfig_instprefix, (char *) fontconfig_path);
 	  strcat ((char *) fontconfig_path, "\\etc\\fonts");
       }
       else
diff --git a/src/fcxml.c b/src/fcxml.c
index 331a444..9a6f08d 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -54,6 +54,7 @@
 
 #ifdef _WIN32
 #include <mbstring.h>
+extern FcChar8 fontconfig_instprefix[];
 #endif
 
 static void
@@ -2187,7 +2188,25 @@ FcParseCacheDir (FcConfigParse *parse)
 	data = prefix;
     }
 #ifdef _WIN32
-    if (strcmp ((const char *) data, "WINDOWSTEMPDIR_FONTCONFIG_CACHE") == 0)
+    else if (data[0] == '/' && fontconfig_instprefix[0] != '\0')
+    {
+	size_t plen = strlen ((const char *)fontconfig_instprefix);
+	size_t dlen = strlen ((const char *)data);
+
+	prefix = malloc (plen + 1 + dlen + 1);
+	if (!prefix)
+	{
+	    FcConfigMessage (parse, FcSevereError, "out of memory");
+	    goto bail;
+	}
+	strcpy ((char *) prefix, (char *) fontconfig_instprefix);
+	prefix[plen] = FC_DIR_SEPARATOR;
+	memcpy (&prefix[plen + 1], data, dlen);
+	prefix[plen + 1 + dlen] = 0;
+	FcStrFree (data);
+	data = prefix;
+    }
+    else if (strcmp ((const char *) data, "WINDOWSTEMPDIR_FONTCONFIG_CACHE") == 0)
     {
 	int rc;
 	FcStrFree (data);


More information about the Fontconfig mailing list