Commit 591dcad6 authored by Egbert Eich's avatar Egbert Eich

Merging XORG-CURRENT into trunk

parent c7e70c7e
Keith Packard, of SuSE, HP, and XFree86
Automake work by Noah Levitt
Frank Giessler - OS/2
Jungshik Shin - UTF-16 api's
Ralf Habacker, Suhaib Siddiqi - Cygwin port
Marc La France - Sun port
David Dawes - bug fixes, maintenance.
Our apologies if we've overlooked someone.
$Id$
Copyright © 2001,2003 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.
Xft is built with the traditional configure script:
$ ./configure --prefix=/usr/X11R6
This should generate valid Makefiles, then:
$ make
$ make install
Xft
X FreeType library
Version 2.1.3
2003-3-10
Xft version 2.1 is the first stand alone release of Xft, a library that
connects X applications with the FreeType font rasterization library. Xft
uses fontconfig to locate fonts so it has no configuration files.
Version 2.1.3
Change Freetype includes to new syntax.
Search for nearest bitmap for bitmap-only fonts.
Support fontconfig 2.2 release which doesn't include FC_HINT_STYLE.
Keith Packard
keithp@keithp.com
/*
* $XFree86: xc/lib/Xft/Xft.h,v 1.33 2003/11/20 22:36:33 dawes Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
......@@ -25,9 +24,15 @@
#ifndef _XFT_H_
#define _XFT_H_
/*
* Current Xft version number. This same number
* must appear in the Xft configure.ac file. Yes,
* it'a a pain to synchronize version numbers like this.
*/
#define XFT_MAJOR 2
#define XFT_MINOR 1
#define XFT_REVISION 0
#define XFT_REVISION 6
#define XFT_VERSION ((XFT_MAJOR * 10000) + (XFT_MINOR * 100) + (XFT_REVISION))
#define XftVersion XFT_VERSION
......
/*
* $XFree86: xc/lib/Xft/XftCompat.h,v 1.6 2003/08/06 14:03:59 eich Exp $
*
* Copyright 2001 Keith Packard, member of The XFree86 Project, Inc.
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
......@@ -111,6 +110,7 @@ typedef FcObjectSet XftObjectSet;
#define XftObjectSetDestroy FcObjectSetDestroy
#define XftObjectSetVaBuild FcObjectSetVaBuild
#define XftObjectSetBuild FcObjectSetBuild
#define XftFontSetMatch FcFontSetMatch
#define XftFontSetDestroy FcFontSetDestroy
......
.\"
.\" $Id$
.\"
.\" 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.
.\"
.de TQ
.br
.ns
.TP \\$1
..
.TH XFT 3 "Version @VERSION@" "Xft"
.SH NAME
Xft \- X FreeType interface library
.SH DESCRIPTION
.B Xft
is a simple library designed to interface the FreeType rasterizer with the X
Rendering Extension. This manual page barely scratches the surface of this
library.
.SH DATATYPES
.B XftPattern
holds a set of names with associated value lists; each name refers to a
property of a font. XftPatterns are used as inputs to the matching code as
well as holding information about specific fonts.
.B XftFont
contains general font metrics and a pointer to either the core XFontStruct
data or a structure holding FreeType and X Render Extension data.
.B XftFontStruct
contains information about FreeType fonts used with the X Render Extension.
.B XftFontSet
contains a list of XftPatterns. Internally Xft uses this data structure to
hold sets of fonts. Externally, Xft returns the results of listing fonts in
this format.
.B XftObjectSet
holds a set of names and is used to specify which fields from fonts are
placed in the the list of returned patterns when listing fonts.
.B XftDraw
is an opaque object which holds information used to render to an X drawable
using either core protocol or the X Rendering extension.
.SH FUNCTIONS
.nf
XftFont *
XftFontOpen (Display *dpy, int screen, ...);
.fi
.B XftFontOpen
takes a list of pattern elements of the form (field, type, value) terminated
with a NULL, matches that pattern against the available fonts and opens the
matching font.
.PP
Example:
.br
font = XftFontOpen (dpy, scr,
XFT_FAMILY, XftTypeString, "charter",
XFT_SIZE, XftTypeDouble, 12.0,
NULL);
.PP
This opens the charter font at 12 points. The point size is automatically
converted to the correct pixel size based on the resolution of the monitor.
.PP
.nf
void
XftTextExtents8 (Display *dpy,
XftFont *font,
unsigned char *string,
int len,
XGlyphInfo *extents);
.fi
.B XftTextExtents8
computes the pixel extents of "string" when drawn with "font".
.PP
.nf
XftDraw *
XftDrawCreate (Display *dpy,
Drawable drawable,
Visual *visual,
Colormap colormap);
.fi
.B XftDrawCreate
creates a structure that can be used to render text and rectangles
to the screen.
.PP
.nf
void
XftDrawString8 (XftDraw *d,
XRenderColor *color,
XftFont *font,
int x,
int y,
unsigned char *string,
int len);
.fi
.B XftDrawString8
draws "string" using "font" in "color" at "x, y".
.PP
.nf
void
XftDrawRect (XftDraw *d,
XRenderColor *color,
int x,
int y,
unsigned int width,
unsigned int height);
.fi
.B XftDrawRect
fills a solid rectangle in the specified color.
.SH COMPATIBILITY
As of version 2,
.B Xft
has become relatively stable and is expected to retain source and binary
compatibility in future releases.
.SH AUTHOR
Keith Packard
/*
* $XFree86: xc/lib/Xft/xftcolor.c,v 1.3 2002/10/11 17:53:02 keithp Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
......
/*
* $XFree86: xc/lib/Xft/xftcore.c,v 1.14 2003/05/27 22:26:40 tsi Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
......@@ -918,8 +917,10 @@ _XftGlyphDefault (Display *dpy, XftFont *public)
XftFontInt *font = (XftFontInt *) public;
FT_UInt missing[XFT_NMISSING];
int nmissing;
FcBool glyphs_loaded = FcFalse;
XftFontCheckGlyph (dpy, public, FcTrue, 0, missing, &nmissing);
if (XftFontCheckGlyph (dpy, public, FcTrue, 0, missing, &nmissing))
glyphs_loaded = FcTrue;
if (nmissing)
XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
return font->glyphs[0];
......
/*
* $XFree86: xc/lib/Xft/xftdbg.c,v 1.4 2002/02/15 07:36:10 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
......
/*
* $XFree86: xc/lib/Xft/xftdpy.c,v 1.20 2002/10/11 17:53:02 keithp Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
......@@ -377,6 +376,10 @@ _XftDefaultInit (Display *dpy)
goto bail1;
if (!_XftDefaultInitBool (dpy, pat, FC_AUTOHINT))
goto bail1;
#ifdef FC_HINT_STYLE
if (!_XftDefaultInitInteger (dpy, pat, FC_HINT_STYLE))
goto bail1;
#endif
if (!_XftDefaultInitBool (dpy, pat, FC_HINTING))
goto bail1;
if (!_XftDefaultInitBool (dpy, pat, FC_MINSPACE))
......@@ -473,6 +476,14 @@ XftDefaultSubstitute (Display *dpy, int screen, FcPattern *pattern)
XftDefaultGetBool (dpy, FC_HINTING, screen,
True));
}
#ifdef FC_HINT_STYLE
if (FcPatternGet (pattern, FC_HINT_STYLE, 0, &v) == FcResultNoMatch)
{
FcPatternAddInteger (pattern, FC_HINT_STYLE,
XftDefaultGetInteger (dpy, FC_HINT_STYLE, screen,
FC_HINT_FULL));
}
#endif
if (FcPatternGet (pattern, FC_AUTOHINT, 0, &v) == FcResultNoMatch)
{
FcPatternAddBool (pattern, FC_AUTOHINT,
......
/*
* $XFree86: xc/lib/Xft/xftdraw.c,v 1.26 2003/04/03 22:25:50 dawes Exp $
* $XFree86: xc/lib/Xft/xftdraw.c,v 1.25 2002/10/11 17:53:02 keithp Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
......@@ -177,6 +177,7 @@ XftDrawCreateBitmap (Display *dpy,
draw->colormap = 0;
draw->render.pict = 0;
draw->core.gc = 0;
draw->core.use_pixmap = 0;
draw->clip_type = XftClipTypeNone;
draw->subwindow_mode = ClipByChildren;
XftMemAlloc (XFT_MEM_DRAW, sizeof (XftDraw));
......@@ -202,6 +203,7 @@ XftDrawCreateAlpha (Display *dpy,
draw->colormap = 0;
draw->render.pict = 0;
draw->core.gc = 0;
draw->core.use_pixmap = 0;
draw->clip_type = XftClipTypeNone;
draw->subwindow_mode = ClipByChildren;
XftMemAlloc (XFT_MEM_DRAW, sizeof (XftDraw));
......@@ -807,7 +809,7 @@ XftDrawRect (XftDraw *draw,
{
if (_XftDrawRenderPrepare (draw))
{
XRenderFillRectangle (draw->dpy, PictOpOver, draw->render.pict,
XRenderFillRectangle (draw->dpy, PictOpSrc, draw->render.pict,
&color->color, x, y, width, height);
}
else if (_XftDrawCorePrepare (draw, color))
......@@ -914,7 +916,10 @@ XftDrawSetClipRectangles (XftDraw *draw,
/*
* Check for quick exit
*/
if (draw->clip_type == XftClipTypeRectangles &&
if (draw->clip_type == XftClipTypeRectangles &&
draw->clip.rect->n == n &&
(n == 0 || (draw->clip.rect->xOrigin == xOrigin &&
draw->clip.rect->yOrigin == yOrigin)) &&
!memcmp (XftClipRects (draw->clip.rect), rects, n * sizeof (XRectangle)))
{
return True;
......
/*
* $XFree86: xc/lib/Xft/xftextent.c,v 1.10 2002/12/14 01:59:38 dawes Exp $
* $XFree86: xc/lib/Xft/xftextent.c,v 1.9 2002/10/11 17:53:02 keithp Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
......
/*
* $XFree86: xc/lib/Xft/xftfont.c,v 1.11 2002/10/11 17:53:02 keithp Exp $
* $XFree86: xc/lib/Xft/xftfont.c,v 1.9 2002/02/15 07:36:11 keithp Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
......
/*
* $XFree86: xc/lib/Xft/xftfreetype.c,v 1.30 2003/03/26 20:43:51 tsi Exp $
* $XFree86: xc/lib/Xft/xftfreetype.c,v 1.29tsi Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
......@@ -81,6 +81,7 @@ _XftGetFile (const FcChar8 *file, int id)
f->face = 0;
f->xsize = 0;
f->ysize = 0;
f->matrix.xx = f->matrix.xy = f->matrix.yx = f->matrix.yy = 0;
return f;
}
......@@ -103,6 +104,7 @@ _XftGetFaceFile (FT_Face face)
f->face = face;
f->xsize = 0;
f->ysize = 0;
f->matrix.xx = f->matrix.xy = f->matrix.yx = f->matrix.yy = 0;
return f;
}
......@@ -180,6 +182,14 @@ _XftUnlockFile (XftFtFile *f)
_XftLockError ("too many file unlocks");
}
#if HAVE_FT_BITMAP_SIZE_Y_PPEM
#define X_SIZE(face,i) ((face)->available_sizes[i].x_ppem)
#define Y_SIZE(face,i) ((face)->available_sizes[i].y_ppem)
#else
#define X_SIZE(face,i) ((face)->available_sizes[i].width << 6)
#define Y_SIZE(face,i) ((face)->available_sizes[i].height << 6)
#endif
FcBool
_XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix)
{
......@@ -190,8 +200,56 @@ _XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix
if (XftDebug() & XFT_DBG_GLYPH)
printf ("Set face size to %dx%d (%dx%d)\n",
(int) (xsize >> 6), (int) (ysize >> 6), (int) xsize, (int) ysize);
if (FT_Set_Char_Size (face, xsize, ysize, 0, 0))
return False;
/*
* Bitmap only faces must match exactly, so find the closest
* one (height dominant search)
*/
if (!(face->face_flags & FT_FACE_FLAG_SCALABLE))
{
int i, best = 0;
#define xft_abs(a) ((a) < 0 ? -(a) : (a))
#define dist(a,b) (xft_abs((a)-(b)))
for (i = 1; i < face->num_fixed_sizes; i++)
{
if (dist (ysize, Y_SIZE(face,i)) <
dist (ysize, Y_SIZE(face, best)) ||
(dist (ysize, Y_SIZE(face, i)) ==
dist (ysize, Y_SIZE(face, best)) &&
dist (xsize, X_SIZE(face, i)) <
dist (xsize, X_SIZE(face, best))))
{
best = i;
}
}
/*
* Freetype 2.1.7 and earlier used width/height
* for matching sizes in the BDF and PCF loaders.
* This has been fixed for 2.1.8. Because BDF and PCF
* files have but a single strike per file, we can
* simply try both sizes.
*/
if (
#if HAVE_FT_BITMAP_SIZE_Y_PPEM
FT_Set_Char_Size (face, face->available_sizes[best].x_ppem,
face->available_sizes[best].y_ppem, 0, 0) != 0
&&
#endif
FT_Set_Char_Size (face, face->available_sizes[best].width << 6,
face->available_sizes[best].height << 6,
0, 0) != 0)
{
return False;
}
}
else
{
if (FT_Set_Char_Size (face, xsize, ysize, 0, 0))
{
return False;
}
}
f->xsize = xsize;
f->ysize = ysize;
}
......@@ -326,6 +384,9 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
double aspect;
FcMatrix *font_matrix;
FcBool hinting, vertical_layout, autohint, global_advance;
#ifdef FC_HINT_STYLE
int hint_style;
#endif
FcChar32 hash, *hashp;
FT_Face face;
int nhash;
......@@ -466,8 +527,65 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
goto bail1;
}
if (!hinting)
#ifdef FC_HINT_STYLE
switch (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style)) {
case FcResultNoMatch:
hint_style = FC_HINT_FULL;
break;
case FcResultMatch:
break;
default:
goto bail1;
}
#endif
if (!hinting
#ifdef FC_HINT_STYLE
|| hint_style == FC_HINT_NONE
#endif
)
{
fi->load_flags |= FT_LOAD_NO_HINTING;
}
/* Figure out the load target, which modifies the hinting
* behavior of FreeType based on the intended use of the glyphs.
*/
if (fi->antialias)
{
#ifdef FC_HINT_STYLE
#ifdef FT_LOAD_TARGET_LIGHT
if (FC_HINT_NONE < hint_style && hint_style < FC_HINT_FULL)
{
fi->load_flags |= FT_LOAD_TARGET_LIGHT;
}
else
#endif
#endif
{
/* autohinter will snap stems to integer widths, when
* the LCD targets are used.
*/
switch (fi->rgba) {
case FC_RGBA_RGB:
case FC_RGBA_BGR:
#ifdef FT_LOAD_TARGET_LCD
fi->load_flags |= FT_LOAD_TARGET_LCD;
#endif
break;
case FC_RGBA_VRGB:
case FC_RGBA_VBGR:
#ifdef FT_LOAD_TARGET_LCD_V
fi->load_flags |= FT_LOAD_TARGET_LCD_V;
#endif
break;
}
}
}
#ifdef FT_LOAD_TARGET_MONO
else
fi->load_flags |= FT_LOAD_TARGET_MONO;
#endif
/* set vertical layout if requested */
switch (FcPatternGetBool (pattern, FC_VERTICAL_LAYOUT, 0, &vertical_layout)) {
......@@ -638,6 +756,7 @@ XftFontOpenInfo (Display *dpy,
int alloc_size;
int ascent, descent, height;
int i;
int num_glyphs;
if (!info)
return 0;
......@@ -680,7 +799,9 @@ XftFontOpenInfo (Display *dpy,
* off and compute it. Yes, this is expensive, but it's
* required to map Unicode to glyph indices.
*/
if (FcPatternGetCharSet (pattern, FC_CHARSET, 0, &charset) != FcResultMatch)
if (FcPatternGetCharSet (pattern, FC_CHARSET, 0, &charset) == FcResultMatch)
charset = FcCharSetCopy (charset);
else
charset = FcFreeTypeCharSet (face, FcConfigGetBlanks (0));
antialias = fi->antialias;
......@@ -699,59 +820,20 @@ XftFontOpenInfo (Display *dpy,
case FC_RGBA_BGR:
case FC_RGBA_VRGB:
case FC_RGBA_VBGR:
pf.depth = 32;
pf.type = PictTypeDirect;
pf.direct.alpha = 24;
pf.direct.alphaMask = 0xff;
pf.direct.red = 16;
pf.direct.redMask = 0xff;
pf.direct.green = 8;
pf.direct.greenMask = 0xff;
pf.direct.blue = 0;
pf.direct.blueMask = 0xff;
format = XRenderFindFormat(dpy,
PictFormatType|
PictFormatDepth|
PictFormatAlpha|
PictFormatAlphaMask|
PictFormatRed|
PictFormatRedMask|
PictFormatGreen|
PictFormatGreenMask|
PictFormatBlue|
PictFormatBlueMask,
&pf, 0);
format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
break;
default:
pf.depth = 8;
pf.type = PictTypeDirect;
pf.direct.alpha = 0;
pf.direct.alphaMask = 0xff;
format = XRenderFindFormat(dpy,
PictFormatType|
PictFormatDepth|
PictFormatAlpha|
PictFormatAlphaMask,
&pf, 0);
format = XRenderFindStandardFormat (dpy, PictStandardA8);
break;
}
}
else
{
pf.depth = 1;
pf.type = PictTypeDirect;
pf.direct.alpha = 0;
pf.direct.alphaMask = 0x1;
format = XRenderFindFormat(dpy,
PictFormatType|
PictFormatDepth|
PictFormatAlpha|
PictFormatAlphaMask,
&pf, 0);
format