aboutsummaryrefslogtreecommitdiff
path: root/libXft/src/xftfont.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-01-19 10:14:56 +0000
committermarha <marha@users.sourceforge.net>2011-01-19 10:14:56 +0000
commite75ba771a1b0e80ef8413d368213a942455a7e2e (patch)
treeeda0e3b99b6ef7da7474c3b5aad38eb322372d22 /libXft/src/xftfont.c
parent36c829ccf632f2f3adc6d13313406d6383b33993 (diff)
parent6e3cfc5bc8ca969856e4d56dec01870df709d75a (diff)
downloadvcxsrv-e75ba771a1b0e80ef8413d368213a942455a7e2e.tar.gz
vcxsrv-e75ba771a1b0e80ef8413d368213a942455a7e2e.tar.bz2
vcxsrv-e75ba771a1b0e80ef8413d368213a942455a7e2e.zip
svn merge ^/branches/released .
Diffstat (limited to 'libXft/src/xftfont.c')
-rw-r--r--libXft/src/xftfont.c206
1 files changed, 206 insertions, 0 deletions
diff --git a/libXft/src/xftfont.c b/libXft/src/xftfont.c
new file mode 100644
index 000000000..70ab5d8bb
--- /dev/null
+++ b/libXft/src/xftfont.c
@@ -0,0 +1,206 @@
+/*
+ * 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
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes 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,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 "xftint.h"
+
+_X_EXPORT FcPattern *
+XftFontMatch (Display *dpy,
+ int screen,
+ _Xconst FcPattern *pattern,
+ FcResult *result)
+{
+ FcPattern *new;
+ FcPattern *match;
+
+ if (!XftInit (NULL))
+ return NULL;
+
+ new = FcPatternDuplicate (pattern);
+ if (!new)
+ return NULL;
+
+ if (XftDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch pattern ");
+ FcPatternPrint (new);
+ }
+ FcConfigSubstitute (NULL, new, FcMatchPattern);
+ if (XftDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch after FcConfig substitutions ");
+ FcPatternPrint (new);
+ }
+ XftDefaultSubstitute (dpy, screen, new);
+ if (XftDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch after X resource substitutions ");
+ FcPatternPrint (new);
+ }
+
+ match = FcFontMatch (NULL, new, result);
+ if (XftDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch result ");
+ FcPatternPrint (match);
+ }
+ FcPatternDestroy (new);
+ return match;
+}
+
+_X_EXPORT XftFont *
+XftFontOpen (Display *dpy, int screen, ...)
+{
+ va_list va;
+ FcPattern *pat;
+ FcPattern *match;
+ FcResult result;
+ XftFont *font;
+
+ va_start (va, screen);
+ pat = FcPatternVaBuild (NULL, va);
+ va_end (va);
+ if (!pat)
+ {
+ if (XftDebug () & XFT_DBG_OPEN)
+ printf ("XftFontOpen: Invalid pattern argument\n");
+ return NULL;
+ }
+ match = XftFontMatch (dpy, screen, pat, &result);
+ if (XftDebug () & XFT_DBG_OPEN)
+ {
+ printf ("Pattern ");
+ FcPatternPrint (pat);
+ if (match)
+ {
+ printf ("Match ");
+ FcPatternPrint (match);
+ }
+ else
+ printf ("No Match\n");
+ }
+ FcPatternDestroy (pat);
+ if (!match)
+ return NULL;
+
+ font = XftFontOpenPattern (dpy, match);
+ if (!font)
+ {
+ if (XftDebug () & XFT_DBG_OPEN)
+ printf ("No Font\n");
+ FcPatternDestroy (match);
+ }
+
+ return font;
+}
+
+_X_EXPORT XftFont *
+XftFontOpenName (Display *dpy, int screen, const char *name)
+{
+ FcPattern *pat;
+ FcPattern *match;
+ FcResult result;
+ XftFont *font;
+
+ pat = FcNameParse ((FcChar8 *) name);
+ if (XftDebug () & XFT_DBG_OPEN)
+ {
+ printf ("XftFontOpenName \"%s\": ", name);
+ if (pat)
+ FcPatternPrint (pat);
+ else
+ printf ("Invalid name\n");
+ }
+
+ if (!pat)
+ return NULL;
+ match = XftFontMatch (dpy, screen, pat, &result);
+ if (XftDebug () & XFT_DBG_OPEN)
+ {
+ if (match)
+ {
+ printf ("Match ");
+ FcPatternPrint (match);
+ }
+ else
+ printf ("No Match\n");
+ }
+ FcPatternDestroy (pat);
+ if (!match)
+ return NULL;
+
+ font = XftFontOpenPattern (dpy, match);
+ if (!font)
+ {
+ if (XftDebug () & XFT_DBG_OPEN)
+ printf ("No Font\n");
+ FcPatternDestroy (match);
+ }
+
+ return font;
+}
+
+_X_EXPORT XftFont *
+XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd)
+{
+ FcPattern *pat;
+ FcPattern *match;
+ FcResult result;
+ XftFont *font;
+
+ pat = XftXlfdParse (xlfd, FcFalse, FcFalse);
+ if (XftDebug () & XFT_DBG_OPEN)
+ {
+ printf ("XftFontOpenXlfd \"%s\": ", xlfd);
+ if (pat)
+ printf ("Invalid xlfd\n");
+ else
+ FcPatternPrint (pat);
+ }
+
+ if (!pat)
+ return NULL;
+ match = XftFontMatch (dpy, screen, pat, &result);
+ if (XftDebug () & XFT_DBG_OPEN)
+ {
+ if (match)
+ {
+ printf ("Match ");
+ FcPatternPrint (match);
+ }
+ else
+ printf ("No Match\n");
+ }
+ FcPatternDestroy (pat);
+ if (!match)
+ return NULL;
+
+ font = XftFontOpenPattern (dpy, match);
+ if (!font)
+ {
+ if (XftDebug () & XFT_DBG_OPEN)
+ printf ("No Font\n");
+ FcPatternDestroy (match);
+ }
+
+ return font;
+}
+