Commit c4324f54 authored by Keith Packard's avatar Keith Packard Committed by Akira TAGOH

Replace UUID file mechanism with per-directory 'map' attribute [v2]

The UUID files would be placed in each font directory to provide the
unique cache name, independent of path, for that directory. The UUID
files are undesireable for a couple of reasons:

 1) They must be placed in the font directories to be useful. This
    requires modifying the font directories themselves, introducing
    potential visible timestamp changes when running multiple
    applications, and makes the cache processing inconsistent between
    applications with permission to write to the font directories and
    applications without such permission.

 2) The UUID contents were generated randomly, which makes the font
    cache not reproducible across multiple runs.

One proposed fix for 2) is to make the UUID dependent on the font
directory path, but once we do that, we can simply use the font
directory path itself as the key as the original MD5-based font cache
naming mechanism did.

The goal of the UUID file mechanism was to fix startup time of
flatpaks; as the font path names inside the flatpak did not match the
font path names in the base system, the font cache would need to be
reconstructed the first time the flatpak was launched.

The new mechanism for doing this is to allow each '<dir>' element in
the configuration include a 'map' attribute. When looking for a cache
file for a particular directory, if the directory name starts with the
contents of the <dir> element, that portion of the name will be
replaced with the value of the 'map' attribute.

Outside of the flatpak, nothing need change -- fontconfig will build
cache files using real directory names.

Inside the flatpak, the custom fonts.conf file will now include
mappings such as this:

	<dir map="/usr/share/fonts">/run/host/fonts</dir>

When scanning the directory /run/host/fonts/ttf, fontconfig will
use the name /usr/share/fonts/ttf as the source for building the cache
file name.

The existing FC_FILE replacement code used for the UUID-based
implementation continues to correctly adapt font path names seen by
applications.

v2:
	Leave FcDirCacheCreateUUID stub around to avoid removing
	public API function.

	Document 'map' attribute of <dir> element in
	fontconfig-user.sgml
Suggested-by: Akira TAGOH's avatarAkira TAGOH <akira@tagoh.org>
Signed-off-by: Keith Packard's avatarKeith Packard <keithp@keithp.com>
parent 4cde12bf
......@@ -332,39 +332,6 @@ AM_CONDITIONAL(FREETYPE_PCF_LONG_FAMILY_NAMES, test "x$have_pcf_long_family_name
LIBS="$fontconfig_save_libs"
CFLAGS="$fontconfig_save_cflags"
#
# Check for uuid
#
if test "$os_win32" != "yes"; then
use_pkgconfig_for_uuid=yes
if test -n "${UUID_LIBS}"; then
save_UUID_LIBS=$UUID_LIBS
fi
PKG_CHECK_MODULES([UUID], [uuid],
[use_pkgconfig_for_uuid=yes],
[use_pkgconfig_for_uuid=no])
if test "x$use_pkgconfig_for_uuid" = "xno"; then
AC_MSG_CHECKING([where uuid functions comes from])
AC_TRY_LINK([#include <uuid/uuid.h>],
[uuid_t a; uuid_generate(a);],
[AC_MSG_RESULT([builtin])
UUID_CFLAGS=""
UUID_LIBS=""
],[AC_MSG_ERROR([
*** uuid is required. install util-linux.
])])
else
if test -z "${save_UUID_LIBS+x}" && test "x${UUID_LIBS}" != "x"; then
PKGCONFIG_REQUIRES_PRIVATELY="$PKGCONFIG_REQUIRES_PRIVATELY uuid"
fi
fi
else
UUID_CFLAGS=""
UUID_LIBS=""
fi
AC_SUBST(UUID_CFLAGS)
AC_SUBST(UUID_LIBS)
#
# Check expat configuration
#
......
......@@ -88,20 +88,6 @@ to <parameter>config</parameter>.
@SINCE@ 2.9.91
@@
@RET@ FcBool
@FUNC@ FcDirCacheCreateUUID
@TYPE1@ FcChar8 * @ARG1@ dir
@TYPE2@ FcBool @ARG2@ force
@TYPE3@ FcConfig * @ARG3@ config
@PURPOSE@ Create .uuid file at a directory
@DESC@
This is to create .uuid file containing an UUID at a font directory of
<parameter>dir</parameter>.
The UUID will be used to identify the font directory and is used to determine
the cache filename if available.
@SINCE@ 2.12.92
@@
@RET@ FcBool
@FUNC@ FcDirCacheDeleteUUID
@TYPE1@ const FcChar8 * @ARG1@ dir
......
......@@ -310,9 +310,15 @@ following structure:
This is the top level element for a font configuration and can contain
<literal>&lt;dir&gt;</literal>, <literal>&lt;cachedir&gt;</literal>, <literal>&lt;include&gt;</literal>, <literal>&lt;match&gt;</literal> and <literal>&lt;alias&gt;</literal> elements in any order.
</para></refsect2>
<refsect2><title><literal>&lt;dir prefix="default"&gt;</literal></title><para>
<refsect2><title><literal>&lt;dir prefix="default" map=""&gt;</literal></title><para>
This element contains a directory name which will be scanned for font files
to include in the set of available fonts. If 'prefix' is set to "default" or "cwd", the current working directory will be added as the path prefix prior to the value. If 'prefix' is set to "xdg", the value in the XDG_DATA_HOME environment variable will be added as the path prefix. please see XDG Base Directory Specification for more details. If 'prefix' is set to "relative", the path of current file will be added prior to the value.
</para><para>
If a 'map' attribute is specified, its value will replace the
directory path when matching cached information for fonts contained in
this directory. This is useful if the directory name is an alias
(via a bind mount or symlink) to another directory in the system for
which cached font information is likely to exist.
</para></refsect2>
<refsect2><title><literal>&lt;cachedir prefix="default"&gt;</literal></title><para>
This element contains a directory name that is supposed to be stored or read
......
......@@ -203,7 +203,6 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
if (really_force)
{
FcDirCacheUnlink (dir, config);
FcDirCacheCreateUUID ((FcChar8 *) dir, FcTrue, config);
}
cache = NULL;
......
......@@ -14,6 +14,7 @@
-->
<!ELEMENT dir (#PCDATA)>
<!ATTLIST dir
map CDATA #IMPLIED
prefix (default|xdg|relative|cwd) "default"
xml:space (default|preserve) 'preserve'>
......
......@@ -77,7 +77,6 @@ AM_CPPFLAGS = \
$(ICONV_CFLAGS) \
$(LIBXML2_CFLAGS) \
$(EXPAT_CFLAGS) \
$(UUID_CFLAGS) \
$(WARN_CFLAGS) \
-DFC_CACHEDIR='"$(FC_CACHEDIR)"' \
-DFONTCONFIG_PATH='"$(BASECONFIGDIR)"' \
......@@ -167,7 +166,7 @@ lib_LTLIBRARIES = libfontconfig.la
libfontconfig_la_LDFLAGS = \
-version-info @LIBT_VERSION_INFO@ -no-undefined $(export_symbols)
libfontconfig_la_LIBADD = $(ICONV_LIBS) $(FREETYPE_LIBS) $(LIBXML2_LIBS) $(EXPAT_LIBS) $(UUID_LIBS) $(LTLIBINTL)
libfontconfig_la_LIBADD = $(ICONV_LIBS) $(FREETYPE_LIBS) $(LIBXML2_LIBS) $(EXPAT_LIBS) $(LTLIBINTL)
libfontconfig_la_DEPENDENCIES = $(fontconfig_def_dependency)
......
......@@ -51,103 +51,7 @@ FcDirCacheCreateUUID (FcChar8 *dir,
FcBool force,
FcConfig *config)
{
FcBool ret = FcTrue;
#ifndef _WIN32
const FcChar8 *sysroot = FcConfigGetSysRoot (config);
FcChar8 *target;
FcChar8 *uuidname;
if (sysroot)
target = FcStrBuildFilename (sysroot, dir, NULL);
else
target = FcStrdup (dir);
uuidname = FcStrBuildFilename (target, ".uuid", NULL);
if (!uuidname)
{
FcStrFree (target);
return FcFalse;
}
if (force || access ((const char *) uuidname, F_OK) < 0)
{
FcAtomic *atomic;
int fd;
uuid_t uuid;
char out[37];
FcBool (* hash_add) (FcHashTable *, void*, void*);
struct stat statb;
struct timeval times[2];
if (FcStat (target, &statb) != 0)
{
ret = FcFalse;
goto bail1;
}
atomic = FcAtomicCreate (uuidname);
if (!atomic)
{
ret = FcFalse;
goto bail1;
}
if (!FcAtomicLock (atomic))
{
ret = FcFalse;
goto bail2;
}
fd = FcOpen ((char *)FcAtomicNewFile (atomic), O_RDWR | O_CREAT, 0644);
if (fd == -1)
{
ret = FcFalse;
goto bail3;
}
uuid_generate_random (uuid);
if (force)
hash_add = FcHashTableReplace;
else
hash_add = FcHashTableAdd;
if (!hash_add (config->uuid_table, target, uuid))
{
ret = FcFalse;
FcAtomicDeleteNew (atomic);
close (fd);
goto bail3;
}
uuid_unparse (uuid, out);
if (FcDebug () & FC_DBG_CACHE)
printf ("FcDirCacheCreateUUID %s: %s\n", uuidname, out);
write (fd, out, strlen (out));
close (fd);
FcAtomicReplaceOrig (atomic);
bail3:
FcAtomicUnlock (atomic);
bail2:
FcAtomicDestroy (atomic);
if (ret)
{
/* revert mtime of the directory */
times[0].tv_sec = statb.st_atime;
times[1].tv_sec = statb.st_mtime;
#ifdef HAVE_STRUCT_STAT_ST_MTIM
times[0].tv_usec = statb.st_atim.tv_nsec / 1000;
times[1].tv_usec = statb.st_mtim.tv_nsec / 1000;
#else
times[0].tv_usec = 0;
times[1].tv_usec = 0;
#endif
if (utimes ((const char *) target, times) != 0)
{
fprintf (stderr, "Unable to revert mtime: %s\n", target);
}
}
}
bail1:
FcStrFree (uuidname);
FcStrFree (target);
#endif
return ret;
return FcTrue;
}
FcBool
......@@ -187,7 +91,6 @@ FcDirCacheDeleteUUID (const FcChar8 *dir,
{
fprintf (stderr, "Unable to revert mtime: %s\n", d);
}
FcHashTableRemove (config->uuid_table, target);
}
FcStrFree (target);
bail:
......@@ -197,59 +100,6 @@ bail:
return ret;
}
#ifndef _WIN32
static void
FcDirCacheReadUUID (FcChar8 *dir,
FcConfig *config)
{
void *u;
uuid_t uuid;
const FcChar8 *sysroot = FcConfigGetSysRoot (config);
FcChar8 *target;
if (sysroot)
target = FcStrBuildFilename (sysroot, dir, NULL);
else
target = FcStrdup (dir);
if (!FcHashTableFind (config->uuid_table, target, &u))
{
FcChar8 *uuidname = FcStrBuildFilename (target, ".uuid", NULL);
int fd;
if ((fd = FcOpen ((char *) uuidname, O_RDONLY)) >= 0)
{
char suuid[37];
ssize_t len;
memset (suuid, 0, sizeof (suuid));
len = read (fd, suuid, 36);
if (len != -1)
{
suuid[len] = 0;
memset (uuid, 0, sizeof (uuid));
if (uuid_parse (suuid, uuid) == 0)
{
if (FcDebug () & FC_DBG_CACHE)
printf ("FcDirCacheReadUUID %s -> %s\n", uuidname, suuid);
FcHashTableAdd (config->uuid_table, target, uuid);
}
}
close (fd);
}
else
{
if (FcDebug () & FC_DBG_CACHE)
printf ("FcDirCacheReadUUID Unable to read %s\n", uuidname);
}
FcStrFree (uuidname);
}
else
FcHashUuidFree (u);
FcStrFree (target);
}
#endif
struct MD5Context {
FcChar32 buf[4];
FcChar32 bits[2];
......@@ -300,18 +150,26 @@ static const char bin2hex[] = { '0', '1', '2', '3',
'c', 'd', 'e', 'f' };
static FcChar8 *
FcDirCacheBasenameMD5 (const FcChar8 *dir, FcChar8 cache_base[CACHEBASE_LEN])
FcDirCacheBasenameMD5 (FcConfig *config, const FcChar8 *dir, FcChar8 cache_base[CACHEBASE_LEN])
{
FcChar8 *new_dir;
unsigned char hash[16];
FcChar8 *hex_hash;
int cnt;
struct MD5Context ctx;
new_dir = FcConfigMapFontPath(config, dir);
if (new_dir)
dir = new_dir;
MD5Init (&ctx);
MD5Update (&ctx, (const unsigned char *)dir, strlen ((const char *) dir));
MD5Final (hash, &ctx);
if (new_dir)
FcStrFree(new_dir);
cache_base[0] = '/';
hex_hash = cache_base + 1;
for (cnt = 0; cnt < 16; ++cnt)
......@@ -325,31 +183,6 @@ FcDirCacheBasenameMD5 (const FcChar8 *dir, FcChar8 cache_base[CACHEBASE_LEN])
return cache_base;
}
#ifndef _WIN32
static FcChar8 *
FcDirCacheBasenameUUID (const FcChar8 *dir, FcChar8 cache_base[CACHEBASE_LEN], FcConfig *config)
{
void *u;
FcChar8 *target;
const FcChar8 *sysroot = FcConfigGetSysRoot (config);
if (sysroot)
target = FcStrBuildFilename (sysroot, dir, NULL);
else
target = FcStrdup (dir);
if (FcHashTableFind (config->uuid_table, target, &u))
{
uuid_unparse (u, (char *) cache_base);
strcat ((char *) cache_base, "-" FC_ARCHITECTURE FC_CACHE_SUFFIX);
FcHashUuidFree (u);
FcStrFree (target);
return cache_base;
}
FcStrFree (target);
return NULL;
}
#endif
FcBool
FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config)
{
......@@ -359,10 +192,7 @@ FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config)
FcChar8 *cache_dir;
const FcChar8 *sysroot = FcConfigGetSysRoot (config);
#ifndef _WIN32
if (!FcDirCacheBasenameUUID (dir, cache_base, config))
#endif
FcDirCacheBasenameMD5 (dir, cache_base);
FcDirCacheBasenameMD5 (config, dir, cache_base);
list = FcStrListCreate (config->cacheDirs);
if (!list)
......@@ -439,10 +269,7 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
}
FcStrFree (d);
#ifndef _WIN32
if (!FcDirCacheBasenameUUID (dir, cache_base, config))
#endif
FcDirCacheBasenameMD5 (dir, cache_base);
FcDirCacheBasenameMD5 (config, dir, cache_base);
list = FcStrListCreate (config->cacheDirs);
if (!list)
......@@ -1070,9 +897,6 @@ FcDirCacheLoad (const FcChar8 *dir, FcConfig *config, FcChar8 **cache_file)
{
FcCache *cache = NULL;
#ifndef _WIN32
FcDirCacheReadUUID ((FcChar8 *) dir, config);
#endif
if (!FcDirCacheProcess (config, dir,
FcDirCacheMapHelper,
&cache, cache_file))
......@@ -1377,10 +1201,7 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
if (!cache_dir)
return FcFalse;
#ifndef _WIN32
if (!FcDirCacheBasenameUUID (dir, cache_base, config))
#endif
FcDirCacheBasenameMD5 (dir, cache_base);
FcDirCacheBasenameMD5 (config, dir, cache_base);
cache_hashed = FcStrBuildFilename (cache_dir, cache_base, NULL);
FcStrFree (cache_dir);
if (!cache_hashed)
......@@ -1577,10 +1398,7 @@ FcDirCacheLock (const FcChar8 *dir,
const FcChar8 *sysroot = FcConfigGetSysRoot (config);
int fd = -1;
#ifndef _WIN32
if (!FcDirCacheBasenameUUID (dir, cache_base, config))
#endif
FcDirCacheBasenameMD5 (dir, cache_base);
FcDirCacheBasenameMD5 (config, dir, cache_base);
list = FcStrListCreate (config->cacheDirs);
if (!list)
return -1;
......
......@@ -52,18 +52,6 @@ retry:
return config;
}
static FcChar32
FcHashAsStrIgnoreCase (const void *data)
{
return FcStrHashIgnoreCase (data);
}
static int
FcCompareAsStr (const void *v1, const void *v2)
{
return FcStrCmp (v1, v2);
}
static void
FcDestroyAsRule (void *data)
{
......@@ -76,12 +64,6 @@ FcDestroyAsRuleSet (void *data)
FcRuleSetDestroy (data);
}
static void
FcDestroyAsStr (void *data)
{
FcStrFree (data);
}
FcBool
FcConfigInit (void)
{
......@@ -127,6 +109,10 @@ FcConfigCreate (void)
if (!config->configDirs)
goto bail1;
config->configMapDirs = FcStrSetCreate();
if (!config->configMapDirs)
goto bail1_5;
config->configFiles = FcStrSetCreate ();
if (!config->configFiles)
goto bail2;
......@@ -182,13 +168,6 @@ FcConfigCreate (void)
if (!config->availConfigFiles)
goto bail10;
config->uuid_table = FcHashTableCreate (FcHashAsStrIgnoreCase,
FcCompareAsStr,
FcHashStrCopy,
FcHashUuidCopy,
FcDestroyAsStr,
FcHashUuidFree);
FcRefInit (&config->ref, 1);
return config;
......@@ -213,6 +192,8 @@ bail4:
bail3:
FcStrSetDestroy (config->configFiles);
bail2:
FcStrSetDestroy (config->configMapDirs);
bail1_5:
FcStrSetDestroy (config->configDirs);
bail1:
free (config);
......@@ -324,6 +305,7 @@ FcConfigDestroy (FcConfig *config)
(void) fc_atomic_ptr_cmpexch (&_fcConfig, config, NULL);
FcStrSetDestroy (config->configDirs);
FcStrSetDestroy (config->configMapDirs);
FcStrSetDestroy (config->fontDirs);
FcStrSetDestroy (config->cacheDirs);
FcStrSetDestroy (config->configFiles);
......@@ -350,8 +332,6 @@ FcConfigDestroy (FcConfig *config)
if (config->sysRoot)
FcStrFree (config->sysRoot);
FcHashTableDestroy (config->uuid_table);
free (config);
}
......@@ -559,9 +539,10 @@ FcConfigGetConfigDirs (FcConfig *config)
FcBool
FcConfigAddFontDir (FcConfig *config,
const FcChar8 *d)
const FcChar8 *d,
const FcChar8 *m)
{
return FcStrSetAddFilename (config->fontDirs, d);
return FcStrSetAddFilenamePair (config->fontDirs, d, m);
}
FcStrList *
......@@ -576,6 +557,47 @@ FcConfigGetFontDirs (FcConfig *config)
return FcStrListCreate (config->fontDirs);
}
static FcBool
FcConfigPathStartsWith(const FcChar8 *path,
const FcChar8 *start)
{
int len = strlen((char *) start);
if (strncmp((char *) path, (char *) start, len) != 0)
return FcFalse;
switch (path[len]) {
case '\0':
case FC_DIR_SEPARATOR:
return FcTrue;
default:
return FcFalse;
}
}
FcChar8 *
FcConfigMapFontPath(FcConfig *config,
const FcChar8 *path)
{
FcStrList *list;
FcChar8 *dir;
FcChar8 *map;
list = FcConfigGetFontDirs(config);
if (!list)
return 0;
while ((dir = FcStrListNext(list)))
if (FcConfigPathStartsWith(path, dir))
break;
FcStrListDone(list);
if (!dir)
return 0;
map = FcStrPairSecond(dir);
if (!map)
return 0;
return FcStrBuildFilename(map, path + strlen((char *) dir), NULL);
}
FcBool
FcConfigAddCacheDir (FcConfig *config,
const FcChar8 *d)
......
......@@ -413,7 +413,6 @@ FcDirCacheRead (const FcChar8 *dir, FcBool force, FcConfig *config)
{
FcCache *cache = NULL;
FcDirCacheCreateUUID ((FcChar8 *) dir, FcFalse, config);
/* Try to use existing cache file */
if (!force)
cache = FcDirCacheLoad (dir, config, NULL);
......
......@@ -52,23 +52,6 @@ FcHashStrCopy (const void *src,
return *dest != NULL;
}
FcBool
FcHashUuidCopy (const void *src,
void **dest)
{
#ifndef _WIN32
*dest = malloc (sizeof (uuid_t));
uuid_copy (*dest, src);
#endif
return FcTrue;
}
void
FcHashUuidFree (void *data)
{
free (data);
}
FcHashTable *
FcHashTableCreate (FcHashFunc hash_func,
FcCompareFunc compare_func,
......
......@@ -509,6 +509,7 @@ struct _FcConfig {
* and those directives may occur in any order
*/
FcStrSet *configDirs; /* directories to scan for fonts */
FcStrSet *configMapDirs; /* mapped names to generate cache entries */
/*
* List of directories containing fonts,
* built by recursively scanning the set
......@@ -565,7 +566,6 @@ struct _FcConfig {
FcChar8 *sysRoot; /* override the system root directory */
FcStrSet *availConfigFiles; /* config files available */
FcPtrList *rulesetList; /* List of rulesets being installed */
FcHashTable *uuid_table; /* UUID table for cachedirs */
};
typedef struct _FcFileTime {
......@@ -659,7 +659,12 @@ FcConfigAddConfigDir (FcConfig *config,
FcPrivate FcBool
FcConfigAddFontDir (FcConfig *config,
const FcChar8 *d);
const FcChar8 *d,
const FcChar8 *m);
FcPrivate FcChar8 *
FcConfigMapFontPath(FcConfig *config,
const FcChar8 *path);
FcPrivate FcBool
FcConfigAddCacheDir (FcConfig *config,
......@@ -1236,6 +1241,15 @@ FcStrSetAddLangs (FcStrSet *strs, const char *languages);
FcPrivate void
FcStrSetSort (FcStrSet * set);
FcPrivate FcBool
FcStrSetAddPair (FcStrSet *set, const FcChar8 *a, const FcChar8 *b);
FcPrivate FcChar8 *
FcStrPairSecond (FcChar8 *s);
FcPrivate FcBool
FcStrSetAddFilenamePair (FcStrSet *strs, const FcChar8 *d, const FcChar8 *m);
FcPrivate void
FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
......
......@@ -36,6 +36,27 @@ FcStrCopy (const FcChar8 *s)
return FcStrdup (s);
}
static FcChar8 *
FcStrMakePair (const FcChar8 *s1, const FcChar8 *s2)
{
int s1l = s1 ? strlen ((char *) s1) : 0;
int s2l = s2 ? strlen ((char *) s2) : 0;
int l = s1l + 1 + s2l + 1;
FcChar8 *s = malloc (l);
if (!s)
return 0;
if (s1)
memcpy (s, s1, s1l + 1);
else
s[0] = '\0';
if (s2)
memcpy (s + s1l + 1, s2, s2l + 1);
else
s[s1l + 1] = '\0';
return s;
}
FcChar8 *
FcStrPlus (const FcChar8 *s1, const FcChar8 *s2)
{
......@@ -1233,6 +1254,30 @@ FcStrSetAdd (FcStrSet *set, const FcChar8 *s)
return FcTrue;
}
FcBool
FcStrSetAddPair (FcStrSet *set, const FcChar8 *a, const FcChar8 *b)
{
FcChar8 *new = FcStrMakePair (a, b);
if (!new)
return FcFalse;
if (!_FcStrSetAppend (set, new))
{
FcStrFree (new);
return FcFalse;
}
return FcTrue;
}
FcChar8 *
FcStrPairSecond (FcChar8 *str)
{
FcChar8 *second = str + strlen((char *) str) + 1;
if (*second == '\0')
return 0;
return second;
}
FcBool
FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s)
{
......@@ -1247,6 +1292,37 @@ FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s)
return FcTrue;
}
FcBool
FcStrSetAddFilenamePair (FcStrSet *set, const FcChar8 *a, const FcChar8 *b)
{
FcChar8 *new_a = NULL;
FcChar8 *new_b = NULL;
FcBool ret;
if (a)
{
new_a = FcStrCopyFilename (a);
if (!new_a)
return FcFalse;
}
if (b)
{
new_b = FcStrCopyFilename(b);
if (!new_b)
{
if (new_a)
FcStrFree(new_a);
return FcFalse;
}
}
ret = FcStrSetAddPair (set, new_a, new_b);
if (new_a)
FcStrFree (new_a);
if (new_b)
FcStrFree (new_b);
return ret;
}
FcBool
FcStrSetAddLangs (FcStrSet *strs, const char *languages)
{
......
......@@ -2071,13 +2071,14 @@ FcParseUnary (FcConfigParse *parse, FcOp op)
static void
FcParseDir (FcConfigParse *parse)
{
const FcChar8 *attr, *data;
const FcChar8 *attr, *data, *map;
FcChar8 *prefix = NULL, *p;
#ifdef _WIN32
FcChar8 buffer[1000];
#endif
attr = FcConfigGetAttribute (parse, "prefix");
map = FcConfigGetAttribute (parse, "map");
data = FcStrBufDoneStatic (&parse->pstack->str);
if (attr)
{
......@@ -2188,7 +2189,7 @@ FcParseDir (FcConfigParse *parse)
FcConfigMessage (parse, FcSevereWarning, "empty font directory name ignored");
else if (!parse->scanOnly && (!FcStrUsesHome (data) || FcConfigHome ()))
{
if (!FcConfigAddFontDir (parse->config, data))
if (!FcConfigAddFontDir (parse->config, data, map))
FcConfigMessage (parse, FcSevereError, "out of memory; cannot add directory %s", data);
}
FcStrBufDestroy (&parse->pstack->str);
......
check_SCRIPTS=run-test.sh
check_SCRIPTS=run-test.sh run-test-map.sh
TEST_EXTENSIONS = \
.sh \
$(NULL)
......
<fontconfig>
<dir>@FONTDIR@</dir>
<dir @MAP@>@FONTDIR@</dir>
<cachedir>@CACHEDIR@</cachedir>
</fontconfig>