1 #include <fontconfig/fontconfig.h>
5 test (const FcChar8 *query, const FcPattern *expect)
11 pat = FcNameParse (query);
15 if (!FcPatternEqual (pat, expect))
19 FcPatternDestroy (pat);
24 #define BEGIN(x) (x) = FcPatternCreate (); c++;
25 #define END(x) FcPatternDestroy (x); (x) = NULL
33 FcPatternAddString (expect, FC_FAMILY, (const FcChar8 *)"sans-serif");
34 if ((ret = test ((const FcChar8 *)"sans\\-serif", expect)) != 0)
38 FcPatternAddString (expect, FC_FAMILY, (const FcChar8 *)"Foo");
39 FcPatternAddInteger (expect, FC_SIZE, 10);
40 if ((ret = test ((const FcChar8 *)"Foo-10", expect)) != 0)
44 FcPatternAddString (expect, FC_FAMILY, (const FcChar8 *)"Foo");
45 FcPatternAddString (expect, FC_FAMILY, (const FcChar8 *)"Bar");
46 FcPatternAddInteger (expect, FC_SIZE, 10);
47 if ((ret = test ((const FcChar8 *)"Foo,Bar-10", expect)) != 0)
51 FcPatternAddString (expect, FC_FAMILY, (const FcChar8 *)"Foo");
52 FcPatternAddInteger (expect, FC_WEIGHT, FC_WEIGHT_MEDIUM);
53 if ((ret = test ((const FcChar8 *)"Foo:weight=medium", expect)) != 0)
57 FcPatternAddString (expect, FC_FAMILY, (const FcChar8 *)"Foo");
58 FcPatternAddInteger (expect, FC_WEIGHT, FC_WEIGHT_MEDIUM);
59 if ((ret = test ((const FcChar8 *)"Foo:weight_medium", expect)) != 0)
63 FcPatternAddInteger (expect, FC_WEIGHT, FC_WEIGHT_MEDIUM);
64 if ((ret = test ((const FcChar8 *)":medium", expect)) != 0)
68 FcPatternAddInteger (expect, FC_WIDTH, FC_WIDTH_NORMAL);
69 if ((ret = test ((const FcChar8 *)":normal", expect)) != 0)
73 FcPatternAddInteger (expect, FC_WIDTH, FC_WIDTH_NORMAL);
74 if ((ret = test ((const FcChar8 *)":normal", expect)) != 0)
78 FcRange *r = FcRangeCreateDouble (FC_WEIGHT_MEDIUM, FC_WEIGHT_BOLD);
79 FcPatternAddRange (expect, FC_WEIGHT, r);
81 if ((ret = test ((const FcChar8 *)":weight=[medium bold]", expect)) != 0)
87 FcPatternDestroy (expect);
89 return ret == 0 ? 0 : (c - 1) * 2 + ret;