2 * fontconfig/src/fcdbg.c
4 * Copyright © 2000 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 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.
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.
30 _FcValuePrintFile (FILE *f, const FcValue v)
34 fprintf (f, "<unknown>");
37 fprintf (f, "<void>");
40 fprintf (f, "%d(i)", v.u.i);
43 fprintf (f, "%g(f)", v.u.d);
46 fprintf (f, "\"%s\"", v.u.s);
50 v.u.b == FcTrue ? "True" :
51 v.u.b == FcFalse ? "False" :
55 fprintf (f, "[%g %g; %g %g]", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
57 case FcTypeCharSet: /* XXX */
59 FcCharSetPrint (v.u.c);
62 FcLangSetPrint (v.u.l);
68 fprintf (f, "[%g %g]", v.u.r->begin, v.u.r->end);
74 FcValuePrintFile (FILE *f, const FcValue v)
77 _FcValuePrintFile (f, v);
81 FcValuePrint (const FcValue v)
84 _FcValuePrintFile (stdout, v);
88 FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark)
91 printf (" [marker] ");
94 _FcValuePrintFile (stdout, v);
98 FcValueBindingPrint (const FcValueListPtr l)
100 switch (l->binding) {
101 case FcValueBindingWeak:
104 case FcValueBindingStrong:
107 case FcValueBindingSame:
111 /* shouldn't be reached */
118 FcValueListPrintWithPosition (FcValueListPtr l, const FcValueListPtr pos)
120 for (; l != NULL; l = FcValueListNext(l))
122 FcValuePrintWithPosition (FcValueCanonicalize (&l->value), pos != NULL && l == pos);
123 FcValueBindingPrint (l);
126 printf (" [marker]");
130 FcValueListPrint (FcValueListPtr l)
132 for (; l != NULL; l = FcValueListNext(l))
134 FcValuePrint (FcValueCanonicalize (&l->value));
135 FcValueBindingPrint (l);
140 FcLangSetPrint (const FcLangSet *ls)
143 FcChar8 init_buf[1024];
145 FcStrBufInit (&buf, init_buf, sizeof (init_buf));
146 if (FcNameUnparseLangSet (&buf, ls) && FcStrBufChar (&buf,'\0'))
147 printf ("%s", buf.buf);
149 printf ("langset (alloc error)");
150 FcStrBufDestroy (&buf);
154 FcCharSetPrint (const FcCharSet *c)
157 intptr_t *leaves = FcCharSetLeaves (c);
158 FcChar16 *numbers = FcCharSetNumbers (c);
161 printf ("CharSet 0x%x\n", (intptr_t) c);
162 printf ("Leaves: +%d = 0x%x\n", c->leaves_offset, (intptr_t) leaves);
163 printf ("Numbers: +%d = 0x%x\n", c->numbers_offset, (intptr_t) numbers);
165 for (i = 0; i < c->num; i++)
167 printf ("Page %d: %04x +%d = 0x%x\n",
168 i, numbers[i], leaves[i],
169 (intptr_t) FcOffsetToPtr (leaves, leaves[i], FcCharLeaf));
174 for (i = 0; i < c->num; i++)
176 intptr_t leaf_offset = leaves[i];
177 FcCharLeaf *leaf = FcOffsetToPtr (leaves, leaf_offset, FcCharLeaf);
180 printf ("%04x:", numbers[i]);
181 for (j = 0; j < 256/32; j++)
182 printf (" %08x", leaf->map[j]);
188 FcPatternPrint (const FcPattern *p)
194 printf ("Null pattern\n");
197 printf ("Pattern has %d elts (size %d)\n", FcPatternObjectCount (p), p->size);
198 FcPatternIterStart (p, &iter);
201 printf ("\t%s:", FcPatternIterGetObject (p, &iter));
202 FcValueListPrint (FcPatternIterGetValues (p, &iter));
204 } while (FcPatternIterNext (p, &iter));
208 #define FcOpFlagsPrint(_o_) \
210 int f = FC_OP_GET_FLAGS (_o_); \
211 if (f & FcOpFlagIgnoreBlanks) \
212 printf ("(ignore blanks)"); \
216 FcPatternPrint2 (FcPattern *pp1,
218 const FcObjectSet *os)
221 FcPatternElt *e1, *e2;
226 p1 = FcPatternFilter (pp1, os);
227 p2 = FcPatternFilter (pp2, os);
234 printf ("Pattern has %d elts (size %d), %d elts (size %d)\n",
235 p1->num, p1->size, p2->num, p2->size);
236 for (i = 0, j = 0; i < p1->num; i++)
238 e1 = &FcPatternElts(p1)[i];
239 e2 = &FcPatternElts(p2)[j];
240 if (!e2 || e1->object != e2->object)
242 pos = FcPatternPosition (p2, FcObjectName (e1->object));
245 for (k = j; k < pos; k++)
247 e2 = &FcPatternElts(p2)[k];
248 printf ("\t%s: (None) -> ", FcObjectName (e2->object));
249 FcValueListPrint (FcPatternEltValues (e2));
257 printf ("\t%s:", FcObjectName (e1->object));
258 FcValueListPrint (FcPatternEltValues (e1));
259 printf (" -> (None)\n");
265 printf ("\t%s:", FcObjectName (e1->object));
266 FcValueListPrint (FcPatternEltValues (e1));
268 e2 = &FcPatternElts(p2)[j];
269 FcValueListPrint (FcPatternEltValues (e2));
276 for (k = j; k < p2->num; k++)
278 e2 = &FcPatternElts(p2)[k];
279 if (FcObjectName (e2->object))
281 printf ("\t%s: (None) -> ", FcObjectName (e2->object));
282 FcValueListPrint (FcPatternEltValues (e2));
288 FcPatternDestroy (p1);
290 FcPatternDestroy (p2);
296 FcOp op = FC_OP_GET_OP (op_);
299 case FcOpInteger: printf ("Integer"); break;
300 case FcOpDouble: printf ("Double"); break;
301 case FcOpString: printf ("String"); break;
302 case FcOpMatrix: printf ("Matrix"); break;
303 case FcOpRange: printf ("Range"); break;
304 case FcOpBool: printf ("Bool"); break;
305 case FcOpCharSet: printf ("CharSet"); break;
306 case FcOpLangSet: printf ("LangSet"); break;
307 case FcOpField: printf ("Field"); break;
308 case FcOpConst: printf ("Const"); break;
309 case FcOpAssign: printf ("Assign"); break;
310 case FcOpAssignReplace: printf ("AssignReplace"); break;
311 case FcOpPrepend: printf ("Prepend"); break;
312 case FcOpPrependFirst: printf ("PrependFirst"); break;
313 case FcOpAppend: printf ("Append"); break;
314 case FcOpAppendLast: printf ("AppendLast"); break;
315 case FcOpDelete: printf ("Delete"); break;
316 case FcOpDeleteAll: printf ("DeleteAll"); break;
317 case FcOpQuest: printf ("Quest"); break;
318 case FcOpOr: printf ("Or"); break;
319 case FcOpAnd: printf ("And"); break;
320 case FcOpEqual: printf ("Equal"); FcOpFlagsPrint (op_); break;
321 case FcOpNotEqual: printf ("NotEqual"); FcOpFlagsPrint (op_); break;
322 case FcOpLess: printf ("Less"); break;
323 case FcOpLessEqual: printf ("LessEqual"); break;
324 case FcOpMore: printf ("More"); break;
325 case FcOpMoreEqual: printf ("MoreEqual"); break;
326 case FcOpContains: printf ("Contains"); break;
327 case FcOpNotContains: printf ("NotContains"); break;
328 case FcOpPlus: printf ("Plus"); break;
329 case FcOpMinus: printf ("Minus"); break;
330 case FcOpTimes: printf ("Times"); break;
331 case FcOpDivide: printf ("Divide"); break;
332 case FcOpNot: printf ("Not"); break;
333 case FcOpNil: printf ("Nil"); break;
334 case FcOpComma: printf ("Comma"); break;
335 case FcOpFloor: printf ("Floor"); break;
336 case FcOpCeil: printf ("Ceil"); break;
337 case FcOpRound: printf ("Round"); break;
338 case FcOpTrunc: printf ("Trunc"); break;
339 case FcOpListing: printf ("Listing"); FcOpFlagsPrint (op_); break;
340 case FcOpInvalid: printf ("Invalid"); break;
345 FcExprPrint (const FcExpr *expr)
347 if (!expr) printf ("none");
348 else switch (FC_OP_GET_OP (expr->op)) {
349 case FcOpInteger: printf ("%d", expr->u.ival); break;
350 case FcOpDouble: printf ("%g", expr->u.dval); break;
351 case FcOpString: printf ("\"%s\"", expr->u.sval); break;
354 FcExprPrint (expr->u.mexpr->xx);
356 FcExprPrint (expr->u.mexpr->xy);
358 FcExprPrint (expr->u.mexpr->yx);
360 FcExprPrint (expr->u.mexpr->yy);
364 printf ("(%g, %g)", expr->u.rval->begin, expr->u.rval->end);
366 case FcOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break;
367 case FcOpCharSet: printf ("charset\n"); break;
370 FcLangSetPrint(expr->u.lval);
373 case FcOpNil: printf ("nil\n"); break;
374 case FcOpField: printf ("%s ", FcObjectName(expr->u.name.object));
375 switch ((int) expr->u.name.kind) {
377 printf ("(pattern) ");
384 case FcOpConst: printf ("%s", expr->u.constant); break;
386 FcExprPrint (expr->u.tree.left);
388 FcExprPrint (expr->u.tree.right->u.tree.left);
390 FcExprPrint (expr->u.tree.right->u.tree.right);
393 case FcOpAssignReplace:
394 case FcOpPrependFirst:
408 case FcOpNotContains:
414 FcExprPrint (expr->u.tree.left);
416 switch (FC_OP_GET_OP (expr->op)) {
417 case FcOpAssign: printf ("Assign"); break;
418 case FcOpAssignReplace: printf ("AssignReplace"); break;
419 case FcOpPrependFirst: printf ("PrependFirst"); break;
420 case FcOpPrepend: printf ("Prepend"); break;
421 case FcOpAppend: printf ("Append"); break;
422 case FcOpAppendLast: printf ("AppendLast"); break;
423 case FcOpOr: printf ("Or"); break;
424 case FcOpAnd: printf ("And"); break;
425 case FcOpEqual: printf ("Equal"); FcOpFlagsPrint (expr->op); break;
426 case FcOpNotEqual: printf ("NotEqual"); FcOpFlagsPrint (expr->op); break;
427 case FcOpLess: printf ("Less"); break;
428 case FcOpLessEqual: printf ("LessEqual"); break;
429 case FcOpMore: printf ("More"); break;
430 case FcOpMoreEqual: printf ("MoreEqual"); break;
431 case FcOpContains: printf ("Contains"); break;
432 case FcOpListing: printf ("Listing"); FcOpFlagsPrint (expr->op); break;
433 case FcOpNotContains: printf ("NotContains"); break;
434 case FcOpPlus: printf ("Plus"); break;
435 case FcOpMinus: printf ("Minus"); break;
436 case FcOpTimes: printf ("Times"); break;
437 case FcOpDivide: printf ("Divide"); break;
438 case FcOpComma: printf ("Comma"); break;
442 FcExprPrint (expr->u.tree.right);
446 FcExprPrint (expr->u.tree.left);
450 FcExprPrint (expr->u.tree.left);
454 FcExprPrint (expr->u.tree.left);
458 FcExprPrint (expr->u.tree.left);
462 FcExprPrint (expr->u.tree.left);
464 case FcOpInvalid: printf ("Invalid"); break;
469 FcTestPrint (const FcTest *test)
471 switch (test->kind) {
482 /* shouldn't be reached */
485 switch (test->qual) {
496 printf ("not_first ");
499 printf ("%s ", FcObjectName (test->object));
500 FcOpPrint (test->op);
502 FcExprPrint (test->expr);
507 FcEditPrint (const FcEdit *edit)
509 printf ("Edit %s ", FcObjectName (edit->object));
510 FcOpPrint (edit->op);
512 FcExprPrint (edit->expr);
516 FcRulePrint (const FcRule *rule)
518 FcRuleType last_type = FcRuleUnknown;
521 for (r = rule; r; r = r->next)
523 if (last_type != r->type)
540 FcTestPrint (r->u.test);
543 FcEditPrint (r->u.edit);
554 FcFontSetPrint (const FcFontSet *s)
558 printf ("FontSet %d of %d\n", s->nfont, s->sfont);
559 for (i = 0; i < s->nfont; i++)
561 printf ("Font %d ", i);
562 FcPatternPrint (s->fonts[i]);
574 e = getenv ("FC_DEBUG");
577 printf ("FC_DEBUG=%s\n", e);
578 FcDebugVal = atoi (e);
585 #include "fcaliastail.h"