/src/fontconfig/src/fcdbg.c
Line | Count | Source |
1 | | /* |
2 | | * fontconfig/src/fcdbg.c |
3 | | * |
4 | | * Copyright © 2000 Keith Packard |
5 | | * |
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 the author(s) not be used in |
11 | | * advertising or publicity pertaining to distribution of the software without |
12 | | * specific, written prior permission. The authors make no |
13 | | * representations about the suitability of this software for any purpose. It |
14 | | * is provided "as is" without express or implied warranty. |
15 | | * |
16 | | * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
17 | | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO |
18 | | * EVENT SHALL THE AUTHOR(S) 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. |
23 | | */ |
24 | | |
25 | | #include "fcint.h" |
26 | | |
27 | | #include <stdio.h> |
28 | | #include <stdlib.h> |
29 | | |
30 | | static void |
31 | | _FcValuePrintFile (FILE *stream, const FcValue v) |
32 | 0 | { |
33 | 0 | switch (v.type) { |
34 | 0 | case FcTypeUnknown: |
35 | 0 | fprintf (stream, "<unknown>"); |
36 | 0 | break; |
37 | 0 | case FcTypeVoid: |
38 | 0 | fprintf (stream, "<void>"); |
39 | 0 | break; |
40 | 0 | case FcTypeInteger: |
41 | 0 | fprintf (stream, "%d(i)", v.u.i); |
42 | 0 | break; |
43 | 0 | case FcTypeDouble: |
44 | 0 | fprintf (stream, "%g(f)", v.u.d); |
45 | 0 | break; |
46 | 0 | case FcTypeString: |
47 | 0 | fprintf (stream, "\"%s\"", v.u.s); |
48 | 0 | break; |
49 | 0 | case FcTypeBool: |
50 | 0 | fprintf (stream, |
51 | 0 | v.u.b == FcTrue ? "True" : v.u.b == FcFalse ? "False" |
52 | 0 | : "DontCare"); |
53 | 0 | break; |
54 | 0 | case FcTypeMatrix: |
55 | 0 | fprintf (stream, "[%g %g; %g %g]", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy); |
56 | 0 | break; |
57 | 0 | case FcTypeCharSet: |
58 | 0 | FcCharSetPrintFile (stream, v.u.c); |
59 | 0 | break; |
60 | 0 | case FcTypeLangSet: |
61 | 0 | FcLangSetPrint (v.u.l); |
62 | 0 | break; |
63 | 0 | case FcTypeFTFace: |
64 | 0 | fprintf (stream, "face"); |
65 | 0 | break; |
66 | 0 | case FcTypeRange: |
67 | 0 | fprintf (stream, "[%g %g]", v.u.r->begin, v.u.r->end); |
68 | 0 | break; |
69 | 0 | } |
70 | 0 | } |
71 | | |
72 | | void |
73 | | FcValuePrintFile (FILE *stream, const FcValue v) |
74 | 0 | { |
75 | 0 | fprintf (stream, " "); |
76 | 0 | _FcValuePrintFile (stream, v); |
77 | 0 | } |
78 | | |
79 | | void |
80 | | FcValuePrint (const FcValue v) |
81 | 0 | { |
82 | 0 | printf (" "); |
83 | 0 | _FcValuePrintFile (stdout, v); |
84 | 0 | } |
85 | | |
86 | | void |
87 | | FcValuePrintFileWithPosition (FILE *stream, const FcValue v, FcBool show_pos_mark) |
88 | 0 | { |
89 | 0 | if (show_pos_mark) |
90 | 0 | fprintf (stream, " [marker] "); |
91 | 0 | else |
92 | 0 | fprintf (stream, " "); |
93 | 0 | _FcValuePrintFile (stream, v); |
94 | 0 | } |
95 | | |
96 | | void |
97 | | FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark) |
98 | 0 | { |
99 | 0 | FcValuePrintFileWithPosition (stdout, v, show_pos_mark); |
100 | 0 | } |
101 | | |
102 | | static void |
103 | | FcValueBindingPrintFile (FILE *stream, const FcValueListPtr l) |
104 | 0 | { |
105 | 0 | switch (l->binding) { |
106 | 0 | case FcValueBindingWeak: |
107 | 0 | fprintf (stream, "(w)"); |
108 | 0 | break; |
109 | 0 | case FcValueBindingStrong: |
110 | 0 | fprintf (stream, "(s)"); |
111 | 0 | break; |
112 | 0 | case FcValueBindingSame: |
113 | 0 | fprintf (stream, "(=)"); |
114 | 0 | break; |
115 | 0 | default: |
116 | | /* shouldn't be reached */ |
117 | 0 | fprintf (stream, "(?)"); |
118 | 0 | break; |
119 | 0 | } |
120 | 0 | } |
121 | | |
122 | | void |
123 | | FcValueListPrintFileWithPosition (FILE *stream, FcValueListPtr l, const FcValueListPtr pos) |
124 | 0 | { |
125 | 0 | for (; l != NULL; l = FcValueListNext (l)) { |
126 | 0 | FcValuePrintFileWithPosition (stream, FcValueCanonicalize (&l->value), pos != NULL && l == pos); |
127 | 0 | FcValueBindingPrintFile (stream, l); |
128 | 0 | } |
129 | 0 | if (!pos) |
130 | 0 | fprintf (stream, " [marker]"); |
131 | 0 | } |
132 | | |
133 | | void |
134 | | FcValueListPrintWithPosition (FcValueListPtr l, const FcValueListPtr pos) |
135 | 0 | { |
136 | 0 | FcValueListPrintFileWithPosition(stdout, l, pos); |
137 | 0 | } |
138 | | |
139 | | void |
140 | | FcValueListPrintFile (FILE *stream, FcValueListPtr l) |
141 | 0 | { |
142 | 0 | for (; l != NULL; l = FcValueListNext (l)) { |
143 | 0 | FcValuePrintFile (stream, FcValueCanonicalize (&l->value)); |
144 | 0 | FcValueBindingPrintFile (stream, l); |
145 | 0 | } |
146 | 0 | } |
147 | | |
148 | | void |
149 | | FcValueListPrint (FcValueListPtr l) |
150 | 0 | { |
151 | 0 | FcValueListPrintFile (stdout, l); |
152 | 0 | } |
153 | | |
154 | | void |
155 | | FcLangSetPrintFile (FILE *stream, const FcLangSet *ls) |
156 | 0 | { |
157 | 0 | FcStrBuf buf; |
158 | 0 | FcChar8 init_buf[1024]; |
159 | |
|
160 | 0 | FcStrBufInit (&buf, init_buf, sizeof (init_buf)); |
161 | 0 | if (FcNameUnparseLangSet (&buf, ls) && FcStrBufChar (&buf, '\0')) |
162 | 0 | fprintf (stream, "%s", buf.buf); |
163 | 0 | else |
164 | 0 | fprintf (stream, "langset (alloc error)"); |
165 | 0 | FcStrBufDestroy (&buf); |
166 | 0 | } |
167 | | |
168 | | void |
169 | | FcLangSetPrint (const FcLangSet *ls) |
170 | 0 | { |
171 | 0 | FcLangSetPrintFile (stdout, ls); |
172 | 0 | } |
173 | | |
174 | | void |
175 | | FcCharSetPrintFile (FILE *stream, const FcCharSet *c) |
176 | 0 | { |
177 | 0 | int i, j; |
178 | 0 | intptr_t *leaves = FcCharSetLeaves (c); |
179 | 0 | FcChar16 *numbers = FcCharSetNumbers (c); |
180 | |
|
181 | | #if 0 |
182 | | fprintf (stream, "CharSet 0x%x\n", (intptr_t) c); |
183 | | fprintf (stream, "Leaves: +%d = 0x%x\n", c->leaves_offset, (intptr_t) leaves); |
184 | | fprintf (stream, "Numbers: +%d = 0x%x\n", c->numbers_offset, (intptr_t) numbers); |
185 | | |
186 | | for (i = 0; i < c->num; i++) |
187 | | { |
188 | | fprintf (stream, "Page %d: %04x +%d = 0x%x\n", |
189 | | i, numbers[i], leaves[i], |
190 | | (intptr_t) FcOffsetToPtr (leaves, leaves[i], FcCharLeaf)); |
191 | | } |
192 | | #endif |
193 | |
|
194 | 0 | fprintf (stream, "\n"); |
195 | 0 | for (i = 0; i < c->num; i++) { |
196 | 0 | intptr_t leaf_offset = leaves[i]; |
197 | 0 | FcCharLeaf *leaf = FcOffsetToPtr (leaves, leaf_offset, FcCharLeaf); |
198 | |
|
199 | 0 | fprintf (stream, "\t"); |
200 | 0 | fprintf (stream, "%04x:", numbers[i]); |
201 | 0 | for (j = 0; j < 256 / 32; j++) |
202 | 0 | fprintf (stream, " %08x", leaf->map[j]); |
203 | 0 | fprintf (stream, "\n"); |
204 | 0 | } |
205 | 0 | } |
206 | | |
207 | | void |
208 | | FcCharSetPrint (const FcCharSet *c) |
209 | 0 | { |
210 | 0 | FcCharSetPrintFile (stdout, c); |
211 | 0 | } |
212 | | |
213 | | void |
214 | | FcPatternPrintFile (FILE *stream, const FcPattern *p) |
215 | 0 | { |
216 | 0 | FcPatternIter iter; |
217 | |
|
218 | 0 | if (!p) { |
219 | 0 | fprintf (stream, "Null pattern\n"); |
220 | 0 | return; |
221 | 0 | } |
222 | 0 | fprintf (stream, "Pattern has %d elts (size %d)\n", FcPatternObjectCount (p), p->size); |
223 | 0 | FcPatternIterStart (p, &iter); |
224 | 0 | do { |
225 | 0 | fprintf (stream, "\t%s:", FcPatternIterGetObject (p, &iter)); |
226 | 0 | FcValueListPrintFile (stream, FcPatternIterGetValues (p, &iter)); |
227 | 0 | fprintf (stream, "\n"); |
228 | 0 | } while (FcPatternIterNext (p, &iter)); |
229 | 0 | fprintf (stream, "\n"); |
230 | 0 | } |
231 | | |
232 | | void |
233 | | FcPatternPrint (const FcPattern *p) |
234 | 0 | { |
235 | 0 | FcPatternPrintFile (stdout, p); |
236 | 0 | } |
237 | | |
238 | | #define FcOpFlagsPrintFile(_f_, _o_) \ |
239 | 0 | { \ |
240 | 0 | int f = FC_OP_GET_FLAGS (_o_); \ |
241 | 0 | if (f & FcOpFlagIgnoreBlanks) \ |
242 | 0 | fprintf (_f_, "(ignore blanks)"); \ |
243 | 0 | } |
244 | | |
245 | | #define FcOpFlagsPrint(_o_) FcOpFlagsPrintFile(stdout, _o_) |
246 | | |
247 | | void |
248 | | FcPatternPrint2File (FILE *stream, |
249 | | FcPattern *pp1, |
250 | | FcPattern *pp2, |
251 | | const FcObjectSet *os) |
252 | 0 | { |
253 | 0 | int i, j, k, pos; |
254 | 0 | FcPatternElt *e1, *e2; |
255 | 0 | FcPattern *p1, *p2; |
256 | |
|
257 | 0 | if (os) { |
258 | 0 | p1 = FcPatternFilter (pp1, os); |
259 | 0 | p2 = FcPatternFilter (pp2, os); |
260 | 0 | } else { |
261 | 0 | p1 = pp1; |
262 | 0 | p2 = pp2; |
263 | 0 | } |
264 | 0 | fprintf (stream, "Pattern has %d elts (size %d), %d elts (size %d)\n", |
265 | 0 | p1->num, p1->size, p2->num, p2->size); |
266 | 0 | for (i = 0, j = 0; i < p1->num; i++) { |
267 | 0 | e1 = &FcPatternElts (p1)[i]; |
268 | 0 | e2 = &FcPatternElts (p2)[j]; |
269 | 0 | if (!e2 || e1->object != e2->object) { |
270 | 0 | pos = FcPatternPosition (p2, FcObjectName (e1->object)); |
271 | 0 | if (pos >= 0) { |
272 | 0 | for (k = j; k < pos; k++) { |
273 | 0 | e2 = &FcPatternElts (p2)[k]; |
274 | 0 | fprintf (stream, "\t%s: (None) -> ", FcObjectName (e2->object)); |
275 | 0 | FcValueListPrintFile (stream, FcPatternEltValues (e2)); |
276 | 0 | fprintf (stream, "\n"); |
277 | 0 | } |
278 | 0 | j = pos; |
279 | 0 | goto cont; |
280 | 0 | } else { |
281 | 0 | fprintf (stream, "\t%s:", FcObjectName (e1->object)); |
282 | 0 | FcValueListPrintFile (stream, FcPatternEltValues (e1)); |
283 | 0 | fprintf (stream, " -> (None)\n"); |
284 | 0 | } |
285 | 0 | } else { |
286 | 0 | cont: |
287 | 0 | fprintf (stream, "\t%s:", FcObjectName (e1->object)); |
288 | 0 | FcValueListPrintFile (stream, FcPatternEltValues (e1)); |
289 | 0 | fprintf (stream, " -> "); |
290 | 0 | e2 = &FcPatternElts (p2)[j]; |
291 | 0 | FcValueListPrintFile (stream, FcPatternEltValues (e2)); |
292 | 0 | fprintf (stream, "\n"); |
293 | 0 | j++; |
294 | 0 | } |
295 | 0 | } |
296 | 0 | if (j < p2->num) { |
297 | 0 | for (k = j; k < p2->num; k++) { |
298 | 0 | e2 = &FcPatternElts (p2)[k]; |
299 | 0 | if (FcObjectName (e2->object)) { |
300 | 0 | fprintf (stream, "\t%s: (None) -> ", FcObjectName (e2->object)); |
301 | 0 | FcValueListPrintFile (stream, FcPatternEltValues (e2)); |
302 | 0 | fprintf (stream, "\n"); |
303 | 0 | } |
304 | 0 | } |
305 | 0 | } |
306 | 0 | if (p1 != pp1) |
307 | 0 | FcPatternDestroy (p1); |
308 | 0 | if (p2 != pp2) |
309 | 0 | FcPatternDestroy (p2); |
310 | 0 | } |
311 | | |
312 | | void |
313 | | FcPatternPrint2 (FcPattern *pp1, |
314 | | FcPattern *pp2, |
315 | | const FcObjectSet *os) |
316 | 0 | { |
317 | 0 | FcPatternPrint2File (stdout, pp1, pp2, os); |
318 | 0 | } |
319 | | |
320 | | void |
321 | | FcOpPrintFile (FILE *stream, FcOp op_) |
322 | 0 | { |
323 | 0 | FcOp op = FC_OP_GET_OP (op_); |
324 | |
|
325 | 0 | switch (op) { |
326 | 0 | case FcOpInteger: fprintf (stream, "Integer"); break; |
327 | 0 | case FcOpDouble: fprintf (stream, "Double"); break; |
328 | 0 | case FcOpString: fprintf (stream, "String"); break; |
329 | 0 | case FcOpMatrix: fprintf (stream, "Matrix"); break; |
330 | 0 | case FcOpRange: fprintf (stream, "Range"); break; |
331 | 0 | case FcOpBool: fprintf (stream, "Bool"); break; |
332 | 0 | case FcOpCharSet: fprintf (stream, "CharSet"); break; |
333 | 0 | case FcOpLangSet: fprintf (stream, "LangSet"); break; |
334 | 0 | case FcOpField: fprintf (stream, "Field"); break; |
335 | 0 | case FcOpConst: fprintf (stream, "Const"); break; |
336 | 0 | case FcOpAssign: fprintf (stream, "Assign"); break; |
337 | 0 | case FcOpAssignReplace: fprintf (stream, "AssignReplace"); break; |
338 | 0 | case FcOpPrepend: fprintf (stream, "Prepend"); break; |
339 | 0 | case FcOpPrependFirst: fprintf (stream, "PrependFirst"); break; |
340 | 0 | case FcOpAppend: fprintf (stream, "Append"); break; |
341 | 0 | case FcOpAppendLast: fprintf (stream, "AppendLast"); break; |
342 | 0 | case FcOpDelete: fprintf (stream, "Delete"); break; |
343 | 0 | case FcOpDeleteAll: fprintf (stream, "DeleteAll"); break; |
344 | 0 | case FcOpQuest: fprintf (stream, "Quest"); break; |
345 | 0 | case FcOpOr: fprintf (stream, "Or"); break; |
346 | 0 | case FcOpAnd: fprintf (stream, "And"); break; |
347 | 0 | case FcOpEqual: |
348 | 0 | fprintf (stream, "Equal"); |
349 | 0 | FcOpFlagsPrintFile (stream, op_); |
350 | 0 | break; |
351 | 0 | case FcOpNotEqual: |
352 | 0 | fprintf (stream, "NotEqual"); |
353 | 0 | FcOpFlagsPrintFile (stream, op_); |
354 | 0 | break; |
355 | 0 | case FcOpLess: fprintf (stream, "Less"); break; |
356 | 0 | case FcOpLessEqual: fprintf (stream, "LessEqual"); break; |
357 | 0 | case FcOpMore: fprintf (stream, "More"); break; |
358 | 0 | case FcOpMoreEqual: fprintf (stream, "MoreEqual"); break; |
359 | 0 | case FcOpContains: fprintf (stream, "Contains"); break; |
360 | 0 | case FcOpNotContains: fprintf (stream, "NotContains"); break; |
361 | 0 | case FcOpPlus: fprintf (stream, "Plus"); break; |
362 | 0 | case FcOpMinus: fprintf (stream, "Minus"); break; |
363 | 0 | case FcOpTimes: fprintf (stream, "Times"); break; |
364 | 0 | case FcOpDivide: fprintf (stream, "Divide"); break; |
365 | 0 | case FcOpNot: fprintf (stream, "Not"); break; |
366 | 0 | case FcOpNil: fprintf (stream, "Nil"); break; |
367 | 0 | case FcOpComma: fprintf (stream, "Comma"); break; |
368 | 0 | case FcOpFloor: fprintf (stream, "Floor"); break; |
369 | 0 | case FcOpCeil: fprintf (stream, "Ceil"); break; |
370 | 0 | case FcOpRound: fprintf (stream, "Round"); break; |
371 | 0 | case FcOpTrunc: fprintf (stream, "Trunc"); break; |
372 | 0 | case FcOpListing: |
373 | 0 | fprintf (stream, "Listing"); |
374 | 0 | FcOpFlagsPrintFile (stream, op_); |
375 | 0 | break; |
376 | 0 | case FcOpInvalid: fprintf (stream, "Invalid"); break; |
377 | 0 | } |
378 | 0 | } |
379 | | |
380 | | void |
381 | | FcOpPrint (FcOp op_) |
382 | 0 | { |
383 | 0 | FcOpPrintFile (stdout, op_); |
384 | 0 | } |
385 | | |
386 | | void |
387 | | FcExprPrintFile (FILE *stream, const FcExpr *expr) |
388 | 0 | { |
389 | 0 | if (!expr) |
390 | 0 | fprintf (stream, "none"); |
391 | 0 | else |
392 | 0 | switch (FC_OP_GET_OP (expr->op)) { |
393 | 0 | case FcOpInteger: fprintf (stream, "%d", expr->u.ival); break; |
394 | 0 | case FcOpDouble: fprintf (stream, "%g", expr->u.dval); break; |
395 | 0 | case FcOpString: fprintf (stream, "\"%s\"", expr->u.sval); break; |
396 | 0 | case FcOpMatrix: |
397 | 0 | fprintf (stream, "["); |
398 | 0 | FcExprPrintFile (stream, expr->u.mexpr->xx); |
399 | 0 | fprintf (stream, " "); |
400 | 0 | FcExprPrintFile (stream, expr->u.mexpr->xy); |
401 | 0 | fprintf (stream, "; "); |
402 | 0 | FcExprPrintFile (stream, expr->u.mexpr->yx); |
403 | 0 | fprintf (stream, " "); |
404 | 0 | FcExprPrintFile (stream, expr->u.mexpr->yy); |
405 | 0 | fprintf (stream, "]"); |
406 | 0 | break; |
407 | 0 | case FcOpRange: |
408 | 0 | fprintf (stream, "(%g, %g)", expr->u.rval->begin, expr->u.rval->end); |
409 | 0 | break; |
410 | 0 | case FcOpBool: fprintf (stream, "%s", expr->u.bval ? "true" : "false"); break; |
411 | 0 | case FcOpCharSet: fprintf (stream, "charset\n"); break; |
412 | 0 | case FcOpLangSet: |
413 | 0 | fprintf (stream, "langset:"); |
414 | 0 | FcLangSetPrintFile (stream, expr->u.lval); |
415 | 0 | fprintf (stream, "\n"); |
416 | 0 | break; |
417 | 0 | case FcOpNil: fprintf (stream, "nil\n"); break; |
418 | 0 | case FcOpField: |
419 | 0 | fprintf (stream, "%s ", FcObjectName (expr->u.name.object)); |
420 | 0 | switch ((int)expr->u.name.kind) { |
421 | 0 | case FcMatchPattern: |
422 | 0 | fprintf (stream, "(pattern) "); |
423 | 0 | break; |
424 | 0 | case FcMatchFont: |
425 | 0 | fprintf (stream, "(font) "); |
426 | 0 | break; |
427 | 0 | } |
428 | 0 | break; |
429 | 0 | case FcOpConst: fprintf (stream, "%s", expr->u.constant); break; |
430 | 0 | case FcOpQuest: |
431 | 0 | FcExprPrintFile (stream, expr->u.tree.left); |
432 | 0 | fprintf (stream, " quest "); |
433 | 0 | FcExprPrintFile (stream, expr->u.tree.right->u.tree.left); |
434 | 0 | fprintf (stream, " colon "); |
435 | 0 | FcExprPrintFile (stream, expr->u.tree.right->u.tree.right); |
436 | 0 | break; |
437 | 0 | case FcOpAssign: |
438 | 0 | case FcOpAssignReplace: |
439 | 0 | case FcOpPrependFirst: |
440 | 0 | case FcOpPrepend: |
441 | 0 | case FcOpAppend: |
442 | 0 | case FcOpAppendLast: |
443 | 0 | case FcOpOr: |
444 | 0 | case FcOpAnd: |
445 | 0 | case FcOpEqual: |
446 | 0 | case FcOpNotEqual: |
447 | 0 | case FcOpLess: |
448 | 0 | case FcOpLessEqual: |
449 | 0 | case FcOpMore: |
450 | 0 | case FcOpMoreEqual: |
451 | 0 | case FcOpContains: |
452 | 0 | case FcOpListing: |
453 | 0 | case FcOpNotContains: |
454 | 0 | case FcOpPlus: |
455 | 0 | case FcOpMinus: |
456 | 0 | case FcOpTimes: |
457 | 0 | case FcOpDivide: |
458 | 0 | case FcOpComma: |
459 | 0 | FcExprPrintFile (stream, expr->u.tree.left); |
460 | 0 | fprintf (stream, " "); |
461 | 0 | switch (FC_OP_GET_OP (expr->op)) { |
462 | 0 | case FcOpAssign: fprintf (stream, "Assign"); break; |
463 | 0 | case FcOpAssignReplace: fprintf (stream, "AssignReplace"); break; |
464 | 0 | case FcOpPrependFirst: fprintf (stream, "PrependFirst"); break; |
465 | 0 | case FcOpPrepend: fprintf (stream, "Prepend"); break; |
466 | 0 | case FcOpAppend: fprintf (stream, "Append"); break; |
467 | 0 | case FcOpAppendLast: fprintf (stream, "AppendLast"); break; |
468 | 0 | case FcOpOr: fprintf (stream, "Or"); break; |
469 | 0 | case FcOpAnd: fprintf (stream, "And"); break; |
470 | 0 | case FcOpEqual: |
471 | 0 | fprintf (stream, "Equal"); |
472 | 0 | FcOpFlagsPrintFile (stream, expr->op); |
473 | 0 | break; |
474 | 0 | case FcOpNotEqual: |
475 | 0 | fprintf (stream, "NotEqual"); |
476 | 0 | FcOpFlagsPrintFile (stream, expr->op); |
477 | 0 | break; |
478 | 0 | case FcOpLess: fprintf (stream, "Less"); break; |
479 | 0 | case FcOpLessEqual: fprintf (stream, "LessEqual"); break; |
480 | 0 | case FcOpMore: fprintf (stream, "More"); break; |
481 | 0 | case FcOpMoreEqual: fprintf (stream, "MoreEqual"); break; |
482 | 0 | case FcOpContains: fprintf (stream, "Contains"); break; |
483 | 0 | case FcOpListing: |
484 | 0 | fprintf (stream, "Listing"); |
485 | 0 | FcOpFlagsPrintFile (stream, expr->op); |
486 | 0 | break; |
487 | 0 | case FcOpNotContains: fprintf (stream, "NotContains"); break; |
488 | 0 | case FcOpPlus: fprintf (stream, "Plus"); break; |
489 | 0 | case FcOpMinus: fprintf (stream, "Minus"); break; |
490 | 0 | case FcOpTimes: fprintf (stream, "Times"); break; |
491 | 0 | case FcOpDivide: fprintf (stream, "Divide"); break; |
492 | 0 | case FcOpComma: fprintf (stream, "Comma"); break; |
493 | 0 | default: break; |
494 | 0 | } |
495 | 0 | fprintf (stream, " "); |
496 | 0 | FcExprPrintFile (stream, expr->u.tree.right); |
497 | 0 | break; |
498 | 0 | case FcOpNot: |
499 | 0 | fprintf (stream, "Not "); |
500 | 0 | FcExprPrintFile (stream, expr->u.tree.left); |
501 | 0 | break; |
502 | 0 | case FcOpFloor: |
503 | 0 | fprintf (stream, "Floor "); |
504 | 0 | FcExprPrintFile (stream, expr->u.tree.left); |
505 | 0 | break; |
506 | 0 | case FcOpCeil: |
507 | 0 | fprintf (stream, "Ceil "); |
508 | 0 | FcExprPrintFile (stream, expr->u.tree.left); |
509 | 0 | break; |
510 | 0 | case FcOpRound: |
511 | 0 | fprintf (stream, "Round "); |
512 | 0 | FcExprPrintFile (stream, expr->u.tree.left); |
513 | 0 | break; |
514 | 0 | case FcOpTrunc: |
515 | 0 | fprintf (stream, "Trunc "); |
516 | 0 | FcExprPrintFile (stream, expr->u.tree.left); |
517 | 0 | break; |
518 | 0 | case FcOpInvalid: fprintf (stream, "Invalid"); break; |
519 | 0 | } |
520 | 0 | } |
521 | | |
522 | | void |
523 | | FcExprPrint (const FcExpr *expr) |
524 | 0 | { |
525 | 0 | FcExprPrintFile (stdout, expr); |
526 | 0 | } |
527 | | |
528 | | void |
529 | | FcTestPrintFile (FILE *stream, const FcTest *test) |
530 | 0 | { |
531 | 0 | switch (test->kind) { |
532 | 0 | case FcMatchPattern: |
533 | 0 | fprintf (stream, "pattern "); |
534 | 0 | break; |
535 | 0 | case FcMatchFont: |
536 | 0 | fprintf (stream, "font "); |
537 | 0 | break; |
538 | 0 | case FcMatchScan: |
539 | 0 | fprintf (stream, "scan "); |
540 | 0 | break; |
541 | 0 | case FcMatchKindEnd: |
542 | | /* shouldn't be reached */ |
543 | 0 | return; |
544 | 0 | } |
545 | 0 | switch (test->qual) { |
546 | 0 | case FcQualAny: |
547 | 0 | fprintf (stream, "any "); |
548 | 0 | break; |
549 | 0 | case FcQualAll: |
550 | 0 | fprintf (stream, "all "); |
551 | 0 | break; |
552 | 0 | case FcQualFirst: |
553 | 0 | fprintf (stream, "first "); |
554 | 0 | break; |
555 | 0 | case FcQualNotFirst: |
556 | 0 | fprintf (stream, "not_first "); |
557 | 0 | break; |
558 | 0 | } |
559 | 0 | fprintf (stream, "%s ", FcObjectName (test->object)); |
560 | 0 | FcOpPrintFile (stream, test->op); |
561 | 0 | fprintf (stream, " "); |
562 | 0 | FcExprPrintFile (stream, test->expr); |
563 | 0 | fprintf (stream, "\n"); |
564 | 0 | } |
565 | | |
566 | | void |
567 | | FcTestPrint (const FcTest *test) |
568 | 0 | { |
569 | 0 | FcTestPrintFile (stdout, test); |
570 | 0 | } |
571 | | |
572 | | void |
573 | | FcEditPrintFile (FILE *stream, const FcEdit *edit) |
574 | 0 | { |
575 | 0 | fprintf (stream, "Edit %s ", FcObjectName (edit->object)); |
576 | 0 | FcOpPrintFile (stream, edit->op); |
577 | 0 | fprintf (stream, " "); |
578 | 0 | FcExprPrintFile (stream, edit->expr); |
579 | 0 | } |
580 | | |
581 | | void |
582 | | FcEditPrint (const FcEdit *edit) |
583 | 0 | { |
584 | 0 | FcEditPrintFile (stdout, edit); |
585 | 0 | } |
586 | | |
587 | | void |
588 | | FcRulePrintFile (FILE *stream, const FcRule *rule) |
589 | 0 | { |
590 | 0 | FcRuleType last_type = FcRuleUnknown; |
591 | 0 | const FcRule *r; |
592 | |
|
593 | 0 | for (r = rule; r; r = r->next) { |
594 | 0 | if (last_type != r->type) { |
595 | 0 | switch (r->type) { |
596 | 0 | case FcRuleTest: |
597 | 0 | fprintf (stream, "[test]\n"); |
598 | 0 | break; |
599 | 0 | case FcRuleEdit: |
600 | 0 | fprintf (stream, "[edit]\n"); |
601 | 0 | break; |
602 | 0 | default: |
603 | 0 | break; |
604 | 0 | } |
605 | 0 | last_type = r->type; |
606 | 0 | } |
607 | 0 | fprintf (stream, "\t"); |
608 | 0 | switch (r->type) { |
609 | 0 | case FcRuleTest: |
610 | 0 | FcTestPrintFile (stream, r->u.test); |
611 | 0 | break; |
612 | 0 | case FcRuleEdit: |
613 | 0 | FcEditPrintFile (stream, r->u.edit); |
614 | 0 | fprintf (stream, ";\n"); |
615 | 0 | break; |
616 | 0 | default: |
617 | 0 | break; |
618 | 0 | } |
619 | 0 | } |
620 | 0 | fprintf (stream, "\n"); |
621 | 0 | } |
622 | | |
623 | | void |
624 | | FcRulePrint (const FcRule *rule) |
625 | 0 | { |
626 | 0 | FcRulePrintFile (stdout, rule); |
627 | 0 | } |
628 | | |
629 | | void |
630 | | FcFontSetPrintFile (FILE *stream, const FcFontSet *s) |
631 | 0 | { |
632 | 0 | int i; |
633 | |
|
634 | 0 | fprintf (stream, "FontSet %d of %d\n", s->nfont, s->sfont); |
635 | 0 | for (i = 0; i < s->nfont; i++) { |
636 | 0 | fprintf (stream, "Font %d ", i); |
637 | 0 | FcPatternPrintFile (stream, s->fonts[i]); |
638 | 0 | } |
639 | 0 | } |
640 | | |
641 | | void |
642 | | FcFontSetPrint (const FcFontSet *s) |
643 | 0 | { |
644 | 0 | FcFontSetPrintFile (stdout, s); |
645 | 0 | } |
646 | | |
647 | | int FcDebugVal; |
648 | | |
649 | | void |
650 | | FcInitDebug (void) |
651 | 22 | { |
652 | 22 | if (!FcDebugVal) { |
653 | 22 | char *e; |
654 | | |
655 | 22 | e = getenv ("FC_DEBUG"); |
656 | 22 | if (e) { |
657 | 0 | fprintf (stderr, "FC_DEBUG=%s\n", e); |
658 | 0 | FcDebugVal = atoi (e); |
659 | 0 | if (FcDebugVal < 0) |
660 | 0 | FcDebugVal = 0; |
661 | 0 | } |
662 | 22 | } |
663 | 22 | } |
664 | | #define __fcdbg__ |
665 | | #include "fcaliastail.h" |
666 | | #undef __fcdbg__ |