/* xscreensaver, Copyright (c) 2014-2015 Jamie Zawinski <jwz@jwz.org>
* 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. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
/* Compatibility layer using XDrawString, XDrawString16() or Xutf8DrawString().
This layer is used by X11 systems without Xft, and by MacOS / iOS.
#ifndef __XSCREENSAVER_XFT_H__
#define __XSCREENSAVER_XFT_H__
/* The XGlyphInfo field names and values are, of course, arbitrarily
different from XCharStruct for no sensible reason. These macros
# define XGlyphInfo_to_XCharStruct(G,C) do { \
(C).rbearing = (G).width - (G).x; \
(C).descent = (G).height - (G).y; \
# define XCharStruct_to_XGlyphInfo(C,G) do { \
(G).width = (C).rbearing - (C).lbearing; \
(G).height = (C).ascent + (C).descent; \
/* Xutf8TextExtents returns a bounding box in an XRectangle, which
conveniently interprets everything in the opposite direction
# define XCharStruct_to_XmbRectangle(C,R) do { \
(R).width = (C).rbearing - (C).lbearing; \
(R).height = (C).ascent + (C).descent; \
# define XmbRectangle_to_XCharStruct(R,C,ADV) do { \
(C).rbearing = (R).width + (R).x; \
(C).descent = (R).height + (R).y; \
# include <X11/Xft/Xft.h>
# else /* !HAVE_XFT -- the rest of the file */
#elif defined(HAVE_ANDROID)
/* This doesn't seem to work right under X11. See comment in xft.c. */
# undef HAVE_XUTF8DRAWSTRING
typedef struct _XGlyphInfo
{
unsigned short width
, height
; /* bounding box of the ink */
short x
, y
; /* distance from upper left of bbox to glyph origin. */
short xOff
, yOff
; /* distance from glyph origin to next origin. */
typedef struct _XftFont
{
# ifdef HAVE_XUTF8DRAWSTRING
typedef struct _XftColor
{
typedef struct _XftDraw XftDraw
;
typedef unsigned char FcChar8
;
XftFont
*XftFontOpenXlfd (Display
*dpy
, int screen
, _Xconst
char *xlfd
);
#define XftFontOpenName XftFontOpenXlfd
void XftFontClose (Display
*dpy
, XftFont
*font
);
Bool
XftColorAllocName (Display
*dpy
,
Bool
XftColorAllocValue (Display
*dpy
,
_Xconst XRenderColor
*color
,
void XftColorFree (Display
*dpy
,
XftDraw
*XftDrawCreate (Display
*dpy
,
void XftDrawDestroy (XftDraw
*draw
);
XftTextExtentsUtf8 (Display
*dpy
,
XftDrawStringUtf8 (XftDraw
*draw
,
#endif /* __XSCREENSAVER_XFT_H__ */