1 /* xscreensaver, Copyright (c) 2014 Jamie Zawinski <jwz@jwz.org>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
12 /* Compatibility layer using XDrawString, XDrawString16() or Xutf8DrawString().
13 This layer is used by X11 systems without Xft, and by MacOS / iOS.
16 #ifndef __XSCREENSAVER_XFT_H__
17 #define __XSCREENSAVER_XFT_H__
21 # include <X11/Xft/Xft.h>
23 # else /* !HAVE_XFT -- whole file */
27 #elif defined(HAVE_ANDROID)
30 # include <X11/Xlib.h>
33 /* This doesn't seem to work right. See comment in xft.c. */
34 # undef HAVE_XUTF8DRAWSTRING
38 # define _Xconst const
41 typedef struct _XGlyphInfo {
42 unsigned short width, height; /* bounding box of the ink */
43 short x, y; /* distance from upper left of bbox to glyph origin. */
44 short xOff, yOff; /* distance from glyph origin to next origin. */
46 /* These field names and values are, of course, arbitrarily different
47 from XCharStruct for no sensible reason. Here's a translation key
50 XGlyphInfo from XCharStruct:
56 g.width = c.rbearing - c.lbearing;
57 g.height = c.ascent + c.descent;
59 XCharStruct from XGlyphInfo:
62 c.rbearing = g.width - g.x;
64 c.descent = g.height - g.y;
71 typedef struct _XftFont {
73 # ifdef HAVE_XUTF8DRAWSTRING
89 typedef struct _XftColor {
94 typedef struct _XftDraw XftDraw;
96 typedef unsigned char FcChar8;
99 XftFont *XftFontOpenXlfd (Display *dpy, int screen, _Xconst char *xlfd);
101 void XftFontClose (Display *dpy, XftFont *font);
103 Bool XftColorAllocName (Display *dpy,
104 _Xconst Visual *visual,
109 Bool XftColorAllocValue (Display *dpy,
110 _Xconst Visual *visual,
112 _Xconst XRenderColor *color,
115 void XftColorFree (Display *dpy,
120 XftDraw *XftDrawCreate (Display *dpy,
125 void XftDrawDestroy (XftDraw *draw);
128 XftTextExtentsUtf8 (Display *dpy,
130 _Xconst FcChar8 *string,
132 XGlyphInfo *extents);
135 XftDrawStringUtf8 (XftDraw *draw,
136 _Xconst XftColor *color,
140 _Xconst FcChar8 *string,
143 # endif /* !HAVE_XFT */
145 #endif /* __XSCREENSAVER_XFT_H__ */