2 * $RCSId: xc/lib/fontconfig/src/fcinit.c,v 1.7 2002/08/22 07:36:44 keithp Exp $
4 * Copyright © 2001 Keith Packard
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.
29 FcInitFallbackConfig (void)
33 config = FcConfigCreate ();
36 if (!FcConfigAddDir (config, (FcChar8 *) FC_DEFAULT_FONTS))
38 if (!FcConfigAddCacheDir (config, (FcChar8 *) FC_CACHEDIR))
43 FcConfigDestroy (config);
55 * Load the configuration files
58 FcInitLoadConfig (void)
63 config = FcConfigCreate ();
67 if (!FcConfigParseAndLoad (config, 0, FcTrue))
69 FcConfigDestroy (config);
70 return FcInitFallbackConfig ();
77 * Load the configuration files and scan for available fonts
80 FcInitLoadConfigAndFonts (void)
82 FcConfig *config = FcInitLoadConfig ();
87 if (!FcConfigBuildFonts (config))
89 FcConfigDestroy (config);
96 * Initialize the default library configuration
105 config = FcInitLoadConfigAndFonts ();
108 FcConfigSetCurrent (config);
109 if (FcDebug() & FC_DBG_MEMORY)
115 * Free all library-allocated data structures.
121 FcConfigDestroy (_fcConfig);
128 * Reread the configuration and available font lists
131 FcInitReinitialize (void)
135 config = FcInitLoadConfigAndFonts ();
138 FcConfigSetCurrent (config);
143 FcInitBringUptoDate (void)
145 FcConfig *config = FcConfigGetCurrent ();
149 * rescanInterval == 0 disables automatic up to date
151 if (config->rescanInterval == 0)
154 * Check no more often than rescanInterval seconds
157 if (config->rescanTime + config->rescanInterval - now > 0)
160 * If up to date, don't reload configuration
162 if (FcConfigUptoDate (0))
164 return FcInitReinitialize ();
173 } FcInUse[FC_MEM_NUM] = {
206 static int FcAllocCount, FcAllocMem;
207 static int FcFreeCount, FcFreeMem;
209 static int FcMemNotice = 1*1024*1024;
211 static int FcAllocNotify, FcFreeNotify;
217 printf ("Fc Memory Usage:\n");
218 printf ("\t Which Alloc Free Active\n");
219 printf ("\t count bytes count bytes count bytes\n");
220 for (i = 0; i < FC_MEM_NUM; i++)
221 printf ("%16.16s%8d%8d%8d%8d%8d%8d\n",
223 FcInUse[i].alloc_count, FcInUse[i].alloc_mem,
224 FcInUse[i].free_count, FcInUse[i].free_mem,
225 FcInUse[i].alloc_count - FcInUse[i].free_count,
226 FcInUse[i].alloc_mem - FcInUse[i].free_mem);
227 printf ("%16.16s%8d%8d%8d%8d%8d%8d\n",
229 FcAllocCount, FcAllocMem,
230 FcFreeCount, FcFreeMem,
231 FcAllocCount - FcFreeCount,
232 FcAllocMem - FcFreeMem);
238 FcMemAlloc (int kind, int size)
240 if (FcDebug() & FC_DBG_MEMORY)
242 FcInUse[kind].alloc_count++;
243 FcInUse[kind].alloc_mem += size;
246 FcAllocNotify += size;
247 if (FcAllocNotify > FcMemNotice)
253 FcMemFree (int kind, int size)
255 if (FcDebug() & FC_DBG_MEMORY)
257 FcInUse[kind].free_count++;
258 FcInUse[kind].free_mem += size;
261 FcFreeNotify += size;
262 if (FcFreeNotify > FcMemNotice)