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))
41 FcConfigDestroy (config);
53 * Load the configuration files
56 FcInitLoadConfig (void)
61 config = FcConfigCreate ();
65 if (!FcConfigParseAndLoad (config, 0, FcTrue))
67 FcConfigDestroy (config);
68 return FcInitFallbackConfig ();
75 * Load the configuration files and scan for available fonts
78 FcInitLoadConfigAndFonts (void)
80 FcConfig *config = FcInitLoadConfig ();
85 if (!FcConfigBuildFonts (config))
87 FcConfigDestroy (config);
94 * Initialize the default library configuration
103 config = FcInitLoadConfigAndFonts ();
106 FcConfigSetCurrent (config);
107 if (FcDebug() & FC_DBG_MEMORY)
113 * Free all library-allocated data structures.
119 FcConfigDestroy (_fcConfig);
126 * Reread the configuration and available font lists
129 FcInitReinitialize (void)
133 config = FcInitLoadConfigAndFonts ();
136 FcConfigSetCurrent (config);
141 FcInitBringUptoDate (void)
143 FcConfig *config = FcConfigGetCurrent ();
147 * rescanInterval == 0 disables automatic up to date
149 if (config->rescanInterval == 0)
152 * Check no more often than rescanInterval seconds
155 if (config->rescanTime + config->rescanInterval - now > 0)
158 * If up to date, don't reload configuration
160 if (FcConfigUptoDate (0))
162 return FcInitReinitialize ();
171 } FcInUse[FC_MEM_NUM] = {
204 static int FcAllocCount, FcAllocMem;
205 static int FcFreeCount, FcFreeMem;
207 static int FcMemNotice = 1*1024*1024;
209 static int FcAllocNotify, FcFreeNotify;
212 FcValueListReport (void);
218 printf ("Fc Memory Usage:\n");
219 printf ("\t Which Alloc Free Active\n");
220 printf ("\t count bytes count bytes count bytes\n");
221 for (i = 0; i < FC_MEM_NUM; i++)
222 printf ("%16.16s%8d%8d%8d%8d%8d%8d\n",
224 FcInUse[i].alloc_count, FcInUse[i].alloc_mem,
225 FcInUse[i].free_count, FcInUse[i].free_mem,
226 FcInUse[i].alloc_count - FcInUse[i].free_count,
227 FcInUse[i].alloc_mem - FcInUse[i].free_mem);
228 printf ("%16.16s%8d%8d%8d%8d%8d%8d\n",
230 FcAllocCount, FcAllocMem,
231 FcFreeCount, FcFreeMem,
232 FcAllocCount - FcFreeCount,
233 FcAllocMem - FcFreeMem);
236 FcValueListReport ();
240 FcMemAlloc (int kind, int size)
242 if (FcDebug() & FC_DBG_MEMORY)
244 FcInUse[kind].alloc_count++;
245 FcInUse[kind].alloc_mem += size;
248 FcAllocNotify += size;
249 if (FcAllocNotify > FcMemNotice)
255 FcMemFree (int kind, int size)
257 if (FcDebug() & FC_DBG_MEMORY)
259 FcInUse[kind].free_count++;
260 FcInUse[kind].free_mem += size;
263 FcFreeNotify += size;
264 if (FcFreeNotify > FcMemNotice)