2 * $XFree86: xc/lib/fontconfig/src/fccfg.c,v 1.14 2002/06/20 03:43:09 keithp Exp $
4 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. Keith Packard makes no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
35 config
= malloc (sizeof (FcConfig
));
38 FcMemAlloc (FC_MEM_CONFIG
, sizeof (FcConfig
));
40 config
->configDirs
= FcStrSetCreate ();
41 if (!config
->configDirs
)
44 config
->configFiles
= FcStrSetCreate ();
45 if (!config
->configFiles
)
48 config
->fontDirs
= FcStrSetCreate ();
49 if (!config
->fontDirs
)
53 if (!FcConfigSetCache (config
, (FcChar8
*) ("~/" FC_USER_CACHE_FILE
)))
58 config
->substPattern
= 0;
59 config
->substFont
= 0;
60 config
->maxObjects
= 0;
61 for (set
= FcSetSystem
; set
<= FcSetApplication
; set
++)
62 config
->fonts
[set
] = 0;
64 config
->rescanTime
= time(0);
65 config
->rescanInterval
= 30;
70 FcStrSetDestroy (config
->fontDirs
);
72 FcStrSetDestroy (config
->configFiles
);
74 FcStrSetDestroy (config
->configDirs
);
77 FcMemFree (FC_MEM_CONFIG
, sizeof (FcConfig
));
82 typedef struct _FcFileTime
{
88 FcConfigNewestFile (FcStrSet
*files
)
90 FcStrList
*list
= FcStrListCreate (files
);
91 FcFileTime newest
= { 0, FcFalse
};
97 while ((file
= FcStrListNext (list
)))
98 if (stat ((char *) file
, &statb
) == 0)
99 if (!newest
.set
|| statb
.st_mtime
- newest
.time
> 0)
100 newest
.time
= statb
.st_mtime
;
101 FcStrListDone (list
);
107 FcConfigUptoDate (FcConfig
*config
)
109 FcFileTime config_time
, font_time
;
110 time_t now
= time(0);
113 config
= FcConfigGetCurrent ();
117 config_time
= FcConfigNewestFile (config
->configFiles
);
118 font_time
= FcConfigNewestFile (config
->configDirs
);
119 if ((config_time
.set
&& config_time
.time
- config
->rescanTime
> 0) ||
120 (font_time
.set
&& font_time
.time
- config
->rescanTime
) > 0)
124 config
->rescanTime
= now
;
129 FcSubstDestroy (FcSubst
*s
)
136 FcTestDestroy (s
->test
);
137 FcEditDestroy (s
->edit
);
143 FcConfigDestroy (FcConfig
*config
)
147 if (config
== _fcConfig
)
150 FcStrSetDestroy (config
->configDirs
);
151 FcStrSetDestroy (config
->fontDirs
);
152 FcStrSetDestroy (config
->configFiles
);
154 FcStrFree (config
->cache
);
156 FcSubstDestroy (config
->substPattern
);
157 FcSubstDestroy (config
->substFont
);
158 for (set
= FcSetSystem
; set
<= FcSetApplication
; set
++)
159 if (config
->fonts
[set
])
160 FcFontSetDestroy (config
->fonts
[set
]);
162 FcMemFree (FC_MEM_CONFIG
, sizeof (FcConfig
));
166 * Scan the current list of directories in the configuration
167 * and build the set of available fonts. Update the
168 * per-user cache file to reflect the new configuration
172 FcConfigBuildFonts (FcConfig
*config
)
179 fonts
= FcFontSetCreate ();
183 cache
= FcFileCacheCreate ();
187 FcFileCacheLoad (cache
, config
->cache
);
189 list
= FcConfigGetFontDirs (config
);
193 while ((dir
= FcStrListNext (list
)))
195 if (FcDebug () & FC_DBG_FONTSET
)
196 printf ("scan dir %s\n", dir
);
197 FcDirScan (fonts
, config
->fontDirs
, cache
, config
->blanks
, dir
, FcFalse
);
200 FcStrListDone (list
);
202 if (FcDebug () & FC_DBG_FONTSET
)
203 FcFontSetPrint (fonts
);
205 FcFileCacheSave (cache
, config
->cache
);
206 FcFileCacheDestroy (cache
);
208 FcConfigSetFonts (config
, fonts
, FcSetSystem
);
212 FcFontSetDestroy (fonts
);
218 FcConfigSetCurrent (FcConfig
*config
)
221 if (!FcConfigBuildFonts (config
))
225 FcConfigDestroy (_fcConfig
);
231 FcConfigGetCurrent (void)
240 FcConfigAddConfigDir (FcConfig
*config
,
243 return FcStrSetAddFilename (config
->configDirs
, d
);
247 FcConfigGetConfigDirs (FcConfig
*config
)
251 config
= FcConfigGetCurrent ();
255 return FcStrListCreate (config
->configDirs
);
259 FcConfigAddFontDir (FcConfig
*config
,
262 return FcStrSetAddFilename (config
->fontDirs
, d
);
266 FcConfigAddDir (FcConfig
*config
,
269 return (FcConfigAddConfigDir (config
, d
) &&
270 FcConfigAddFontDir (config
, d
));
274 FcConfigGetFontDirs (FcConfig
*config
)
278 config
= FcConfigGetCurrent ();
282 return FcStrListCreate (config
->fontDirs
);
286 FcConfigAddConfigFile (FcConfig
*config
,
290 FcChar8
*file
= FcConfigFilename (f
);
295 ret
= FcStrSetAdd (config
->configFiles
, file
);
301 FcConfigGetConfigFiles (FcConfig
*config
)
305 config
= FcConfigGetCurrent ();
309 return FcStrListCreate (config
->configFiles
);
313 FcConfigSetCache (FcConfig
*config
,
316 FcChar8
*new = FcStrCopyFilename (c
);
321 FcStrFree (config
->cache
);
327 FcConfigGetCache (FcConfig
*config
)
331 config
= FcConfigGetCurrent ();
335 return config
->cache
;
339 FcConfigGetFonts (FcConfig
*config
,
344 config
= FcConfigGetCurrent ();
348 return config
->fonts
[set
];
352 FcConfigSetFonts (FcConfig
*config
,
356 if (config
->fonts
[set
])
357 FcFontSetDestroy (config
->fonts
[set
]);
358 config
->fonts
[set
] = fonts
;
364 FcConfigGetBlanks (FcConfig
*config
)
368 config
= FcConfigGetCurrent ();
372 return config
->blanks
;
376 FcConfigAddBlank (FcConfig
*config
,
384 b
= FcBlanksCreate ();
388 if (!FcBlanksAdd (b
, blank
))
395 FcConfigGetRescanInverval (FcConfig
*config
)
399 config
= FcConfigGetCurrent ();
403 return config
->rescanInterval
;
407 FcConfigSetRescanInverval (FcConfig
*config
, int rescanInterval
)
411 config
= FcConfigGetCurrent ();
415 config
->rescanInterval
= rescanInterval
;
420 FcConfigAddEdit (FcConfig
*config
,
425 FcSubst
*subst
, **prev
;
429 subst
= (FcSubst
*) malloc (sizeof (FcSubst
));
432 if (kind
== FcMatchPattern
)
433 prev
= &config
->substPattern
;
435 prev
= &config
->substFont
;
436 for (; *prev
; prev
= &(*prev
)->next
);
441 if (FcDebug () & FC_DBG_EDIT
)
443 printf ("Add Subst ");
444 FcSubstPrint (subst
);
447 for (t
= test
; t
; t
= t
->next
)
449 if (config
->maxObjects
< num
)
450 config
->maxObjects
= num
;
454 typedef struct _FcSubState
{
459 static const FcMatrix FcIdentityMatrix
= { 1, 0, 0, 1 };
462 FcConfigPromote (FcValue v
, FcValue u
)
464 if (v
.type
== FcTypeInteger
)
466 v
.type
= FcTypeDouble
;
467 v
.u
.d
= (double) v
.u
.i
;
469 else if (v
.type
== FcTypeVoid
&& u
.type
== FcTypeMatrix
)
471 v
.u
.m
= FcMatrixCopy (&FcIdentityMatrix
);
473 v
.type
= FcTypeMatrix
;
479 FcConfigCompareValue (FcValue m
,
483 FcBool ret
= FcFalse
;
485 m
= FcConfigPromote (m
, v
);
486 v
= FcConfigPromote (v
, m
);
487 if (m
.type
== v
.type
)
492 break; /* FcConfigPromote prevents this from happening */
497 ret
= m
.u
.d
== v
.u
.d
;
500 ret
= m
.u
.d
!= v
.u
.d
;
506 ret
= m
.u
.d
<= v
.u
.d
;
512 ret
= m
.u
.d
>= v
.u
.d
;
522 ret
= m
.u
.b
== v
.u
.b
;
525 ret
= m
.u
.b
!= v
.u
.b
;
535 ret
= FcStrCmpIgnoreCase (m
.u
.s
, v
.u
.s
) == 0;
538 ret
= FcStrCmpIgnoreCase (m
.u
.s
, v
.u
.s
) != 0;
548 ret
= FcMatrixEqual (m
.u
.m
, v
.u
.m
);
551 ret
= !FcMatrixEqual (m
.u
.m
, v
.u
.m
);
560 /* m contains v if v is a subset of m */
561 ret
= FcCharSetIsSubset (v
.u
.c
, m
.u
.c
);
564 ret
= FcCharSetEqual (m
.u
.c
, v
.u
.c
);
567 ret
= !FcCharSetEqual (m
.u
.c
, v
.u
.c
);
586 ret
= m
.u
.f
== v
.u
.f
;
589 ret
= m
.u
.f
!= v
.u
.f
;
598 if (op
== FcOpNotEqual
)
606 FcConfigEvaluate (FcPattern
*p
, FcExpr
*e
)
614 v
.type
= FcTypeInteger
;
618 v
.type
= FcTypeDouble
;
622 v
.type
= FcTypeString
;
627 v
.type
= FcTypeMatrix
;
632 v
.type
= FcTypeCharSet
;
641 r
= FcPatternGet (p
, e
->u
.field
, 0, &v
);
642 if (r
!= FcResultMatch
)
646 if (FcNameConstant (e
->u
.constant
, &v
.u
.i
))
647 v
.type
= FcTypeInteger
;
652 vl
= FcConfigEvaluate (p
, e
->u
.tree
.left
);
653 if (vl
.type
== FcTypeBool
)
656 v
= FcConfigEvaluate (p
, e
->u
.tree
.right
->u
.tree
.left
);
658 v
= FcConfigEvaluate (p
, e
->u
.tree
.right
->u
.tree
.right
);
677 vl
= FcConfigEvaluate (p
, e
->u
.tree
.left
);
678 vr
= FcConfigEvaluate (p
, e
->u
.tree
.right
);
679 vl
= FcConfigPromote (vl
, vr
);
680 vr
= FcConfigPromote (vr
, vl
);
681 if (vl
.type
== vr
.type
)
687 v
.type
= FcTypeDouble
;
688 v
.u
.d
= vl
.u
.d
+ vr
.u
.d
;
691 v
.type
= FcTypeDouble
;
692 v
.u
.d
= vl
.u
.d
- vr
.u
.d
;
695 v
.type
= FcTypeDouble
;
696 v
.u
.d
= vl
.u
.d
* vr
.u
.d
;
699 v
.type
= FcTypeDouble
;
700 v
.u
.d
= vl
.u
.d
/ vr
.u
.d
;
705 v
.u
.b
= vl
.u
.d
== vr
.u
.d
;
709 v
.u
.b
= vl
.u
.d
!= vr
.u
.d
;
713 v
.u
.b
= vl
.u
.d
< vr
.u
.d
;
717 v
.u
.b
= vl
.u
.d
<= vr
.u
.d
;
721 v
.u
.b
= vl
.u
.d
> vr
.u
.d
;
725 v
.u
.b
= vl
.u
.d
>= vr
.u
.d
;
731 if (v
.type
== FcTypeDouble
&&
732 v
.u
.d
== (double) (int) v
.u
.d
)
734 v
.type
= FcTypeInteger
;
742 v
.u
.b
= vl
.u
.b
|| vr
.u
.b
;
746 v
.u
.b
= vl
.u
.b
&& vr
.u
.b
;
751 v
.u
.b
= vl
.u
.b
== vr
.u
.b
;
755 v
.u
.b
= vl
.u
.b
!= vr
.u
.b
;
767 v
.u
.b
= FcStrCmpIgnoreCase (vl
.u
.s
, vr
.u
.s
) == 0;
771 v
.u
.b
= FcStrCmpIgnoreCase (vl
.u
.s
, vr
.u
.s
) != 0;
774 v
.type
= FcTypeString
;
775 v
.u
.s
= FcStrPlus (vl
.u
.s
, vr
.u
.s
);
789 v
.u
.b
= FcMatrixEqual (vl
.u
.m
, vr
.u
.m
);
793 v
.u
.b
= FcMatrixEqual (vl
.u
.m
, vr
.u
.m
);
796 v
.type
= FcTypeMatrix
;
797 m
= malloc (sizeof (FcMatrix
));
800 FcMemAlloc (FC_MEM_MATRIX
, sizeof (FcMatrix
));
801 FcMatrixMultiply (m
, vl
.u
.m
, vr
.u
.m
);
817 /* vl contains vr if vr is a subset of vl */
819 v
.u
.b
= FcCharSetIsSubset (vr
.u
.c
, vl
.u
.c
);
823 v
.u
.b
= FcCharSetEqual (vl
.u
.c
, vr
.u
.c
);
827 v
.u
.b
= !FcCharSetEqual (vl
.u
.c
, vr
.u
.c
);
845 vl
= FcConfigEvaluate (p
, e
->u
.tree
.left
);
865 FcConfigMatchValueList (FcPattern
*p
,
869 FcValueList
*ret
= 0;
876 if (e
->op
== FcOpComma
)
878 value
= FcConfigEvaluate (p
, e
->u
.tree
.left
);
883 value
= FcConfigEvaluate (p
, e
);
887 for (v
= values
; v
; v
= v
->next
)
889 if (FcConfigCompareValue (v
->value
, t
->op
, value
))
896 if (t
->qual
== FcQualAll
)
903 FcValueDestroy (value
);
909 FcConfigValues (FcPattern
*p
, FcExpr
*e
)
915 l
= (FcValueList
*) malloc (sizeof (FcValueList
));
918 FcMemAlloc (FC_MEM_VALLIST
, sizeof (FcValueList
));
919 if (e
->op
== FcOpComma
)
921 l
->value
= FcConfigEvaluate (p
, e
->u
.tree
.left
);
922 l
->next
= FcConfigValues (p
, e
->u
.tree
.right
);
926 l
->value
= FcConfigEvaluate (p
, e
);
929 while (l
&& l
->value
.type
== FcTypeVoid
)
931 FcValueList
*next
= l
->next
;
933 FcMemFree (FC_MEM_VALLIST
, sizeof (FcValueList
));
941 FcConfigAdd (FcValueList
**head
,
942 FcValueList
*position
,
946 FcValueList
**prev
, *last
;
951 prev
= &position
->next
;
953 for (prev
= head
; *prev
; prev
= &(*prev
)->next
)
960 for (prev
= head
; *prev
; prev
= &(*prev
)->next
)
962 if (*prev
== position
)
969 if (FcDebug () & FC_DBG_EDIT
)
972 printf ("position not on list\n");
976 if (FcDebug () & FC_DBG_EDIT
)
978 printf ("%s list before ", append
? "Append" : "Prepend");
979 FcValueListPrint (*head
);
993 if (FcDebug () & FC_DBG_EDIT
)
995 printf ("%s list after ", append
? "Append" : "Prepend");
996 FcValueListPrint (*head
);
1004 FcConfigDel (FcValueList
**head
,
1005 FcValueList
*position
)
1009 for (prev
= head
; *prev
; prev
= &(*prev
)->next
)
1011 if (*prev
== position
)
1013 *prev
= position
->next
;
1015 FcValueListDestroy (position
);
1022 FcConfigPatternAdd (FcPattern
*p
,
1029 FcPatternElt
*e
= FcPatternInsertElt (p
, object
);
1033 FcConfigAdd (&e
->values
, 0, append
, list
);
1038 * Delete all values associated with a field
1041 FcConfigPatternDel (FcPattern
*p
,
1044 FcPatternElt
*e
= FcPatternFindElt (p
, object
);
1048 FcConfigDel (&e
->values
, e
->values
);
1052 FcConfigPatternCanon (FcPattern
*p
,
1055 FcPatternElt
*e
= FcPatternFindElt (p
, object
);
1059 FcPatternDel (p
, object
);
1063 FcConfigSubstitute (FcConfig
*config
,
1076 config
= FcConfigGetCurrent ();
1081 st
= (FcSubState
*) malloc (config
->maxObjects
* sizeof (FcSubState
));
1082 if (!st
&& config
->maxObjects
)
1084 FcMemAlloc (FC_MEM_SUBSTATE
, config
->maxObjects
* sizeof (FcSubState
));
1086 if (FcDebug () & FC_DBG_EDIT
)
1088 printf ("FcConfigSubstitute ");
1091 if (kind
== FcMatchPattern
)
1092 s
= config
->substPattern
;
1094 s
= config
->substFont
;
1095 for (; s
; s
= s
->next
)
1098 * Check the tests to see if
1099 * they all match the pattern
1101 for (t
= s
->test
, i
= 0; t
; t
= t
->next
, i
++)
1103 if (FcDebug () & FC_DBG_EDIT
)
1105 printf ("FcConfigSubstitute test ");
1108 st
[i
].elt
= FcPatternFindElt (p
, t
->field
);
1110 * If there's no such field in the font,
1111 * then FcQualAll matches while FcQualAny does not
1115 if (t
->qual
== FcQualAll
)
1124 * Check to see if there is a match, mark the location
1125 * to apply match-relative edits
1127 st
[i
].value
= FcConfigMatchValueList (p
, t
, st
[i
].elt
->values
);
1130 if (t
->qual
== FcQualFirst
&& st
[i
].value
!= st
[i
].elt
->values
)
1132 if (t
->qual
== FcQualNotFirst
&& st
[i
].value
== st
[i
].elt
->values
)
1137 if (FcDebug () & FC_DBG_EDIT
)
1138 printf ("No match\n");
1141 if (FcDebug () & FC_DBG_EDIT
)
1143 printf ("Substitute ");
1146 for (e
= s
->edit
; e
; e
= e
->next
)
1149 * Evaluate the list of expressions
1151 l
= FcConfigValues (p
, e
->expr
);
1153 * Locate any test associated with this field
1155 for (t
= s
->test
, i
= 0; t
; t
= t
->next
, i
++)
1156 if (!FcStrCmpIgnoreCase ((FcChar8
*) t
->field
, (FcChar8
*) e
->field
))
1161 * If there was a test, then replace the matched
1162 * value with the new list of values
1166 FcValueList
*thisValue
= st
[i
].value
;
1167 FcValueList
*nextValue
= thisValue
? thisValue
->next
: 0;
1170 * Append the new list of values after the current value
1172 FcConfigAdd (&st
[i
].elt
->values
, thisValue
, FcTrue
, l
);
1174 * Delete the marked value
1176 FcConfigDel (&st
[i
].elt
->values
, thisValue
);
1178 * Adjust any pointers into the value list to ensure
1179 * future edits occur at the same place
1181 for (t
= s
->test
, i
= 0; t
; t
= t
->next
, i
++)
1183 if (st
[i
].value
== thisValue
)
1184 st
[i
].value
= nextValue
;
1188 /* fall through ... */
1189 case FcOpAssignReplace
:
1191 * Delete all of the values and insert
1194 FcConfigPatternDel (p
, e
->field
);
1195 FcConfigPatternAdd (p
, e
->field
, l
, FcTrue
);
1197 * Adjust any pointers into the value list as they no
1198 * longer point to anything valid
1202 FcPatternElt
*thisElt
= st
[i
].elt
;
1203 for (t
= s
->test
, i
= 0; t
; t
= t
->next
, i
++)
1205 if (st
[i
].elt
== thisElt
)
1213 FcConfigAdd (&st
[i
].elt
->values
, st
[i
].value
, FcFalse
, l
);
1216 /* fall through ... */
1217 case FcOpPrependFirst
:
1218 FcConfigPatternAdd (p
, e
->field
, l
, FcFalse
);
1223 FcConfigAdd (&st
[i
].elt
->values
, st
[i
].value
, FcTrue
, l
);
1226 /* fall through ... */
1227 case FcOpAppendLast
:
1228 FcConfigPatternAdd (p
, e
->field
, l
, FcTrue
);
1235 * Now go through the pattern and eliminate
1236 * any properties without data
1238 for (e
= s
->edit
; e
; e
= e
->next
)
1239 FcConfigPatternCanon (p
, e
->field
);
1241 if (FcDebug () & FC_DBG_EDIT
)
1243 printf ("FcConfigSubstitute edit");
1247 FcMemFree (FC_MEM_SUBSTATE
, config
->maxObjects
* sizeof (FcSubState
));
1249 if (FcDebug () & FC_DBG_EDIT
)
1251 printf ("FcConfigSubstitute done");
1257 #ifndef FONTCONFIG_PATH
1258 #define FONTCONFIG_PATH "/etc/fonts"
1261 #ifndef FONTCONFIG_FILE
1262 #define FONTCONFIG_FILE "fonts.conf"
1266 FcConfigFileExists (const FcChar8
*dir
, const FcChar8
*file
)
1271 dir
= (FcChar8
*) "";
1272 path
= malloc (strlen ((char *) dir
) + 1 + strlen ((char *) file
) + 1);
1276 strcpy ((char *) path
, (const char *) dir
);
1277 /* make sure there's a single separating / */
1278 if ((!path
[0] || path
[strlen((char *) path
)-1] != '/') && file
[0] != '/')
1279 strcat ((char *) path
, "/");
1280 strcat ((char *) path
, (char *) file
);
1282 if (access ((char *) path
, R_OK
) == 0)
1290 FcConfigGetPath (void)
1293 FcChar8
*env
, *e
, *colon
;
1298 npath
= 2; /* default dir + null */
1299 env
= (FcChar8
*) getenv ("FONTCONFIG_PATH");
1308 path
= calloc (npath
, sizeof (FcChar8
*));
1318 colon
= (FcChar8
*) strchr ((char *) e
, ':');
1320 colon
= e
+ strlen ((char *) e
);
1321 path
[i
] = malloc (colon
- e
+ 1);
1324 strncpy ((char *) path
[i
], (const char *) e
, colon
- e
);
1325 path
[i
][colon
- e
] = '\0';
1334 dir
= (FcChar8
*) FONTCONFIG_PATH
;
1335 path
[i
] = malloc (strlen ((char *) dir
) + 1);
1338 strcpy ((char *) path
[i
], (const char *) dir
);
1342 for (i
= 0; path
[i
]; i
++)
1350 FcConfigFreePath (FcChar8
**path
)
1354 for (p
= path
; *p
; p
++)
1360 FcConfigFilename (const FcChar8
*url
)
1362 FcChar8
*file
, *dir
, **path
, **p
;
1366 url
= (FcChar8
*) getenv ("FONTCONFIG_FILE");
1368 url
= (FcChar8
*) FONTCONFIG_FILE
;
1373 dir
= (FcChar8
*) getenv ("HOME");
1375 file
= FcConfigFileExists (dir
, url
+ 1);
1380 file
= FcConfigFileExists (0, url
);
1383 path
= FcConfigGetPath ();
1386 for (p
= path
; *p
; p
++)
1388 file
= FcConfigFileExists (*p
, url
);
1392 FcConfigFreePath (path
);
1399 * Manage the application-specific fonts
1403 FcConfigAppFontAddFile (FcConfig
*config
,
1404 const FcChar8
*file
)
1413 config
= FcConfigGetCurrent ();
1418 subdirs
= FcStrSetCreate ();
1422 set
= FcConfigGetFonts (config
, FcSetApplication
);
1425 set
= FcFontSetCreate ();
1428 FcStrSetDestroy (subdirs
);
1431 FcConfigSetFonts (config
, set
, FcSetApplication
);
1434 if (!FcFileScan (set
, subdirs
, 0, config
->blanks
, file
, FcFalse
))
1436 FcStrSetDestroy (subdirs
);
1439 if ((sublist
= FcStrListCreate (subdirs
)))
1441 while ((subdir
= FcStrListNext (sublist
)))
1443 FcConfigAppFontAddDir (config
, subdir
);
1445 FcStrListDone (sublist
);
1451 FcConfigAppFontAddDir (FcConfig
*config
,
1461 config
= FcConfigGetCurrent ();
1465 subdirs
= FcStrSetCreate ();
1469 set
= FcConfigGetFonts (config
, FcSetApplication
);
1472 set
= FcFontSetCreate ();
1475 FcStrSetDestroy (subdirs
);
1478 FcConfigSetFonts (config
, set
, FcSetApplication
);
1481 if (!FcDirScan (set
, subdirs
, 0, config
->blanks
, dir
, FcFalse
))
1483 FcStrSetDestroy (subdirs
);
1486 if ((sublist
= FcStrListCreate (subdirs
)))
1488 while ((subdir
= FcStrListNext (sublist
)))
1490 FcConfigAppFontAddDir (config
, subdir
);
1492 FcStrListDone (sublist
);
1498 FcConfigAppFontClear (FcConfig
*config
)
1500 FcConfigSetFonts (config
, 0, FcSetApplication
);