]>
git.wh0rd.org - fontconfig.git/blob - src/fcinit.c
2 * $XFree86: xc/lib/fontconfig/src/fcinit.c,v 1.4 2002/05/21 17:06:22 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
);
47 * Load the configuration files
50 FcInitLoadConfig (void)
54 config
= FcConfigCreate ();
58 if (!FcConfigParseAndLoad (config
, 0, FcTrue
))
60 FcConfigDestroy (config
);
61 return FcInitFallbackConfig ();
68 * Load the configuration files and scan for available fonts
71 FcInitLoadConfigAndFonts (void)
73 FcConfig
*config
= FcInitLoadConfig ();
77 if (!FcConfigBuildFonts (config
))
79 FcConfigDestroy (config
);
86 * Initialize the default library configuration
95 config
= FcInitLoadConfigAndFonts ();
98 FcConfigSetCurrent (config
);
103 * Reread the configuration and available font lists
106 FcInitReinitialize (void)
110 config
= FcInitLoadConfigAndFonts ();
113 FcConfigSetCurrent (config
);
118 FcInitBringUptoDate (void)
120 FcConfig
*config
= FcConfigGetCurrent ();
124 * rescanInterval == 0 disables automatic up to date
126 if (config
->rescanInterval
== 0)
129 * Check no more often than rescanInterval seconds
132 if (config
->rescanTime
+ config
->rescanInterval
- now
> 0)
135 * If up to date, don't reload configuration
137 if (FcConfigUptoDate (0))
139 return FcInitReinitialize ();
148 } FcInUse
[FC_MEM_NUM
] = {
150 { "charnode", 0 ,0 },
153 { "objectset", 0, 0 },
154 { "objectptr", 0, 0 },
159 { "substate", 0, 0 },
161 { "listbuck", 0, 0 },
164 static int FcAllocCount
, FcAllocMem
;
165 static int FcFreeCount
, FcFreeMem
;
167 static int FcMemNotice
= 1*1024*1024;
169 static int FcAllocNotify
, FcFreeNotify
;
175 printf ("Fc Memory Usage:\n");
176 printf ("\t Which Alloc Free Active\n");
177 printf ("\t count bytes count bytes count bytes\n");
178 for (i
= 0; i
< FC_MEM_NUM
; i
++)
179 printf ("\t%8.8s%8d%8d%8d%8d%8d%8d\n",
181 FcInUse
[i
].alloc_count
, FcInUse
[i
].alloc_mem
,
182 FcInUse
[i
].free_count
, FcInUse
[i
].free_mem
,
183 FcInUse
[i
].alloc_count
- FcInUse
[i
].free_count
,
184 FcInUse
[i
].alloc_mem
- FcInUse
[i
].free_mem
);
185 printf ("\t%8.8s%8d%8d%8d%8d%8d%8d\n",
187 FcAllocCount
, FcAllocMem
,
188 FcFreeCount
, FcFreeMem
,
189 FcAllocCount
- FcFreeCount
,
190 FcAllocMem
- FcFreeMem
);
196 FcMemAlloc (int kind
, int size
)
198 if (FcDebug() & FC_DBG_MEMORY
)
200 FcInUse
[kind
].alloc_count
++;
201 FcInUse
[kind
].alloc_mem
+= size
;
204 FcAllocNotify
+= size
;
205 if (FcAllocNotify
> FcMemNotice
)
211 FcMemFree (int kind
, int size
)
213 if (FcDebug() & FC_DBG_MEMORY
)
215 FcInUse
[kind
].free_count
++;
216 FcInUse
[kind
].free_mem
+= size
;
219 FcFreeNotify
+= size
;
220 if (FcFreeNotify
> FcMemNotice
)