]>
git.wh0rd.org - fontconfig.git/blob - src/fcinit.c
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.
33 config
= FcConfigGetCurrent ();
37 if (FcConfigGetFonts (config
, FcSetSystem
))
40 return FcConfigBuildFonts (config
);
44 FcInitFallbackConfig (void)
48 config
= FcConfigCreate ();
51 if (!FcConfigAddDir (config
, (FcChar8
*) FC_FALLBACK_FONTS
))
53 FcConfigSetCurrent (config
);
57 FcConfigDestroy (config
);
63 * Locate and parse the configuration file
70 if (FcConfigGetCurrent ())
73 config
= FcConfigCreate ();
77 if (!FcConfigParseAndLoad (config
, 0, FcTrue
))
79 FcConfigDestroy (config
);
80 return FcInitFallbackConfig ();
83 FcConfigSetCurrent (config
);
90 return FcInitConfig () && FcInitFonts ();
99 } FcInUse
[FC_MEM_NUM
] = {
101 { "charnode", 0 ,0 },
104 { "objectset", 0, 0 },
105 { "objectptr", 0, 0 },
110 { "substate", 0, 0 },
112 { "listbuck", 0, 0 },
115 static int FcAllocCount
, FcAllocMem
;
116 static int FcFreeCount
, FcFreeMem
;
118 static int FcMemNotice
= 1*1024*1024;
120 static int FcAllocNotify
, FcFreeNotify
;
126 printf ("Fc Memory Usage:\n");
127 printf ("\t Which Alloc Free Active\n");
128 printf ("\t count bytes count bytes count bytes\n");
129 for (i
= 0; i
< FC_MEM_NUM
; i
++)
130 printf ("\t%8.8s%8d%8d%8d%8d%8d%8d\n",
132 FcInUse
[i
].alloc_count
, FcInUse
[i
].alloc_mem
,
133 FcInUse
[i
].free_count
, FcInUse
[i
].free_mem
,
134 FcInUse
[i
].alloc_count
- FcInUse
[i
].free_count
,
135 FcInUse
[i
].alloc_mem
- FcInUse
[i
].free_mem
);
136 printf ("\t%8.8s%8d%8d%8d%8d%8d%8d\n",
138 FcAllocCount
, FcAllocMem
,
139 FcFreeCount
, FcFreeMem
,
140 FcAllocCount
- FcFreeCount
,
141 FcAllocMem
- FcFreeMem
);
147 FcMemAlloc (int kind
, int size
)
149 if (FcDebug() & FC_DBG_MEMORY
)
151 FcInUse
[kind
].alloc_count
++;
152 FcInUse
[kind
].alloc_mem
+= size
;
155 FcAllocNotify
+= size
;
156 if (FcAllocNotify
> FcMemNotice
)
162 FcMemFree (int kind
, int size
)
164 if (FcDebug() & FC_DBG_MEMORY
)
166 FcInUse
[kind
].free_count
++;
167 FcInUse
[kind
].free_mem
+= size
;
170 FcFreeNotify
+= size
;
171 if (FcFreeNotify
> FcMemNotice
)