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