2 * Copyright © 2000 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Keith Packard not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Keith Packard makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
26 XftFontMatch (Display *dpy,
28 _Xconst FcPattern *pattern,
37 new = FcPatternDuplicate (pattern);
41 if (XftDebug () & XFT_DBG_OPENV)
43 printf ("XftFontMatch pattern ");
46 FcConfigSubstitute (NULL, new, FcMatchPattern);
47 if (XftDebug () & XFT_DBG_OPENV)
49 printf ("XftFontMatch after FcConfig substitutions ");
52 XftDefaultSubstitute (dpy, screen, new);
53 if (XftDebug () & XFT_DBG_OPENV)
55 printf ("XftFontMatch after X resource substitutions ");
59 match = FcFontMatch (NULL, new, result);
60 if (XftDebug () & XFT_DBG_OPENV)
62 printf ("XftFontMatch result ");
63 FcPatternPrint (match);
65 FcPatternDestroy (new);
70 XftFontOpen (Display *dpy, int screen, ...)
78 va_start (va, screen);
79 pat = FcPatternVaBuild (NULL, va);
83 if (XftDebug () & XFT_DBG_OPEN)
84 printf ("XftFontOpen: Invalid pattern argument\n");
87 match = XftFontMatch (dpy, screen, pat, &result);
88 if (XftDebug () & XFT_DBG_OPEN)
95 FcPatternPrint (match);
98 printf ("No Match\n");
100 FcPatternDestroy (pat);
104 font = XftFontOpenPattern (dpy, match);
107 if (XftDebug () & XFT_DBG_OPEN)
108 printf ("No Font\n");
109 FcPatternDestroy (match);
116 XftFontOpenName (Display *dpy, int screen, const char *name)
123 pat = FcNameParse ((FcChar8 *) name);
124 if (XftDebug () & XFT_DBG_OPEN)
126 printf ("XftFontOpenName \"%s\": ", name);
128 FcPatternPrint (pat);
130 printf ("Invalid name\n");
135 match = XftFontMatch (dpy, screen, pat, &result);
136 if (XftDebug () & XFT_DBG_OPEN)
141 FcPatternPrint (match);
144 printf ("No Match\n");
146 FcPatternDestroy (pat);
150 font = XftFontOpenPattern (dpy, match);
153 if (XftDebug () & XFT_DBG_OPEN)
154 printf ("No Font\n");
155 FcPatternDestroy (match);
162 XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd)
169 pat = XftXlfdParse (xlfd, FcFalse, FcFalse);
170 if (XftDebug () & XFT_DBG_OPEN)
172 printf ("XftFontOpenXlfd \"%s\": ", xlfd);
174 printf ("Invalid xlfd\n");
176 FcPatternPrint (pat);
181 match = XftFontMatch (dpy, screen, pat, &result);
182 if (XftDebug () & XFT_DBG_OPEN)
187 FcPatternPrint (match);
190 printf ("No Match\n");
192 FcPatternDestroy (pat);
196 font = XftFontOpenPattern (dpy, match);
199 if (XftDebug () & XFT_DBG_OPEN)
200 printf ("No Font\n");
201 FcPatternDestroy (match);