summaryrefslogtreecommitdiff
path: root/xc/lib/Xft
diff options
context:
space:
mode:
Diffstat (limited to 'xc/lib/Xft')
-rw-r--r--xc/lib/Xft/Imakefile19
-rw-r--r--xc/lib/Xft/Xft-def.cpp6
-rw-r--r--xc/lib/Xft/Xft.h36
-rw-r--r--xc/lib/Xft/XftFreetype.h9
-rw-r--r--xc/lib/Xft/xftcfg.c45
-rw-r--r--xc/lib/Xft/xftdbg.c11
-rw-r--r--xc/lib/Xft/xftdraw.c72
-rw-r--r--xc/lib/Xft/xftextent.c3
-rw-r--r--xc/lib/Xft/xftfreetype.c65
-rw-r--r--xc/lib/Xft/xftglyphs.c105
-rw-r--r--xc/lib/Xft/xftgram.y43
-rw-r--r--xc/lib/Xft/xftint.h42
-rw-r--r--xc/lib/Xft/xftlex.l4
-rw-r--r--xc/lib/Xft/xftmatch.c4
-rw-r--r--xc/lib/Xft/xftmatrix.c104
-rw-r--r--xc/lib/Xft/xftname.c16
-rw-r--r--xc/lib/Xft/xftpat.c40
-rw-r--r--xc/lib/Xft/xftstr.c5
18 files changed, 528 insertions, 101 deletions
diff --git a/xc/lib/Xft/Imakefile b/xc/lib/Xft/Imakefile
index 68135d7aa..9b62f6212 100644
--- a/xc/lib/Xft/Imakefile
+++ b/xc/lib/Xft/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/Xft/Imakefile,v 1.10 2001/02/09 00:35:03 keithp Exp $
+XCOMM $XFree86: xc/lib/Xft/Imakefile,v 1.12 2001/03/30 18:50:18 keithp Exp $
#define DoNormalLib NormalLibXft
#define DoSharedLib SharedLibXft
@@ -29,9 +29,14 @@ TYPE1DIR=XftType1Dir
CONFIG_DEFS=-DXFT_TYPE1_DIR=\"$(TYPE1DIR)\"
INCLUDES=$(FREETYPE2INCLUDES)
DEFINES=-DXFT_DEFAULT_PATH=\"$(XFTCONFIG)\" $(FREETYPE2DEFINES) $(RENDERDEFINES)
-REQUIREDLIBS=$(LDPRELIBS) $(XRENDERLIB) $(XLIB) $(FREETYPE2LIB)
-#if HasFreetype2
+#if UseFreetype2
+FREETYPE2REQLIB = $(FREETYPE2LIB)
+#endif
+
+REQUIREDLIBS=$(LDPRELIBS) $(XRENDERLIB) $(XLIB) $(FREETYPE2REQLIB)
+
+#if UseFreetype2
FT_HEADERS = XftFreetype.h
FT_SRCS = xftcache.c xftdir.c xftfreetype.c xftglyphs.c xftrender.c
FT_OBJS = xftcache.o xftdir.o xftfreetype.o xftglyphs.o xftrender.o
@@ -41,13 +46,13 @@ HEADERS = Xft.h $(FT_HEADERS)
SRCS = xftcfg.c xftcolor.c xftcore.c xftdbg.c xftdpy.c \
xftdraw.c xftextent.c xftfont.c xftfs.c xftgram.c \
- xftinit.c xftlex.c xftlist.c xftmatch.c xftname.c \
- xftpat.c xftstr.c xftxlfd.c $(FT_SRCS)
+ xftinit.c xftlex.c xftlist.c xftmatch.c xftmatrix.c \
+ xftname.c xftpat.c xftstr.c xftxlfd.c $(FT_SRCS)
OBJS = xftcfg.o xftcolor.o xftcore.o xftdbg.o xftdpy.o \
xftdraw.o xftextent.o xftfont.o xftfs.o xftgram.o \
- xftinit.o xftlex.o xftlist.o xftmatch.o xftname.o \
- xftpat.o xftstr.o xftxlfd.o $(FT_OBJS)
+ xftinit.o xftlex.o xftlist.o xftmatch.o xftmatrix.o \
+ xftname.o xftpat.o xftstr.o xftxlfd.o $(FT_OBJS)
#include <Library.tmpl>
diff --git a/xc/lib/Xft/Xft-def.cpp b/xc/lib/Xft/Xft-def.cpp
index 0f27d645e..3d8602021 100644
--- a/xc/lib/Xft/Xft-def.cpp
+++ b/xc/lib/Xft/Xft-def.cpp
@@ -141,6 +141,10 @@ XftCoreAddFonts
XftCoreClose
XftCoreOpen
XftXlfdParse
+XftInitFtLibrary
+XftConfigDirs
+XftDirScan
+XftDirSave
-/* $XFree86: xc/lib/Xft/Xft-def.cpp,v 1.1 2001/02/13 19:19:12 dawes Exp $ */
+/* $XFree86: xc/lib/Xft/Xft-def.cpp,v 1.2 2001/04/05 19:29:38 dawes Exp $ */
diff --git a/xc/lib/Xft/Xft.h b/xc/lib/Xft/Xft.h
index 6304c633b..3e900de90 100644
--- a/xc/lib/Xft/Xft.h
+++ b/xc/lib/Xft/Xft.h
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/Xft.h,v 1.17 2001/01/26 20:51:14 keithp Exp $
+ * $XFree86: xc/lib/Xft/Xft.h,v 1.18 2001/03/30 18:50:18 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -62,6 +62,7 @@ typedef unsigned int XftChar32;
/* specific to FreeType rasterizer */
#define XFT_CHAR_WIDTH "charwidth" /* Int */
#define XFT_CHAR_HEIGHT "charheight"/* Int */
+#define XFT_MATRIX "matrix" /* XftMatrix */
#define XFT_WEIGHT_LIGHT 0
#define XFT_WEIGHT_MEDIUM 100
@@ -88,9 +89,17 @@ typedef enum _XftType {
XftTypeInteger,
XftTypeDouble,
XftTypeString,
- XftTypeBool
+ XftTypeBool,
+ XftTypeMatrix
} XftType;
+typedef struct _XftMatrix {
+ double xx, xy, yx, yy;
+} XftMatrix;
+
+#define XftMatrixInit(m) ((m)->xx = (m)->yy = 1, \
+ (m)->xy = (m)->yx = 0)
+
typedef enum _XftResult {
XftResultMatch, XftResultNoMatch, XftResultTypeMismatch, XftResultNoId
} XftResult;
@@ -102,6 +111,7 @@ typedef struct _XftValue {
int i;
Bool b;
double d;
+ XftMatrix *m;
} u;
} XftValue;
@@ -395,6 +405,22 @@ XftFontSetMatch (XftFontSet **sets,
XftPattern *p,
XftResult *result);
+/* xftmatrix.c */
+int
+XftMatrixEqual (const XftMatrix *mat1, const XftMatrix *mat2);
+
+void
+XftMatrixMultiply (XftMatrix *result, XftMatrix *a, XftMatrix *b);
+
+void
+XftMatrixRotate (XftMatrix *m, double c, double s);
+
+void
+XftMatrixScale (XftMatrix *m, double sx, double sy);
+
+void
+XftMatrixShear (XftMatrix *m, double sh, double sv);
+
/* xftname.c */
XftPattern *
XftNameParse (const char *name);
@@ -440,6 +466,9 @@ Bool
XftPatternAddString (XftPattern *p, const char *object, const char *s);
Bool
+XftPatternAddMatrix (XftPattern *p, const char *object, const XftMatrix *s);
+
+Bool
XftPatternAddBool (XftPattern *p, const char *object, Bool b);
XftResult
@@ -452,6 +481,9 @@ XftResult
XftPatternGetString (XftPattern *p, const char *object, int n, char **s);
XftResult
+XftPatternGetMatrix (XftPattern *p, const char *object, int n, XftMatrix **s);
+
+XftResult
XftPatternGetBool (XftPattern *p, const char *object, int n, Bool *b);
XftPattern *
diff --git a/xc/lib/Xft/XftFreetype.h b/xc/lib/Xft/XftFreetype.h
index a8b6fb360..38635a110 100644
--- a/xc/lib/Xft/XftFreetype.h
+++ b/xc/lib/Xft/XftFreetype.h
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/XftFreetype.h,v 1.12 2001/01/02 02:46:50 keithp Exp $
+ * $XFree86: xc/lib/Xft/XftFreetype.h,v 1.15 2001/03/31 23:07:29 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -50,6 +50,8 @@ struct _XftFontStruct {
XRenderPictFormat *format;
XGlyphInfo **realized;
int nrealized;
+ Bool transform;
+ FT_Matrix matrix;
};
_XFUNCPROTOBEGIN
@@ -66,7 +68,7 @@ XftPattern *
XftFreeTypeQuery (const char *file, int id, int *count);
Bool
-XftFreeTypeSetFace (FT_Face face, FT_F26Dot6 size, int charmap);
+XftFreeTypeSetFace (FT_Face face, FT_F26Dot6 size, int charmap, FT_Matrix *matrix);
XftFontStruct *
XftFreeTypeOpen (Display *dpy, XftPattern *pattern);
@@ -157,9 +159,6 @@ XftRenderExtentsUtf8 (Display *dpy,
int len,
XGlyphInfo *extents);
-XftFontStruct *
-XftFreeTypeGet (XftFont *font);
-
_XFUNCPROTOEND
#endif /* _XFTFREETYPE_H_ */
diff --git a/xc/lib/Xft/xftcfg.c b/xc/lib/Xft/xftcfg.c
index 972d2502c..8ddbc463c 100644
--- a/xc/lib/Xft/xftcfg.c
+++ b/xc/lib/Xft/xftcfg.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/xftcfg.c,v 1.8 2001/01/02 02:46:51 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftcfg.c,v 1.9 2001/03/31 01:57:20 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -39,7 +39,7 @@ char XftConfigDefaultCache[] = "~/.xftcache";
char *XftConfigCache = 0;
static XftSubst *XftSubsts;
-/* #define XFT_DEBUG_EDIT */
+/* #define XFT_DEBUG_EDIT */
Bool
XftConfigAddDir (char *d)
@@ -154,14 +154,21 @@ typedef struct _XftSubState {
XftValueList *value;
} XftSubState;
+static XftMatrix XftIdentityMatrix = { 1, 0, 0, 1 };
+
static XftValue
-_XftConfigPromote (XftValue v)
+_XftConfigPromote (XftValue v, XftValue u)
{
if (v.type == XftTypeInteger)
{
v.type = XftTypeDouble;
v.u.d = (double) v.u.i;
}
+ if (v.type == XftTypeVoid && u.type == XftTypeMatrix)
+ {
+ v.u.m = &XftIdentityMatrix;
+ v.type = XftTypeMatrix;
+ }
return v;
}
@@ -174,8 +181,8 @@ _XftConfigCompareValue (XftValue m,
if (m.type == XftTypeVoid)
return True;
- m = _XftConfigPromote (m);
- v = _XftConfigPromote (v);
+ m = _XftConfigPromote (m, v);
+ v = _XftConfigPromote (v, m);
if (m.type == v.type)
{
ret = False;
@@ -286,6 +293,10 @@ _XftConfigEvaluate (XftPattern *p, XftExpr *e)
v.type = XftTypeString;
v.u.s = e->u.sval;
break;
+ case XftOpMatrix:
+ v.type = XftTypeMatrix;
+ v.u.m = e->u.mval;
+ break;
case XftOpBool:
v.type = XftTypeBool;
v.u.b = e->u.bval;
@@ -321,8 +332,8 @@ _XftConfigEvaluate (XftPattern *p, XftExpr *e)
case XftOpDivide:
vl = _XftConfigEvaluate (p, e->u.tree.left);
vr = _XftConfigEvaluate (p, e->u.tree.right);
- vl = _XftConfigPromote (vl);
- vr = _XftConfigPromote (vr);
+ vl = _XftConfigPromote (vl, vr);
+ vr = _XftConfigPromote (vr, vl);
if (vl.type == vr.type)
{
switch (vl.type) {
@@ -427,6 +438,26 @@ _XftConfigEvaluate (XftPattern *p, XftExpr *e)
v.type = XftTypeVoid;
break;
}
+ case XftTypeMatrix:
+ switch (e->op) {
+ case XftOpEqual:
+ v.type = XftTypeBool;
+ v.u.b = XftMatrixEqual (vl.u.m, vr.u.m) == 0;
+ break;
+ case XftOpNotEqual:
+ v.type = XftTypeBool;
+ v.u.b = XftMatrixEqual (vl.u.m, vr.u.m) != 0;
+ break;
+ case XftOpTimes:
+ v.type = XftTypeMatrix;
+ v.u.m = malloc (sizeof (XftMatrix));
+ XftMatrixMultiply (v.u.m, vl.u.m, vr.u.m);
+ break;
+ default:
+ v.type = XftTypeVoid;
+ break;
+ }
+ break;
default:
v.type = XftTypeVoid;
break;
diff --git a/xc/lib/Xft/xftdbg.c b/xc/lib/Xft/xftdbg.c
index 69e3e6695..e58c166a2 100644
--- a/xc/lib/Xft/xftdbg.c
+++ b/xc/lib/Xft/xftdbg.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/xftdbg.c,v 1.1 2000/11/29 08:39:21 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftdbg.c,v 1.3 2001/03/31 01:57:20 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -44,6 +44,9 @@ XftValuePrint (XftValue v)
case XftTypeBool:
printf (" %s", v.u.b ? "True" : "False");
break;
+ case XftTypeMatrix:
+ printf (" (%f %f; %f %f)", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
+ break;
}
}
@@ -78,6 +81,7 @@ XftOpPrint (XftOp op)
case XftOpInteger: printf ("Integer"); break;
case XftOpDouble: printf ("Double"); break;
case XftOpString: printf ("String"); break;
+ case XftOpMatrix: printf ("Matrix"); break;
case XftOpBool: printf ("Bool"); break;
case XftOpField: printf ("Field"); break;
case XftOpAssign: printf ("Assign"); break;
@@ -126,6 +130,11 @@ XftExprPrint (XftExpr *expr)
case XftOpInteger: printf ("%d", expr->u.ival); break;
case XftOpDouble: printf ("%g", expr->u.dval); break;
case XftOpString: printf ("\"%s\"", expr->u.sval); break;
+ case XftOpMatrix: printf ("[%g %g %g %g]",
+ expr->u.mval->xx,
+ expr->u.mval->xy,
+ expr->u.mval->yx,
+ expr->u.mval->yy);
case XftOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break;
case XftOpField: printf ("%s", expr->u.field); break;
case XftOpQuest:
diff --git a/xc/lib/Xft/xftdraw.c b/xc/lib/Xft/xftdraw.c
index d8f2c9835..409a5c947 100644
--- a/xc/lib/Xft/xftdraw.c
+++ b/xc/lib/Xft/xftdraw.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/xftdraw.c,v 1.12 2000/12/20 00:28:44 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftdraw.c,v 1.14 2001/04/01 14:00:01 tsi Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "xftint.h"
#include <X11/Xutil.h>
@@ -150,11 +151,13 @@ XftDrawChange (XftDraw *draw,
void
XftDrawDestroy (XftDraw *draw)
{
+ int n;
+
if (draw->render_able)
{
XRenderFreePicture (draw->dpy, draw->render.pict);
- XFreePixmap (draw->dpy, draw->render.fg_pix);
- XRenderFreePicture (draw->dpy, draw->render.fg_pict);
+ for (n = 0; n < XFT_DRAW_N_SRC; n++)
+ XRenderFreePicture (draw->dpy, draw->render.src[n].pict);
}
if (draw->core_set)
XFreeGC (draw->dpy, draw->core.draw_gc);
@@ -166,13 +169,16 @@ XftDrawDestroy (XftDraw *draw)
Bool
XftDrawRenderPrepare (XftDraw *draw,
XftColor *color,
- XftFont *font)
+ XftFont *font,
+ int src)
{
if (!draw->render_set)
{
XRenderPictFormat *format;
XRenderPictFormat *pix_format;
XRenderPictureAttributes pa;
+ int n;
+ Pixmap pix;
draw->render_set = True;
draw->render_able = False;
@@ -184,14 +190,22 @@ XftDrawRenderPrepare (XftDraw *draw,
draw->render.pict = XRenderCreatePicture (draw->dpy, draw->drawable,
format, 0, 0);
- draw->render.fg_pix = XCreatePixmap (draw->dpy, draw->drawable,
- 1, 1, pix_format->depth);
- pa.repeat = True;
- draw->render.fg_pict = XRenderCreatePicture (draw->dpy,
- draw->render.fg_pix,
- pix_format,
- CPRepeat, &pa);
- draw->render.fg_color.red = ~color->color.red;
+ for (n = 0; n < XFT_DRAW_N_SRC; n++)
+ {
+ pix = XCreatePixmap (draw->dpy, draw->drawable,
+ 1, 1, pix_format->depth);
+ pa.repeat = True;
+ draw->render.src[n].pict = XRenderCreatePicture (draw->dpy,
+ pix,
+ pix_format,
+ CPRepeat, &pa);
+ XFreePixmap (draw->dpy, pix);
+
+ draw->render.src[n].color = color->color;
+ XRenderFillRectangle (draw->dpy, PictOpSrc,
+ draw->render.src[n].pict,
+ &color->color, 0, 0, 1, 1);
+ }
if (draw->clip)
XRenderSetPictureClipRegion (draw->dpy, draw->render.pict,
draw->clip);
@@ -199,7 +213,8 @@ XftDrawRenderPrepare (XftDraw *draw,
}
if (!draw->render_able)
return False;
- if (memcmp (&color->color, &draw->render.fg_color, sizeof (XRenderColor)))
+ if (memcmp (&color->color, &draw->render.src[src].color,
+ sizeof (XRenderColor)))
{
if (_XftFontDebug () & XFT_DBG_DRAW)
{
@@ -209,9 +224,10 @@ XftDrawRenderPrepare (XftDraw *draw,
color->color.green,
color->color.blue);
}
- XRenderFillRectangle (draw->dpy, PictOpSrc, draw->render.fg_pict,
+ XRenderFillRectangle (draw->dpy, PictOpSrc,
+ draw->render.src[src].pict,
&color->color, 0, 0, 1, 1);
- draw->render.fg_color = color->color;
+ draw->render.src[src].color = color->color;
}
return True;
}
@@ -275,9 +291,11 @@ XftDrawString8 (XftDraw *draw,
(char *) string, len);
}
#ifdef FREETYPE2
- else if (XftDrawRenderPrepare (draw, color, font))
+ else if (XftDrawRenderPrepare (draw, color, font, XFT_DRAW_SRC_TEXT))
{
- XftRenderString8 (draw->dpy, draw->render.fg_pict, font->u.ft.font,
+ XftRenderString8 (draw->dpy,
+ draw->render.src[XFT_DRAW_SRC_TEXT].pict,
+ font->u.ft.font,
draw->render.pict, 0, 0, x, y, string, len);
}
#endif
@@ -307,9 +325,11 @@ XftDrawString16 (XftDraw *draw,
free (xc);
}
#ifdef FREETYPE2
- else if (XftDrawRenderPrepare (draw, color, font))
+ else if (XftDrawRenderPrepare (draw, color, font, XFT_DRAW_SRC_TEXT))
{
- XftRenderString16 (draw->dpy, draw->render.fg_pict, font->u.ft.font,
+ XftRenderString16 (draw->dpy,
+ draw->render.src[XFT_DRAW_SRC_TEXT].pict,
+ font->u.ft.font,
draw->render.pict, 0, 0, x, y, string, len);
}
#endif
@@ -337,9 +357,11 @@ XftDrawString32 (XftDraw *draw,
free (xc);
}
#ifdef FREETYPE2
- else if (XftDrawRenderPrepare (draw, color, font))
+ else if (XftDrawRenderPrepare (draw, color, font, XFT_DRAW_SRC_TEXT))
{
- XftRenderString32 (draw->dpy, draw->render.fg_pict, font->u.ft.font,
+ XftRenderString32 (draw->dpy,
+ draw->render.src[XFT_DRAW_SRC_TEXT].pict,
+ font->u.ft.font,
draw->render.pict, 0, 0, x, y, string, len);
}
#endif
@@ -371,9 +393,11 @@ XftDrawStringUtf8 (XftDraw *draw,
free (xc);
}
#ifdef FREETYPE2
- else if (XftDrawRenderPrepare (draw, color, font))
+ else if (XftDrawRenderPrepare (draw, color, font, XFT_DRAW_SRC_TEXT))
{
- XftRenderStringUtf8 (draw->dpy, draw->render.fg_pict, font->u.ft.font,
+ XftRenderStringUtf8 (draw->dpy,
+ draw->render.src[XFT_DRAW_SRC_TEXT].pict,
+ font->u.ft.font,
draw->render.pict, 0, 0, x, y, string, len);
}
#endif
@@ -388,7 +412,7 @@ XftDrawRect (XftDraw *draw,
unsigned int width,
unsigned int height)
{
- if (XftDrawRenderPrepare (draw, color, 0))
+ if (XftDrawRenderPrepare (draw, color, 0, XFT_DRAW_SRC_RECT))
{
XRenderFillRectangle (draw->dpy, PictOpSrc, draw->render.pict,
&color->color, x, y, width, height);
diff --git a/xc/lib/Xft/xftextent.c b/xc/lib/Xft/xftextent.c
index 3bff6d535..dab433f9b 100644
--- a/xc/lib/Xft/xftextent.c
+++ b/xc/lib/Xft/xftextent.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/xftextent.c,v 1.5 2000/12/20 00:28:44 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftextent.c,v 1.6 2001/04/01 14:00:01 tsi Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -23,6 +23,7 @@
*/
#include <stdlib.h>
+#include <string.h>
#include "xftint.h"
void
diff --git a/xc/lib/Xft/xftfreetype.c b/xc/lib/Xft/xftfreetype.c
index e891e0577..a750c10d0 100644
--- a/xc/lib/Xft/xftfreetype.c
+++ b/xc/lib/Xft/xftfreetype.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/xftfreetype.c,v 1.10 2001/01/26 20:51:15 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftfreetype.c,v 1.12 2001/04/01 14:00:01 tsi Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include "xftint.h"
FT_Library _XftFTlibrary;
@@ -43,6 +44,11 @@ static XftFtEncoding xftFtEncoding[] = {
#define NUM_FT_ENCODINGS (sizeof xftFtEncoding / sizeof xftFtEncoding[0])
+#define FT_Matrix_Equal(a,b) ((a)->xx == (b)->xx && \
+ (a)->yy == (b)->yy && \
+ (a)->xy == (b)->xy && \
+ (a)->yx == (b)->yx)
+
XftPattern *
XftFreeTypeQuery (const char *file, int id, int *count)
{
@@ -136,7 +142,7 @@ XftFreeTypeQuery (const char *file, int id, int *count)
if (!XftPatternAddString (pat, XFT_ENCODING,
"glyphs-fontspecific"))
goto bail1;
-
+
FT_Done_Face (face);
return pat;
@@ -160,6 +166,7 @@ typedef struct _XftFtFile {
FT_Face face;
FT_F26Dot6 size;
+ FT_Matrix matrix;
int charmap;
} XftFtFile;
@@ -207,7 +214,7 @@ _XftFreeTypeOpenFile (char *file, int id)
}
Bool
-XftFreeTypeSetFace (FT_Face face, FT_F26Dot6 size, int charmap)
+XftFreeTypeSetFace (FT_Face face, FT_F26Dot6 size, int charmap, FT_Matrix *matrix)
{
XftFtFile *f, **prev;
@@ -239,6 +246,17 @@ XftFreeTypeSetFace (FT_Face face, FT_F26Dot6 size, int charmap)
return False;
f->charmap = charmap;
}
+ if (!FT_Matrix_Equal (&f->matrix, matrix))
+ {
+ if (_XftFontDebug() & XFT_DBG_GLYPH)
+ printf ("Set face matrix to (%g,%g,%g,%g)\n",
+ (double) matrix->xx / 0x10000,
+ (double) matrix->xy / 0x10000,
+ (double) matrix->yx / 0x10000,
+ (double) matrix->yy / 0x10000);
+ FT_Set_Transform (face, matrix, 0);
+ f->matrix = *matrix;
+ }
break;
}
}
@@ -300,6 +318,8 @@ XftFreeTypeOpen (Display *dpy, XftPattern *pattern)
int j;
FT_Encoding encoding;
int charmap;
+ FT_Matrix matrix;
+ XftMatrix *font_matrix;
int extra;
int height, ascent, descent;
@@ -338,7 +358,7 @@ XftFreeTypeOpen (Display *dpy, XftPattern *pattern)
default:
goto bail0;
}
-
+
switch (XftPatternGetBool (pattern, XFT_ANTIALIAS, 0, &antialias)) {
case XftResultNoMatch:
antialias = True;
@@ -368,6 +388,32 @@ XftFreeTypeOpen (Display *dpy, XftPattern *pattern)
default:
goto bail1;
}
+
+ if (XftPatternGetInteger (pattern, XFT_CHAR_WIDTH,
+ 0, &char_width) != XftResultMatch)
+ {
+ char_width = 0;
+ }
+ else if (char_width)
+ spacing = XFT_MONO;
+
+ matrix.xx = matrix.yy = 0x10000;
+ matrix.xy = matrix.yx = 0;
+
+ switch (XftPatternGetMatrix (pattern, XFT_MATRIX, 0, &font_matrix)) {
+ case XftResultNoMatch:
+ break;
+ case XftResultMatch:
+ matrix.xx = 0x10000L * font_matrix->xx;
+ matrix.yy = 0x10000L * font_matrix->yy;
+ matrix.xy = 0x10000L * font_matrix->xy;
+ matrix.yx = 0x10000L * font_matrix->yx;
+ break;
+ default:
+ goto bail1;
+ }
+
+
if (XftPatternGetInteger (pattern, XFT_CHAR_WIDTH,
0, &char_width) != XftResultMatch)
@@ -413,7 +459,8 @@ XftFreeTypeOpen (Display *dpy, XftPattern *pattern)
gs->font.spacing == spacing &&
gs->font.charmap == charmap &&
gs->font.rgba == rgba &&
- gs->font.antialias == antialias)
+ gs->font.antialias == antialias &&
+ FT_Matrix_Equal (&gs->font.matrix, &matrix))
{
++gs->ref;
if (_XftFontDebug () & XFT_DBG_REF)
@@ -503,9 +550,7 @@ XftFreeTypeOpen (Display *dpy, XftPattern *pattern)
if (!format)
goto bail2;
- font->size = size;
-
- if (!XftFreeTypeSetFace (face, size, charmap))
+ if (!XftFreeTypeSetFace (face, size, charmap, &matrix))
goto bail2;
descent = -(face->size->metrics.descender >> 6);
@@ -540,6 +585,7 @@ XftFreeTypeOpen (Display *dpy, XftPattern *pattern)
font->glyphset = XRenderCreateGlyphSet (dpy, format);
+ font->size = size;
font->spacing = spacing;
font->format = format;
font->realized =0;
@@ -547,6 +593,9 @@ XftFreeTypeOpen (Display *dpy, XftPattern *pattern)
font->rgba = rgba;
font->antialias = antialias;
font->charmap = charmap;
+ font->transform = (matrix.xx != 0x10000 || matrix.xy != 0 ||
+ matrix.yx != 0 || matrix.yy != 0x10000);
+ font->matrix = matrix;
font->face = face;
return font;
diff --git a/xc/lib/Xft/xftglyphs.c b/xc/lib/Xft/xftglyphs.c
index 6a6f2c274..b06431131 100644
--- a/xc/lib/Xft/xftglyphs.c
+++ b/xc/lib/Xft/xftglyphs.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/xftglyphs.c,v 1.9 2001/01/26 20:51:16 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftglyphs.c,v 1.12 2001/04/01 14:00:01 tsi Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "xftint.h"
#include <freetype/ftoutln.h>
@@ -74,29 +75,33 @@ XftGlyphLoad (Display *dpy,
int vmul = 1;
FT_Bitmap ftbit;
FT_Matrix matrix;
+ FT_Vector vector;
+ Bool subpixel = False;
- if (!XftFreeTypeSetFace (font->face, font->size, font->charmap))
+ if (!XftFreeTypeSetFace (font->face, font->size, font->charmap, &font->matrix))
return ;
+ matrix.xx = matrix.yy = 0x10000L;
+ matrix.xy = matrix.yx = 0;
+
if (font->antialias)
{
switch (font->rgba) {
case XFT_RGBA_RGB:
case XFT_RGBA_BGR:
- matrix.xx = 0x30000L;
- matrix.yy = 0x10000L;
- matrix.xy = matrix.yx = 0;
+ matrix.xx *= 3;
+ subpixel = True;
hmul = 3;
break;
case XFT_RGBA_VRGB:
case XFT_RGBA_VBGR:
- matrix.xx = 0x10000L;
- matrix.yy = 0x30000L;
- matrix.xy = matrix.yx = 0;
+ matrix.yy *= 3;
vmul = 3;
+ subpixel = True;
break;
}
}
+
while (nglyph--)
{
charcode = (FT_ULong) *glyphs++;
@@ -127,14 +132,56 @@ XftGlyphLoad (Display *dpy,
#define ROUND(x) (((x)+32) & -64)
glyph = font->face->glyph;
-
- left = FLOOR( glyph->metrics.horiBearingX );
- right = CEIL( glyph->metrics.horiBearingX + glyph->metrics.width );
+
+ if(font->transform)
+ {
+ /*
+ * calculate the true width by transforming all four corners.
+ */
+ int xc, yc;
+ left = right = top = bottom = 0;
+ for(xc = 0; xc <= 1; xc ++) {
+ for(yc = 0; yc <= 1; yc++) {
+ vector.x = glyph->metrics.horiBearingX + xc * glyph->metrics.width;
+ vector.y = glyph->metrics.horiBearingY - yc * glyph->metrics.height;
+ FT_Vector_Transform(&vector, &font->matrix);
+ if (_XftFontDebug() & XFT_DBG_GLYPH)
+ printf("Trans %d %d: %d %d\n", (int) xc, (int) yc,
+ (int) vector.x, (int) vector.y);
+ if(xc == 0 && yc == 0) {
+ left = right = vector.x;
+ top = bottom = vector.y;
+ } else {
+ if(left > vector.x) left = vector.x;
+ if(right < vector.x) right = vector.x;
+ if(bottom > vector.y) bottom = vector.y;
+ if(top < vector.y) top = vector.y;
+ }
+
+ }
+ }
+ left = FLOOR(left);
+ right = CEIL(right);
+ bottom = FLOOR(bottom);
+ top = CEIL(top);
+
+ } else {
+ left = FLOOR( glyph->metrics.horiBearingX );
+ right = CEIL( glyph->metrics.horiBearingX + glyph->metrics.width );
+
+ top = CEIL( glyph->metrics.horiBearingY );
+ bottom = FLOOR( glyph->metrics.horiBearingY - glyph->metrics.height );
+ }
+
width = TRUNC(right - left);
+ height = TRUNC( top - bottom );
+
+
/*
* Try to keep monospace fonts ink-inside
+ * XXX transformed?
*/
- if (font->spacing != XFT_PROPORTIONAL)
+ if (font->spacing != XFT_PROPORTIONAL && !font->transform)
{
if (TRUNC(right) > font->max_advance_width)
{
@@ -149,10 +196,6 @@ XftGlyphLoad (Display *dpy,
}
}
- top = CEIL( glyph->metrics.horiBearingY );
- bottom = FLOOR( glyph->metrics.horiBearingY - glyph->metrics.height );
- height = TRUNC( top - bottom );
-
if ( glyph->format == ft_glyph_format_outline )
{
if (font->antialias)
@@ -183,7 +226,7 @@ XftGlyphLoad (Display *dpy,
ftbit.buffer = bufBitmap;
- if (font->antialias && font->rgba != XFT_RGBA_NONE)
+ if (subpixel)
FT_Outline_Transform (&glyph->outline, &matrix);
FT_Outline_Translate ( &glyph->outline, -left*hmul, -bottom*vmul );
@@ -217,6 +260,13 @@ XftGlyphLoad (Display *dpy,
if (_XftFontDebug() & XFT_DBG_GLYPH)
{
printf ("char 0x%x (%c):\n", (int) charcode, (char) charcode);
+ printf (" xywh (%d %d %d %d), trans (%d %d %d %d) wh (%d %d)\n",
+ (int) glyph->metrics.horiBearingX,
+ (int) glyph->metrics.horiBearingY,
+ (int) glyph->metrics.width,
+ (int) glyph->metrics.height,
+ left, right, top, bottom,
+ width, height);
if (_XftFontDebug() & XFT_DBG_GLYPHV)
{
int x, y;
@@ -238,7 +288,7 @@ XftGlyphLoad (Display *dpy,
printf ("%c", line[x>>3] & (1 << (x & 7)) ? '#' : ' ');
}
}
- printf ("\n");
+ printf ("|\n");
line += pitch;
}
printf ("\n");
@@ -259,17 +309,28 @@ XftGlyphLoad (Display *dpy,
gi->y = TRUNC(top);
if (font->spacing != XFT_PROPORTIONAL)
{
- gi->xOff = font->max_advance_width;
- gi->yOff = 0;
+ if (font->transform)
+ {
+ vector.x = font->max_advance_width;
+ vector.y = 0;
+ FT_Vector_Transform (&vector, &font->matrix);
+ gi->xOff = vector.x;
+ gi->yOff = -vector.y;
+ }
+ else
+ {
+ gi->xOff = font->max_advance_width;
+ gi->yOff = 0;
+ }
}
else
{
gi->xOff = TRUNC(ROUND(glyph->advance.x));
- gi->yOff = TRUNC(ROUND(glyph->advance.y));
+ gi->yOff = -TRUNC(ROUND(glyph->advance.y));
}
g = charcode;
- if (font->antialias && font->rgba != XFT_RGBA_NONE)
+ if (subpixel)
{
int x, y;
unsigned char *in_line, *out_line, *in;
diff --git a/xc/lib/Xft/xftgram.y b/xc/lib/Xft/xftgram.y
index a6cb6ef4b..b58dcddbf 100644
--- a/xc/lib/Xft/xftgram.y
+++ b/xc/lib/Xft/xftgram.y
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/xftgram.y,v 1.3 2001/01/02 02:46:51 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftgram.y,v 1.4 2001/03/31 01:57:20 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -28,6 +28,8 @@
#include <stdio.h>
#include "xftint.h"
+static XftMatrix matrix;
+
%}
%union {
@@ -49,7 +51,7 @@
%token <ival> ANY ALL
%token <ival> DIR CACHE INCLUDE INCLUDEIF MATCH EDIT
%token <ival> TOK_TRUE TOK_FALSE TOK_NIL
-%token <ival> EQUAL SEMI
+%token <ival> EQUAL SEMI OS CS
%type <eval> expr
%type <vval> value
@@ -60,6 +62,7 @@
%type <qval> qual
%type <oval> compare
%type <tval> tests test
+%type <dval> number
%right <ival> QUEST COLON
%left <ival> OROR
@@ -149,6 +152,22 @@ value : INTEGER
{
$$.type = XftTypeVoid;
}
+ | matrix
+ {
+ $$.type = XftTypeMatrix;
+ $$.u.m = &matrix;
+ }
+ ;
+matrix : OS number number number number CS
+ {
+ matrix.xx = $2;
+ matrix.xy = $3;
+ matrix.yx = $4;
+ matrix.__REALLY_YY__ = $5;
+ }
+number : INTEGER
+ { $$ = (double) $1; }
+ | DOUBLE
;
edits : edit edits
{ $1->next = $2; $$ = $1; }
@@ -177,6 +196,8 @@ expr : INTEGER
{ $$ = XftExprCreateBool (False); }
| TOK_NIL
{ $$ = XftExprCreateNil (); }
+ | matrix
+ { $$ = XftExprCreateMatrix (&matrix); }
| NAME
{ $$ = XftExprCreateField ($1); }
| expr OROR expr
@@ -241,6 +262,8 @@ XftTestCreate (XftQual qual, const char *field, XftOp compare, XftValue value)
test->op = compare;
if (value.type == XftTypeString)
value.u.s = _XftSaveString (value.u.s);
+ else if (value.type == XftTypeMatrix)
+ value.u.m = _XftSaveMatrix (value.u.m);
test->value = value;
}
return test;
@@ -286,6 +309,19 @@ XftExprCreateString (const char *s)
}
XftExpr *
+XftExprCreateMatrix (const XftMatrix *m)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpMatrix;
+ e->u.mval = _XftSaveMatrix (m);
+ }
+ return e;
+}
+
+XftExpr *
XftExprCreateBool (Bool b)
{
XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
@@ -348,6 +384,9 @@ XftExprDestroy (XftExpr *e)
case XftOpString:
free (e->u.sval);
break;
+ case XftOpMatrix:
+ free (e->u.mval);
+ break;
case XftOpBool:
break;
case XftOpField:
diff --git a/xc/lib/Xft/xftint.h b/xc/lib/Xft/xftint.h
index 53b95facc..37b8e8d81 100644
--- a/xc/lib/Xft/xftint.h
+++ b/xc/lib/Xft/xftint.h
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/xftint.h,v 1.21 2001/01/26 20:51:16 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftint.h,v 1.24 2001/03/31 01:57:20 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -42,6 +42,11 @@ typedef struct _XftSymbolic {
int value;
} XftSymbolic;
+#define XFT_DRAW_N_SRC 2
+
+#define XFT_DRAW_SRC_TEXT 0
+#define XFT_DRAW_SRC_RECT 1
+
struct _XftDraw {
Display *dpy;
Drawable drawable;
@@ -53,9 +58,10 @@ struct _XftDraw {
Bool render_able;
struct {
Picture pict;
- Pixmap fg_pix;
- Picture fg_pict;
- XRenderColor fg_color;
+ struct {
+ Picture pict;
+ XRenderColor color;
+ } src[XFT_DRAW_N_SRC];
} render;
struct {
GC draw_gc;
@@ -97,7 +103,7 @@ extern XftFontSet *_XftFontSet;
#define XFT_DBG_MATCHV 1024
typedef enum _XftOp {
- XftOpInteger, XftOpDouble, XftOpString, XftOpBool, XftOpNil,
+ XftOpInteger, XftOpDouble, XftOpString, XftOpMatrix, XftOpBool, XftOpNil,
XftOpField,
XftOpAssign, XftOpPrepend, XftOpAppend,
XftOpQuest,
@@ -110,11 +116,12 @@ typedef enum _XftOp {
typedef struct _XftExpr {
XftOp op;
union {
- int ival;
- double dval;
- char *sval;
- Bool bval;
- char *field;
+ int ival;
+ double dval;
+ char *sval;
+ XftMatrix *mval;
+ Bool bval;
+ char *field;
struct {
struct _XftExpr *left, *right;
} tree;
@@ -185,6 +192,9 @@ typedef struct _XftSubst {
case XftTypeBool: \
__v__.u.b = va_arg (va, Bool); \
break; \
+ case XftTypeMatrix: \
+ __v__.u.m = va_arg (va, XftMatrix *); \
+ break; \
} \
if (!XftPatternAdd (__p__, __o__, __v__, True)) \
goto _XftPatternVapBuild_bail1; \
@@ -333,7 +343,8 @@ XftDisplayGetFontSet (Display *dpy);
Bool
XftDrawRenderPrepare (XftDraw *draw,
XftColor *color,
- XftFont *font);
+ XftFont *font,
+ int src);
Bool
XftDrawCorePrepare (XftDraw *draw,
@@ -372,6 +383,9 @@ XftExpr *
XftExprCreateString (const char *s);
XftExpr *
+XftExprCreateMatrix (const XftMatrix *m);
+
+XftExpr *
XftExprCreateBool (Bool b);
XftExpr *
@@ -393,8 +407,6 @@ void
XftEditDestroy (XftEdit *e);
/* xftinit.c */
-Bool
-XftInit (char *config);
/* xftlex.l */
extern int XftConfigLineno;
@@ -440,6 +452,10 @@ XftNameConstant (char *string, int *result);
/* xftrender.c */
+/* xftmatrix.c */
+XftMatrix *
+_XftSaveMatrix (const XftMatrix *mat);
+
/* xftstr.c */
char *
_XftSaveString (const char *s);
diff --git a/xc/lib/Xft/xftlex.l b/xc/lib/Xft/xftlex.l
index 14773789b..c426fa315 100644
--- a/xc/lib/Xft/xftlex.l
+++ b/xc/lib/Xft/xftlex.l
@@ -1,6 +1,6 @@
%{
/*
- * $XFree86: xc/lib/Xft/xftlex.l,v 1.4 2001/01/02 02:46:51 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftlex.l,v 1.5 2001/03/31 01:57:20 keithp Exp $
*
* Copyright (c) 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -124,6 +124,8 @@ all return ALL;
">" return MORE;
"!=" return NOTEQ;
"?" return QUEST;
+"[" return OS;
+"]" return CS;
\"([^\n\"]|\\\")*\" {
yytext[yyleng - 1] = '\0';
yylval.sval = yytext+1;
diff --git a/xc/lib/Xft/xftmatch.c b/xc/lib/Xft/xftmatch.c
index 2f274c302..e0e9b0f00 100644
--- a/xc/lib/Xft/xftmatch.c
+++ b/xc/lib/Xft/xftmatch.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/xftmatch.c,v 1.4 2001/01/26 20:51:17 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftmatch.c,v 1.5 2001/03/06 18:00:26 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -97,9 +97,9 @@ _XftCompareSize (char *object, XftValue value1, XftValue value2)
static XftMatcher _XftMatchers [] = {
{ XFT_FOUNDRY, _XftCompareString, },
{ XFT_ENCODING, _XftCompareString, },
- { XFT_SPACING, _XftCompareInteger, },
{ XFT_ANTIALIAS, _XftCompareBool, },
{ XFT_FAMILY, _XftCompareString, },
+ { XFT_SPACING, _XftCompareInteger, },
{ XFT_PIXEL_SIZE, _XftCompareSize, },
{ XFT_STYLE, _XftCompareString, },
{ XFT_SLANT, _XftCompareInteger, },
diff --git a/xc/lib/Xft/xftmatrix.c b/xc/lib/Xft/xftmatrix.c
new file mode 100644
index 000000000..bd6f155ed
--- /dev/null
+++ b/xc/lib/Xft/xftmatrix.c
@@ -0,0 +1,104 @@
+/*
+ * $XFree86: xc/lib/Xft/xftmatrix.c,v 1.1 2001/03/30 18:50:18 keithp Exp $
+ *
+ * Copyright © 2000 Tuomas J. Lukka
+ *
+ * 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 Tuomas Lukka not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Tuomas Lukka makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * TUOMAS LUKKA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL TUOMAS LUKKA 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 <math.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "xftint.h"
+
+XftMatrix *
+_XftSaveMatrix (const XftMatrix *mat)
+{
+ XftMatrix *r;
+ if(!mat)
+ return 0;
+ r = (XftMatrix *) malloc (sizeof (*r) );
+ if (!r)
+ return 0;
+ *r = *mat;
+ return r;
+}
+
+int
+XftMatrixEqual (const XftMatrix *mat1, const XftMatrix *mat2)
+{
+ if(mat1 == mat2) return True;
+ if(mat1 == 0 || mat2 == 0) return False;
+ return mat1->xx == mat2->xx &&
+ mat1->xy == mat2->xy &&
+ mat1->yx == mat2->yx &&
+ mat1->yy == mat2->yy;
+}
+
+void
+XftMatrixMultiply (XftMatrix *result, XftMatrix *a, XftMatrix *b)
+{
+ XftMatrix r;
+
+ r.xx = a->xx * b->xx + a->xy * b->yx;
+ r.xy = a->xx * b->xy + a->xy * b->yy;
+ r.yx = a->yx * b->xx + a->yy * b->yx;
+ r.yy = a->yx * b->xy + a->yy * b->yy;
+ *result = r;
+}
+
+void
+XftMatrixRotate (XftMatrix *m, double c, double s)
+{
+ XftMatrix r;
+
+ /*
+ * X Coordinate system is upside down, swap to make
+ * rotations counterclockwise
+ */
+ r.xx = c;
+ r.xy = -s;
+ r.yx = s;
+ r.yy = c;
+ XftMatrixMultiply (m, &r, m);
+}
+
+void
+XftMatrixScale (XftMatrix *m, double sx, double sy)
+{
+ XftMatrix r;
+
+ r.xx = sx;
+ r.xy = 0;
+ r.yx = 0;
+ r.yy = sy;
+ XftMatrixMultiply (m, &r, m);
+}
+
+void
+XftMatrixShear (XftMatrix *m, double sh, double sv)
+{
+ XftMatrix r;
+
+ r.xx = 1;
+ r.xy = sh;
+ r.yx = sv;
+ r.yy = 1;
+ XftMatrixMultiply (m, &r, m);
+}
diff --git a/xc/lib/Xft/xftname.c b/xc/lib/Xft/xftname.c
index 39e40e0b5..39af64a43 100644
--- a/xc/lib/Xft/xftname.c
+++ b/xc/lib/Xft/xftname.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/xftname.c,v 1.9 2001/01/26 20:51:17 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftname.c,v 1.10 2001/03/30 18:50:18 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -57,6 +57,7 @@ static const XftObjectType _XftObjectTypes[] = {
{ XFT_MINSPACE, XftTypeBool, },
{ XFT_CHAR_WIDTH, XftTypeInteger },
{ XFT_CHAR_HEIGHT, XftTypeInteger },
+ { XFT_MATRIX, XftTypeMatrix },
};
#define NUM_OBJECT_TYPES (sizeof _XftObjectTypes / sizeof _XftObjectTypes[0])
@@ -128,7 +129,7 @@ XftNameConstant (char *string, int *result)
}
static XftValue
-_XftNameConvert (XftType type, char *string)
+_XftNameConvert (XftType type, char *string, XftMatrix *m)
{
XftValue v;
@@ -147,6 +148,10 @@ _XftNameConvert (XftType type, char *string)
case XftTypeDouble:
v.u.d = strtod (string, 0);
break;
+ case XftTypeMatrix:
+ v.u.m = m;
+ sscanf (string, "%lg %lg %lg %lg", &m->xx, &m->xy, &m->yx, &m->yy);
+ break;
default:
break;
}
@@ -187,6 +192,7 @@ XftNameParse (const char *name)
char *e;
char delim;
XftValue v;
+ XftMatrix m;
const XftObjectType *t;
XftConstant *c;
@@ -236,7 +242,7 @@ XftNameParse (const char *name)
name = _XftNameFindNext (name, ":,", save, &delim);
if (save[0] && t)
{
- v = _XftNameConvert (t->type, save);
+ v = _XftNameConvert (t->type, save, &m);
if (!XftPatternAdd (pat, t->object, v, True))
goto bail2;
}
@@ -308,6 +314,10 @@ _XftNameUnparseValue (XftValue v, char *escape, char **destp, int *lenp)
return _XftNameUnparseString (v.u.s, escape, destp, lenp);
case XftTypeBool:
return _XftNameUnparseString (v.u.b ? "True" : "False", 0, destp, lenp);
+ case XftTypeMatrix:
+ sprintf (temp, "%g %g %g %g",
+ v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
+ return _XftNameUnparseString (temp, 0, destp, lenp);
}
return False;
}
diff --git a/xc/lib/Xft/xftpat.c b/xc/lib/Xft/xftpat.c
index 6bd372c1f..d93dacae2 100644
--- a/xc/lib/Xft/xftpat.c
+++ b/xc/lib/Xft/xftpat.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/xftpat.c,v 1.5 2000/12/14 23:03:56 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftpat.c,v 1.6 2001/03/30 18:50:18 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -45,6 +45,8 @@ XftValueDestroy (XftValue v)
{
if (v.type == XftTypeString)
free (v.u.s);
+ if( v.type == XftTypeMatrix)
+ free (v.u.m);
}
void
@@ -55,6 +57,8 @@ XftValueListDestroy (XftValueList *l)
{
if (l->value.type == XftTypeString)
free (l->value.u.s);
+ if (l->value.type == XftTypeMatrix)
+ free (l->value.u.m);
next = l->next;
free (l);
}
@@ -136,6 +140,12 @@ XftPatternAdd (XftPattern *p, const char *object, XftValue value, Bool append)
if (!value.u.s)
goto bail1;
}
+ else if (value.type == XftTypeMatrix)
+ {
+ value.u.m = _XftSaveMatrix (value.u.m);
+ if (!value.u.m)
+ goto bail1;
+ }
new->value = value;
new->next = 0;
@@ -160,6 +170,8 @@ XftPatternAdd (XftPattern *p, const char *object, XftValue value, Bool append)
bail2:
if (value.type == XftTypeString)
free (value.u.s);
+ else if (value.type == XftTypeMatrix)
+ free (value.u.m);
bail1:
free (new);
bail0:
@@ -220,6 +232,16 @@ XftPatternAddString (XftPattern *p, const char *object, const char *s)
return XftPatternAdd (p, object, v, True);
}
+Bool
+XftPatternAddMatrix (XftPattern *p, const char *object, const XftMatrix *s)
+{
+ XftValue v;
+
+ v.type = XftTypeMatrix;
+ v.u.m = (XftMatrix *) s;
+ return XftPatternAdd (p, object, v, True);
+}
+
Bool
XftPatternAddBool (XftPattern *p, const char *object, Bool b)
@@ -312,6 +334,22 @@ XftPatternGetString (XftPattern *p, const char *object, int id, char **s)
}
XftResult
+XftPatternGetMatrix (XftPattern *p, const char *object, int id, XftMatrix **m)
+{
+ XftValue v;
+ XftResult r;
+
+ r = XftPatternGet (p, object, id, &v);
+ if (r != XftResultMatch)
+ return r;
+ if (v.type != XftTypeMatrix)
+ return XftResultTypeMismatch;
+ *m = v.u.m;
+ return XftResultMatch;
+}
+
+
+XftResult
XftPatternGetBool (XftPattern *p, const char *object, int id, Bool *b)
{
XftValue v;
diff --git a/xc/lib/Xft/xftstr.c b/xc/lib/Xft/xftstr.c
index e17c0fb40..8ab743b6f 100644
--- a/xc/lib/Xft/xftstr.c
+++ b/xc/lib/Xft/xftstr.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xft/xftstr.c,v 1.4 2000/12/20 10:24:27 keithp Exp $
+ * $XFree86: xc/lib/Xft/xftstr.c,v 1.6 2001/04/01 14:00:01 tsi Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <ctype.h>
+#include <string.h>
#include "xftint.h"
char *
@@ -31,6 +32,8 @@ _XftSaveString (const char *s)
{
char *r;
+ if (!s)
+ return 0;
r = (char *) malloc (strlen (s) + 1);
if (!r)
return 0;