scx/c/libs/xft.h

147 lines
4.8 KiB
C
Raw Normal View History

#include <X11/Xft/Xft.h>
#include <scheme48.h>
#include <xlib.h>
#include <xrender.h>
#ifndef XFT_VERSION
#define XFT_VERSION 1
#endif
#define SCX_XFT_FAMILY 0 /* String */
#define SCX_XFT_STYLE 1 /* String */
#define SCX_XFT_SLANT 2 /* Int */
#define SCX_XFT_WEIGHT 3 /* Int */
#define SCX_XFT_SIZE 4 /* Double */
#define SCX_XFT_PIXEL_SIZE 5 /* Double */
#define SCX_XFT_ENCODING 6 /* String */
#define SCX_XFT_SPACING 7 /* Int */
#define SCX_XFT_FOUNDRY 8 /* String */
#define SCX_XFT_CORE 9 /* Bool */
#define SCX_XFT_ANTIALIAS 10 /* Bool */
#define SCX_XFT_XLFD 11 /* String */
#define SCX_XFT_FILE 12 /* String */
#define SCX_XFT_INDEX 13 /* Int */
#define SCX_XFT_RASTERIZER 14 /* String */
#define SCX_XFT_OUTLINE 15 /* Bool */
#define SCX_XFT_SCALABLE 16 /* Bool */
#define SCX_XFT_RGBA 17 /* Int */
#define SCX_XFT_SCALE 18 /* double */
#define SCX_XFT_RENDER 19 /* Bool */
#define SCX_XFT_MINSPACE 20 /* Bool use minimum line spacing */
#define SCX_XFT_DPI 21 /* double */
#define SCX_XFT_CHAR_WIDTH 22 /* Int */
#define SCX_XFT_CHAR_HEIGHT 23 /* Int */
enum xft_pattern_get_return_type {
SCX_XFT_INVALID,
SCX_XFT_UNIMPLEMENTED,
SCX_XFT_STRING,
SCX_XFT_DOUBLE,
SCX_XFT_INT,
SCX_XFT_BOOL
};
struct xft_pattern_property {
int scx_id;
char *name;
enum xft_pattern_get_return_type type;
};
static struct xft_pattern_property xft_pattern_property_tbl [] = {
{SCX_XFT_FAMILY, XFT_FAMILY, SCX_XFT_STRING},
{SCX_XFT_STYLE, XFT_STYLE, SCX_XFT_STRING},
{SCX_XFT_SLANT, XFT_SLANT, SCX_XFT_INT},
{SCX_XFT_WEIGHT, XFT_WEIGHT, SCX_XFT_INT},
{SCX_XFT_SIZE, XFT_SIZE, SCX_XFT_DOUBLE},
{SCX_XFT_PIXEL_SIZE, XFT_PIXEL_SIZE, SCX_XFT_DOUBLE},
#if XFT_VERSION < 2
{SCX_XFT_ENCODING, XFT_ENCODING, SCX_XFT_STRING},
#else
{SCX_XFT_ENCODING, XFT_ENCODING, SCX_XFT_UNIMPLEMENTED},
#endif
{SCX_XFT_SPACING, XFT_SPACING, SCX_XFT_INT},
{SCX_XFT_FOUNDRY, XFT_FOUNDRY, SCX_XFT_STRING},
#if XFT_VERSION < 2
{SCX_XFT_CORE, XFT_CORE, SCX_XFT_BOOL},
#else
{SCX_XFT_CORE, XFT_CORE, SCX_XFT_UNIMPLEMENTED},
#endif
{SCX_XFT_ANTIALIAS, XFT_ANTIALIAS, SCX_XFT_BOOL},
{SCX_XFT_XLFD, XFT_XLFD, SCX_XFT_STRING},
{SCX_XFT_FILE, XFT_FILE, SCX_XFT_STRING},
{SCX_XFT_INDEX, XFT_INDEX, SCX_XFT_INT},
{SCX_XFT_RASTERIZER, XFT_RASTERIZER, SCX_XFT_STRING},
{SCX_XFT_OUTLINE, XFT_OUTLINE, SCX_XFT_STRING},
{SCX_XFT_SCALABLE, XFT_SCALABLE, SCX_XFT_BOOL},
{SCX_XFT_RGBA, XFT_RGBA, SCX_XFT_INT},
{SCX_XFT_SCALE, XFT_SCALE, SCX_XFT_DOUBLE},
{SCX_XFT_RENDER, XFT_RENDER, SCX_XFT_BOOL},
{SCX_XFT_MINSPACE, XFT_MINSPACE, SCX_XFT_BOOL},
{SCX_XFT_DPI, XFT_DPI, SCX_XFT_DOUBLE},
#if XFT_VERSION < 2
{SCX_XFT_CHAR_WIDTH, XFT_CHAR_WIDTH, SCX_XFT_INT},
{SCX_XFT_CHAR_HEIGHT, XFT_CHAR_HEIGHT, SCX_XFT_INT},
#else
{SCX_XFT_CHAR_WIDTH, XFT_CHAR_WIDTH, SCX_XFT_UNIMPLEMENTED},
{SCX_XFT_CHAR_HEIGHT, XFT_CHAR_HEIGHT, SCX_XFT_UNIMPLEMENTED},
#endif
{NULL, NULL, SCX_XFT_INVALID}
};
/* scheme record types */
static s48_value scx_xftpattern_record_type = S48_UNSPECIFIC;
static s48_value scx_xftfont_record_type = S48_UNSPECIFIC;
static s48_value scx_xftdraw_record_type = S48_UNSPECIFIC;
static s48_value scx_xftcolor_record_type = S48_UNSPECIFIC;
static s48_value scx_xftobjectset_record_type = S48_UNSPECIFIC;
static s48_value scx_xftfontset_record_type = S48_UNSPECIFIC;
#define XFT_GC_PROTECT_IMPORT_BINDING(CN, SN) \
S48_GC_PROTECT_GLOBAL(CN); \
CN = s48_get_imported_binding("SN");
/* C values exported to scheme */
static s48_value scx_XftResultMatch = S48_UNSPECIFIC;
static s48_value scx_XftResultNoMatch = S48_UNSPECIFIC;
static s48_value scx_XftResultTypeMismatch = S48_UNSPECIFIC;
static s48_value scx_XftResultNoId = S48_UNSPECIFIC;
#define XFT_REC_ACCESSOR_MAKER(FN, TN, RN) \
s48_value FN(TN *p) \
{ \
s48_value xftrec = S48_UNSPECIFIC; \
S48_DECLARE_GC_PROTECT(1); \
\
S48_GC_PROTECT_1(xftrec); \
xftrec = s48_make_record(RN); \
S48_RECORD_SET(xftrec, 0, s48_enter_integer((long) p)); \
S48_GC_UNPROTECT(); \
return xftrec; \
}
#define GC_PROTECT_ENTER_INT(schemeval, i) \
S48_GC_PROTECT_GLOBAL(schemeval); \
schemeval = s48_enter_integer(i);
/* function prototypes */
s48_value scx_enter_xftpattern(XftPattern *p);
s48_value scx_extract_xftpattern(s48_value s);
s48_value scx_enter_xftfont(XftFont *f);
s48_value scx_extract_xftfont(s48_value s);
s48_value scx_enter_xftdraw(XftDraw *d);
s48_value scx_extract_xftdraw(s48_value s);
s48_value scx_enter_xftcolor(XftColor *c);
s48_value scx_extract_xftcolor(s48_value s);
s48_value scx_enter_xftobjectset(XftObjectSet *os);
s48_value scx_extract_xftobjectset(s48_value s);
s48_value scx_enter_xftfontset(XftFontSet *fs);
s48_value scx_extract_xftfontset(s48_value s);
struct xft_pattern_property* lookup_pattern_property_by_id(int id);