View | Details | Raw Unified | Return to bug 239167 | Differences between
and this patch

Collapse All | Expand All

(-)UPDATING (+10 lines)
Lines 5-10 Link Here
5
You should get into the habit of checking this file for changes each time
5
You should get into the habit of checking this file for changes each time
6
you update your ports collection, before attempting any port upgrades.
6
you update your ports collection, before attempting any port upgrades.
7
7
8
20200330
9
  AFFECTS: users of x11-fonts/fonctonfig
10
  AUTHOR: desktop@FreeBSD.org
11
12
  Fontconfig 2.13.1 generated .uuid files in the fonts directory which where
13
  not properly registered to the packages. To clean them up, please execute the
14
  following command:
15
16
  	find %%LOCALBASE%%/share/fonts -type f -name .uuid -delete
17
8
20200320
18
20200320
9
  AFFECTS: users of devel/qca
19
  AFFECTS: users of devel/qca
10
  AUTHOR: kde@FreeBSD.org
20
  AUTHOR: kde@FreeBSD.org
(-)x11-fonts/fontconfig/Makefile (-6 / +4 lines)
Lines 2-12 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	fontconfig
4
PORTNAME=	fontconfig
5
PORTVERSION=	2.13.1
5
PORTVERSION=	2.13.92
6
PORTREVISION?=	1
7
PORTEPOCH?=	1
6
PORTEPOCH?=	1
8
CATEGORIES=	x11-fonts
7
CATEGORIES=	x11-fonts
9
MASTER_SITES=	http://www.freedesktop.org/software/fontconfig/release/
8
MASTER_SITES=	https://www.freedesktop.org/software/fontconfig/release/
10
9
11
MAINTAINER=	desktop@FreeBSD.org
10
MAINTAINER=	desktop@FreeBSD.org
12
COMMENT=	XML-based font configuration API for X Windows
11
COMMENT=	XML-based font configuration API for X Windows
Lines 14-26 Link Here
14
LICENSE=	MIT
13
LICENSE=	MIT
15
LICENSE_FILE=	${WRKSRC}/COPYING
14
LICENSE_FILE=	${WRKSRC}/COPYING
16
15
17
USES=		gperf tar:bzip2
16
USES=		gperf tar:xz
18
17
19
.if !defined(REFERENCE_PORT)
18
.if !defined(REFERENCE_PORT)
20
19
21
LIB_DEPENDS=	libfreetype.so:print/freetype2 \
20
LIB_DEPENDS=	libfreetype.so:print/freetype2 \
22
		libexpat.so:textproc/expat2 \
21
		libexpat.so:textproc/expat2
23
		libuuid.so:misc/e2fsprogs-libuuid
24
22
25
USES+=		cpe gmake libtool pathfix pkgconfig
23
USES+=		cpe gmake libtool pathfix pkgconfig
26
CPE_VENDOR=	fontconfig_project
24
CPE_VENDOR=	fontconfig_project
(-)x11-fonts/fontconfig/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1550745725
1
TIMESTAMP = 1565349179
2
SHA256 (fontconfig-2.13.1.tar.bz2) = f655dd2a986d7aa97e052261b36aa67b0a64989496361eca8d604e6414006741
2
SHA256 (fontconfig-2.13.92.tar.xz) = 506e61283878c1726550bc94f2af26168f1e9f2106eac77eaaf0b2cdfad66e4e
3
SIZE (fontconfig-2.13.1.tar.bz2) = 1723639
3
SIZE (fontconfig-2.13.92.tar.xz) = 1413128
(-)x11-fonts/fontconfig/files/patch-2.13.1.diff (-592 lines)
Lines 1-592 Link Here
1
# Fix the build issue with --enable-static
2
# https://cgit.freedesktop.org/fontconfig/commit/?id=8208f99fa1676c42bfd8d74de3e9dac5366c150c
3
# Fix the issue that '~' wasn't extracted to the proper homedir
4
# https://cgit.freedesktop.org/fontconfig/commit/?id=806fd4c2c5164d66d978b0a4c579c157e5cbe766
5
# Add more prefix support in <dir> element
6
# https://cgit.freedesktop.org/fontconfig/commit/?id=1aa8b700c3f09a31c78e7834e0db373f80b5e226
7
# Update fonts.dtd for last commit
8
# https://cgit.freedesktop.org/fontconfig/commit/?id=67b4090321c0ec3cf3dc96f6d3cd7b9d03af0f25
9
# add missing the case of prefix="default" as documented
10
# https://cgit.freedesktop.org/fontconfig/commit/?id=e4788c5a96e0f384ad5702ad8096b0e144613895
11
# Do not update mtime when removing .uuid file
12
# https://cgit.freedesktop.org/fontconfig/commit/?id=ff5b49be2be0922f0fb6b9daf08f64a88d2fae6b
13
# Do not try updating mtime when unlink was failed
14
# https://cgit.freedesktop.org/fontconfig/commit/?id=5f5ec5676c61b9773026a9335c9b0dfa73a73353
15
# Do not remove UUID file when a scanned directory is empty
16
# https://cgit.freedesktop.org/fontconfig/commit/?id=5f12f564f8748deaa603adb7a4b8f616b6390ad4
17
# Fix name-table language code mapping for Mongolian
18
# https://cgit.freedesktop.org/fontconfig/commit/?id=f7036d589bffe353c1982b881afae6ec0a2ef200
19
# Use FC_PATH_MAX instead of PATH_MAX
20
# https://cgit.freedesktop.org/fontconfig/commit/?id=648e0cf3d5a53efeab93b24ae37490427d05229d
21
# Fix FcFontList doesn't return a font with FC_COLOR=true
22
# https://cgit.freedesktop.org/fontconfig/commit/?id=9d5149ac41e18ab67404ddba41d7ef7e71839ebc
23
# Fix a dereference of a null pointer
24
# https://cgit.freedesktop.org/fontconfig/commit/?id=b047e299546ac3abb79cf0bac3c67f5c2dfc7fb6
25
# Fix a crash with invalid matrix element
26
# https://cgit.freedesktop.org/fontconfig/commit/?id=699d6e4d8415a5d94483ea81fdf277964a33b8f1
27
# src/fccache.c: Fix define for HAVE_POSIX_FADVISE
28
# https://cgit.freedesktop.org/fontconfig/commit/?id=586e35450e9ca7c1dc647ceb9d75ac8ed08c5c16
29
# Reset errno to do error handling properly
30
# https://cgit.freedesktop.org/fontconfig/commit/?id=97fa77d27facc6a31486fdca5b3b853c591f792c
31
# fc-validate: returns an error code when missing some glyphs
32
# https://cgit.freedesktop.org/fontconfig/commit/?id=c336b8471877371f0190ba06f7547c54e2b890ba
33
# Fix endianness on generating MD5 cache name
34
# https://cgit.freedesktop.org/fontconfig/commit/?id=66b0af41b81c5f0db1a8f952beaaada95e221d14
35
# Fix a typo on masking face id
36
# https://cgit.freedesktop.org/fontconfig/commit/?id=c0dc76268bb278c4bd123afbfb3409be64d0ed75
37
# Fix the linear interpolation during weight mapping
38
# https://cgit.freedesktop.org/fontconfig/commit/?id=f2d4291d12ca1a2146d90da32a399fffff3e8227
39
# Fix a crash when running with FC_DEBUG=256
40
# https://cgit.freedesktop.org/fontconfig/commit/?id=322131f4330f972820fd903959999af9360120c0
41
# Fix a typo
42
# https://cgit.freedesktop.org/fontconfig/commit/?id=a57f22bf6d93ad4079a6ae01fa00456921dc73e1
43
# Improve the performance a bit
44
# https://cgit.freedesktop.org/fontconfig/commit/?id=cb3e6ff4d7628b6eb1dd8f78737de5c387aaf2e1
45
# Add English name first into a cache
46
# https://cgit.freedesktop.org/fontconfig/commit/?id=2960391699ab3b417a17a0a2ac29e97e9c3d3c99
47
# Fix a memory leak in FcFreeTypeQuery*()
48
# https://cgit.freedesktop.org/fontconfig/commit/?id=e2f9f28aed1470a07c33a57940d68b6a3cbe235b
49
50
Excluding changes for the following files: .gitlab-ci.yml, doc/fcstring.fncs,
51
test/Makefile.am, test/test-bz106632.c, test/test-issue107.c, test/test-issue110.c
52
53
--- fc-validate/fc-validate.c.orig	2018-06-05 10:36:38 UTC
54
+++ fc-validate/fc-validate.c
55
@@ -197,6 +197,7 @@ main (int argc, char **argv)
56
 		{
57
 		    FcChar32 ucs4, pos, map[FC_CHARSET_MAP_SIZE];
58
 
59
+		    err = 1;
60
 		    printf (_("%s:%d Missing %d glyph(s) to satisfy the coverage for %s language\n"),
61
 			    argv[i], index, count, lang);
62
 
63
--- fontconfig/fontconfig.h.orig	2018-08-30 08:20:15 UTC
64
+++ fontconfig/fontconfig.h
65
@@ -1077,6 +1077,10 @@ FcUtf16Len (const FcChar8   *string,
66
 	    int		    *wchar);
67
 
68
 FcPublic FcChar8 *
69
+FcStrBuildFilename (const FcChar8 *path,
70
+		    ...);
71
+
72
+FcPublic FcChar8 *
73
 FcStrDirname (const FcChar8 *file);
74
 
75
 FcPublic FcChar8 *
76
--- fonts.dtd.orig	2016-12-02 03:22:19 UTC
77
+++ fonts.dtd
78
@@ -13,14 +13,18 @@
79
 -->
80
 <!ELEMENT dir (#PCDATA)>
81
 <!ATTLIST dir
82
-	  prefix    CDATA       "default"
83
-	  xml:space (default|preserve) 'preserve'>
84
+	  prefix    (default|xdg|relative|cwd)    "default"
85
+	  xml:space (default|preserve)            'preserve'>
86
 
87
 <!--
88
     Define the per-user file that holds cache font information.
89
 
90
     If the filename begins with '~', it is replaced with the users
91
     home directory path.
92
+
93
+    If 'prefix' is 'default' or 'cwd', then the current working directory will be added prior to the value.
94
+    If 'prefix' is 'xdg', then the value in the $XDG_DATA_HOME will be added prior to the value.
95
+    If 'prefix' is 'relative', then the path of curent file will be added prior to the value.
96
 -->
97
 <!ELEMENT cache (#PCDATA)>
98
 <!ATTLIST cache xml:space (default|preserve) 'preserve'>
99
--- src/fccache.c.orig	2018-07-19 07:05:17 UTC
100
+++ src/fccache.c
101
@@ -155,17 +155,42 @@ FcDirCacheDeleteUUID (const FcChar8  *di
102
 		      FcConfig       *config)
103
 {
104
     const FcChar8 *sysroot = FcConfigGetSysRoot (config);
105
-    FcChar8 *target;
106
+    FcChar8 *target, *d;
107
     FcBool ret = FcTrue;
108
+    struct stat statb;
109
+    struct timeval times[2];
110
 
111
     if (sysroot)
112
-	target = FcStrBuildFilename (sysroot, dir, ".uuid", NULL);
113
+	d = FcStrBuildFilename (sysroot, dir, NULL);
114
     else
115
-	target = FcStrBuildFilename (dir, ".uuid", NULL);
116
-
117
+	d = FcStrBuildFilename (dir, NULL);
118
+    if (FcStat (d, &statb) != 0)
119
+    {
120
+	ret = FcFalse;
121
+	goto bail;
122
+    }
123
+    target = FcStrBuildFilename (d, ".uuid", NULL);
124
     ret = unlink ((char *) target) == 0;
125
-    FcHashTableRemove (config->uuid_table, target);
126
-    FcStrFree(target);
127
+    if (ret)
128
+    {
129
+	times[0].tv_sec = statb.st_atime;
130
+	times[1].tv_sec = statb.st_mtime;
131
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
132
+	times[0].tv_usec = statb.st_atim.tv_nsec / 1000;
133
+	times[1].tv_usec = statb.st_mtim.tv_nsec / 1000;
134
+#else
135
+	times[0].tv_usec = 0;
136
+	times[1].tv_usec = 0;
137
+#endif
138
+	if (utimes ((const char *) d, times) != 0)
139
+	{
140
+	    fprintf (stderr, "Unable to revert mtime: %s\n", d);
141
+	}
142
+	FcHashTableRemove (config->uuid_table, target);
143
+    }
144
+    FcStrFree (target);
145
+bail:
146
+    FcStrFree (d);
147
 
148
     return ret;
149
 }
150
@@ -685,15 +710,18 @@ FcCacheRemoveUnlocked (FcCache *cache)
151
     while (fcCacheMaxLevel > 0 && fcCacheChains[fcCacheMaxLevel - 1] == NULL)
152
 	fcCacheMaxLevel--;
153
 
154
-    allocated = s->allocated;
155
-    while (allocated)
156
+    if (s)
157
     {
158
-	/* First element in allocated chunk is the free list */
159
-	next = *(void **)allocated;
160
-	free (allocated);
161
-	allocated = next;
162
+	allocated = s->allocated;
163
+	while (allocated)
164
+	{
165
+	    /* First element in allocated chunk is the free list */
166
+	    next = *(void **)allocated;
167
+	    free (allocated);
168
+	    allocated = next;
169
+	}
170
+	free (s);
171
     }
172
-    free (s);
173
 }
174
 
175
 static FcCache *
176
@@ -948,7 +976,7 @@ FcDirCacheMapFd (FcConfig *config, int f
177
     {
178
 #if defined(HAVE_MMAP) || defined(__CYGWIN__)
179
 	cache = mmap (0, fd_stat->st_size, PROT_READ, MAP_SHARED, fd, 0);
180
-#if (HAVE_POSIX_FADVISE) && defined(POSIX_FADV_WILLNEED)
181
+#if defined(HAVE_POSIX_FADVISE) && defined(POSIX_FADV_WILLNEED)
182
 	posix_fadvise (fd, 0, fd_stat->st_size, POSIX_FADV_WILLNEED);
183
 #endif
184
 	if (cache == MAP_FAILED)
185
@@ -1079,6 +1107,7 @@ FcDirChecksum (struct stat *statb)
186
     source_date_epoch = getenv("SOURCE_DATE_EPOCH");
187
     if (source_date_epoch)
188
     {
189
+	errno = 0;
190
 	epoch = strtoull(source_date_epoch, &endptr, 10);
191
 
192
 	if (endptr == source_date_epoch)
193
@@ -1685,7 +1714,7 @@ FcCacheNumFont args1(const FcCache *c)
194
  * will fill a supplied 16-byte array with the digest.
195
  */
196
 
197
-#ifndef HIGHFIRST
198
+#ifndef WORDS_BIGENDIAN
199
 #define byteReverse(buf, len)	/* Nothing */
200
 #else
201
 /*
202
--- src/fccfg.c.orig	2018-07-19 07:53:00 UTC
203
+++ src/fccfg.c
204
@@ -821,25 +821,25 @@ FcConfigCompareValue (const FcValue	*lef
205
 		break;
206
 	    case FcOpContains:
207
 	    case FcOpListing:
208
-		ret = left.u.b == right.u.b || left.u.b == FcDontCare;
209
+		ret = left.u.b == right.u.b || left.u.b >= FcDontCare;
210
 		break;
211
 	    case FcOpNotEqual:
212
 		ret = left.u.b != right.u.b;
213
 		break;
214
 	    case FcOpNotContains:
215
-		ret = !(left.u.b == right.u.b || left.u.b == FcDontCare);
216
+		ret = !(left.u.b == right.u.b || left.u.b >= FcDontCare);
217
 		break;
218
 	    case FcOpLess:
219
-		ret = left.u.b != right.u.b && right.u.b == FcDontCare;
220
+		ret = left.u.b != right.u.b && right.u.b >= FcDontCare;
221
 		break;
222
 	    case FcOpLessEqual:
223
-		ret = left.u.b == right.u.b || right.u.b == FcDontCare;
224
+		ret = left.u.b == right.u.b || right.u.b >= FcDontCare;
225
 		break;
226
 	    case FcOpMore:
227
-		ret = left.u.b != right.u.b && left.u.b == FcDontCare;
228
+		ret = left.u.b != right.u.b && left.u.b >= FcDontCare;
229
 		break;
230
 	    case FcOpMoreEqual:
231
-		ret = left.u.b == right.u.b || left.u.b == FcDontCare;
232
+		ret = left.u.b == right.u.b || left.u.b >= FcDontCare;
233
 		break;
234
 	    default:
235
 		break;
236
@@ -2207,17 +2207,19 @@ FcConfigFilename (const FcChar8 *url)
237
 	else
238
 	    file = 0;
239
     }
240
-
241
-    path = FcConfigGetPath ();
242
-    if (!path)
243
-	return NULL;
244
-    for (p = path; *p; p++)
245
+    else
246
     {
247
-	file = FcConfigFileExists (*p, url);
248
-	if (file)
249
-	    break;
250
+	path = FcConfigGetPath ();
251
+	if (!path)
252
+	    return NULL;
253
+	for (p = path; *p; p++)
254
+	{
255
+	    file = FcConfigFileExists (*p, url);
256
+	    if (file)
257
+		break;
258
+	}
259
+	FcConfigFreePath (path);
260
     }
261
-    FcConfigFreePath (path);
262
     return file;
263
 }
264
 
265
@@ -2231,7 +2233,7 @@ FcConfigRealFilename (FcConfig		*config,
266
 
267
     if (n)
268
     {
269
-	FcChar8 buf[PATH_MAX];
270
+	FcChar8 buf[FC_PATH_MAX];
271
 	ssize_t len;
272
 
273
 	if (sysroot)
274
--- src/fcdir.c.orig	2018-07-19 03:14:39 UTC
275
+++ src/fcdir.c
276
@@ -421,13 +421,6 @@ FcDirCacheRead (const FcChar8 *dir, FcBo
277
     /* Not using existing cache file, construct new cache */
278
     if (!cache)
279
 	cache = FcDirCacheScan (dir, config);
280
-    if (cache)
281
-    {
282
-	FcFontSet *fs = FcCacheSet (cache);
283
-
284
-	if (cache->dirs_count == 0 && (!fs || fs->nfont == 0))
285
-	    FcDirCacheDeleteUUID (dir, config);
286
-    }
287
 
288
     return cache;
289
 }
290
--- src/fcfreetype.c.orig	2018-08-01 06:41:28 UTC
291
+++ src/fcfreetype.c
292
@@ -193,9 +193,9 @@ static const FcFtLanguage   fcFtLanguage
293
  {  TT_PLATFORM_MACINTOSH,	TT_MAC_LANGID_KIRGHIZ,		    "ky" },
294
  {  TT_PLATFORM_MACINTOSH,	TT_MAC_LANGID_TAJIKI,		    "tg" },
295
  {  TT_PLATFORM_MACINTOSH,	TT_MAC_LANGID_TURKMEN,		    "tk" },
296
- {  TT_PLATFORM_MACINTOSH,	TT_MAC_LANGID_MONGOLIAN,	    "mo" },
297
- {  TT_PLATFORM_MACINTOSH,	TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT,"mo" },
298
- {  TT_PLATFORM_MACINTOSH,	TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT, "mo" },
299
+ {  TT_PLATFORM_MACINTOSH,	TT_MAC_LANGID_MONGOLIAN,	    "mn" },
300
+ {  TT_PLATFORM_MACINTOSH,	TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT,"mn" },
301
+ {  TT_PLATFORM_MACINTOSH,	TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT, "mn" },
302
  {  TT_PLATFORM_MACINTOSH,	TT_MAC_LANGID_PASHTO,		    "ps" },
303
  {  TT_PLATFORM_MACINTOSH,	TT_MAC_LANGID_KURDISH,		    "ku" },
304
  {  TT_PLATFORM_MACINTOSH,	TT_MAC_LANGID_KASHMIRI,		    "ks" },
305
@@ -1101,15 +1101,22 @@ FcGetPixelSize (FT_Face face, int i)
306
 }
307
 
308
 static FcBool
309
-FcStringInPatternElement (FcPattern *pat, const char *elt, FcChar8 *string)
310
+FcStringInPatternElement (FcPattern *pat, FcObject obj, const FcChar8 *string)
311
 {
312
-    int	    e;
313
-    FcChar8 *old;
314
-    for (e = 0; FcPatternGetString (pat, elt, e, &old) == FcResultMatch; e++)
315
-	if (!FcStrCmpIgnoreBlanksAndCase (old, string))
316
-	{
317
+    FcPatternIter iter;
318
+    FcValueListPtr l;
319
+
320
+    FcPatternIterStart (pat, &iter);
321
+    if (!FcPatternFindObjectIter (pat, &iter, obj))
322
+	return FcFalse;
323
+    for (l = FcPatternIterGetValues (pat, &iter); l; l = FcValueListNext (l))
324
+    {
325
+	FcValue v = FcValueCanonicalize (&l->value);
326
+	if (v.type != FcTypeString)
327
+	    break;
328
+	if (!FcStrCmpIgnoreBlanksAndCase (v.u.s, string))
329
 	    return FcTrue;
330
-	}
331
+    }
332
     return FcFalse;
333
 }
334
 
335
@@ -1145,6 +1152,23 @@ typedef struct
336
   unsigned int idx;
337
 } FcNameMapping;
338
 
339
+static FcBool
340
+_is_english(int platform, int language)
341
+{
342
+    FcBool ret = FcFalse;
343
+
344
+    switch (platform)
345
+    {
346
+    case TT_PLATFORM_MACINTOSH:
347
+	ret = language == TT_MAC_LANGID_ENGLISH;
348
+	break;
349
+    case TT_PLATFORM_MICROSOFT:
350
+	ret = language == TT_MS_LANGID_ENGLISH_UNITED_STATES;
351
+	break;
352
+    }
353
+    return ret;
354
+}
355
+
356
 static int
357
 name_mapping_cmp (const void *pa, const void *pb)
358
 {
359
@@ -1154,7 +1178,7 @@ name_mapping_cmp (const void *pa, const 
360
   if (a->platform_id != b->platform_id) return (int) a->platform_id - (int) b->platform_id;
361
   if (a->name_id != b->name_id) return (int) a->name_id - (int) b->name_id;
362
   if (a->encoding_id != b->encoding_id) return (int) a->encoding_id - (int) b->encoding_id;
363
-  if (a->language_id != b->language_id) return (int) a->language_id - (int) b->language_id;
364
+  if (a->language_id != b->language_id) return _is_english(a->platform_id, a->language_id) ? -1 : _is_english(b->platform_id, b->language_id) ? 1 : (int) a->language_id - (int) b->language_id;
365
   if (a->idx != b->idx) return (int) a->idx - (int) b->idx;
366
 
367
   return 0;
368
@@ -1455,10 +1479,10 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
369
 	    FT_SfntName sname;
370
 	    int nameidx;
371
 	    const FcChar8	*lang;
372
-	    const char	*elt = 0, *eltlang = 0;
373
 	    int		*np = 0, *nlangp = 0;
374
 	    size_t		len;
375
 	    int nameid, lookupid;
376
+	    FcObject obj = FC_INVALID_OBJECT, objlang = FC_INVALID_OBJECT;
377
 
378
 	    nameid = lookupid = nameid_order[n];
379
 
380
@@ -1494,8 +1518,8 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
381
 				sname.name_id, sname.platform_id,
382
 				sname.encoding_id, sname.language_id);
383
 
384
-		    elt = FC_FAMILY;
385
-		    eltlang = FC_FAMILYLANG;
386
+		    obj = FC_FAMILY_OBJECT;
387
+		    objlang = FC_FAMILYLANG_OBJECT;
388
 		    np = &nfamily;
389
 		    nlangp = &nfamily_lang;
390
 		    break;
391
@@ -1506,8 +1530,8 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
392
 				sname.name_id, sname.platform_id,
393
 				sname.encoding_id, sname.language_id);
394
 
395
-		    elt = FC_FULLNAME;
396
-		    eltlang = FC_FULLNAMELANG;
397
+		    obj = FC_FULLNAME_OBJECT;
398
+		    objlang = FC_FULLNAMELANG_OBJECT;
399
 		    np = &nfullname;
400
 		    nlangp = &nfullname_lang;
401
 		    break;
402
@@ -1521,8 +1545,8 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
403
 				sname.name_id, sname.platform_id,
404
 				sname.encoding_id, sname.language_id);
405
 
406
-		    elt = FC_STYLE;
407
-		    eltlang = FC_STYLELANG;
408
+		    obj = FC_STYLE_OBJECT;
409
+		    objlang = FC_STYLELANG_OBJECT;
410
 		    np = &nstyle;
411
 		    nlangp = &nstyle_lang;
412
 		    break;
413
@@ -1538,7 +1562,7 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
414
 		    }
415
 		    break;
416
 		}
417
-		if (elt)
418
+		if (obj != FC_INVALID_OBJECT)
419
 		{
420
 		    FcChar8		*utf8, *pp;
421
 
422
@@ -1546,7 +1570,7 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
423
 		    lang = FcSfntNameLanguage (&sname);
424
 
425
 		    if (FcDebug () & FC_DBG_SCANV)
426
-			printf ("%s\n", utf8);
427
+			printf ("%s\n", utf8 ? (char *)utf8 : "(null)");
428
 
429
 		    if (!utf8)
430
 			continue;
431
@@ -1562,14 +1586,14 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
432
 			pp--;
433
 		    *pp = 0;
434
 
435
-		    if (FcStringInPatternElement (pat, elt, utf8))
436
+		    if (FcStringInPatternElement (pat, obj, utf8))
437
 		    {
438
 			free (utf8);
439
 			continue;
440
 		    }
441
 
442
 		    /* add new element */
443
-		    if (!FcPatternAddString (pat, elt, utf8))
444
+		    if (!FcPatternObjectAddString (pat, obj, utf8))
445
 		    {
446
 			free (utf8);
447
 			goto bail1;
448
@@ -1580,11 +1604,11 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
449
 			/* pad lang list with 'und' to line up with elt */
450
 			while (*nlangp < *np)
451
 			{
452
-			    if (!FcPatternAddString (pat, eltlang, (FcChar8 *) "und"))
453
+			    if (!FcPatternObjectAddString (pat, objlang, (FcChar8 *) "und"))
454
 				goto bail1;
455
 			    ++*nlangp;
456
 			}
457
-			if (!FcPatternAddString (pat, eltlang, lang))
458
+			if (!FcPatternObjectAddString (pat, objlang, lang))
459
 			    goto bail1;
460
 			++*nlangp;
461
 		    }
462
@@ -1606,7 +1630,7 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
463
 	    printf ("using FreeType family \"%s\"\n", face->family_name);
464
 	if (!FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) face->family_name))
465
 	    goto bail1;
466
-	if (!FcPatternAddString (pat, FC_STYLELANG, (FcChar8 *) "en"))
467
+	if (!FcPatternAddString (pat, FC_FAMILYLANG, (FcChar8 *) "en"))
468
 	    goto bail1;
469
 	++nfamily;
470
     }
471
@@ -2097,9 +2121,14 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
472
 	free (foundry_);
473
 
474
     if (master)
475
-      {
476
-	/* TODO: How to free master?! */
477
-      }
478
+    {
479
+#ifdef HAVE_FT_DONE_MM_VAR
480
+	if (face->glyph)
481
+	    FT_Done_MM_Var (face->glyph->library, master);
482
+#else
483
+	free (master);
484
+#endif
485
+    }
486
 
487
     return pat;
488
 
489
@@ -2135,7 +2164,7 @@ FcFreeTypeQuery(const FcChar8	*file,
490
     if (FT_Init_FreeType (&ftLibrary))
491
 	return NULL;
492
 
493
-    if (FT_New_Face (ftLibrary, (char *) file, id & 0x7FFFFFFFF, &face))
494
+    if (FT_New_Face (ftLibrary, (char *) file, id & 0x7FFFFFFF, &face))
495
 	goto bail;
496
 
497
     if (count)
498
--- src/fcint.h.orig	2018-07-19 03:14:39 UTC
499
+++ src/fcint.h
500
@@ -1283,10 +1283,6 @@ FcPrivate FcBool
501
 FcStrIsAbsoluteFilename (const FcChar8 *s);
502
 
503
 FcPrivate FcChar8 *
504
-FcStrBuildFilename (const FcChar8 *path,
505
-		    ...);
506
-
507
-FcPrivate FcChar8 *
508
 FcStrLastSlash (const FcChar8  *path);
509
 
510
 FcPrivate FcChar32
511
--- src/fcweight.c.orig	2018-06-05 10:36:38 UTC
512
+++ src/fcweight.c
513
@@ -46,7 +46,7 @@ static double lerp(double x, int x1, int
514
   int dx = x2 - x1;
515
   int dy = y2 - y1;
516
   assert (dx > 0 && dy >= 0 && x1 <= x && x <= x2);
517
-  return y1 + (dy*(x-x1) + dx/2) / dx;
518
+  return y1 + (x-x1) * dy / dx;
519
 }
520
 
521
 double
522
--- src/fcxml.c.orig	2018-07-26 02:57:07 UTC
523
+++ src/fcxml.c
524
@@ -1480,6 +1480,11 @@ FcParseMatrix (FcConfigParse *parse)
525
     m.xy = FcPopExpr (parse);
526
     m.xx = FcPopExpr (parse);
527
 
528
+    if (!m.yy || !m.yx || !m.xy || !m.xx)
529
+    {
530
+	FcConfigMessage (parse, FcSevereWarning, "Missing values in matrix element");
531
+	return;
532
+    }
533
     if (FcPopExpr (parse))
534
       FcConfigMessage (parse, FcSevereError, "wrong number of matrix elements");
535
     else
536
@@ -2073,16 +2078,36 @@ FcParseDir (FcConfigParse *parse)
537
 #endif
538
 
539
     attr = FcConfigGetAttribute (parse, "prefix");
540
-    if (attr && FcStrCmp (attr, (const FcChar8 *)"xdg") == 0)
541
+    data = FcStrBufDoneStatic (&parse->pstack->str);
542
+    if (attr)
543
     {
544
-	prefix = FcConfigXdgDataHome ();
545
-	/* home directory might be disabled.
546
-	 * simply ignore this element.
547
-	 */
548
-	if (!prefix)
549
-	    goto bail;
550
+	if (FcStrCmp (attr, (const FcChar8 *)"xdg") == 0)
551
+	{
552
+	    prefix = FcConfigXdgDataHome ();
553
+	    /* home directory might be disabled.
554
+	     * simply ignore this element.
555
+	     */
556
+	    if (!prefix)
557
+		goto bail;
558
+	}
559
+	else if (FcStrCmp (attr, (const FcChar8 *)"default") == 0 || FcStrCmp (attr, (const FcChar8 *)"cwd") == 0)
560
+	{
561
+	}
562
+	else if (FcStrCmp (attr, (const FcChar8 *)"relative") == 0)
563
+	{
564
+	    prefix = FcStrDirname (parse->name);
565
+	    if (!prefix)
566
+		goto bail;
567
+	}
568
     }
569
-    data = FcStrBufDoneStatic (&parse->pstack->str);
570
+#ifndef _WIN32
571
+    /* For Win32, check this later for dealing with special cases */
572
+    else
573
+    {
574
+	if (!FcStrIsAbsoluteFilename (data) && data[0] != '~')
575
+	    FcConfigMessage (parse, FcSevereWarning, "Use of ambiguous <dir> element. please add prefix=\"cwd\" if current behavior is desired.");
576
+    }
577
+#endif
578
     if (!data)
579
     {
580
 	FcConfigMessage (parse, FcSevereError, "out of memory");
581
@@ -2153,6 +2178,11 @@ FcParseDir (FcConfigParse *parse)
582
 	    strcat ((char *) data, "\\");
583
 	strcat ((char *) data, "fonts");
584
     }
585
+    else if (!attr)
586
+    {
587
+	if (!FcStrIsAbsoluteFilename (data) && data[0] != '~')
588
+	    FcConfigMessage (parse, FcSevereWarning, "Use of ambiguous <dir> element. please add prefix=\"cwd\" if current behavior is desired.");
589
+    }
590
 #endif
591
     if (strlen ((char *) data) == 0)
592
 	FcConfigMessage (parse, FcSevereWarning, "empty font directory name ignored");
(-)x11-fonts/fontconfig/files/patch-2.13.92.diff (+1748 lines)
Line 0 Link Here
1
# Affect FC_FONT_HAS_HINT property to score on matcher
2
# https://cgit.freedesktop.org/fontconfig/commit/?id=cb1036a7c7f1cb79fa799b1db368c86b018ec368
3
# Add missing return type for FcFontSet* functions
4
# https://cgit.freedesktop.org/fontconfig/commit/?id=7172f08d4231c59cf14dab9ebab714df37e352ac
5
# Do not return FcFalse from FcConfigParseAndLoad*() if complain is set to false
6
# https://cgit.freedesktop.org/fontconfig/commit/?id=fcada522913e5e07efa6367eff87ace9f06d24c8
7
# conf: Add JoyPixels emoji font
8
# https://cgit.freedesktop.org/fontconfig/commit/?id=65087ac7ce4cc5f2109967c1380b474955dcb590
9
# Warn as well if no directory name for cachedir provided
10
# https://cgit.freedesktop.org/fontconfig/commit/?id=75eadca26648abf69497691ff0f4c7803b9ff23c
11
# Take effect sysroot functionality to the default config file
12
# https://cgit.freedesktop.org/fontconfig/commit/?id=cd51cb241aad7b362b793200ca7d42595c14f52b
13
# Read latest cache in paths
14
# https://cgit.freedesktop.org/fontconfig/commit/?id=c9862b6ea7c3234b29f6500c7d07359847e55ed7
15
# Fix a memory leak caused by the previous commit
16
# https://cgit.freedesktop.org/fontconfig/commit/?id=a45fc8a33256d9d3ea0ea7947f33c8e5e3cc7238
17
# Use FcConfigReference/Destroy appropriately instead of FcConfigGetCurrent
18
# https://cgit.freedesktop.org/fontconfig/commit/?id=b5bcf61fe789e66df2de609ec246cb7e4d326180
19
# Fix potential race condition in FcConfigSetCurrent and FcConfigReference
20
# https://cgit.freedesktop.org/fontconfig/commit/?id=aa8c8cfa9fb2563482336249e3f56459099fcf6e
21
# Correct reset-dirs in DTD
22
# https://cgit.freedesktop.org/fontconfig/commit/?id=a4aa66a858f1ecd375c5efe5916398281f73f794
23
# Don't add a value for FC_FULLNAME in meta face
24
# https://cgit.freedesktop.org/fontconfig/commit/?id=8249f871b373db5c6559f8c48242beed612b23a0
25
# Add proper fullname for named-instances
26
# https://cgit.freedesktop.org/fontconfig/commit/?id=452be8125f0e2a18a7dfef469e05d19374d36307
27
# Fix the process substitution doesn't work with FONTCONFIG_FILE
28
# https://cgit.freedesktop.org/fontconfig/commit/?id=71d6866d381a0ab3585eb9ee760aeec98e722359
29
# Fix memory leaks
30
# https://cgit.freedesktop.org/fontconfig/commit/?id=61573ad5f7c4dd0860d613d99d0086433240eb75
31
# Fix assertion in FcFini()
32
# https://cgit.freedesktop.org/fontconfig/commit/?id=fbc05949ef52c8a8d69233eed77f6636dffec280
33
# Set exact boolean value to color property
34
# https://cgit.freedesktop.org/fontconfig/commit/?id=d3bfbea7dc53aa7fa52aa9616235a23d4507da1b
35
36
Excluding changes for the following files: test/Makefile.am, test/run-test.sh,
37
test/test-bz1744377.c, test/test-crbug1004254.c, test/test-issue180.c.
38
39
--- conf.d/45-generic.conf.orig	2018-06-05 10:36:38 UTC
40
+++ conf.d/45-generic.conf
41
@@ -38,6 +38,10 @@
42
 		<default><family>emoji</family></default>
43
 	</alias>
44
 	<alias binding="same">
45
+		<family>JoyPixels</family>
46
+		<default><family>emoji</family></default>
47
+	</alias>
48
+	<alias binding="same">
49
 		<family>Emoji One</family>
50
 		<default><family>emoji</family></default>
51
 	</alias>
52
--- conf.d/60-generic.conf.orig	2018-06-05 10:36:38 UTC
53
+++ conf.d/60-generic.conf
54
@@ -42,6 +42,7 @@
55
 			<family>EmojiOne Mozilla</family> <!-- Mozilla -->
56
 			<!-- Third-Party fonts -->
57
 			<family>Emoji Two</family>
58
+			<family>JoyPixels</family>
59
 			<family>Emoji One</family>
60
 			<!-- Non-color -->
61
 			<family>Noto Emoji</family> <!-- Google -->
62
--- doc/fcconfig.fncs.orig	2019-05-08 08:22:25 UTC
63
+++ doc/fcconfig.fncs
64
@@ -174,6 +174,10 @@ Returns one of the two sets of fonts fro
65
 by <parameter>set</parameter>. This font set is owned by the library and must
66
 not be modified or freed.
67
 If <parameter>config</parameter> is NULL, the current configuration is used.
68
+    </para><para>
69
+This function isn't MT-safe. <function>FcConfigReference</function> must be called
70
+before using this and then <function>FcConfigDestroy</function> when
71
+the return value is no longer referenced.
72
 @@
73
 
74
 @RET@           FcBlanks *
75
@@ -344,6 +348,15 @@ to be up to date, and used.
76
 @TYPE1@         const FcChar8 *			@ARG1@          name
77
 @PURPOSE@	Find a config file
78
 @DESC@
79
+This function is deprecated and is replaced by <function>FcConfigGetFilename</function>.
80
+@@
81
+
82
+@RET@           FcChar8 *
83
+@FUNC@          FcConfigGetFilename
84
+@TYPE1@         FcConfig *			@ARG1@          config
85
+@TYPE2@         const FcChar8 *			@ARG2@          name
86
+@PURPOSE@	Find a config file
87
+@DESC@
88
 Given the specified external entity name, return the associated filename.
89
 This provides applications a way to convert various configuration file
90
 references into filename form.
91
@@ -355,6 +368,8 @@ refers to a file in the current users ho
92
 doesn't start with '/', it refers to a file in the default configuration
93
 directory; the built-in default directory can be overridden with the
94
 FONTCONFIG_PATH environment variable.
95
+    </para><para>
96
+The result of this function is affected by the FONTCONFIG_SYSROOT environment variable or equivalent functionality.
97
 @@
98
 
99
 @RET@		FcBool
100
@@ -396,6 +411,10 @@ parse error, semantic error or allocatio
101
 Obtains the system root directory in 'config' if available. All files
102
 (including file properties in patterns) obtained from this 'config' are
103
 relative to this system root directory.
104
+    </para><para>
105
+This function isn't MT-safe. <function>FcConfigReference</function> must be called
106
+before using this and then <function>FcConfigDestroy</function> when
107
+the return value is no longer referenced.
108
 @SINCE@		2.10.92
109
 @@
110
 
111
@@ -422,6 +441,10 @@ When setting this on the current config 
112
 @PURPOSE@	Initialize the iterator
113
 @DESC@
114
 Initialize 'iter' with the first iterator in the config file information list.
115
+    </para><para>
116
+This function isn't MT-safe. <function>FcConfigReference</function> must be called
117
+before using this and then <function>FcConfigDestroy</function> when the relevant
118
+values are no longer referenced.
119
 @SINCE@		2.12.91
120
 @@
121
 
122
@@ -433,6 +456,10 @@ Initialize 'iter' with the first iterato
123
 @DESC@
124
 Set 'iter' to point to the next node in the config file information list.
125
 If there is no next node, FcFalse is returned.
126
+    </para><para>
127
+This function isn't MT-safe. <function>FcConfigReference</function> must be called
128
+before using <function>FcConfigFileInfoIterInit</function> and then
129
+<function>FcConfigDestroy</function> when the relevant values are no longer referenced.
130
 @SINCE@		2.12.91
131
 @@
132
 
133
@@ -448,5 +475,9 @@ If there is no next node, FcFalse is ret
134
 Obtain the filename, the description and the flag whether it is enabled or not
135
 for 'iter' where points to current configuration file information.
136
 If the iterator is invalid, FcFalse is returned.
137
+    </para><para>
138
+This function isn't MT-safe. <function>FcConfigReference</function> must be called
139
+before using <function>FcConfigFileInfoIterInit</function> and then
140
+<function>FcConfigDestroy</function> when the relevant values are no longer referenced.
141
 @SINCE@		2.12.91
142
 @@
143
--- doc/fcfontset.fncs.orig	2016-07-11 02:41:05 UTC
144
+++ doc/fcfontset.fncs
145
@@ -97,7 +97,7 @@ of the output is designed to be of help 
146
 change at any time.
147
 @@
148
 
149
-@RET@		
150
+@RET@		FcFontSet *
151
 @FUNC@		FcFontSetSort
152
 @TYPE1@         FcConfig *			@ARG1@		config
153
 @TYPE2@		FcFontSet **			@ARG2@		sets
154
@@ -128,7 +128,7 @@ modify these patterns.  Instead, they sh
155
 The FcFontSet returned by FcFontSetSort is destroyed by calling FcFontSetDestroy.
156
 @@
157
 
158
-@RET@		
159
+@RET@		void
160
 @FUNC@		FcFontSetSortDestroy
161
 @TYPE1@		FcFontSet *			@ARG1@		set
162
 @PURPOSE@	DEPRECATED destroy a font set
163
--- fontconfig/fontconfig.h.orig	2019-08-09 11:09:32 UTC
164
+++ fontconfig/fontconfig.h
165
@@ -375,7 +375,7 @@ FcPublic FcBool
166
 FcDirCacheClean (const FcChar8 *cache_dir, FcBool verbose);
167
 
168
 FcPublic void
169
-FcCacheCreateTagFile (const FcConfig *config);
170
+FcCacheCreateTagFile (FcConfig *config);
171
 
172
 FcPublic FcBool
173
 FcDirCacheCreateUUID (FcChar8  *dir,
174
@@ -394,6 +394,10 @@ FcPublic FcBool
175
 FcConfigEnableHome (FcBool enable);
176
 
177
 FcPublic FcChar8 *
178
+FcConfigGetFilename (FcConfig      *config,
179
+		     const FcChar8 *url);
180
+
181
+FcPublic FcChar8 *
182
 FcConfigFilename (const FcChar8 *url);
183
     
184
 FcPublic FcConfig *
185
@@ -433,7 +437,7 @@ FcPublic FcBlanks *
186
 FcConfigGetBlanks (FcConfig *config);
187
 
188
 FcPublic FcStrList *
189
-FcConfigGetCacheDirs (const FcConfig	*config);
190
+FcConfigGetCacheDirs (FcConfig	*config);
191
 
192
 FcPublic int
193
 FcConfigGetRescanInterval (FcConfig *config);
194
--- fonts.dtd.orig	2019-05-08 08:22:25 UTC
195
+++ fonts.dtd
196
@@ -124,7 +124,7 @@
197
 <!--
198
     Reset the list of fonts directories
199
 -->
200
-<!ELEMENT reset-dirs >
201
+<!ELEMENT reset-dirs EMPTY>
202
 
203
 <!--
204
     Periodically rescan the font configuration and
205
--- src/fccache.c.orig	2019-07-29 05:17:34 UTC
206
+++ src/fccache.c
207
@@ -58,11 +58,15 @@ FcDirCacheDeleteUUID (const FcChar8  *di
208
 {
209
     FcBool ret = FcTrue;
210
 #ifndef _WIN32
211
-    const FcChar8 *sysroot = FcConfigGetSysRoot (config);
212
+    const FcChar8 *sysroot;
213
     FcChar8 *target, *d;
214
     struct stat statb;
215
     struct timeval times[2];
216
 
217
+    config = FcConfigReference (config);
218
+    if (!config)
219
+	return FcFalse;
220
+    sysroot = FcConfigGetSysRoot (config);
221
     if (sysroot)
222
 	d = FcStrBuildFilename (sysroot, dir, NULL);
223
     else
224
@@ -94,6 +98,7 @@ FcDirCacheDeleteUUID (const FcChar8  *di
225
 bail:
226
     FcStrFree (d);
227
 #endif
228
+    FcConfigDestroy (config);
229
 
230
     return ret;
231
 }
232
@@ -265,7 +270,13 @@ FcDirCacheUnlink (const FcChar8 *dir, Fc
233
 #endif
234
     FcStrList	*list;
235
     FcChar8	*cache_dir;
236
-    const FcChar8 *sysroot = FcConfigGetSysRoot (config);
237
+    const FcChar8 *sysroot;
238
+    FcBool	ret = FcTrue;
239
+
240
+    config = FcConfigReference (config);
241
+    if (!config)
242
+	return FcFalse;
243
+    sysroot = FcConfigGetSysRoot (config);
244
 
245
     FcDirCacheBasenameMD5 (config, dir, cache_base);
246
 #ifndef _WIN32
247
@@ -274,7 +285,10 @@ FcDirCacheUnlink (const FcChar8 *dir, Fc
248
 
249
     list = FcStrListCreate (config->cacheDirs);
250
     if (!list)
251
-        return FcFalse;
252
+    {
253
+	ret = FcFalse;
254
+	goto bail;
255
+    }
256
 	
257
     while ((cache_dir = FcStrListNext (list)))
258
     {
259
@@ -304,8 +318,11 @@ FcDirCacheUnlink (const FcChar8 *dir, Fc
260
     FcDirCacheDeleteUUID (dir, config);
261
     /* return FcFalse if something went wrong */
262
     if (cache_dir)
263
-	return FcFalse;
264
-    return FcTrue;
265
+	ret = FcFalse;
266
+bail:
267
+    FcConfigDestroy (config);
268
+
269
+    return ret;
270
 }
271
 
272
 static int
273
@@ -338,7 +355,7 @@ FcDirCacheOpenFile (const FcChar8 *cache
274
 static FcBool
275
 FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
276
 		   FcBool (*callback) (FcConfig *config, int fd, struct stat *fd_stat,
277
-				       struct stat *dir_stat, void *closure),
278
+				       struct stat *dir_stat, struct timeval *cache_mtime, void *closure),
279
 		   void *closure, FcChar8 **cache_file_ret)
280
 {
281
     int		fd = -1;
282
@@ -372,6 +389,8 @@ FcDirCacheProcess (FcConfig *config, con
283
 #ifndef _WIN32
284
 	FcBool retried = FcFalse;
285
 #endif
286
+	struct timeval latest_mtime = (struct timeval){ 0 };
287
+
288
 	if (sysroot)
289
 	    cache_hashed = FcStrBuildFilename (sysroot, cache_dir, cache_base, NULL);
290
 	else
291
@@ -383,16 +402,21 @@ FcDirCacheProcess (FcConfig *config, con
292
 #endif
293
         fd = FcDirCacheOpenFile (cache_hashed, &file_stat);
294
         if (fd >= 0) {
295
-	    ret = (*callback) (config, fd, &file_stat, &dir_stat, closure);
296
+	    ret = (*callback) (config, fd, &file_stat, &dir_stat, &latest_mtime, closure);
297
 	    close (fd);
298
 	    if (ret)
299
 	    {
300
 		if (cache_file_ret)
301
+		{
302
+		    if (*cache_file_ret)
303
+			FcStrFree (*cache_file_ret);
304
 		    *cache_file_ret = cache_hashed;
305
+		}
306
 		else
307
 		    FcStrFree (cache_hashed);
308
-		break;
309
 	    }
310
+	    else
311
+		FcStrFree (cache_hashed);
312
 	}
313
 #ifndef _WIN32
314
 	else if (!retried)
315
@@ -412,9 +436,12 @@ FcDirCacheProcess (FcConfig *config, con
316
 		    break;
317
 		goto retry;
318
 	    }
319
+	    else
320
+		FcStrFree (cache_hashed);
321
 	}
322
 #endif
323
-    	FcStrFree (cache_hashed);
324
+	else
325
+	    FcStrFree (cache_hashed);
326
     }
327
     FcStrListDone (list);
328
 
329
@@ -998,12 +1025,31 @@ FcDirCacheUnload (FcCache *cache)
330
 }
331
 
332
 static FcBool
333
-FcDirCacheMapHelper (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat, void *closure)
334
+FcDirCacheMapHelper (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat, struct timeval *latest_cache_mtime, void *closure)
335
 {
336
     FcCache *cache = FcDirCacheMapFd (config, fd, fd_stat, dir_stat);
337
+    struct timeval cache_mtime;
338
 
339
     if (!cache)
340
 	return FcFalse;
341
+    cache_mtime.tv_sec = fd_stat->st_mtime;
342
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
343
+    cache_mtime.tv_usec = fd_stat->st_mtim.tv_nsec / 1000;
344
+#else
345
+    cache_mtime.tv_usec = 0;
346
+#endif
347
+    if (timercmp (latest_cache_mtime, &cache_mtime, <))
348
+    {
349
+	if (*((FcCache **) closure))
350
+	    FcDirCacheUnload (*((FcCache **) closure));
351
+    }
352
+    else
353
+    {
354
+	FcDirCacheUnload (cache);
355
+	return FcFalse;
356
+    }
357
+    latest_cache_mtime->tv_sec = cache_mtime.tv_sec;
358
+    latest_cache_mtime->tv_usec = cache_mtime.tv_usec;
359
     *((FcCache **) closure) = cache;
360
     return FcTrue;
361
 }
362
@@ -1013,10 +1059,15 @@ FcDirCacheLoad (const FcChar8 *dir, FcCo
363
 {
364
     FcCache *cache = NULL;
365
 
366
+    config = FcConfigReference (config);
367
+    if (!config)
368
+	return NULL;
369
     if (!FcDirCacheProcess (config, dir,
370
 			    FcDirCacheMapHelper,
371
 			    &cache, cache_file))
372
-	return NULL;
373
+	cache = NULL;
374
+
375
+    FcConfigDestroy (config);
376
 
377
     return cache;
378
 }
379
@@ -1027,13 +1078,18 @@ FcDirCacheLoadFile (const FcChar8 *cache
380
     int	fd;
381
     FcCache *cache;
382
     struct stat	my_file_stat;
383
+    FcConfig *config;
384
 
385
     if (!file_stat)
386
 	file_stat = &my_file_stat;
387
+    config = FcConfigReference (NULL);
388
+    if (!config)
389
+	return NULL;
390
     fd = FcDirCacheOpenFile (cache_file, file_stat);
391
     if (fd < 0)
392
 	return NULL;
393
-    cache = FcDirCacheMapFd (FcConfigGetCurrent (), fd, file_stat, NULL);
394
+    cache = FcDirCacheMapFd (config, fd, file_stat, NULL);
395
+    FcConfigDestroy (config);
396
     close (fd);
397
     return cache;
398
 }
399
@@ -1093,7 +1149,7 @@ FcDirChecksumNano (struct stat *statb)
400
  * the magic number and the size field
401
  */
402
 static FcBool
403
-FcDirCacheValidateHelper (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat, void *closure FC_UNUSED)
404
+FcDirCacheValidateHelper (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat, struct timeval *latest_cache_mtime, void *closure FC_UNUSED)
405
 {
406
     FcBool  ret = FcTrue;
407
     FcCache	c;
408
@@ -1127,12 +1183,16 @@ FcBool
409
 FcDirCacheValid (const FcChar8 *dir)
410
 {
411
     FcConfig	*config;
412
+    FcBool	ret;
413
 
414
-    config = FcConfigGetCurrent ();
415
+    config = FcConfigReference (NULL);
416
     if (!config)
417
         return FcFalse;
418
 
419
-    return FcDirCacheValidConfig (dir, config);
420
+    ret = FcDirCacheValidConfig (dir, config);
421
+    FcConfigDestroy (config);
422
+
423
+    return ret;
424
 }
425
 
426
 /*
427
@@ -1410,9 +1470,13 @@ FcDirCacheClean (const FcChar8 *cache_di
428
     FcCache	*cache;
429
     struct stat	target_stat;
430
     const FcChar8 *sysroot;
431
+    FcConfig	*config;
432
 
433
+    config = FcConfigReference (NULL);
434
+    if (!config)
435
+	return FcFalse;
436
     /* FIXME: this API needs to support non-current FcConfig */
437
-    sysroot = FcConfigGetSysRoot (NULL);
438
+    sysroot = FcConfigGetSysRoot (config);
439
     if (sysroot)
440
 	dir = FcStrBuildFilename (sysroot, cache_dir, NULL);
441
     else
442
@@ -1420,7 +1484,8 @@ FcDirCacheClean (const FcChar8 *cache_di
443
     if (!dir)
444
     {
445
 	fprintf (stderr, "Fontconfig error: %s: out of memory\n", cache_dir);
446
-	return FcFalse;
447
+	ret = FcFalse;
448
+	goto bail;
449
     }
450
     if (access ((char *) dir, W_OK) != 0)
451
     {
452
@@ -1497,8 +1562,10 @@ FcDirCacheClean (const FcChar8 *cache_di
453
     }
454
 
455
     closedir (d);
456
-  bail0:
457
+bail0:
458
     FcStrFree (dir);
459
+bail:
460
+    FcConfigDestroy (config);
461
 
462
     return ret;
463
 }
464
@@ -1940,15 +2007,20 @@ FcDirCacheCreateTagFile (const FcChar8 *
465
 }
466
 
467
 void
468
-FcCacheCreateTagFile (const FcConfig *config)
469
+FcCacheCreateTagFile (FcConfig *config)
470
 {
471
     FcChar8   *cache_dir = NULL, *d = NULL;
472
     FcStrList *list;
473
-    const FcChar8 *sysroot = FcConfigGetSysRoot (config);
474
+    const FcChar8 *sysroot;
475
+
476
+    config = FcConfigReference (config);
477
+    if (!config)
478
+	return;
479
+    sysroot = FcConfigGetSysRoot (config);
480
 
481
     list = FcConfigGetCacheDirs (config);
482
     if (!list)
483
-	return;
484
+	goto bail;
485
 
486
     while ((cache_dir = FcStrListNext (list)))
487
     {
488
@@ -1964,6 +2036,8 @@ FcCacheCreateTagFile (const FcConfig *co
489
     if (d)
490
 	FcStrFree (d);
491
     FcStrListDone (list);
492
+bail:
493
+    FcConfigDestroy (config);
494
 }
495
 
496
 #define __fccache__
497
--- src/fccfg.c.orig	2019-05-08 08:22:25 UTC
498
+++ src/fccfg.c
499
@@ -33,6 +33,49 @@
500
 #endif
501
 
502
 static FcConfig    *_fcConfig; /* MT-safe */
503
+static FcMutex	   *_lock;
504
+
505
+static void
506
+lock_config (void)
507
+{
508
+    FcMutex *lock;
509
+retry:
510
+    lock = fc_atomic_ptr_get (&_lock);
511
+    if (!lock)
512
+    {
513
+	lock = (FcMutex *) malloc (sizeof (FcMutex));
514
+	FcMutexInit (lock);
515
+	if (!fc_atomic_ptr_cmpexch (&_lock, NULL, lock))
516
+	{
517
+	    FcMutexFinish (lock);
518
+	    goto retry;
519
+	}
520
+	FcMutexLock (lock);
521
+	/* Initialize random state */
522
+	FcRandom ();
523
+	return;
524
+    }
525
+    FcMutexLock (lock);
526
+}
527
+
528
+static void
529
+unlock_config (void)
530
+{
531
+    FcMutexUnlock (_lock);
532
+}
533
+
534
+static void
535
+free_lock (void)
536
+{
537
+    FcMutex *lock;
538
+
539
+    lock = fc_atomic_ptr_get (&_lock);
540
+    if (lock && fc_atomic_ptr_cmpexch (&_lock, lock, NULL))
541
+    {
542
+	FcMutexFinish (lock);
543
+	free (lock);
544
+    }
545
+}
546
 
547
 static FcConfig *
548
 FcConfigEnsure (void)
549
@@ -44,8 +87,9 @@ retry:
550
     {
551
 	config = FcInitLoadConfigAndFonts ();
552
 
553
-	if (!fc_atomic_ptr_cmpexch (&_fcConfig, NULL, config)) {
554
-	    FcConfigDestroy (config);
555
+	if (!config || !fc_atomic_ptr_cmpexch (&_fcConfig, NULL, config)) {
556
+	    if (config)
557
+		FcConfigDestroy (config);
558
 	    goto retry;
559
 	}
560
     }
561
@@ -76,6 +120,7 @@ FcConfigFini (void)
562
     FcConfig *cfg = fc_atomic_ptr_get (&_fcConfig);
563
     if (cfg && fc_atomic_ptr_cmpexch (&_fcConfig, cfg, NULL))
564
 	FcConfigDestroy (cfg);
565
+    free_lock ();
566
 }
567
 
568
 static FcChar8 *
569
@@ -237,12 +282,12 @@ FcConfigUptoDate (FcConfig *config)
570
 {
571
     FcFileTime	config_time, config_dir_time, font_time;
572
     time_t	now = time(0);
573
+    FcBool	ret = FcTrue;
574
+
575
+    config = FcConfigReference (config);
576
     if (!config)
577
-    {
578
-	config = FcConfigGetCurrent ();
579
-	if (!config)
580
-	    return FcFalse;
581
-    }
582
+	return FcFalse;
583
+
584
     config_time = FcConfigNewestFile (config->configFiles);
585
     config_dir_time = FcConfigNewestFile (config->configDirs);
586
     font_time = FcConfigNewestFile (config->fontDirs);
587
@@ -258,13 +303,19 @@ FcConfigUptoDate (FcConfig *config)
588
 	    fprintf (stderr,
589
                     "Fontconfig warning: Directory/file mtime in the future. New fonts may not be detected.\n");
590
 	    config->rescanTime = now;
591
-	    return FcTrue;
592
+	    goto bail;
593
 	}
594
 	else
595
-	    return FcFalse;
596
+	{
597
+	    ret = FcFalse;
598
+	    goto bail;
599
+	}
600
     }
601
     config->rescanTime = now;
602
-    return FcTrue;
603
+bail:
604
+    FcConfigDestroy (config);
605
+
606
+    return ret;
607
 }
608
 
609
 FcExpr *
610
@@ -291,12 +342,31 @@ FcConfigReference (FcConfig *config)
611
 {
612
     if (!config)
613
     {
614
-	config = FcConfigGetCurrent ();
615
+	/* lock during obtaining the value from _fcConfig and count up refcount there,
616
+	 * there are the race between them.
617
+	 */
618
+	lock_config ();
619
+    retry:
620
+	config = fc_atomic_ptr_get (&_fcConfig);
621
 	if (!config)
622
-	    return 0;
623
-    }
624
+	{
625
+	    unlock_config ();
626
 
627
-    FcRefInc (&config->ref);
628
+	    config = FcInitLoadConfigAndFonts ();
629
+	    if (!config)
630
+		goto retry;
631
+	    lock_config ();
632
+	    if (!fc_atomic_ptr_cmpexch (&_fcConfig, NULL, config))
633
+	    {
634
+		FcConfigDestroy (config);
635
+		goto retry;
636
+	    }
637
+	}
638
+	FcRefInc (&config->ref);
639
+	unlock_config ();
640
+    }
641
+    else
642
+	FcRefInc (&config->ref);
643
 
644
     return config;
645
 }
646
@@ -475,25 +545,32 @@ FcBool
647
 FcConfigBuildFonts (FcConfig *config)
648
 {
649
     FcFontSet	    *fonts;
650
+    FcBool	    ret = FcTrue;
651
 
652
+    config = FcConfigReference (config);
653
     if (!config)
654
-    {
655
-	config = FcConfigGetCurrent ();
656
-	if (!config)
657
-	    return FcFalse;
658
-    }
659
+	return FcFalse;
660
 	
661
     fonts = FcFontSetCreate ();
662
     if (!fonts)
663
-	return FcFalse;
664
+    {
665
+	ret = FcFalse;
666
+	goto bail;
667
+    }
668
 
669
     FcConfigSetFonts (config, fonts, FcSetSystem);
670
 
671
     if (!FcConfigAddDirList (config, FcSetSystem, config->fontDirs))
672
-	return FcFalse;
673
+    {
674
+	ret = FcFalse;
675
+	goto bail;
676
+    }
677
     if (FcDebug () & FC_DBG_FONTSET)
678
 	FcFontSetPrint (fonts);
679
-    return FcTrue;
680
+bail:
681
+    FcConfigDestroy (config);
682
+
683
+    return ret;
684
 }
685
 
686
 FcBool
687
@@ -501,20 +578,29 @@ FcConfigSetCurrent (FcConfig *config)
688
 {
689
     FcConfig *cfg;
690
 
691
+    if (config)
692
+    {
693
+	if (!config->fonts[FcSetSystem])
694
+	    if (!FcConfigBuildFonts (config))
695
+		return FcFalse;
696
+	FcRefInc (&config->ref);
697
+    }
698
+
699
+    lock_config ();
700
 retry:
701
     cfg = fc_atomic_ptr_get (&_fcConfig);
702
 
703
     if (config == cfg)
704
+    {
705
+	unlock_config ();
706
+	if (config)
707
+	    FcConfigDestroy (config);
708
 	return FcTrue;
709
-
710
-    if (config && !config->fonts[FcSetSystem])
711
-	if (!FcConfigBuildFonts (config))
712
-	    return FcFalse;
713
+    }
714
 
715
     if (!fc_atomic_ptr_cmpexch (&_fcConfig, cfg, config))
716
 	goto retry;
717
-
718
-    FcConfigReference (config);
719
+    unlock_config ();
720
     if (cfg)
721
 	FcConfigDestroy (cfg);
722
 
723
@@ -537,13 +623,15 @@ FcConfigAddConfigDir (FcConfig	    *conf
724
 FcStrList *
725
 FcConfigGetConfigDirs (FcConfig   *config)
726
 {
727
+    FcStrList *ret;
728
+
729
+    config = FcConfigReference (config);
730
     if (!config)
731
-    {
732
-	config = FcConfigGetCurrent ();
733
-	if (!config)
734
-	    return 0;
735
-    }
736
-    return FcStrListCreate (config->configDirs);
737
+	return NULL;
738
+    ret = FcStrListCreate (config->configDirs);
739
+    FcConfigDestroy (config);
740
+
741
+    return ret;
742
 }
743
 
744
 FcBool
745
@@ -579,13 +667,15 @@ FcConfigResetFontDirs (FcConfig *config)
746
 FcStrList *
747
 FcConfigGetFontDirs (FcConfig	*config)
748
 {
749
+    FcStrList *ret;
750
+
751
+    config = FcConfigReference (config);
752
     if (!config)
753
-    {
754
-	config = FcConfigGetCurrent ();
755
-	if (!config)
756
-	    return 0;
757
-    }
758
-    return FcStrListCreate (config->fontDirs);
759
+	return NULL;
760
+    ret = FcStrListCreate (config->fontDirs);
761
+    FcConfigDestroy (config);
762
+
763
+    return ret;
764
 }
765
 
766
 static FcBool
767
@@ -670,15 +760,17 @@ FcConfigAddCacheDir (FcConfig	    *confi
768
 }
769
 
770
 FcStrList *
771
-FcConfigGetCacheDirs (const FcConfig *config)
772
+FcConfigGetCacheDirs (FcConfig *config)
773
 {
774
+    FcStrList *ret;
775
+
776
+    config = FcConfigReference (config);
777
     if (!config)
778
-    {
779
-	config = FcConfigGetCurrent ();
780
-	if (!config)
781
-	    return 0;
782
-    }
783
-    return FcStrListCreate (config->cacheDirs);
784
+	return NULL;
785
+    ret = FcStrListCreate (config->cacheDirs);
786
+    FcConfigDestroy (config);
787
+
788
+    return ret;
789
 }
790
 
791
 FcBool
792
@@ -686,7 +778,7 @@ FcConfigAddConfigFile (FcConfig	    *con
793
 		       const FcChar8   *f)
794
 {
795
     FcBool	ret;
796
-    FcChar8	*file = FcConfigFilename (f);
797
+    FcChar8	*file = FcConfigGetFilename (config, f);
798
 
799
     if (!file)
800
 	return FcFalse;
801
@@ -699,13 +791,15 @@ FcConfigAddConfigFile (FcConfig	    *con
802
 FcStrList *
803
 FcConfigGetConfigFiles (FcConfig    *config)
804
 {
805
+    FcStrList *ret;
806
+
807
+    config = FcConfigReference (config);
808
     if (!config)
809
-    {
810
-	config = FcConfigGetCurrent ();
811
-	if (!config)
812
-	    return 0;
813
-    }
814
-    return FcStrListCreate (config->configFiles);
815
+	return NULL;
816
+    ret = FcStrListCreate (config->configFiles);
817
+    FcConfigDestroy (config);
818
+
819
+    return ret;
820
 }
821
 
822
 FcChar8 *
823
@@ -784,25 +878,26 @@ FcConfigAddBlank (FcConfig	*config FC_UN
824
 int
825
 FcConfigGetRescanInterval (FcConfig *config)
826
 {
827
+    int ret;
828
+
829
+    config = FcConfigReference (config);
830
     if (!config)
831
-    {
832
-	config = FcConfigGetCurrent ();
833
-	if (!config)
834
-	    return 0;
835
-    }
836
-    return config->rescanInterval;
837
+	return 0;
838
+    ret = config->rescanInterval;
839
+    FcConfigDestroy (config);
840
+
841
+    return ret;
842
 }
843
 
844
 FcBool
845
 FcConfigSetRescanInterval (FcConfig *config, int rescanInterval)
846
 {
847
+    config = FcConfigReference (config);
848
     if (!config)
849
-    {
850
-	config = FcConfigGetCurrent ();
851
-	if (!config)
852
-	    return FcFalse;
853
-    }
854
+	return FcFalse;
855
     config->rescanInterval = rescanInterval;
856
+    FcConfigDestroy (config);
857
+
858
     return FcTrue;
859
 }
860
 
861
@@ -1670,15 +1765,13 @@ FcConfigSubstituteWithPat (FcConfig    *
862
     FcBool	    retval = FcTrue;
863
     FcTest	    **tst = NULL;
864
 
865
-    if (!config)
866
-    {
867
-	config = FcConfigGetCurrent ();
868
-	if (!config)
869
-	    return FcFalse;
870
-    }
871
-
872
     if (kind < FcMatchKindBegin || kind >= FcMatchKindEnd)
873
 	return FcFalse;
874
+
875
+    config = FcConfigReference (config);
876
+    if (!config)
877
+	return FcFalse;
878
+
879
     s = config->subst[kind];
880
     if (kind == FcMatchPattern)
881
     {
882
@@ -1973,6 +2066,7 @@ bail1:
883
 	free (value);
884
     if (tst)
885
 	free (tst);
886
+    FcConfigDestroy (config);
887
 
888
     return retval;
889
 }
890
@@ -2284,10 +2378,16 @@ FcConfigEnableHome (FcBool enable)
891
 }
892
 
893
 FcChar8 *
894
-FcConfigFilename (const FcChar8 *url)
895
+FcConfigGetFilename (FcConfig      *config,
896
+		     const FcChar8 *url)
897
 {
898
     FcChar8    *file, *dir, **path, **p;
899
+    const FcChar8 *sysroot;
900
 
901
+    config = FcConfigReference (config);
902
+    if (!config)
903
+	return NULL;
904
+    sysroot = FcConfigGetSysRoot (config);
905
     if (!url || !*url)
906
     {
907
 	url = (FcChar8 *) getenv ("FONTCONFIG_FILE");
908
@@ -2297,13 +2397,26 @@ FcConfigFilename (const FcChar8 *url)
909
     file = 0;
910
 
911
     if (FcStrIsAbsoluteFilename(url))
912
-	return FcConfigFileExists (0, url);
913
+    {
914
+	file = FcConfigFileExists (sysroot, url);
915
+	goto bail;
916
+    }
917
 
918
     if (*url == '~')
919
     {
920
 	dir = FcConfigHome ();
921
 	if (dir)
922
-	    file = FcConfigFileExists (dir, url + 1);
923
+	{
924
+	    FcChar8 *s;
925
+
926
+	    if (sysroot)
927
+		s = FcStrBuildFilename (sysroot, dir, NULL);
928
+	    else
929
+		s = dir;
930
+	    file = FcConfigFileExists (s, url + 1);
931
+	    if (sysroot)
932
+		FcStrFree (s);
933
+	}
934
 	else
935
 	    file = 0;
936
     }
937
@@ -2311,45 +2424,64 @@ FcConfigFilename (const FcChar8 *url)
938
     {
939
 	path = FcConfigGetPath ();
940
 	if (!path)
941
-	    return NULL;
942
+	{
943
+	    file = NULL;
944
+	    goto bail;
945
+	}
946
 	for (p = path; *p; p++)
947
 	{
948
-	    file = FcConfigFileExists (*p, url);
949
+	    FcChar8 *s;
950
+
951
+	    if (sysroot)
952
+		s = FcStrBuildFilename (sysroot, *p, NULL);
953
+	    else
954
+		s = *p;
955
+	    file = FcConfigFileExists (s, url);
956
+	    if (sysroot)
957
+		FcStrFree (s);
958
 	    if (file)
959
 		break;
960
 	}
961
 	FcConfigFreePath (path);
962
     }
963
+bail:
964
+    FcConfigDestroy (config);
965
+
966
     return file;
967
 }
968
 
969
 FcChar8 *
970
+FcConfigFilename (const FcChar8 *url)
971
+{
972
+    return FcConfigGetFilename (NULL, url);
973
+}
974
+
975
+FcChar8 *
976
 FcConfigRealFilename (FcConfig		*config,
977
 		      const FcChar8	*url)
978
 {
979
-    const FcChar8 *sysroot = FcConfigGetSysRoot (config);
980
-    FcChar8 *n = FcConfigFilename (url);
981
-    FcChar8 *nn = NULL;
982
+    FcChar8 *n = FcConfigGetFilename (config, url);
983
 
984
     if (n)
985
     {
986
 	FcChar8 buf[FC_PATH_MAX];
987
 	ssize_t len;
988
+	struct stat sb;
989
 
990
-	if (sysroot)
991
-	    nn = FcStrBuildFilename (sysroot, n, NULL);
992
-	else
993
-	    nn = FcStrdup (n);
994
-	FcStrFree (n);
995
-
996
-	if ((len = FcReadLink (nn, buf, sizeof (buf) - 1)) != -1)
997
+	if ((len = FcReadLink (n, buf, sizeof (buf) - 1)) != -1)
998
 	{
999
 	    buf[len] = 0;
1000
 
1001
-	    if (!FcStrIsAbsoluteFilename (buf))
1002
+	    /* We try to pick up a config from FONTCONFIG_FILE
1003
+	     * when url is null. don't try to address the real filename
1004
+	     * if it is a named pipe.
1005
+	     */
1006
+	    if (!url && FcStat (n, &sb) == 0 && S_ISFIFO (sb.st_mode))
1007
+		return n;
1008
+	    else if (!FcStrIsAbsoluteFilename (buf))
1009
 	    {
1010
-		FcChar8 *dirname = FcStrDirname (nn);
1011
-		FcStrFree (nn);
1012
+		FcChar8 *dirname = FcStrDirname (n);
1013
+		FcStrFree (n);
1014
 		if (!dirname)
1015
 		    return NULL;
1016
 
1017
@@ -2358,18 +2490,18 @@ FcConfigRealFilename (FcConfig		*config,
1018
 		if (!path)
1019
 		    return NULL;
1020
 
1021
-		nn = FcStrCanonFilename (path);
1022
+		n = FcStrCanonFilename (path);
1023
 		FcStrFree (path);
1024
 	    }
1025
 	    else
1026
 	    {
1027
-		FcStrFree (nn);
1028
-		nn = FcStrdup (buf);
1029
+		FcStrFree (n);
1030
+		n = FcStrdup (buf);
1031
 	    }
1032
 	}
1033
     }
1034
 
1035
-    return nn;
1036
+    return n;
1037
 }
1038
 
1039
 /*
1040
@@ -2384,17 +2516,18 @@ FcConfigAppFontAddFile (FcConfig    *con
1041
     FcStrSet	*subdirs;
1042
     FcStrList	*sublist;
1043
     FcChar8	*subdir;
1044
+    FcBool	ret = FcTrue;
1045
 
1046
+    config = FcConfigReference (config);
1047
     if (!config)
1048
-    {
1049
-	config = FcConfigGetCurrent ();
1050
-	if (!config)
1051
-	    return FcFalse;
1052
-    }
1053
+	return FcFalse;
1054
 
1055
     subdirs = FcStrSetCreateEx (FCSS_GROW_BY_64);
1056
     if (!subdirs)
1057
-	return FcFalse;
1058
+    {
1059
+	ret = FcFalse;
1060
+	goto bail;
1061
+    }
1062
 
1063
     set = FcConfigGetFonts (config, FcSetApplication);
1064
     if (!set)
1065
@@ -2403,7 +2536,8 @@ FcConfigAppFontAddFile (FcConfig    *con
1066
 	if (!set)
1067
 	{
1068
 	    FcStrSetDestroy (subdirs);
1069
-	    return FcFalse;
1070
+	    ret = FcFalse;
1071
+	    goto bail;
1072
 	}
1073
 	FcConfigSetFonts (config, set, FcSetApplication);
1074
     }
1075
@@ -2411,7 +2545,8 @@ FcConfigAppFontAddFile (FcConfig    *con
1076
     if (!FcFileScanConfig (set, subdirs, file, config))
1077
     {
1078
 	FcStrSetDestroy (subdirs);
1079
-	return FcFalse;
1080
+	ret = FcFalse;
1081
+	goto bail;
1082
     }
1083
     if ((sublist = FcStrListCreate (subdirs)))
1084
     {
1085
@@ -2422,7 +2557,10 @@ FcConfigAppFontAddFile (FcConfig    *con
1086
 	FcStrListDone (sublist);
1087
     }
1088
     FcStrSetDestroy (subdirs);
1089
-    return FcTrue;
1090
+bail:
1091
+    FcConfigDestroy (config);
1092
+
1093
+    return ret;
1094
 }
1095
 
1096
 FcBool
1097
@@ -2431,17 +2569,18 @@ FcConfigAppFontAddDir (FcConfig	    *con
1098
 {
1099
     FcFontSet	*set;
1100
     FcStrSet	*dirs;
1101
+    FcBool	ret = FcTrue;
1102
 
1103
+    config = FcConfigReference (config);
1104
     if (!config)
1105
-    {
1106
-	config = FcConfigGetCurrent ();
1107
-	if (!config)
1108
-	    return FcFalse;
1109
-    }
1110
+	return FcFalse;
1111
 
1112
     dirs = FcStrSetCreateEx (FCSS_GROW_BY_64);
1113
     if (!dirs)
1114
-	return FcFalse;
1115
+    {
1116
+	ret = FcFalse;
1117
+	goto bail;
1118
+    }
1119
 
1120
     set = FcConfigGetFonts (config, FcSetApplication);
1121
     if (!set)
1122
@@ -2450,7 +2589,8 @@ FcConfigAppFontAddDir (FcConfig	    *con
1123
 	if (!set)
1124
 	{
1125
 	    FcStrSetDestroy (dirs);
1126
-	    return FcFalse;
1127
+	    ret = FcFalse;
1128
+	    goto bail;
1129
 	}
1130
 	FcConfigSetFonts (config, set, FcSetApplication);
1131
     }
1132
@@ -2460,23 +2600,26 @@ FcConfigAppFontAddDir (FcConfig	    *con
1133
     if (!FcConfigAddDirList (config, FcSetApplication, dirs))
1134
     {
1135
 	FcStrSetDestroy (dirs);
1136
-	return FcFalse;
1137
+	ret = FcFalse;
1138
+	goto bail;
1139
     }
1140
     FcStrSetDestroy (dirs);
1141
-    return FcTrue;
1142
+bail:
1143
+    FcConfigDestroy (config);
1144
+
1145
+    return ret;
1146
 }
1147
 
1148
 void
1149
 FcConfigAppFontClear (FcConfig	    *config)
1150
 {
1151
+    config = FcConfigReference (config);
1152
     if (!config)
1153
-    {
1154
-	config = FcConfigGetCurrent ();
1155
-	if (!config)
1156
-	    return;
1157
-    }
1158
+	return;
1159
 
1160
     FcConfigSetFonts (config, 0, FcSetApplication);
1161
+
1162
+    FcConfigDestroy (config);
1163
 }
1164
 
1165
 /*
1166
@@ -2571,7 +2714,9 @@ FcConfigSetSysRoot (FcConfig      *confi
1167
 {
1168
     FcChar8 *s = NULL;
1169
     FcBool init = FcFalse;
1170
+    int nretry = 3;
1171
 
1172
+retry:
1173
     if (!config)
1174
     {
1175
 	/* We can't use FcConfigGetCurrent() here to ensure
1176
@@ -2603,6 +2748,17 @@ FcConfigSetSysRoot (FcConfig      *confi
1177
     if (init)
1178
     {
1179
 	config = FcInitLoadOwnConfigAndFonts (config);
1180
+	if (!config)
1181
+	{
1182
+	    /* Something failed. this is usually unlikely. so retrying */
1183
+	    init = FcFalse;
1184
+	    if (--nretry == 0)
1185
+	    {
1186
+		fprintf (stderr, "Fontconfig warning: Unable to initialize config and retry limit exceeded. sysroot functionality may not work as expected.\n");
1187
+		return;
1188
+	    }
1189
+	    goto retry;
1190
+	}
1191
 	FcConfigSetCurrent (config);
1192
 	/* FcConfigSetCurrent() increases the refcount.
1193
 	 * decrease it here to avoid the memory leak.
1194
--- src/fcdir.c.orig	2019-05-08 08:22:25 UTC
1195
+++ src/fcdir.c
1196
@@ -167,7 +167,16 @@ FcFileScan (FcFontSet	    *set,
1197
 	    const FcChar8   *file,
1198
 	    FcBool	    force FC_UNUSED)
1199
 {
1200
-    return FcFileScanConfig (set, dirs, file, FcConfigGetCurrent ());
1201
+    FcConfig *config;
1202
+    FcBool ret;
1203
+
1204
+    config = FcConfigReference (NULL);
1205
+    if (!config)
1206
+	return FcFalse;
1207
+    ret = FcFileScanConfig (set, dirs, file, config);
1208
+    FcConfigDestroy (config);
1209
+
1210
+    return ret;
1211
 }
1212
 
1213
 /*
1214
@@ -271,10 +280,19 @@ FcDirScan (FcFontSet	    *set,
1215
 	   const FcChar8    *dir,
1216
 	   FcBool	    force FC_UNUSED)
1217
 {
1218
+    FcConfig *config;
1219
+    FcBool ret;
1220
+
1221
     if (cache || !force)
1222
 	return FcFalse;
1223
 
1224
-    return FcDirScanConfig (set, dirs, dir, force, FcConfigGetCurrent ());
1225
+    config = FcConfigReference (NULL);
1226
+    if (!config)
1227
+	return FcFalse;
1228
+    ret = FcDirScanConfig (set, dirs, dir, force, config);
1229
+    FcConfigDestroy (config);
1230
+
1231
+    return ret;
1232
 }
1233
 
1234
 /*
1235
@@ -353,12 +371,16 @@ FcDirCacheRescan (const FcChar8 *dir, Fc
1236
     FcCache *new = NULL;
1237
     struct stat dir_stat;
1238
     FcStrSet *dirs;
1239
-    const FcChar8 *sysroot = FcConfigGetSysRoot (config);
1240
+    const FcChar8 *sysroot;
1241
     FcChar8 *d = NULL;
1242
 #ifndef _WIN32
1243
     int fd = -1;
1244
 #endif
1245
 
1246
+    config = FcConfigReference (config);
1247
+    if (!config)
1248
+	return NULL;
1249
+    sysroot = FcConfigGetSysRoot (config);
1250
     cache = FcDirCacheLoad (dir, config, NULL);
1251
     if (!cache)
1252
 	goto bail;
1253
@@ -401,6 +423,7 @@ bail1:
1254
 bail:
1255
     if (d)
1256
 	FcStrFree (d);
1257
+    FcConfigDestroy (config);
1258
 
1259
     return new;
1260
 }
1261
@@ -413,6 +436,7 @@ FcDirCacheRead (const FcChar8 *dir, FcBo
1262
 {
1263
     FcCache		*cache = NULL;
1264
 
1265
+    config = FcConfigReference (config);
1266
     /* Try to use existing cache file */
1267
     if (!force)
1268
 	cache = FcDirCacheLoad (dir, config, NULL);
1269
@@ -420,6 +444,7 @@ FcDirCacheRead (const FcChar8 *dir, FcBo
1270
     /* Not using existing cache file, construct new cache */
1271
     if (!cache)
1272
 	cache = FcDirCacheScan (dir, config);
1273
+    FcConfigDestroy (config);
1274
 
1275
     return cache;
1276
 }
1277
--- src/fcfreetype.c.orig	2019-08-09 10:47:03 UTC
1278
+++ src/fcfreetype.c
1279
@@ -1294,7 +1294,7 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
1280
 	if (!FcPatternObjectAddBool (pat, FC_OUTLINE_OBJECT, has_outline))
1281
 	    goto bail1;
1282
 
1283
-	has_color = FT_HAS_COLOR (face);
1284
+	has_color = !!FT_HAS_COLOR (face);
1285
 	if (!FcPatternObjectAddBool (pat, FC_COLOR_OBJECT, has_color))
1286
 	    goto bail1;
1287
 
1288
@@ -1495,7 +1495,8 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
1289
 		 * and treat the instance's nameid as FONT_SUBFAMILY.
1290
 		 * Postscript name is automatically handled by FreeType. */
1291
 		if (nameid == TT_NAME_ID_WWS_SUBFAMILY ||
1292
-		    nameid == TT_NAME_ID_PREFERRED_SUBFAMILY)
1293
+		    nameid == TT_NAME_ID_PREFERRED_SUBFAMILY ||
1294
+		    nameid == TT_NAME_ID_FULL_NAME)
1295
 		    continue;
1296
 
1297
 		if (nameid == TT_NAME_ID_FONT_SUBFAMILY)
1298
@@ -1528,6 +1529,8 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
1299
 		    break;
1300
 		case TT_NAME_ID_MAC_FULL_NAME:
1301
 		case TT_NAME_ID_FULL_NAME:
1302
+		    if (variable)
1303
+			break;
1304
 		    if (FcDebug () & FC_DBG_SCANV)
1305
 			printf ("found full   (n %2d p %d e %d l 0x%04x)",
1306
 				sname.name_id, sname.platform_id,
1307
@@ -1679,6 +1682,61 @@ FcFreeTypeQueryFaceInternal (const FT_Fa
1308
 	++nfamily;
1309
     }
1310
 
1311
+    /* Add the fullname into the cache */
1312
+    if (!variable && !nfullname)
1313
+    {
1314
+	FcChar8 *family, *style, *lang;
1315
+	int n = 0;
1316
+	size_t len, i;
1317
+	FcStrBuf sbuf;
1318
+
1319
+	while (FcPatternObjectGetString (pat, FC_FAMILYLANG_OBJECT, n, &lang) == FcResultMatch)
1320
+	{
1321
+	    if (FcStrCmp (lang, (const FcChar8 *) "en") == 0)
1322
+		break;
1323
+	    n++;
1324
+	    lang = NULL;
1325
+	}
1326
+	if (!lang)
1327
+	    n = 0;
1328
+	if (FcPatternObjectGetString (pat, FC_FAMILY_OBJECT, n, &family) != FcResultMatch)
1329
+	    goto bail1;
1330
+	len = strlen ((const char *) family);
1331
+	for (i = len; i > 0; i--)
1332
+	{
1333
+	    if (!isspace (family[i]))
1334
+		break;
1335
+	}
1336
+	family[i] = 0;
1337
+	while (FcPatternObjectGetString (pat, FC_STYLELANG_OBJECT, n, &lang) == FcResultMatch)
1338
+	{
1339
+	    if (FcStrCmp (lang, (const FcChar8 *) "en") == 0)
1340
+		break;
1341
+	    n++;
1342
+	    lang = NULL;
1343
+	}
1344
+	if (!lang)
1345
+	    n = 0;
1346
+	if (FcPatternObjectGetString (pat, FC_STYLE_OBJECT, n, &style) != FcResultMatch)
1347
+	    goto bail1;
1348
+	len = strlen ((const char *) style);
1349
+	for (i = 0; style[i] != 0 && isspace (style[i]); i++)
1350
+	    break;
1351
+	memcpy (style, &style[i], len - i);
1352
+	FcStrBufInit (&sbuf, NULL, 0);
1353
+	FcStrBufString (&sbuf, family);
1354
+	FcStrBufChar (&sbuf, ' ');
1355
+	FcStrBufString (&sbuf, style);
1356
+	if (!FcPatternObjectAddString (pat, FC_FULLNAME_OBJECT, FcStrBufDoneStatic (&sbuf)))
1357
+	{
1358
+	    FcStrBufDestroy (&sbuf);
1359
+	    goto bail1;
1360
+	}
1361
+	FcStrBufDestroy (&sbuf);
1362
+	if (!FcPatternObjectAddString (pat, FC_FULLNAMELANG_OBJECT, (const FcChar8 *) "en"))
1363
+	    goto bail1;
1364
+	++nfullname;
1365
+    }
1366
     /* Add the PostScript name into the cache */
1367
     if (!variable)
1368
     {
1369
@@ -2142,6 +2200,17 @@ bail2:
1370
     FcCharSetDestroy (cs);
1371
 bail1:
1372
     FcPatternDestroy (pat);
1373
+    if (master)
1374
+    {
1375
+#ifdef HAVE_FT_DONE_MM_VAR
1376
+	if (face->glyph)
1377
+	    FT_Done_MM_Var (face->glyph->library, master);
1378
+#else
1379
+	free (master);
1380
+#endif
1381
+    }
1382
+    if (!nm_share && name_mapping)
1383
+	free (name_mapping);
1384
     if (foundry_)
1385
 	free (foundry_);
1386
 bail0:
1387
@@ -2302,6 +2371,8 @@ bail:
1388
     if (face)
1389
 	FT_Done_Face (face);
1390
     FT_Done_FreeType (ftLibrary);
1391
+    if (nm)
1392
+	free (nm);
1393
 
1394
     return ret;
1395
 }
1396
--- src/fcinit.c.orig	2018-06-05 10:36:38 UTC
1397
+++ src/fcinit.c
1398
@@ -199,10 +199,10 @@ void
1399
 FcFini (void)
1400
 {
1401
     FcConfigFini ();
1402
-    FcCacheFini ();
1403
+    FcConfigPathFini ();
1404
     FcDefaultFini ();
1405
     FcObjectFini ();
1406
-    FcConfigPathFini ();
1407
+    FcCacheFini ();
1408
 }
1409
 
1410
 /*
1411
@@ -229,7 +229,8 @@ FcInitReinitialize (void)
1412
 FcBool
1413
 FcInitBringUptoDate (void)
1414
 {
1415
-    FcConfig	*config = FcConfigGetCurrent ();
1416
+    FcConfig	*config = FcConfigReference (NULL);
1417
+    FcBool	ret = FcTrue;
1418
     time_t	now;
1419
 
1420
     if (!config)
1421
@@ -238,19 +239,23 @@ FcInitBringUptoDate (void)
1422
      * rescanInterval == 0 disables automatic up to date
1423
      */
1424
     if (config->rescanInterval == 0)
1425
-	return FcTrue;
1426
+	goto bail;
1427
     /*
1428
      * Check no more often than rescanInterval seconds
1429
      */
1430
     now = time (0);
1431
     if (config->rescanTime + config->rescanInterval - now > 0)
1432
-	return FcTrue;
1433
+	goto bail;
1434
     /*
1435
      * If up to date, don't reload configuration
1436
      */
1437
     if (FcConfigUptoDate (0))
1438
-	return FcTrue;
1439
-    return FcInitReinitialize ();
1440
+	goto bail;
1441
+    ret = FcInitReinitialize ();
1442
+bail:
1443
+    FcConfigDestroy (config);
1444
+
1445
+    return ret;
1446
 }
1447
 
1448
 #define __fcinit__
1449
--- src/fclist.c.orig	2018-07-19 03:15:01 UTC
1450
+++ src/fclist.c
1451
@@ -491,11 +491,10 @@ FcFontSetList (FcConfig	    *config,
1452
     {
1453
 	if (!FcInitBringUptoDate ())
1454
 	    goto bail0;
1455
-
1456
-	config = FcConfigGetCurrent ();
1457
-	if (!config)
1458
-	    goto bail0;
1459
     }
1460
+    config = FcConfigReference (config);
1461
+    if (!config)
1462
+	goto bail0;
1463
     FcListHashTableInit (&table);
1464
 
1465
     if (!os)
1466
@@ -558,7 +557,7 @@ FcFontSetList (FcConfig	    *config,
1467
      */
1468
     ret = FcFontSetCreate ();
1469
     if (!ret)
1470
-	goto bail0;
1471
+	goto bail1;
1472
     for (i = 0; i < FC_LIST_HASH_SIZE; i++)
1473
 	while ((bucket = table.buckets[i]))
1474
 	{
1475
@@ -570,6 +569,7 @@ FcFontSetList (FcConfig	    *config,
1476
 
1477
     if (destroy_os)
1478
         FcObjectSetDestroy (os);
1479
+    FcConfigDestroy (config);
1480
 
1481
     return ret;
1482
 
1483
@@ -577,6 +577,7 @@ bail2:
1484
     FcFontSetDestroy (ret);
1485
 bail1:
1486
     FcListHashTableCleanup (&table);
1487
+    FcConfigDestroy (config);
1488
 bail0:
1489
     if (destroy_os)
1490
 	FcObjectSetDestroy (os);
1491
@@ -588,24 +589,26 @@ FcFontList (FcConfig	*config,
1492
 	    FcPattern	*p,
1493
 	    FcObjectSet *os)
1494
 {
1495
-    FcFontSet	*sets[2];
1496
+    FcFontSet	*sets[2], *ret;
1497
     int		nsets;
1498
 
1499
     if (!config)
1500
     {
1501
 	if (!FcInitBringUptoDate ())
1502
 	    return 0;
1503
-
1504
-	config = FcConfigGetCurrent ();
1505
-	if (!config)
1506
-	    return 0;
1507
     }
1508
+    config = FcConfigReference (config);
1509
+    if (!config)
1510
+	return NULL;
1511
     nsets = 0;
1512
     if (config->fonts[FcSetSystem])
1513
 	sets[nsets++] = config->fonts[FcSetSystem];
1514
     if (config->fonts[FcSetApplication])
1515
 	sets[nsets++] = config->fonts[FcSetApplication];
1516
-    return FcFontSetList (config, sets, nsets, p, os);
1517
+    ret = FcFontSetList (config, sets, nsets, p, os);
1518
+    FcConfigDestroy (config);
1519
+
1520
+    return ret;
1521
 }
1522
 #define __fclist__
1523
 #include "fcaliastail.h"
1524
--- src/fcmatch.c.orig	2018-07-19 08:28:09 UTC
1525
+++ src/fcmatch.c
1526
@@ -342,6 +342,7 @@ typedef enum _FcMatcherPriority {
1527
     PRI1(SLANT),
1528
     PRI1(WEIGHT),
1529
     PRI1(WIDTH),
1530
+    PRI1(FONT_HAS_HINT),
1531
     PRI1(DECORATIVE),
1532
     PRI1(ANTIALIAS),
1533
     PRI1(RASTERIZER),
1534
@@ -844,7 +845,7 @@ FcFontSetMatch (FcConfig    *config,
1535
 		FcPattern   *p,
1536
 		FcResult    *result)
1537
 {
1538
-    FcPattern	    *best;
1539
+    FcPattern	    *best, *ret = NULL;
1540
 
1541
     assert (sets != NULL);
1542
     assert (p != NULL);
1543
@@ -852,17 +853,16 @@ FcFontSetMatch (FcConfig    *config,
1544
 
1545
     *result = FcResultNoMatch;
1546
 
1547
+    config = FcConfigReference (config);
1548
     if (!config)
1549
-    {
1550
-	config = FcConfigGetCurrent ();
1551
-	if (!config)
1552
-	    return 0;
1553
-    }
1554
+	    return NULL;
1555
     best = FcFontSetMatchInternal (sets, nsets, p, result);
1556
     if (best)
1557
-	return FcFontRenderPrepare (config, p, best);
1558
-    else
1559
-	return NULL;
1560
+	ret = FcFontRenderPrepare (config, p, best);
1561
+
1562
+    FcConfigDestroy (config);
1563
+
1564
+    return ret;
1565
 }
1566
 
1567
 FcPattern *
1568
@@ -872,19 +872,16 @@ FcFontMatch (FcConfig	*config,
1569
 {
1570
     FcFontSet	*sets[2];
1571
     int		nsets;
1572
-    FcPattern   *best;
1573
+    FcPattern   *best, *ret = NULL;
1574
 
1575
     assert (p != NULL);
1576
     assert (result != NULL);
1577
 
1578
     *result = FcResultNoMatch;
1579
 
1580
+    config = FcConfigReference (config);
1581
     if (!config)
1582
-    {
1583
-	config = FcConfigGetCurrent ();
1584
-	if (!config)
1585
-	    return 0;
1586
-    }
1587
+	return NULL;
1588
     nsets = 0;
1589
     if (config->fonts[FcSetSystem])
1590
 	sets[nsets++] = config->fonts[FcSetSystem];
1591
@@ -893,9 +890,11 @@ FcFontMatch (FcConfig	*config,
1592
 
1593
     best = FcFontSetMatchInternal (sets, nsets, p, result);
1594
     if (best)
1595
-	return FcFontRenderPrepare (config, p, best);
1596
-    else
1597
-	return NULL;
1598
+	ret = FcFontRenderPrepare (config, p, best);
1599
+
1600
+    FcConfigDestroy (config);
1601
+
1602
+    return ret;
1603
 }
1604
 
1605
 typedef struct _FcSortNode {
1606
@@ -1182,7 +1181,7 @@ FcFontSort (FcConfig	*config,
1607
 	    FcCharSet	**csp,
1608
 	    FcResult	*result)
1609
 {
1610
-    FcFontSet	*sets[2];
1611
+    FcFontSet	*sets[2], *ret;
1612
     int		nsets;
1613
 
1614
     assert (p != NULL);
1615
@@ -1190,18 +1189,18 @@ FcFontSort (FcConfig	*config,
1616
 
1617
     *result = FcResultNoMatch;
1618
 
1619
+    config = FcConfigReference (config);
1620
     if (!config)
1621
-    {
1622
-	config = FcConfigGetCurrent ();
1623
-	if (!config)
1624
-	    return 0;
1625
-    }
1626
+	return NULL;
1627
     nsets = 0;
1628
     if (config->fonts[FcSetSystem])
1629
 	sets[nsets++] = config->fonts[FcSetSystem];
1630
     if (config->fonts[FcSetApplication])
1631
 	sets[nsets++] = config->fonts[FcSetApplication];
1632
-    return FcFontSetSort (config, sets, nsets, p, trim, csp, result);
1633
+    ret = FcFontSetSort (config, sets, nsets, p, trim, csp, result);
1634
+    FcConfigDestroy (config);
1635
+
1636
+    return ret;
1637
 }
1638
 #define __fcmatch__
1639
 #include "fcaliastail.h"
1640
--- src/fcobjs.h.orig	2019-07-30 11:03:27 UTC
1641
+++ src/fcobjs.h
1642
@@ -72,5 +72,5 @@ FC_OBJECT (COLOR,		FcTypeBool,	FcCompare
1643
 FC_OBJECT (SYMBOL,		FcTypeBool,	FcCompareBool)
1644
 FC_OBJECT (FONT_VARIATIONS,	FcTypeString,	NULL)
1645
 FC_OBJECT (VARIABLE,		FcTypeBool,	FcCompareBool)
1646
-FC_OBJECT (FONT_HAS_HINT,	FcTypeBool,	NULL)
1647
+FC_OBJECT (FONT_HAS_HINT,	FcTypeBool,	FcCompareBool)
1648
 /* ^-------------- Add new objects here. */
1649
--- src/fcxml.c.orig	2019-07-29 05:17:34 UTC
1650
+++ src/fcxml.c
1651
@@ -2301,6 +2301,11 @@ FcParseCacheDir (FcConfigParse *parse)
1652
 	data = prefix;
1653
 	goto bail;
1654
     }
1655
+    if (data[0] == 0)
1656
+    {
1657
+	FcConfigMessage (parse, FcSevereWarning, "empty cache directory name ignored");
1658
+	return;
1659
+    }
1660
     if (prefix)
1661
     {
1662
 	size_t plen = strlen ((const char *)prefix);
1663
@@ -2536,7 +2541,7 @@ FcParseInclude (FcConfigParse *parse)
1664
         FcChar8 *filename;
1665
 	static FcBool warn_conf = FcFalse, warn_confd = FcFalse;
1666
 
1667
-        filename = FcConfigFilename(s);
1668
+        filename = FcConfigGetFilename(parse->config, s);
1669
 	if (deprecated == FcTrue &&
1670
 	    filename != NULL &&
1671
 	    userdir != NULL &&
1672
@@ -3526,8 +3531,10 @@ _FcConfigParse (FcConfig	*config,
1673
     int		    len;
1674
     FcStrBuf	    sbuf;
1675
     char            buf[BUFSIZ];
1676
-    FcBool	    ret = FcFalse;
1677
+    FcBool	    ret = FcFalse, complain_again = complain;
1678
+    FcStrBuf	    reason;
1679
 
1680
+    FcStrBufInit (&reason, NULL, 0);
1681
 #ifdef _WIN32
1682
     if (!pGetSystemWindowsDirectory)
1683
     {
1684
@@ -3544,12 +3551,20 @@ _FcConfigParse (FcConfig	*config,
1685
     }
1686
 #endif
1687
 
1688
-    filename = FcConfigFilename (name);
1689
+    filename = FcConfigGetFilename (config, name);
1690
     if (!filename)
1691
+    {
1692
+	FcStrBufString (&reason, (FcChar8 *)"No such file: ");
1693
+	FcStrBufString (&reason, name ? name : (FcChar8 *)"(null)");
1694
 	goto bail0;
1695
+    }
1696
     realfilename = FcConfigRealFilename (config, name);
1697
     if (!realfilename)
1698
+    {
1699
+	FcStrBufString (&reason, (FcChar8 *)"No such realfile: ");
1700
+	FcStrBufString (&reason, name ? name : (FcChar8 *)"(null)");
1701
 	goto bail0;
1702
+    }
1703
     if (FcStrSetMember (config->availConfigFiles, realfilename))
1704
     {
1705
         FcStrFree (filename);
1706
@@ -3577,7 +3592,11 @@ _FcConfigParse (FcConfig	*config,
1707
 
1708
     fd = FcOpen ((char *) realfilename, O_RDONLY);
1709
     if (fd == -1)
1710
+    {
1711
+	FcStrBufString (&reason, (FcChar8 *)"Unable to open ");
1712
+	FcStrBufString (&reason, realfilename);
1713
 	goto bail1;
1714
+    }
1715
 
1716
     do {
1717
 	len = read (fd, buf, BUFSIZ);
1718
@@ -3605,7 +3624,7 @@ _FcConfigParse (FcConfig	*config,
1719
     close (fd);
1720
 
1721
     ret = FcConfigParseAndLoadFromMemoryInternal (config, filename, FcStrBufDoneStatic (&sbuf), complain, load);
1722
-    complain = FcFalse; /* no need to reclaim here */
1723
+    complain_again = FcFalse; /* no need to reclaim here */
1724
 bail1:
1725
     FcStrBufDestroy (&sbuf);
1726
 bail0:
1727
@@ -3613,14 +3632,18 @@ bail0:
1728
 	FcStrFree (filename);
1729
     if (realfilename)
1730
 	FcStrFree (realfilename);
1731
-    if (!ret && complain)
1732
+    if (!complain)
1733
+	return FcTrue;
1734
+    if (!ret && complain_again)
1735
     {
1736
 	if (name)
1737
-	    FcConfigMessage (0, FcSevereError, "Cannot %s config file \"%s\"", load ? "load" : "scan", name);
1738
+	    FcConfigMessage (0, FcSevereError, "Cannot %s config file \"%s\": %s", load ? "load" : "scan", name, FcStrBufDoneStatic (&reason));
1739
 	else
1740
-	    FcConfigMessage (0, FcSevereError, "Cannot %s default config file", load ? "load" : "scan");
1741
+	    FcConfigMessage (0, FcSevereError, "Cannot %s default config file: %s", load ? "load" : "scan", FcStrBufDoneStatic (&reason));
1742
+	FcStrBufDestroy (&reason);
1743
 	return FcFalse;
1744
     }
1745
+    FcStrBufDestroy (&reason);
1746
     return ret;
1747
 }
1748
 
(-)x11-fonts/fontconfig/pkg-messsage (+15 lines)
Line 0 Link Here
1
[
2
{
3
        type: upgrade,
4
        maximum_version: "2.13.92,1",
5
        message: <<EOM
6
Fontconfig 2.13.1 generated .uuid files in the fonts directory
7
which where not properly registered to the packages.
8
To clean them up, please execute the following command:
9
10
    find %%LOCALBASE%%/share/fonts -type f -name .uuid
11
12
and delete the files at your discretion.
13
EOM
14
}
15
]
(-)x11-fonts/fontconfig/pkg-plist (+3 lines)
Lines 7-12 Link Here
7
bin/fc-query
7
bin/fc-query
8
bin/fc-scan
8
bin/fc-scan
9
bin/fc-validate
9
bin/fc-validate
10
etc/fonts/conf.avail/05-reset-dirs-sample.conf
11
etc/fonts/conf.avail/09-autohint-if-no-hinting.conf
10
etc/fonts/conf.avail/10-autohint.conf
12
etc/fonts/conf.avail/10-autohint.conf
11
etc/fonts/conf.avail/10-hinting-full.conf
13
etc/fonts/conf.avail/10-hinting-full.conf
12
etc/fonts/conf.avail/10-hinting-medium.conf
14
etc/fonts/conf.avail/10-hinting-medium.conf
Lines 25-30 Link Here
25
etc/fonts/conf.avail/20-unhint-small-vera.conf
27
etc/fonts/conf.avail/20-unhint-small-vera.conf
26
etc/fonts/conf.avail/25-unhint-nonlatin.conf
28
etc/fonts/conf.avail/25-unhint-nonlatin.conf
27
etc/fonts/conf.avail/30-metric-aliases.conf
29
etc/fonts/conf.avail/30-metric-aliases.conf
30
etc/fonts/conf.avail/35-lang-normalize.conf
28
etc/fonts/conf.avail/40-nonlatin.conf
31
etc/fonts/conf.avail/40-nonlatin.conf
29
etc/fonts/conf.avail/45-generic.conf
32
etc/fonts/conf.avail/45-generic.conf
30
etc/fonts/conf.avail/45-latin.conf
33
etc/fonts/conf.avail/45-latin.conf
(-)x11-fonts/fontconfig-reference/pkg-plist (+1 lines)
Lines 179-184 Link Here
179
man/man3/FcRangeDestroy.3.gz
179
man/man3/FcRangeDestroy.3.gz
180
man/man3/FcRangeGetDouble.3.gz
180
man/man3/FcRangeGetDouble.3.gz
181
man/man3/FcStrBasename.3.gz
181
man/man3/FcStrBasename.3.gz
182
man/man3/FcStrBuildFilename.3.gz
182
man/man3/FcStrCmp.3.gz
183
man/man3/FcStrCmp.3.gz
183
man/man3/FcStrCmpIgnoreCase.3.gz
184
man/man3/FcStrCmpIgnoreCase.3.gz
184
man/man3/FcStrCopy.3.gz
185
man/man3/FcStrCopy.3.gz

Return to bug 239167