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 |
|