diff -u -r orig/fontconfig-2.13.0/fontconfig/fontconfig.h next/fontconfig-2.13.0/fontconfig/fontconfig.h
--- orig/fontconfig-2.13.0/fontconfig/fontconfig.h	2018-03-05 20:31:12.000000000 -0700
+++ next/fontconfig-2.13.0/fontconfig/fontconfig.h	2018-03-28 20:11:52.000000000 -0600
@@ -377,6 +377,9 @@
 		      FcConfig *config);
 
 /* fccfg.c */
+FcPublic void
+FcSetConfigDir (const FcChar8 *config_dir);
+
 FcPublic FcChar8 *
 FcConfigHome (void);
 
@@ -635,6 +638,9 @@
 FcPublic void
 FcFini (void);
 
+FcPublic void
+FcSetFallbackDirs (const FcChar8 *font_dir,  const FcChar8 *cache_dir);
+
 FcPublic int
 FcGetVersion (void);
 
Only in next/fontconfig-2.13.0/fontconfig: fontconfig.h.orig
diff -u -r orig/fontconfig-2.13.0/src/fccfg.c next/fontconfig-2.13.0/src/fccfg.c
--- orig/fontconfig-2.13.0/src/fccfg.c	2018-02-04 04:01:46.000000000 -0700
+++ next/fontconfig-2.13.0/src/fccfg.c	2018-03-28 20:11:52.000000000 -0600
@@ -1914,6 +1914,22 @@
 #define FONTCONFIG_FILE	"fonts.conf"
 #endif
 
+static const FcChar8 * fc_config_dir = NULL;
+
+void
+FcSetConfigDir (const FcChar8 *config_dir)
+{
+  if (!fc_config_dir) {
+    fc_config_dir = (const FcChar8 *)strdup((const char *)config_dir);
+  }
+}
+
+FcChar8 *
+FcConfigDir (void)
+{
+  return fc_config_dir ? (FcChar8 *)fc_config_dir : (FcChar8 *)FONTCONFIG_PATH;
+}
+
 static FcChar8 *
 FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file)
 {
@@ -2015,7 +2031,7 @@
 		strcat ((char *) fontconfig_path, "\\fonts");
 	}
 #endif
-    dir = (FcChar8 *) FONTCONFIG_PATH;
+        dir = (fc_config_dir ? (FcChar8 *)fc_config_dir : (FcChar8 *)FONTCONFIG_PATH);
     path[i] = malloc (strlen ((char *) dir) + 1);
     if (!path[i])
 	goto bail1;
Only in next/fontconfig-2.13.0/src: fccfg.c.orig
diff -u -r orig/fontconfig-2.13.0/src/fcinit.c next/fontconfig-2.13.0/src/fcinit.c
--- orig/fontconfig-2.13.0/src/fcinit.c	2018-02-04 21:28:01.000000000 -0700
+++ next/fontconfig-2.13.0/src/fcinit.c	2018-03-28 20:15:42.000000000 -0600
@@ -35,25 +35,52 @@
 #pragma message("To suppress these warnings, define FC_NO_MT.")
 #endif
 
+static const FcChar8 * fc_default_fonts = NULL;
+static const FcChar8 * fc_cachedir = NULL;
+
+void
+FcSetFallbackDirs (const FcChar8 *font_dir,  const FcChar8 *cache_dir)
+{
+  if (!fc_default_fonts) {
+    fc_default_fonts = (const FcChar8 *)strdup((const char *)font_dir);
+    fc_cachedir = (const FcChar8 *)strdup((const char *)cache_dir);
+  }
+}
+
+FcChar8 *
+FcFallbackCacheDir (void)
+{
+  return (fc_cachedir
+          ? fc_cachedir
+          : (const FcChar8 *)FC_CACHEDIR);
+}
+
 static FcConfig *
 FcInitFallbackConfig (const FcChar8 *sysroot)
 {
     FcConfig	*config;
     const FcChar8 *fallback = (const FcChar8 *) ""	\
 	"<fontconfig>" \
-	"  <dir>" FC_DEFAULT_FONTS "</dir>" \
+	"  <dir>" "%s" "</dir>" \
 	"  <dir prefix=\"xdg\">fonts</dir>" \
-	"  <cachedir>" FC_CACHEDIR "</cachedir>" \
+	"  <cachedir>" "%s" "</cachedir>" \
 	"  <cachedir prefix=\"xdg\">fontconfig</cachedir>" \
 	"  <include ignore_missing=\"yes\" prefix=\"xdg\">fontconfig/conf.d</include>" \
 	"  <include ignore_missing=\"yes\" prefix=\"xdg\">fontconfig/fonts.conf</include>" \
 	"</fontconfig>";
+    const char *default_fonts, *cache_dir, *fallback_s;
+
+    default_fonts = (fc_default_fonts ? fc_default_fonts : (const FcChar8 *)FC_DEFAULT_FONTS);
+    cache_dir = (fc_cachedir ? fc_cachedir : (const FcChar8 *)FC_CACHEDIR);
+
+    fallback_s = malloc(strlen(fallback) + strlen(default_fonts) + strlen(cache_dir) + 1);
+    sprintf(fallback_s, fallback, default_fonts, cache_dir);
 
     config = FcConfigCreate ();
     if (!config)
 	goto bail0;
     FcConfigSetSysRoot (config, sysroot);
-    if (!FcConfigParseAndLoadFromMemory (config, fallback, FcFalse))
+    if (!FcConfigParseAndLoadFromMemory (config, fallback_s, FcFalse))
 	goto bail1;
 
     return config;
Only in next/fontconfig-2.13.0/src: fcinit.c.orig
Only in next/fontconfig-2.13.0/src: fcinit.c.rej
diff -u -r orig/fontconfig-2.13.0/src/fcint.h next/fontconfig-2.13.0/src/fcint.h
--- orig/fontconfig-2.13.0/src/fcint.h	2018-02-04 03:20:56.000000000 -0700
+++ next/fontconfig-2.13.0/src/fcint.h	2018-03-28 20:11:52.000000000 -0600
@@ -647,6 +647,9 @@
 FcPrivate FcChar8 *
 FcConfigXdgDataHome (void);
 
+FcPrivate FcChar8 *
+FcConfigDir (void);
+
 FcPrivate FcExpr *
 FcConfigAllocExpr (FcConfig *config);
 
@@ -878,6 +881,9 @@
 FcPrivate void
 FcDefaultFini (void);
 
+FcPrivate FcChar8 *
+FcFallbackCacheDir (void);
+
 /* fcdir.c */
 
 FcPrivate FcBool
Only in next/fontconfig-2.13.0/src: fcint.h.orig
diff -u -r orig/fontconfig-2.13.0/src/fcxml.c next/fontconfig-2.13.0/src/fcxml.c
--- orig/fontconfig-2.13.0/src/fcxml.c	2018-02-04 04:01:55.000000000 -0700
+++ next/fontconfig-2.13.0/src/fcxml.c	2018-03-28 20:16:52.000000000 -0600
@@ -2080,6 +2080,14 @@
 	if (!prefix)
 	    goto bail;
     }
+    if (attr && FcStrCmp (attr, (const FcChar8 *)"cfg") == 0) {
+      prefix = FcConfigDir ();
+      if (!prefix) goto bail;
+    }
+    if (attr && FcStrCmp (attr, (const FcChar8 *)"cache") == 0) {
+      prefix = FcFallbackCacheDir ();
+      if (!prefix) goto bail;
+    }
     data = FcStrBufDoneStatic (&parse->pstack->str);
     if (!data)
     {
Only in next/fontconfig-2.13.0/src: fcxml.c.orig
Only in next/fontconfig-2.13.0/src: fcxml.c.rej
