]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcdbg.c
Bug 44826 - <alias> must contain only a single <family>
[fontconfig.git] / src / fcdbg.c
index 055a8bf8ea99a309d5314057a0ade8a63d8381b3..cf2ff0870dadb80a2aaee4b0292acca7e57f795a 100644 (file)
@@ -1,46 +1,43 @@
 /*
- * $XFree86: xc/lib/fontconfig/src/fcdbg.c,v 1.10 2002/08/22 18:53:22 keithp Exp $
+ * fontconfig/src/fcdbg.c
  *
- * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2000 Keith Packard
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
+ * documentation, and that the name of the author(s) not be used in
  * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
+ * specific, written prior permission.  The authors make no
  * representations about the suitability of this software for any purpose.  It
  * is provided "as is" without express or implied warranty.
  *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include "fcint.h"
 #include <stdio.h>
 #include <stdlib.h>
-#include "fcint.h"
 
 void
 FcValuePrint (const FcValue v)
 {
-    FcStrBuf   buf;
-    FcChar8    init_buf[1024];
-    
     switch (v.type) {
     case FcTypeVoid:
        printf (" <void>");
        break;
     case FcTypeInteger:
-       printf (" %d", v.u.i);
+       printf (" %d(i)", v.u.i);
        break;
     case FcTypeDouble:
-       printf (" %g", v.u.d);
+       printf (" %g(f)", v.u.d);
        break;
     case FcTypeString:
        printf (" \"%s\"", v.u.s);
@@ -52,15 +49,12 @@ FcValuePrint (const FcValue v)
        printf (" (%f %f; %f %f)", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
        break;
     case FcTypeCharSet:        /* XXX */
-       printf (" set");
+       printf (" ");
+       FcCharSetPrint (v.u.c);
        break;
     case FcTypeLangSet:
-       FcStrBufInit (&buf, init_buf, sizeof (init_buf));
-        if (FcNameUnparseLangSet (&buf, v.u.l) && FcStrBufChar (&buf,'\0'))
-           printf (" %s", buf.buf);
-       else
-           printf ("langset (alloc error)");
-       FcStrBufDestroy (&buf);
+       printf (" ");
+       FcLangSetPrint (v.u.l);
        break;
     case FcTypeFTFace:
        printf (" face");
@@ -69,11 +63,11 @@ FcValuePrint (const FcValue v)
 }
 
 void
-FcValueListPrint (const FcValueList *l)
+FcValueListPrint (FcValueListPtr l)
 {
-    for (; l; l = l->next)
+    for (; l != NULL; l = FcValueListNext(l))
     {
-       FcValuePrint (l->value);
+       FcValuePrint (FcValueCanonicalize(&l->value));
        switch (l->binding) {
        case FcValueBindingWeak:
            printf ("(w)");
@@ -88,23 +82,71 @@ FcValueListPrint (const FcValueList *l)
     }
 }
 
+void
+FcLangSetPrint (const FcLangSet *ls)
+{
+    FcStrBuf   buf;
+    FcChar8    init_buf[1024];
+
+    FcStrBufInit (&buf, init_buf, sizeof (init_buf));
+    if (FcNameUnparseLangSet (&buf, ls) && FcStrBufChar (&buf,'\0'))
+       printf ("%s", buf.buf);
+    else
+       printf ("langset (alloc error)");
+    FcStrBufDestroy (&buf);
+}
+
+void
+FcCharSetPrint (const FcCharSet *c)
+{
+    int        i, j;
+    intptr_t   *leaves = FcCharSetLeaves (c);
+    FcChar16   *numbers = FcCharSetNumbers (c);
+
+#if 0
+    printf ("CharSet  0x%x\n", (intptr_t) c);
+    printf ("Leaves:  +%d = 0x%x\n", c->leaves_offset, (intptr_t) leaves);
+    printf ("Numbers: +%d = 0x%x\n", c->numbers_offset, (intptr_t) numbers);
+
+    for (i = 0; i < c->num; i++)
+    {
+       printf ("Page %d: %04x +%d = 0x%x\n",
+               i, numbers[i], leaves[i],
+               (intptr_t) FcOffsetToPtr (leaves, leaves[i], FcCharLeaf));
+    }
+#endif
+               
+    printf ("\n");
+    for (i = 0; i < c->num; i++)
+    {
+       intptr_t        leaf_offset = leaves[i];
+       FcCharLeaf      *leaf = FcOffsetToPtr (leaves, leaf_offset, FcCharLeaf);
+       
+       printf ("\t");
+       printf ("%04x:", numbers[i]);
+       for (j = 0; j < 256/32; j++)
+           printf (" %08x", leaf->map[j]);
+       printf ("\n");
+    }
+}
+
 void
 FcPatternPrint (const FcPattern *p)
 {
     int                    i;
     FcPatternElt   *e;
-    
+
     if (!p)
     {
        printf ("Null pattern\n");
        return;
     }
-    printf ("Pattern %d of %d\n", p->num, p->size);
+    printf ("Pattern has %d elts (size %d)\n", p->num, p->size);
     for (i = 0; i < p->num; i++)
     {
-       e = &p->elts[i];
-       printf ("\t%s:", e->object);
-       FcValueListPrint (e->values);
+       e = &FcPatternElts(p)[i];
+       printf ("\t%s:", FcObjectName(e->object));
+       FcValueListPrint (FcPatternEltValues(e));
        printf ("\n");
     }
     printf ("\n");
@@ -118,8 +160,10 @@ FcOpPrint (FcOp op)
     case FcOpDouble: printf ("Double"); break;
     case FcOpString: printf ("String"); break;
     case FcOpMatrix: printf ("Matrix"); break;
+    case FcOpRange: printf ("Range"); break;
     case FcOpBool: printf ("Bool"); break;
     case FcOpCharSet: printf ("CharSet"); break;
+    case FcOpLangSet: printf ("LangSet"); break;
     case FcOpField: printf ("Field"); break;
     case FcOpConst: printf ("Const"); break;
     case FcOpAssign: printf ("Assign"); break;
@@ -146,6 +190,11 @@ FcOpPrint (FcOp op)
     case FcOpNot: printf ("Not"); break;
     case FcOpNil: printf ("Nil"); break;
     case FcOpComma: printf ("Comma"); break;
+    case FcOpFloor: printf ("Floor"); break;
+    case FcOpCeil: printf ("Ceil"); break;
+    case FcOpRound: printf ("Round"); break;
+    case FcOpTrunc: printf ("Trunc"); break;
+    case FcOpListing: printf ("Listing"); break;
     case FcOpInvalid: printf ("Invalid"); break;
     }
 }
@@ -153,7 +202,8 @@ FcOpPrint (FcOp op)
 void
 FcExprPrint (const FcExpr *expr)
 {
-    switch (expr->op) {
+    if (!expr) printf ("none");
+    else switch (expr->op) {
     case FcOpInteger: printf ("%d", expr->u.ival); break;
     case FcOpDouble: printf ("%g", expr->u.dval); break;
     case FcOpString: printf ("\"%s\"", expr->u.sval); break;
@@ -162,10 +212,16 @@ FcExprPrint (const FcExpr *expr)
                              expr->u.mval->xy,
                              expr->u.mval->yx,
                              expr->u.mval->yy); break;
+    case FcOpRange: break;
     case FcOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break;
     case FcOpCharSet: printf ("charset\n"); break;
+    case FcOpLangSet:
+       printf ("langset:");
+       FcLangSetPrint(expr->u.lval);
+       printf ("\n");
+       break;
     case FcOpNil: printf ("nil\n"); break;
-    case FcOpField: printf ("%s", expr->u.field); break;
+    case FcOpField: printf ("%s", FcObjectName(expr->u.object)); break;
     case FcOpConst: printf ("%s", expr->u.constant); break;
     case FcOpQuest:
        FcExprPrint (expr->u.tree.left);
@@ -189,6 +245,7 @@ FcExprPrint (const FcExpr *expr)
     case FcOpMore:
     case FcOpMoreEqual:
     case FcOpContains:
+    case FcOpListing:
     case FcOpNotContains:
     case FcOpPlus:
     case FcOpMinus:
@@ -213,6 +270,7 @@ FcExprPrint (const FcExpr *expr)
        case FcOpMore: printf ("More"); break;
        case FcOpMoreEqual: printf ("MoreEqual"); break;
        case FcOpContains: printf ("Contains"); break;
+       case FcOpListing: printf ("Listing"); break;
        case FcOpNotContains: printf ("NotContains"); break;
        case FcOpPlus: printf ("Plus"); break;
        case FcOpMinus: printf ("Minus"); break;
@@ -228,6 +286,22 @@ FcExprPrint (const FcExpr *expr)
        printf ("Not ");
        FcExprPrint (expr->u.tree.left);
        break;
+    case FcOpFloor:
+       printf ("Floor ");
+       FcExprPrint (expr->u.tree.left);
+       break;
+    case FcOpCeil:
+       printf ("Ceil ");
+       FcExprPrint (expr->u.tree.left);
+       break;
+    case FcOpRound:
+       printf ("Round ");
+       FcExprPrint (expr->u.tree.left);
+       break;
+    case FcOpTrunc:
+       printf ("Trunc ");
+       FcExprPrint (expr->u.tree.left);
+       break;
     case FcOpInvalid: printf ("Invalid"); break;
     }
 }
@@ -242,6 +316,9 @@ FcTestPrint (const FcTest *test)
     case FcMatchFont:
        printf ("font ");
        break;
+    case FcMatchScan:
+       printf ("scan ");
+       break;
     }
     switch (test->qual) {
     case FcQualAny:
@@ -257,7 +334,7 @@ FcTestPrint (const FcTest *test)
        printf ("not_first ");
        break;
     }
-    printf ("%s ", test->field);
+    printf ("%s ", FcObjectName (test->object));
     FcOpPrint (test->op);
     printf (" ");
     FcExprPrint (test->expr);
@@ -267,7 +344,7 @@ FcTestPrint (const FcTest *test)
 void
 FcEditPrint (const FcEdit *edit)
 {
-    printf ("Edit %s ", edit->field);
+    printf ("Edit %s ", FcObjectName (edit->object));
     FcOpPrint (edit->op);
     printf (" ");
     FcExprPrint (edit->expr);
@@ -278,7 +355,7 @@ FcSubstPrint (const FcSubst *subst)
 {
     FcEdit     *e;
     FcTest     *t;
-    
+
     printf ("match\n");
     for (t = subst->test; t; t = t->next)
     {
@@ -308,25 +385,22 @@ FcFontSetPrint (const FcFontSet *s)
     }
 }
 
-int
-FcDebug (void)
+int FcDebugVal;
+
+void
+FcInitDebug (void)
 {
-    static int  initialized;
-    static int  debug;
+    char    *e;
 
-    if (!initialized)
+    e = getenv ("FC_DEBUG");
+    if (e)
     {
-       char    *e;
-
-       initialized = 1;
-       e = getenv ("FC_DEBUG");
-       if (e)
-       {
-           printf ("FC_DEBUG=%s\n", e);
-           debug = atoi (e);
-           if (debug < 0)
-               debug = 0;
-       }
+        printf ("FC_DEBUG=%s\n", e);
+        FcDebugVal = atoi (e);
+        if (FcDebugVal < 0)
+           FcDebugVal = 0;
     }
-    return debug;
 }
+#define __fcdbg__
+#include "fcaliastail.h"
+#undef __fcdbg__