[Fontconfig] WINDOWSTEMPDIR_FONTCONFIG_CACHE
LRN
lrn1986 at gmail.com
Mon Apr 6 04:53:36 PDT 2015
On 13.04.2013 6:12, LRN wrote:
> On 04.04.2013 02:40, Raimund Steger wrote:
>> LRN wrote:
>>> On *nix it resides in /var/cache/fontconfig.
>>
>> On Unix, users have cache directories too, as they can use their
>> own fonts and/or fontconfig versions.
>
> They can, but as far as Debian goes, dpkg postinst and postrm scripts
> only know of one cache - /var/cache/fontconfig, and is set to trigger
> cache re-generation when one of these directories
> /usr/share/fonts
> /usr/share/ghostscript/fonts
> /usr/share/texmf/fonts
> changes (apparently).
> Users can, obviously, whip up anything they like, but that does not
> seem to be the "usual" case.
>
>
>> System-wide fontconfig installations are not really widely used on
>> Windows although a sysadmin could certainly provide such a thing
>> (maybe using a custom sysconfdir or fontconfig's feature to load
>> its configuration from location relative to the DLL on Windows).
>
> Yes, i'm planning to implement a feature like that. If everything goes
> well, expect a patch in foreseeable future.
> It will add another special value - RELATIVE_SPECIAL_FONTCONFIG_CACHE,
> which will make fc take its location from the DLL, guess where root
> directory is (assuming that fc dll is in root/bin), look up
> root/var/cache directory, and use root/var/cache/fontconfig as the
> cache file.
>
Well, it's been a year, and here i am. Foreseeable future :)
Anyway, here's the patch.
It checks for the cache path starting with '/' and then prepends the
installation prefix (which is already figured out elsewhere in fccfg.c) to it.
This way each fontconfig installation has its own cache, plus there's a
user-specific cache.
This way fc-cache -v outputs:
F:/e43/mingw/var/cache/fontconfig: cleaning cache directory
C:/Users/LRN/.cache/fontconfig: not cleaning non-existent cache directory
C:/Users/LRN/.fontconfig: not cleaning non-existent cache directory
instead of:
C:/Users/LRN/AppData/Local/fontconfig/cache: cleaning cache directory
C:/Users/LRN/.cache/fontconfig: not cleaning non-existent cache directory
C:/Users/LRN/.fontconfig: not cleaning non-existent cache directory
(where F:/e43/mingw is the installation prefix).
FC needs to be configured with
--with-cache-dir='${localstatedir}/cache/${PACKAGE}', because otherwise
LOCAL_APPDATA_FONTCONFIG_CACHE will become the default.
--
O< ascii ribbon - stop html email! - www.asciiribbon.org
-------------- next part --------------
--- fontconfig-2.11.93/src/fccfg.c.orig 2015-03-09 02:54:03.000000000 +0000
+++ fontconfig-2.11.93/src/fccfg.c 2015-04-06 11:19:36.349541200 +0000
@@ -1843,6 +1843,7 @@
#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 @@
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
--- fontconfig-2.11.93/src/fcxml.c.orig 2015-04-06 11:09:23.922272800 +0000
+++ fontconfig-2.11.93/src/fcxml.c 2015-04-06 11:24:37.575792100 +0000
@@ -54,6 +54,7 @@
#ifdef _WIN32
#include <mbstring.h>
+extern FcChar8 fontconfig_instprefix[];
#endif
static void
@@ -2187,7 +2188,25 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0x922360B0.asc
Type: application/pgp-keys
Size: 1717 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/fontconfig/attachments/20150406/92b5f52f/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/fontconfig/attachments/20150406/92b5f52f/attachment.sig>
More information about the Fontconfig
mailing list