From ec3c708eab3915d3925a98b922b500a00662dc8f Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Sun, 3 Apr 2011 16:08:56 -0400 Subject: [PATCH] Use xdg basedir spec https://bugs.freedesktop.org/show_bug.cgi?id=25378 --- conf.d/50-user.conf | 2 ++ fonts.conf.in | 2 ++ src/fcinit.c | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 0 deletions(-) diff --git a/conf.d/50-user.conf b/conf.d/50-user.conf index 3f89012..bb30096 100644 --- a/conf.d/50-user.conf +++ b/conf.d/50-user.conf @@ -2,6 +2,8 @@ + ~/.config/fonts.conf.d + ~/.config/fonts.conf ~/.fonts.conf.d ~/.fonts.conf diff --git a/fonts.conf.in b/fonts.conf.in index a17c01e..6b9b040 100644 --- a/fonts.conf.in +++ b/fonts.conf.in @@ -25,6 +25,7 @@ @FC_DEFAULT_FONTS@ @FC_FONTPATH@ + ~/.config/fonts ~/.fonts @FC_CACHEDIR@ + ~/.cache/fontconfig ~/.fontconfig diff --git a/src/fcinit.c b/src/fcinit.c index b7966b6..ff1a272 100644 --- a/src/fcinit.c +++ b/src/fcinit.c @@ -72,21 +72,36 @@ FcInitLoadConfig (void) if (config->cacheDirs && config->cacheDirs->num == 0) { + FcChar8 *cachehome; + FcChar8 *cachedir; + + cachehome = getenv ("XDG_CACHE_HOME"); + if (cachehome != NULL && *cachehome != '\0') + cachedir = FcStrPlus (cachehome, (FcChar8 *) "/fontconfig"); + else + cachedir = FcStrCopy ("~/.config/fontconfig"); + fprintf (stderr, "Fontconfig warning: no elements found. Check configuration.\n"); fprintf (stderr, "Fontconfig warning: adding %s\n", FC_CACHEDIR); fprintf (stderr, + "Fontconfig warning: adding %s\n", + cachedir); + fprintf (stderr, "Fontconfig warning: adding ~/.fontconfig\n"); if (!FcConfigAddCacheDir (config, (FcChar8 *) FC_CACHEDIR) || + !FcConfigAddCacheDir (config, (FcChar8 *) cachedir) || !FcConfigAddCacheDir (config, (FcChar8 *) "~/.fontconfig")) { fprintf (stderr, "Fontconfig error: out of memory"); FcConfigDestroy (config); + FcStrFree (cachedir); return FcInitFallbackConfig (); } + FcStrFree (cachedir); } return config; -- 1.7.3.4