summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/fontconfig
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-graphics/fontconfig')
-rw-r--r--meta/recipes-graphics/fontconfig/files/Add-sysroot-option-to-fc-cache-and-fc-cat.patch731
-rw-r--r--meta/recipes-graphics/fontconfig/fontconfig/sysroot-arg.patch32
-rw-r--r--meta/recipes-graphics/fontconfig/fontconfig_2.11.0.bb (renamed from meta/recipes-graphics/fontconfig/fontconfig_2.10.2.bb)14
3 files changed, 37 insertions, 740 deletions
diff --git a/meta/recipes-graphics/fontconfig/files/Add-sysroot-option-to-fc-cache-and-fc-cat.patch b/meta/recipes-graphics/fontconfig/files/Add-sysroot-option-to-fc-cache-and-fc-cat.patch
deleted file mode 100644
index f0b3b7fc32..0000000000
--- a/meta/recipes-graphics/fontconfig/files/Add-sysroot-option-to-fc-cache-and-fc-cat.patch
+++ /dev/null
@@ -1,731 +0,0 @@
1Upstream-Status: Pending
2
3From a5eeeafb623a5508d2745f89aaf69118799f7e5c Mon Sep 17 00:00:00 2001
4From: Laurentiu Palcu <laurentiu.palcu@intel.com>
5Date: Mon, 28 Jan 2013 11:42:56 +0200
6Subject: [PATCH] Add sysroot option to fc-cache and fc-cat
7
8Whether one needs to generate the font cache offline and then deploy the
9image to a target or do some testing in a separate rootfs, the sysroot
10option will facilitate that.
11
12Suppose you've got a rootfs in the following directory:
13/path/to/test/rootfs. In order to contain the fc-cache generation to
14that particular directory, the following command can be used:
15
16fc-cache --sysroot=/path/to/test/rootfs
17
18That will make fc-cache to prepend the sysroot directory to all paths
19during scanning. For example, instead of searching /etc/fonts/ directory
20for configuration files, it will look in /path/to/test/rootfs/etc/fonts.
21The paths found in fonts.conf will also be prepended with the sysroot.
22
23However, the generated cache files will not contain any references to
24sysroot. This way, one can generate the font cache offline and then deploy
25the image to target. Or, simply, use it for various tests without
26polluting the system/user cache files.
27
28In order to inspect the cache generated using the sysroot option, one
29has to use fc-cat like below (for example):
30
31fc-cat --sysroot=/path/to/test/rootfs
32/path/to/test/rootfs/var/cache/fontconfig/*
33
34Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
35---
36 fc-cache/fc-cache.c | 63 ++++++++++++++++++++++++++++-------
37 fc-cat/fc-cat.c | 77 +++++++++++++++++++++++++++++++++++-------
38 fc-lang/fc-lang.c | 1 +
39 fontconfig/fontconfig.h | 6 ++++
40 src/fccache.c | 85 +++++++++++++++++++++++++++++++++++++++++++----
41 src/fccfg.c | 52 +++++++++++++++++++++++++++++
42 src/fcfreetype.c | 4 +++
43 src/fcstr.c | 27 +++++++++++++++
44 8 files changed, 285 insertions(+), 30 deletions(-)
45
46diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c
47index 9fb383b..a91e1f1 100644
48--- a/fc-cache/fc-cache.c
49+++ b/fc-cache/fc-cache.c
50@@ -68,6 +68,7 @@ const struct option longopts[] = {
51 {"force", 0, 0, 'f'},
52 {"really-force", 0, 0, 'r'},
53 {"system-only", 0, 0, 's'},
54+ {"sysroot", 1, 0, 'y'},
55 {"version", 0, 0, 'V'},
56 {"verbose", 0, 0, 'v'},
57 {"help", 0, 0, 'h'},
58@@ -85,26 +86,28 @@ usage (char *program, int error)
59 {
60 FILE *file = error ? stderr : stdout;
61 #if HAVE_GETOPT_LONG
62- fprintf (file, "usage: %s [-frsvVh] [--force|--really-force] [--system-only] [--verbose] [--version] [--help] [dirs]\n",
63+ fprintf (file, "usage: %s [-frsvVh] [-y SYSROOT] [--force|--really-force] [--system-only] [--sysroot=SYSROOT] [--verbose] [--version] [--help] [dirs]\n",
64 program);
65 #else
66- fprintf (file, "usage: %s [-frsvVh] [dirs]\n",
67+ fprintf (file, "usage: %s [-frsvVh] [-y SYSROOT] [dirs]\n",
68 program);
69 #endif
70 fprintf (file, "Build font information caches in [dirs]\n"
71 "(all directories in font configuration by default).\n");
72 fprintf (file, "\n");
73 #if HAVE_GETOPT_LONG
74- fprintf (file, " -f, --force scan directories with apparently valid caches\n");
75- fprintf (file, " -r, --really-force erase all existing caches, then rescan\n");
76- fprintf (file, " -s, --system-only scan system-wide directories only\n");
77- fprintf (file, " -v, --verbose display status information while busy\n");
78- fprintf (file, " -V, --version display font config version and exit\n");
79- fprintf (file, " -h, --help display this help and exit\n");
80+ fprintf (file, " -f, --force scan directories with apparently valid caches\n");
81+ fprintf (file, " -r, --really-force erase all existing caches, then rescan\n");
82+ fprintf (file, " -s, --system-only scan system-wide directories only\n");
83+ fprintf (file, " -y, --sysroot=SYSROOT for scanning, prefix all paths with SYSROOT. The cache file will not contain the SYSROOT!\n");
84+ fprintf (file, " -v, --verbose display status information while busy\n");
85+ fprintf (file, " -V, --version display font config version and exit\n");
86+ fprintf (file, " -h, --help display this help and exit\n");
87 #else
88 fprintf (file, " -f (force) scan directories with apparently valid caches\n");
89 fprintf (file, " -r, (really force) erase all existing caches, then rescan\n");
90 fprintf (file, " -s (system) scan system-wide directories only\n");
91+ fprintf (file, " -y SYSROOT for scanning, prefix all paths with SYSROOT. The cache file will not contain the SYSROOT!\n");
92 fprintf (file, " -v (verbose) display status information while busy\n");
93 fprintf (file, " -V (version) display font config version and exit\n");
94 fprintf (file, " -h (help) display this help and exit\n");
95@@ -125,7 +128,7 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
96 struct stat statb;
97 FcBool was_valid;
98 int i;
99-
100+ FcChar8 *sysroot = FcConfigGetSysRoot ();
101 /*
102 * Now scan all of the directories into separate databases
103 * and write out the results
104@@ -227,7 +230,22 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
105 continue;
106 }
107 for (i = 0; i < FcCacheNumSubdir (cache); i++)
108- FcStrSetAdd (subdirs, FcCacheSubdir (cache, i));
109+ {
110+ const FcChar8 *subdir = FcCacheSubdir (cache, i);
111+ if (sysroot)
112+ {
113+ subdir = FcStrPlus (sysroot, subdir);
114+ if (!subdir)
115+ {
116+ fprintf (stderr, "malloc failure\n");
117+ return ++ret;
118+ }
119+ }
120+
121+ FcStrSetAdd (subdirs, subdir);
122+ if (sysroot)
123+ FcStrFree ((FcChar8 *) subdir);
124+ }
125
126 FcDirCacheUnload (cache);
127
128@@ -277,6 +295,7 @@ main (int argc, char **argv)
129 FcBool really_force = FcFalse;
130 FcBool systemOnly = FcFalse;
131 FcConfig *config;
132+ FcChar8 *sysroot = NULL;
133 int i;
134 int changed;
135 int ret;
136@@ -284,9 +303,9 @@ main (int argc, char **argv)
137 int c;
138
139 #if HAVE_GETOPT_LONG
140- while ((c = getopt_long (argc, argv, "frsVvh", longopts, NULL)) != -1)
141+ while ((c = getopt_long (argc, argv, "frsy:Vvh", longopts, NULL)) != -1)
142 #else
143- while ((c = getopt (argc, argv, "frsVvh")) != -1)
144+ while ((c = getopt (argc, argv, "frsy:Vvh")) != -1)
145 #endif
146 {
147 switch (c) {
148@@ -299,6 +318,9 @@ main (int argc, char **argv)
149 case 's':
150 systemOnly = FcTrue;
151 break;
152+ case 'y':
153+ sysroot = FcStrCopy ((const FcChar8*) optarg);
154+ break;
155 case 'V':
156 fprintf (stderr, "fontconfig version %d.%d.%d\n",
157 FC_MAJOR, FC_MINOR, FC_REVISION);
158@@ -319,6 +341,21 @@ main (int argc, char **argv)
159
160 if (systemOnly)
161 FcConfigEnableHome (FcFalse);
162+
163+ if (sysroot)
164+ {
165+ FcChar8 *canon_sysroot;
166+ canon_sysroot = FcConfigSetSysRoot(sysroot);
167+ FcStrFree (sysroot);
168+ if (!canon_sysroot)
169+ {
170+ fprintf (stderr, "Cannot set the sysroot. Out of memory!\n");
171+ return 1;
172+ }
173+
174+ sysroot = canon_sysroot;
175+ }
176+
177 config = FcInitLoadConfig ();
178 if (!config)
179 {
180@@ -378,6 +415,8 @@ main (int argc, char **argv)
181 * library, and there aren't any signals flying around here.
182 */
183 FcConfigDestroy (config);
184+ if (sysroot)
185+ FcStrFree (sysroot);
186 FcFini ();
187 if (changed)
188 sleep (2);
189diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c
190index 72912b7..4b4f0f0 100644
191--- a/fc-cat/fc-cat.c
192+++ b/fc-cat/fc-cat.c
193@@ -57,6 +57,7 @@ const struct option longopts[] = {
194 {"verbose", 0, 0, 'v'},
195 {"recurse", 0, 0, 'r'},
196 {"help", 0, 0, 'h'},
197+ {"sysroot", 1, 0, 'y'},
198 {NULL,0,0,0},
199 };
200 #else
201@@ -150,11 +151,11 @@ usage (char *program, int error)
202 {
203 FILE *file = error ? stderr : stdout;
204 #if HAVE_GETOPT_LONG
205- fprintf (file, "usage: %s [-rv] [--recurse] [--verbose] [*-%s" FC_CACHE_SUFFIX "|directory]...\n",
206+ fprintf (file, "usage: %s [-rv] [--recurse] [--verbose] [--sysroot=SYSROOT] [*-%s" FC_CACHE_SUFFIX "|directory]...\n",
207 program, FC_ARCHITECTURE);
208 fprintf (file, " %s [-Vh] [--version] [--help]\n", program);
209 #else
210- fprintf (file, "usage: %s [-rvVh] [*-%s" FC_CACHE_SUFFIX "|directory]...\n",
211+ fprintf (file, "usage: %s [-rvVh] [-y SYSROOT] [*-%s" FC_CACHE_SUFFIX "|directory]...\n",
212 program, FC_ARCHITECTURE);
213 #endif
214 fprintf (file, "Reads font information cache from:\n");
215@@ -162,15 +163,17 @@ usage (char *program, int error)
216 fprintf (file, " 2) related to a particular font directory\n");
217 fprintf (file, "\n");
218 #if HAVE_GETOPT_LONG
219- fprintf (file, " -r, --recurse recurse into subdirectories\n");
220- fprintf (file, " -v, --verbose be verbose\n");
221- fprintf (file, " -V, --version display font config version and exit\n");
222- fprintf (file, " -h, --help display this help and exit\n");
223+ fprintf (file, " -r, --recurse recurse into subdirectories\n");
224+ fprintf (file, " -v, --verbose be verbose\n");
225+ fprintf (file, " -V, --version display font config version and exit\n");
226+ fprintf (file, " -h, --help display this help and exit\n");
227+ fprintf (file, " -y, --sysroot=SYSROOT needed if the cache was generated using --sysroot\n");
228 #else
229 fprintf (file, " -r (recurse) recurse into subdirectories\n");
230 fprintf (file, " -v (verbose) be verbose\n");
231 fprintf (file, " -V (version) display font config version and exit\n");
232 fprintf (file, " -h (help) display this help and exit\n");
233+ fprintf (file, " -y SYSROOT needed if the cache was generated using --sysroot\n");
234 #endif
235 exit (error);
236 }
237@@ -262,13 +265,14 @@ main (int argc, char **argv)
238 int verbose = 0;
239 int recurse = 0;
240 FcBool first = FcTrue;
241+ FcChar8 *sysroot = NULL;
242 #if HAVE_GETOPT_LONG || HAVE_GETOPT
243 int c;
244
245 #if HAVE_GETOPT_LONG
246- while ((c = getopt_long (argc, argv, "Vvrh", longopts, NULL)) != -1)
247+ while ((c = getopt_long (argc, argv, "Vvrhy:", longopts, NULL)) != -1)
248 #else
249- while ((c = getopt (argc, argv, "Vvrh")) != -1)
250+ while ((c = getopt (argc, argv, "Vvrhy:")) != -1)
251 #endif
252 {
253 switch (c) {
254@@ -284,6 +288,9 @@ main (int argc, char **argv)
255 break;
256 case 'h':
257 usage (argv[0], 0);
258+ case 'y':
259+ sysroot = FcStrCopy ((const FcChar8*) optarg);
260+ break;
261 default:
262 usage (argv[0], 1);
263 }
264@@ -293,6 +300,20 @@ main (int argc, char **argv)
265 i = 1;
266 #endif
267
268+ if (sysroot)
269+ {
270+ FcChar8 *canon_sysroot;
271+ canon_sysroot = FcConfigSetSysRoot(sysroot);
272+ FcStrFree (sysroot);
273+ if (!canon_sysroot)
274+ {
275+ fprintf (stderr, "%s: malloc failure\n", argv[0]);
276+ return 1;
277+ }
278+
279+ sysroot = canon_sysroot;
280+ }
281+
282 config = FcInitLoadConfig ();
283 if (!config)
284 {
285@@ -348,6 +369,7 @@ main (int argc, char **argv)
286 int j;
287 FcChar8 *cache_file = NULL;
288 struct stat file_stat;
289+ const FcChar8 *base_dir = NULL;
290
291 if (FcFileIsDir (arg))
292 cache = FcDirCacheLoad (arg, config, &cache_file);
293@@ -364,9 +386,34 @@ main (int argc, char **argv)
294 fs = FcCacheCopySet (cache);
295 for (j = 0; j < FcCacheNumSubdir (cache); j++)
296 {
297- FcStrSetAdd (dirs, FcCacheSubdir (cache, j));
298+ const FcChar8 *subdir = FcCacheSubdir (cache, j);
299+ if (sysroot)
300+ {
301+ subdir = FcStrPlus (sysroot, subdir);
302+ if (!subdir)
303+ {
304+ fprintf (stderr, "%s: malloc failure\n", argv[0]);
305+ return 1;
306+ }
307+ }
308+
309+ FcStrSetAdd (dirs, subdir);
310 if (recurse)
311- FcStrSetAdd (args, FcCacheSubdir (cache, j));
312+ FcStrSetAdd (args, subdir);
313+
314+ if (sysroot)
315+ FcStrFree ((FcChar8 *) subdir);
316+ }
317+
318+ base_dir = FcCacheDir (cache);
319+ if (sysroot)
320+ {
321+ base_dir = FcStrPlus (sysroot, base_dir);
322+ if (!base_dir)
323+ {
324+ fprintf (stderr, "%s: malloc failure\n", argv[0]);
325+ return 1;
326+ }
327 }
328
329 if (verbose)
330@@ -374,10 +421,13 @@ main (int argc, char **argv)
331 if (!first)
332 printf ("\n");
333 printf ("Directory: %s\nCache: %s\n--------\n",
334- FcCacheDir(cache), cache_file ? cache_file : arg);
335+ base_dir, cache_file ? cache_file : arg);
336 first = FcFalse;
337 }
338- cache_print_set (fs, dirs, FcCacheDir (cache), verbose);
339+ cache_print_set (fs, dirs, base_dir, verbose);
340+
341+ if (sysroot)
342+ FcStrFree ((FcChar8 *) base_dir);
343
344 FcStrSetDestroy (dirs);
345
346@@ -387,6 +437,9 @@ main (int argc, char **argv)
347 FcStrFree (cache_file);
348 }
349
350+ if (sysroot)
351+ FcStrFree (sysroot);
352+
353 FcFini ();
354 return 0;
355 }
356diff --git a/fc-lang/fc-lang.c b/fc-lang/fc-lang.c
357index 93200c4..e74e856 100644
358--- a/fc-lang/fc-lang.c
359+++ b/fc-lang/fc-lang.c
360@@ -22,6 +22,7 @@
361 * PERFORMANCE OF THIS SOFTWARE.
362 */
363
364+#define FC_LANG_C
365 #include "fccharset.c"
366 #include "fcstr.c"
367 #include "fcserialize.c"
368diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
369index 266986c..b05f6ca 100644
370--- a/fontconfig/fontconfig.h
371+++ b/fontconfig/fontconfig.h
372@@ -417,6 +417,12 @@ FcConfigSubstitute (FcConfig *config,
373 FcPattern *p,
374 FcMatchKind kind);
375
376+FcPublic FcChar8 *
377+FcConfigSetSysRoot (const FcChar8 *sysroot);
378+
379+FcPublic FcChar8 *
380+FcConfigGetSysRoot (void);
381+
382 /* fccharset.c */
383 FcPublic FcCharSet*
384 FcCharSetCreate (void);
385diff --git a/src/fccache.c b/src/fccache.c
386index 81985df..c3dcc72 100644
387--- a/src/fccache.c
388+++ b/src/fccache.c
389@@ -93,6 +93,14 @@ FcDirCacheBasename (const FcChar8 * dir, FcChar8 cache_base[CACHEBASE_LEN])
390 FcChar8 *hex_hash;
391 int cnt;
392 struct MD5Context ctx;
393+ FcChar8 *sysroot = FcConfigGetSysRoot();
394+
395+ /*
396+ * remove sysroot when generating the hex hash
397+ */
398+ if (sysroot && !strncmp ((const char*) sysroot, (const char*) dir,
399+ strlen ((const char*) sysroot)))
400+ dir += strlen((const char*) sysroot);
401
402 MD5Init (&ctx);
403 MD5Update (&ctx, (const unsigned char *)dir, strlen ((const char *) dir));
404@@ -505,16 +513,31 @@ static FcBool
405 FcCacheTimeValid (FcCache *cache, struct stat *dir_stat)
406 {
407 struct stat dir_static;
408+ FcChar8 *dir = FcCacheDir (cache);
409+ FcChar8 *sysroot = FcConfigGetSysRoot ();
410+
411+ if (sysroot)
412+ {
413+ dir = FcStrPlus (sysroot, dir);
414+ if (!dir)
415+ return FcFalse;
416+ }
417
418 if (!dir_stat)
419 {
420- if (FcStatChecksum (FcCacheDir (cache), &dir_static) < 0)
421+ if (FcStatChecksum (dir, &dir_static) < 0)
422+ {
423+ if (sysroot)
424+ FcStrFree (dir);
425 return FcFalse;
426+ }
427 dir_stat = &dir_static;
428 }
429 if (FcDebug () & FC_DBG_CACHE)
430 printf ("FcCacheTimeValid dir \"%s\" cache checksum %d dir checksum %d\n",
431- FcCacheDir (cache), cache->checksum, (int) dir_stat->st_mtime);
432+ dir, cache->checksum, (int) dir_stat->st_mtime);
433+ if (sysroot)
434+ FcStrFree (dir);
435 return cache->checksum == (int) dir_stat->st_mtime;
436 }
437
438@@ -716,9 +739,27 @@ FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, struct stat *dir_stat, FcSt
439 FcChar8 *dir_serialize;
440 intptr_t *dirs_serialize;
441 FcFontSet *set_serialize;
442+ FcChar8 *sysroot = FcConfigGetSysRoot ();
443+ FcStrSet *dirs_without_sysroot;
444
445 if (!serialize)
446 return NULL;
447+
448+ if (sysroot)
449+ {
450+ dir += strlen ((const char*) sysroot);
451+
452+ dirs_without_sysroot = FcStrSetCreate ();
453+ if (!dirs_without_sysroot)
454+ return NULL;
455+
456+ for (i = 0; i < dirs->num; i++)
457+ FcStrSetAdd (dirs_without_sysroot,
458+ dirs->strs[i] + strlen ((const char*) sysroot));
459+
460+ dirs = dirs_without_sysroot;
461+ }
462+
463 /*
464 * Space for cache structure
465 */
466@@ -792,11 +833,17 @@ FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, struct stat *dir_stat, FcSt
467
468 FcCacheInsert (cache, NULL);
469
470+ if (sysroot)
471+ FcStrSetDestroy(dirs_without_sysroot);
472+
473 return cache;
474
475 bail2:
476 free (cache);
477 bail1:
478+ if (sysroot)
479+ FcStrSetDestroy(dirs_without_sysroot);
480+
481 FcSerializeDestroy (serialize);
482 return NULL;
483 }
484@@ -844,6 +891,14 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
485 struct stat cache_stat;
486 int magic;
487 int written;
488+ FcChar8 *sysroot = FcConfigGetSysRoot ();
489+
490+ if (sysroot)
491+ {
492+ dir = FcStrPlus (sysroot, dir);
493+ if (!dir)
494+ return FcFalse;
495+ }
496
497 /*
498 * Write it to the first directory in the list which is writable
499@@ -851,7 +906,7 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
500
501 list = FcStrListCreate (config->cacheDirs);
502 if (!list)
503- return FcFalse;
504+ goto bail0;
505 while ((test_dir = FcStrListNext (list))) {
506 if (access ((char *) test_dir, W_OK) == 0)
507 {
508@@ -886,12 +941,12 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
509 }
510 FcStrListDone (list);
511 if (!cache_dir)
512- return FcFalse;
513+ goto bail0;
514
515 FcDirCacheBasename (dir, cache_base);
516 cache_hashed = FcStrPlus (cache_dir, cache_base);
517 if (!cache_hashed)
518- return FcFalse;
519+ goto bail0;
520
521 if (FcDebug () & FC_DBG_CACHE)
522 printf ("FcDirCacheWriteDir dir \"%s\" file \"%s\"\n",
523@@ -948,6 +1003,8 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
524 FcStrFree (cache_hashed);
525 FcAtomicUnlock (atomic);
526 FcAtomicDestroy (atomic);
527+ if (sysroot)
528+ FcStrFree (dir);
529 return FcTrue;
530
531 bail5:
532@@ -958,6 +1015,9 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
533 FcAtomicDestroy (atomic);
534 bail1:
535 FcStrFree (cache_hashed);
536+ bail0:
537+ if (sysroot)
538+ FcStrFree (dir);
539 return FcFalse;
540 }
541
542@@ -997,7 +1057,8 @@ FcDirCacheClean (const FcChar8 *cache_dir, FcBool verbose)
543 while ((ent = readdir (d)))
544 {
545 FcChar8 *file_name;
546- const FcChar8 *target_dir;
547+ FcChar8 *target_dir;
548+ FcChar8 *sysroot = FcConfigGetSysRoot ();
549
550 if (ent->d_name[0] == '.')
551 continue;
552@@ -1025,6 +1086,16 @@ FcDirCacheClean (const FcChar8 *cache_dir, FcBool verbose)
553 else
554 {
555 target_dir = FcCacheDir (cache);
556+ if (sysroot)
557+ {
558+ target_dir = FcStrPlus (sysroot, target_dir);
559+ if (!target_dir)
560+ {
561+ ret = FcFalse;
562+ FcStrFree (file_name);
563+ break;
564+ }
565+ }
566 if (stat ((char *) target_dir, &target_stat) < 0)
567 {
568 if (verbose || FcDebug () & FC_DBG_CACHE)
569@@ -1043,6 +1114,8 @@ FcDirCacheClean (const FcChar8 *cache_dir, FcBool verbose)
570 }
571 FcDirCacheUnload (cache);
572 FcStrFree (file_name);
573+ if (sysroot)
574+ FcStrFree (target_dir);
575 }
576
577 closedir (d);
578diff --git a/src/fccfg.c b/src/fccfg.c
579index d3752e5..ad97c05 100644
580--- a/src/fccfg.c
581+++ b/src/fccfg.c
582@@ -37,6 +37,7 @@
583 #endif
584
585 FcConfig *_fcConfig;
586+static FcChar8 *_FcConfigSysRoot = NULL;
587
588 FcConfig *
589 FcConfigCreate (void)
590@@ -1716,6 +1717,7 @@ FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file)
591 {
592 FcChar8 *path;
593 int size, osize;
594+ FcChar8 *sysroot = _FcConfigSysRoot;
595
596 if (!dir)
597 dir = (FcChar8 *) "";
598@@ -1747,6 +1749,19 @@ FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file)
599 strcat ((char *) path, (char *) file);
600
601 FcMemAlloc (FC_MEM_STRING, osize);
602+
603+ if (sysroot &&
604+ strncmp ((const char*) sysroot, (const char*) path,
605+ strlen ((const char *) sysroot)))
606+ {
607+ FcChar8 *new_path = FcStrPlus (sysroot, path);
608+ FcStrFree (path);
609+ if (!new_path)
610+ return 0;
611+
612+ path = new_path;
613+ }
614+
615 if (access ((char *) path, R_OK) == 0)
616 return path;
617
618@@ -2217,6 +2232,43 @@ FcConfigAcceptFont (FcConfig *config,
619 return FcFalse;
620 return FcTrue;
621 }
622+
623+
624+FcPublic FcChar8 *
625+FcConfigSetSysRoot (const FcChar8 *sysroot)
626+{
627+ FcChar8 *old_sysroot, *new_sysroot;
628+
629+ if (!sysroot)
630+ return NULL;
631+
632+ new_sysroot = FcStrCopyFilename(sysroot);
633+ if (!new_sysroot)
634+ return NULL;
635+
636+ old_sysroot = _FcConfigSysRoot;
637+
638+ if (old_sysroot &&
639+ !strcmp ((const char *) new_sysroot, (const char *) old_sysroot))
640+ {
641+ FcStrFree (new_sysroot);
642+ return old_sysroot;
643+ }
644+
645+ _FcConfigSysRoot = new_sysroot;
646+
647+ if (old_sysroot)
648+ FcStrFree (old_sysroot);
649+
650+ return new_sysroot;
651+}
652+
653+FcPublic FcChar8 *
654+FcConfigGetSysRoot (void)
655+{
656+ return _FcConfigSysRoot;
657+}
658+
659 #define __fccfg__
660 #include "fcaliastail.h"
661 #undef __fccfg__
662diff --git a/src/fcfreetype.c b/src/fcfreetype.c
663index fb2b0f2..c497be5 100644
664--- a/src/fcfreetype.c
665+++ b/src/fcfreetype.c
666@@ -1124,6 +1124,7 @@ FcFreeTypeQueryFace (const FT_Face face,
667
668 FcChar8 *style = 0;
669 int st;
670+ FcChar8 *sysroot = FcConfigGetSysRoot();
671
672 pat = FcPatternCreate ();
673 if (!pat)
674@@ -1340,6 +1341,9 @@ FcFreeTypeQueryFace (const FT_Face face,
675 ++nstyle;
676 }
677
678+ if (sysroot)
679+ file += strlen ((const char*) sysroot);
680+
681 if (!nfamily)
682 {
683 FcChar8 *start, *end;
684diff --git a/src/fcstr.c b/src/fcstr.c
685index 037960d..62ceae6 100644
686--- a/src/fcstr.c
687+++ b/src/fcstr.c
688@@ -1170,6 +1170,8 @@ FcBool
689 FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s)
690 {
691 FcChar8 *new = FcStrCopyFilename (s);
692+
693+#ifdef FC_LANG_C
694 if (!new)
695 return FcFalse;
696 if (!_FcStrSetAppend (set, new))
697@@ -1177,6 +1179,31 @@ FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s)
698 FcStrFree (new);
699 return FcFalse;
700 }
701+#else
702+ FcChar8 *full;
703+ FcChar8 *sysroot = FcConfigGetSysRoot();
704+
705+ if (!new)
706+ return FcFalse;
707+
708+ if (sysroot && strncmp ((const char *) sysroot, (const char *) new,
709+ strlen ((const char*) sysroot)))
710+ {
711+ full = FcStrPlus(sysroot, new);
712+ FcStrFree(new);
713+ if (!full)
714+ return FcFalse;
715+ }
716+ else
717+ full = new;
718+
719+ if (!_FcStrSetAppend (set, full))
720+ {
721+ FcStrFree (full);
722+ return FcFalse;
723+ }
724+#endif
725+
726 return FcTrue;
727 }
728
729--
7301.7.9.5
731
diff --git a/meta/recipes-graphics/fontconfig/fontconfig/sysroot-arg.patch b/meta/recipes-graphics/fontconfig/fontconfig/sysroot-arg.patch
new file mode 100644
index 0000000000..abfdbc710d
--- /dev/null
+++ b/meta/recipes-graphics/fontconfig/fontconfig/sysroot-arg.patch
@@ -0,0 +1,32 @@
1Upstream-Status: Submitted [https://bugs.freedesktop.org/show_bug.cgi?id=72044]
2Signed-off-by: Ross Burton <ross.burton@intel.com>
3
4From f2ade764cc9f009e1fe25b856b24b7695f66a952 Mon Sep 17 00:00:00 2001
5From: Ross Burton <ross.burton@intel.com>
6Date: Tue, 26 Nov 2013 17:18:25 +0000
7Subject: [PATCH] fc-cache: --sysroot option takes an argument
8
9The getopt_long option definitions say that sysroot doesn't take an argument,
10when it in fact does.
11
12Signed-off-by: Ross Burton <ross.burton@intel.com>
13---
14 fc-cache/fc-cache.c | 2 +-
15 1 file changed, 1 insertion(+), 1 deletion(-)
16
17diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c
18index 27c7513..bf3b6b4 100644
19--- a/fc-cache/fc-cache.c
20+++ b/fc-cache/fc-cache.c
21@@ -67,7 +67,7 @@
22 const struct option longopts[] = {
23 {"force", 0, 0, 'f'},
24 {"really-force", 0, 0, 'r'},
25- {"sysroot", 0, 0, 'y'},
26+ {"sysroot", required_argument, 0, 'y'},
27 {"system-only", 0, 0, 's'},
28 {"version", 0, 0, 'V'},
29 {"verbose", 0, 0, 'v'},
30--
311.8.4.4
32
diff --git a/meta/recipes-graphics/fontconfig/fontconfig_2.10.2.bb b/meta/recipes-graphics/fontconfig/fontconfig_2.11.0.bb
index 45631ed802..48385a369a 100644
--- a/meta/recipes-graphics/fontconfig/fontconfig_2.10.2.bb
+++ b/meta/recipes-graphics/fontconfig/fontconfig_2.11.0.bb
@@ -12,22 +12,18 @@ HOMEPAGE = "http://www.fontconfig.org"
12BUGTRACKER = "https://bugs.freedesktop.org/enter_bug.cgi?product=fontconfig" 12BUGTRACKER = "https://bugs.freedesktop.org/enter_bug.cgi?product=fontconfig"
13 13
14LICENSE = "MIT-style & MIT & PD" 14LICENSE = "MIT-style & MIT & PD"
15LIC_FILES_CHKSUM = "file://COPYING;md5=dc5b39c592e47a22dbec44855988d2a0 \ 15LIC_FILES_CHKSUM = "file://COPYING;md5=7a0449e9bc5370402a94c00204beca3d \
16 file://src/fcfreetype.c;endline=45;md5=5d9513e3196a1fbfdfa94051c09dfc84 \ 16 file://src/fcfreetype.c;endline=45;md5=5d9513e3196a1fbfdfa94051c09dfc84 \
17 file://src/fccache.c;beginline=1182;endline=1197;md5=0326cfeb4a7333dd4dd25fbbc4b9f27f" 17 file://src/fccache.c;beginline=1131;endline=1146;md5=754c7b855210ee746e5f0b840fad9a9f"
18 18
19SECTION = "libs" 19SECTION = "libs"
20 20
21DEPENDS = "expat freetype zlib" 21DEPENDS = "expat freetype zlib"
22 22
23PR = "r1"
24
25SRC_URI = "http://fontconfig.org/release/fontconfig-${PV}.tar.gz \ 23SRC_URI = "http://fontconfig.org/release/fontconfig-${PV}.tar.gz \
26 file://Add-sysroot-option-to-fc-cache-and-fc-cat.patch \ 24 file://sysroot-arg.patch"
27 " 25SRC_URI[md5sum] = "84278204cd7f36adbea7ad8094e039ac"
28 26SRC_URI[sha256sum] = "274c047487b90dacbaa55f4d70b8cdcd556944e7251ce9cf1de442c00a16343b"
29SRC_URI[md5sum] = "025e08b3d7fe45c433de5718e441ed15"
30SRC_URI[sha256sum] = "5c3bf994bb6d6303bbf1e641eaa4b431932138dc90de33642e5845e31e1fdfd6"
31 27
32PACKAGES =+ "fontconfig-utils" 28PACKAGES =+ "fontconfig-utils"
33FILES_${PN} =+ "${datadir}/xml/*" 29FILES_${PN} =+ "${datadir}/xml/*"