]>
git.wh0rd.org - fontconfig.git/blob - src/fcinit.c
2 * $XFree86: xc/lib/fontconfig/src/fcinit.c,v 1.6 2002/05/23 23:00:46 keithp Exp $
4 * Copyright © 2001 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.
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)
60 config
= FcConfigCreate ();
64 if (!FcConfigParseAndLoad (config
, 0, FcTrue
))
66 FcConfigDestroy (config
);
67 return FcInitFallbackConfig ();
74 * Load the configuration files and scan for available fonts
77 FcInitLoadConfigAndFonts (void)
79 FcConfig
*config
= FcInitLoadConfig ();
83 if (!FcConfigBuildFonts (config
))
85 FcConfigDestroy (config
);
92 * Initialize the default library configuration
101 config
= FcInitLoadConfigAndFonts ();
104 FcConfigSetCurrent (config
);
105 if (FcDebug() & FC_DBG_MEMORY
)
111 * Reread the configuration and available font lists
114 FcInitReinitialize (void)
118 config
= FcInitLoadConfigAndFonts ();
121 FcConfigSetCurrent (config
);
126 FcInitBringUptoDate (void)
128 FcConfig
*config
= FcConfigGetCurrent ();
132 * rescanInterval == 0 disables automatic up to date
134 if (config
->rescanInterval
== 0)
137 * Check no more often than rescanInterval seconds
140 if (config
->rescanTime
+ config
->rescanInterval
- now
> 0)
143 * If up to date, don't reload configuration
145 if (FcConfigUptoDate (0))
147 return FcInitReinitialize ();
156 } FcInUse
[FC_MEM_NUM
] = {
158 { "charleaf", 0 ,0 },
161 { "objectset", 0, 0 },
162 { "objectptr", 0, 0 },
167 { "substate", 0, 0 },
169 { "listbuck", 0, 0 },
176 static int FcAllocCount
, FcAllocMem
;
177 static int FcFreeCount
, FcFreeMem
;
179 static int FcMemNotice
= 1*1024*1024;
181 static int FcAllocNotify
, FcFreeNotify
;
184 FcValueListReport (void);
190 printf ("Fc Memory Usage:\n");
191 printf ("\t Which Alloc Free Active\n");
192 printf ("\t count bytes count bytes count bytes\n");
193 for (i
= 0; i
< FC_MEM_NUM
; i
++)
194 printf ("\t%8.8s%8d%8d%8d%8d%8d%8d\n",
196 FcInUse
[i
].alloc_count
, FcInUse
[i
].alloc_mem
,
197 FcInUse
[i
].free_count
, FcInUse
[i
].free_mem
,
198 FcInUse
[i
].alloc_count
- FcInUse
[i
].free_count
,
199 FcInUse
[i
].alloc_mem
- FcInUse
[i
].free_mem
);
200 printf ("\t%8.8s%8d%8d%8d%8d%8d%8d\n",
202 FcAllocCount
, FcAllocMem
,
203 FcFreeCount
, FcFreeMem
,
204 FcAllocCount
- FcFreeCount
,
205 FcAllocMem
- FcFreeMem
);
208 FcValueListReport ();
212 FcMemAlloc (int kind
, int size
)
214 if (FcDebug() & FC_DBG_MEMORY
)
216 FcInUse
[kind
].alloc_count
++;
217 FcInUse
[kind
].alloc_mem
+= size
;
220 FcAllocNotify
+= size
;
221 if (FcAllocNotify
> FcMemNotice
)
227 FcMemFree (int kind
, int size
)
229 if (FcDebug() & FC_DBG_MEMORY
)
231 FcInUse
[kind
].free_count
++;
232 FcInUse
[kind
].free_mem
+= size
;
235 FcFreeNotify
+= size
;
236 if (FcFreeNotify
> FcMemNotice
)