]>
git.wh0rd.org - fontconfig.git/blob - src/fcinit.c
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 ();
73 if (config
->cacheDirs
&& config
->cacheDirs
->num
== 0)
76 "Fontconfig warning: no <cachedir> elements found. Check configuration.\n");
78 "Fontconfig warning: adding <cachedir>%s</cachedir>\n",
81 "Fontconfig warning: adding <cachedir>~/.fontconfig</cachedir>\n");
82 if (!FcConfigAddCacheDir (config
, (FcChar8
*) FC_CACHEDIR
) ||
83 !FcConfigAddCacheDir (config
, (FcChar8
*) "~/.fontconfig"))
86 "Fontconfig error: out of memory");
87 FcConfigDestroy (config
);
88 return FcInitFallbackConfig ();
96 * Load the configuration files and scan for available fonts
99 FcInitLoadConfigAndFonts (void)
101 FcConfig
*config
= FcInitLoadConfig ();
106 if (!FcConfigBuildFonts (config
))
108 FcConfigDestroy (config
);
115 * Initialize the default library configuration
124 config
= FcInitLoadConfigAndFonts ();
127 FcConfigSetCurrent (config
);
128 if (FcDebug() & FC_DBG_MEMORY
)
134 * Free all library-allocated data structures.
140 FcConfigDestroy (_fcConfig
);
147 * Reread the configuration and available font lists
150 FcInitReinitialize (void)
154 config
= FcInitLoadConfigAndFonts ();
157 FcConfigSetCurrent (config
);
162 FcInitBringUptoDate (void)
164 FcConfig
*config
= FcConfigGetCurrent ();
168 * rescanInterval == 0 disables automatic up to date
170 if (config
->rescanInterval
== 0)
173 * Check no more often than rescanInterval seconds
176 if (config
->rescanTime
+ config
->rescanInterval
- now
> 0)
179 * If up to date, don't reload configuration
181 if (FcConfigUptoDate (0))
183 return FcInitReinitialize ();
192 } FcInUse
[FC_MEM_NUM
] = {
225 static int FcAllocCount
, FcAllocMem
;
226 static int FcFreeCount
, FcFreeMem
;
228 static int FcMemNotice
= 1*1024*1024;
230 static int FcAllocNotify
, FcFreeNotify
;
236 printf ("Fc Memory Usage:\n");
237 printf ("\t Which Alloc Free Active\n");
238 printf ("\t count bytes count bytes count bytes\n");
239 for (i
= 0; i
< FC_MEM_NUM
; i
++)
240 printf ("%16.16s%8d%8d%8d%8d%8d%8d\n",
242 FcInUse
[i
].alloc_count
, FcInUse
[i
].alloc_mem
,
243 FcInUse
[i
].free_count
, FcInUse
[i
].free_mem
,
244 FcInUse
[i
].alloc_count
- FcInUse
[i
].free_count
,
245 FcInUse
[i
].alloc_mem
- FcInUse
[i
].free_mem
);
246 printf ("%16.16s%8d%8d%8d%8d%8d%8d\n",
248 FcAllocCount
, FcAllocMem
,
249 FcFreeCount
, FcFreeMem
,
250 FcAllocCount
- FcFreeCount
,
251 FcAllocMem
- FcFreeMem
);
257 FcMemAlloc (int kind
, int size
)
259 if (FcDebug() & FC_DBG_MEMORY
)
261 FcInUse
[kind
].alloc_count
++;
262 FcInUse
[kind
].alloc_mem
+= size
;
265 FcAllocNotify
+= size
;
266 if (FcAllocNotify
> FcMemNotice
)
272 FcMemFree (int kind
, int size
)
274 if (FcDebug() & FC_DBG_MEMORY
)
276 FcInUse
[kind
].free_count
++;
277 FcInUse
[kind
].free_mem
+= size
;
280 FcFreeNotify
+= size
;
281 if (FcFreeNotify
> FcMemNotice
)
286 #include "fcaliastail.h"