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