diff options
author | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-03-17 20:29:01 +0000 |
---|---|---|
committer | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-03-17 20:29:01 +0000 |
commit | 0042f82b364d96f6c4747de481945d40e082a2d1 (patch) | |
tree | 4db22f0a4ff0761e5013f9467e9b94d9b8fb799e | |
parent | d7b40bfbde99825269c97a12af4897d9b5ef9be2 (diff) | |
download | xorg-lib-libXft-0042f82b364d96f6c4747de481945d40e082a2d1.tar.gz |
merge with XORG-RELEASE-1 (tag XORG-CYGWIN-LAST-MERGE)CYGWIN-RELEASE-1-MERGE
-rw-r--r-- | AUTHORS | 10 | ||||
-rw-r--r-- | COPYING | 22 | ||||
-rw-r--r-- | INSTALL | 8 | ||||
-rw-r--r-- | NEWS | 0 | ||||
-rw-r--r-- | README | 19 | ||||
-rw-r--r-- | include/X11/Xft/Xft.h | 12 | ||||
-rw-r--r-- | include/X11/Xft/XftCompat.h | 5 | ||||
-rw-r--r-- | man/Xft.3.in | 141 | ||||
-rw-r--r-- | src/xftcolor.c | 4 | ||||
-rw-r--r-- | src/xftcore.c | 8 | ||||
-rw-r--r-- | src/xftdbg.c | 4 | ||||
-rw-r--r-- | src/xftdpy.c | 16 | ||||
-rw-r--r-- | src/xftdraw.c | 13 | ||||
-rw-r--r-- | src/xftextent.c | 4 | ||||
-rw-r--r-- | src/xftfont.c | 4 | ||||
-rw-r--r-- | src/xftfreetype.c | 196 | ||||
-rw-r--r-- | src/xftglyphs.c | 31 | ||||
-rw-r--r-- | src/xftinit.c | 4 | ||||
-rw-r--r-- | src/xftint.h | 8 | ||||
-rw-r--r-- | src/xftlist.c | 4 | ||||
-rw-r--r-- | src/xftname.c | 23 | ||||
-rw-r--r-- | src/xftrender.c | 39 | ||||
-rw-r--r-- | src/xftstr.c | 4 | ||||
-rw-r--r-- | src/xftswap.c | 4 | ||||
-rw-r--r-- | src/xftxlfd.c | 10 | ||||
-rw-r--r-- | xft-config.in | 7 | ||||
-rw-r--r-- | xft.pc.in | 5 |
27 files changed, 487 insertions, 118 deletions
@@ -0,0 +1,10 @@ +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. @@ -0,0 +1,22 @@ +$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. + @@ -0,0 +1,8 @@ +Xft is built with the traditional configure script: + + $ ./configure --prefix=/usr/X11R6 + +This should generate valid Makefiles, then: + + $ make + $ make install @@ -0,0 +1,19 @@ + 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 diff --git a/include/X11/Xft/Xft.h b/include/X11/Xft/Xft.h index db3cd24..d495b58 100644 --- a/include/X11/Xft/Xft.h +++ b/include/X11/Xft/Xft.h @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/Xft.h,v 1.33 2003/11/20 22:36:33 dawes Exp $ + * $Id$ * - * 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 +25,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 5 #define XFT_VERSION ((XFT_MAJOR * 10000) + (XFT_MINOR * 100) + (XFT_REVISION)) #define XftVersion XFT_VERSION diff --git a/include/X11/Xft/XftCompat.h b/include/X11/Xft/XftCompat.h index 470b750..30e08e7 100644 --- a/include/X11/Xft/XftCompat.h +++ b/include/X11/Xft/XftCompat.h @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/XftCompat.h,v 1.6 2003/08/06 14:03:59 eich Exp $ + * $Id$ * - * 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 +111,7 @@ typedef FcObjectSet XftObjectSet; #define XftObjectSetDestroy FcObjectSetDestroy #define XftObjectSetVaBuild FcObjectSetVaBuild #define XftObjectSetBuild FcObjectSetBuild + #define XftFontSetMatch FcFontSetMatch #define XftFontSetDestroy FcFontSetDestroy diff --git a/man/Xft.3.in b/man/Xft.3.in new file mode 100644 index 0000000..b7313d8 --- /dev/null +++ b/man/Xft.3.in @@ -0,0 +1,141 @@ +.\" +.\" $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, member of the XFree86 Project, Inc. diff --git a/src/xftcolor.c b/src/xftcolor.c index 7a5005d..4d17045 100644 --- a/src/xftcolor.c +++ b/src/xftcolor.c @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftcolor.c,v 1.3 2002/10/11 17:53:02 keithp Exp $ + * $Id$ * - * 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 diff --git a/src/xftcore.c b/src/xftcore.c index 25e78b7..4c8470a 100644 --- a/src/xftcore.c +++ b/src/xftcore.c @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftcore.c,v 1.14 2003/05/27 22:26:40 tsi Exp $ + * $Id$ * - * 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 +918,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]; diff --git a/src/xftdbg.c b/src/xftdbg.c index 4f5a6cf..0c6e8c9 100644 --- a/src/xftdbg.c +++ b/src/xftdbg.c @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftdbg.c,v 1.4 2002/02/15 07:36:10 keithp Exp $ + * $Id$ * - * 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 diff --git a/src/xftdpy.c b/src/xftdpy.c index 09f5f0e..86f9c2a 100644 --- a/src/xftdpy.c +++ b/src/xftdpy.c @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftdpy.c,v 1.20 2002/10/11 17:53:02 keithp Exp $ + * $Id$ * - * 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 +377,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 +477,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, diff --git a/src/xftdraw.c b/src/xftdraw.c index e25bf5b..2eb3306 100644 --- a/src/xftdraw.c +++ b/src/xftdraw.c @@ -1,7 +1,7 @@ /* - * $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; diff --git a/src/xftextent.c b/src/xftextent.c index d8e91e5..25e096e 100644 --- a/src/xftextent.c +++ b/src/xftextent.c @@ -1,7 +1,7 @@ /* - * $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 diff --git a/src/xftfont.c b/src/xftfont.c index 7698d60..8c28d97 100644 --- a/src/xftfont.c +++ b/src/xftfont.c @@ -1,7 +1,7 @@ /* - * $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 diff --git a/src/xftfreetype.c b/src/xftfreetype.c index 6fce545..d6285b4 100644 --- a/src/xftfreetype.c +++ b/src/xftfreetype.c @@ -1,7 +1,7 @@ /* - * $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; } @@ -190,8 +192,53 @@ _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)) + { + FT_Short width = xsize >> 6; + FT_Short height = ysize >> 6; + int i, best = -1; + +#define xft_abs(a) ((a) < 0 ? -(a) : (a)) +#define dist(a,b) (xft_abs((a)-(b))) + +#if !HAVE_FT_BITMAP_SIZE_Y_PPEM +#define y_ppem height +#define x_ppem width +#endif + for (i = 0; i < face->num_fixed_sizes; i++) + { + if (best == -1 || + dist (height, face->available_sizes[i].y_ppem >> 6) < + dist (height, face->available_sizes[best].y_ppem >> 6) || + (dist (height, face->available_sizes[i].y_ppem >> 6) == + dist (height, face->available_sizes[best].y_ppem >> 6) && + dist (width, face->available_sizes[i].x_ppem >> 6) < + dist (width, face->available_sizes[best].x_ppem >> 6))) + { + best = i; + } + } + if (FT_Set_Char_Size (face, face->available_sizes[best].x_ppem, + face->available_sizes[best].y_ppem, 0, 0) != 0) + { + return False; + } +#if !HAVE_FT_BITMAP_SIZE_Y_PPEM +#undef y_ppem +#undef x_ppem +#endif + } + else + { + if (FT_Set_Char_Size (face, xsize, ysize, 0, 0)) + { + return False; + } + } f->xsize = xsize; f->ysize = ysize; } @@ -326,6 +373,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 +516,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 +745,7 @@ XftFontOpenInfo (Display *dpy, int alloc_size; int ascent, descent, height; int i; + int num_glyphs; if (!info) return 0; @@ -680,7 +788,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 +809,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 = XRenderFindStandardFormat (dpy, PictStandardA1); } if (!format) - goto bail0; + goto bail2; } else format = 0; @@ -769,13 +840,18 @@ XftFontOpenInfo (Display *dpy, rehash_value = 0; } + /* + * Sometimes the glyphs are numbered 1..n, other times 0..n-1, + * accept either numbering scheme by making room in the table + */ + num_glyphs = face->num_glyphs + 1; alloc_size = (sizeof (XftFontInt) + - face->num_glyphs * sizeof (XftGlyph *) + + num_glyphs * sizeof (XftGlyph *) + hash_value * sizeof (XftUcsHash)); font = malloc (alloc_size); if (!font) - goto bail1; + goto bail2; XftMemAlloc (XFT_MEM_FONT, alloc_size); @@ -867,8 +943,8 @@ XftFontOpenInfo (Display *dpy, * Per glyph information */ font->glyphs = (XftGlyph **) (font + 1); - memset (font->glyphs, '\0', face->num_glyphs * sizeof (XftGlyph *)); - font->num_glyphs = face->num_glyphs; + memset (font->glyphs, '\0', num_glyphs * sizeof (XftGlyph *)); + font->num_glyphs = num_glyphs; /* * Unicode hash table information */ @@ -897,6 +973,8 @@ XftFontOpenInfo (Display *dpy, return &font->public; +bail2: + FcCharSetDestroy (charset); bail1: _XftUnlockFile (fi->file); bail0: @@ -929,9 +1007,13 @@ XftFontCopy (Display *dpy, XftFont *public) static void XftFontDestroy (Display *dpy, XftFont *public) { - XftFontInt *font = (XftFontInt *) public; - int i; + XftDisplayInfo *info = _XftDisplayInfoGet (dpy, False); + XftFontInt *font = (XftFontInt *) public; + int i; + /* note reduction in memory use */ + if (info) + info->glyph_memory -= font->glyph_memory; /* Clean up the info */ XftFontInfoEmpty (dpy, &font->info); /* Free the glyphset */ @@ -949,6 +1031,10 @@ XftFontDestroy (Display *dpy, XftFont *public) } } + /* Free the pattern and the charset */ + FcPatternDestroy (font->public.pattern); + FcCharSetDestroy (font->public.charset); + /* Finally, free the font structure */ XftMemFree (XFT_MEM_FONT, sizeof (XftFontInt) + font->num_glyphs * sizeof (XftGlyph *) + diff --git a/src/xftglyphs.c b/src/xftglyphs.c index 900f1f5..51fc816 100644 --- a/src/xftglyphs.c +++ b/src/xftglyphs.c @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftglyphs.c,v 1.24 2003/11/20 22:36:33 dawes Exp $ + * $Id$ * - * 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 @@ -26,8 +26,7 @@ #include <stdlib.h> #include <string.h> #include "xftint.h" -#include <ft2build.h> -#include FT_OUTLINE_H +#include <freetype/ftoutln.h> #include <fontconfig/fcfreetype.h> static const int filters[3][3] = { @@ -535,9 +534,14 @@ XftFontLoadGlyphs (Display *dpy, } else { - xftg->bitmap = malloc (sizergba); - if (xftg->bitmap) - memcpy (xftg->bitmap, bufBitmapRgba, sizergba); + if (sizergba) + { + xftg->bitmap = malloc (sizergba); + if (xftg->bitmap) + memcpy (xftg->bitmap, bufBitmapRgba, sizergba); + } + else + xftg->bitmap = 0; } } else @@ -576,9 +580,14 @@ XftFontLoadGlyphs (Display *dpy, } else { - xftg->bitmap = malloc (size); - if (xftg->bitmap) - memcpy (xftg->bitmap, bufBitmap, size); + if (size) + { + xftg->bitmap = malloc (size); + if (xftg->bitmap) + memcpy (xftg->bitmap, bufBitmap, size); + } + else + xftg->bitmap = 0; } } font->glyph_memory += xftg->glyph_memory; @@ -735,7 +744,7 @@ XftCharIndex (Display *dpy, offset = 1; } ent = ent + offset; - if (ent > font->hash_value) + if (ent >= font->hash_value) ent -= font->hash_value; } return font->hash_table[ent].glyph; diff --git a/src/xftinit.c b/src/xftinit.c index b858503..7cb4bb9 100644 --- a/src/xftinit.c +++ b/src/xftinit.c @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftinit.c,v 1.5 2002/10/11 17:53:02 keithp Exp $ + * $Id$ * - * 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 diff --git a/src/xftint.h b/src/xftint.h index f867cec..9e69900 100644 --- a/src/xftint.h +++ b/src/xftint.h @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftint.h,v 1.37 2002/10/11 17:53:02 keithp Exp $ + * $Id$ * - * 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 @@ -33,6 +33,10 @@ #ifndef _XFTINT_H_ #define _XFTINT_H_ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <X11/Xlib.h> #include <X11/Xmd.h> #define _XFT_NO_COMPAT_ diff --git a/src/xftlist.c b/src/xftlist.c index e96f553..3f7b390 100644 --- a/src/xftlist.c +++ b/src/xftlist.c @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftlist.c,v 1.4 2003/08/06 14:03:59 eich Exp $ + * $Id$ * - * 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 diff --git a/src/xftname.c b/src/xftname.c index ae0ab2e..a9b9ff4 100644 --- a/src/xftname.c +++ b/src/xftname.c @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftname.c,v 1.12 2002/05/24 07:02:38 keithp Exp $ + * $Id$ * - * 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 @@ -33,13 +33,14 @@ static const FcObjectType _XftObjectTypes[] = { #define NUM_OBJECT_TYPES (sizeof _XftObjectTypes / sizeof _XftObjectTypes[0]) -Bool _XftNameInitialized; +FcBool _XftNameInitialized; void _XftNameInit (void) { if (_XftNameInitialized) return; + _XftNameInitialized = FcTrue; FcNameRegisterObjectTypes (_XftObjectTypes, NUM_OBJECT_TYPES); } @@ -55,13 +56,27 @@ XftNameUnparse (FcPattern *pat, char *dest, int len) { FcChar8 *name; + _XftNameInit (); name = FcNameUnparse (pat); if (!name) return FcFalse; if (strlen ((char *) name) + 1 > len) { + FcPattern *new = FcPatternDuplicate (pat); free (name); - return FcFalse; + FcPatternDel (new, FC_LANG); + FcPatternDel (new, FC_CHARSET); + name = FcNameUnparse (new); + FcPatternDestroy (new); + if (!name) + return FcFalse; + if (strlen ((char *) name) + 1 > len) + { + strncpy (dest, ((char *) name), (size_t) len - 1); + dest[len - 1] = '\0'; + free (name); + return FcFalse; + } } strcpy (dest, ((char *) name)); free (name); diff --git a/src/xftrender.c b/src/xftrender.c index 1836a14..f027eb4 100644 --- a/src/xftrender.c +++ b/src/xftrender.c @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftrender.c,v 1.15 2002/12/14 01:59:38 dawes Exp $ + * $Id$ * - * 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 @@ -386,6 +386,31 @@ XftCharSpecRender (Display *dpy, free (glyphs); } +/* + * Choose which format to draw text in when drawing with fonts + * of different formats. The trick is that ARGB formats aren't + * compatible with A formats as PictOpAdd does the wrong thing, so + * fall back to an A format when presented with an ARGB and A format + */ + +#define XftIsARGBFormat(a) ((a)->depth == 32) + +static XRenderPictFormat * +XftPreferFormat (Display *dpy, XRenderPictFormat *a, XRenderPictFormat *b) +{ + XRenderPictFormat *prefer = 0; + + if (a == b) + prefer = a; + else if (XftIsARGBFormat(a) != XftIsARGBFormat(b)) + prefer = XRenderFindStandardFormat (dpy, PictStandardA8); + else if (a->depth > b->depth) + prefer = a; + else + prefer = b; + return prefer; +} + void XftGlyphFontSpecRender (Display *dpy, int op, @@ -399,6 +424,7 @@ XftGlyphFontSpecRender (Display *dpy, int i, j; XftFont *prevPublic; XftFontInt *firstFont; + XRenderPictFormat *format; FT_UInt missing[XFT_NMISSING]; int nmissing; int n; @@ -496,6 +522,7 @@ XftGlyphFontSpecRender (Display *dpy, if (i == nglyphs) goto bail2; glyph = firstFont->glyphs[g]; + format = firstFont->format; x = glyphs[i].x + glyph->metrics.xOff; y = glyphs[i].y + glyph->metrics.yOff; prevPublic = 0; @@ -516,6 +543,8 @@ XftGlyphFontSpecRender (Display *dpy, if (pub != prevPublic || x != glyphs[i].x || y != glyphs[i].y) { prevPublic = pub; + if (font->format != format) + format = XftPreferFormat (dpy, font->format, format); x = glyphs[i].x; y = glyphs[i].y; ++nelt; @@ -586,17 +615,17 @@ XftGlyphFontSpecRender (Display *dpy, } switch (width) { case 1: - XRenderCompositeText8 (dpy, op, src, dst, firstFont->format, + XRenderCompositeText8 (dpy, op, src, dst, format, srcx, srcy, glyphs[0].x, glyphs[0].y, elts, nelt); break; case 2: - XRenderCompositeText16 (dpy, op, src, dst, firstFont->format, + XRenderCompositeText16 (dpy, op, src, dst, format, srcx, srcy, glyphs[0].x, glyphs[0].y, (XGlyphElt16 *) elts, nelt); break; case 4: - XRenderCompositeText32 (dpy, op, src, dst, firstFont->format, + XRenderCompositeText32 (dpy, op, src, dst, format, srcx, srcy, glyphs[0].x, glyphs[0].y, (XGlyphElt32 *) elts, nelt); break; diff --git a/src/xftstr.c b/src/xftstr.c index 473ffad..f6cbd35 100644 --- a/src/xftstr.c +++ b/src/xftstr.c @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftstr.c,v 1.7 2002/02/15 07:36:11 keithp Exp $ + * $Id$ * - * 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 diff --git a/src/xftswap.c b/src/xftswap.c index d9c5313..f632a87 100644 --- a/src/xftswap.c +++ b/src/xftswap.c @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftswap.c,v 1.1 2002/02/15 07:37:35 keithp Exp $ + * $Id$ * - * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. + * Copyright © 2002 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 diff --git a/src/xftxlfd.c b/src/xftxlfd.c index dd15630..26a84c9 100644 --- a/src/xftxlfd.c +++ b/src/xftxlfd.c @@ -1,7 +1,7 @@ /* - * $XFree86: xc/lib/Xft/xftxlfd.c,v 1.10 2003/05/27 22:26:41 tsi Exp $ + * $Id$ * - * 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 @@ -94,6 +94,8 @@ XftXlfdParse (const char *xlfd_orig, FcBool ignore_scalable, FcBool complete) const char *family; const char *weight_name; const char *slant; + const char *registry; + const char *encoding; char *save; int pixel; int point; @@ -116,9 +118,9 @@ XftXlfdParse (const char *xlfd_orig, FcBool ignore_scalable, FcBool complete) if (!(xlfd = XftGetInt (++xlfd, &resy))) return 0; if (!(xlfd = strchr (/* spacing = */ ++xlfd, '-'))) return 0; if (!(xlfd = strchr (/* average_width = */ ++xlfd, '-'))) return 0; - if (!(xlfd = strchr (/* registry = */ ++xlfd, '-'))) return 0; + if (!(xlfd = strchr (registry = ++xlfd, '-'))) return 0; /* make sure no fields follow this one */ - if ((xlfd = strchr (/* encoding = */ ++xlfd, '-'))) return 0; + if ((xlfd = strchr (encoding = ++xlfd, '-'))) return 0; if (!pixel) return 0; diff --git a/xft-config.in b/xft-config.in index 755ad83..549b73a 100644 --- a/xft-config.in +++ b/xft-config.in @@ -3,9 +3,8 @@ prefix="@prefix@" exec_prefix="@exec_prefix@" libdir="@libdir@" -hardcode_libdir_flag_spec=@hardcode_libdir_flag_spec@ includedir="@includedir@" -version="@PACKAGE_VERSION@" +version="@VERSION@" freetypelibs="@FREETYPE_LIBS@" freetypecflags="@FREETYPE_CFLAGS@" fontconfiglibs="@FONTCONFIG_LIBS@" @@ -90,9 +89,9 @@ if test "$echo_cflags" = "yes" ; then fi if test "$echo_libs" = "yes" ; then - libs="-lXft ${freetypelibs} ${fontconfiglibs} ${xrenderlibs}" + libs="-lXft -lX11 ${freetypelibs} ${fontconfiglibs} ${xrenderlibs}" if test "${libdir}" != "/usr/lib" ; then - echo ${hardcode_libdir_flag_spec} -L${libdir} $libs + echo -L${libdir} $libs else echo $libs fi @@ -1,7 +1,6 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ -hardcode_libdir_flag_spec=@hardcode_libdir_flag_spec@ includedir=@includedir@ freetypelibs=@FREETYPE_LIBS@ freetypecflags=@FREETYPE_CFLAGS@ @@ -10,7 +9,7 @@ xrendercflags=@XRENDER_CFLAGS@ Name: Xft Description: X FreeType library -Version: @PACKAGE_VERSION@ +Version: @VERSION@ Requires: fontconfig -Libs: ${hardcode_libdir_flag_spec} -L${libdir} -lXft ${freetypelibs} ${xrenderlibs} +Libs: -L${libdir} -lXft -lX11 ${freetypelibs} ${xrenderlibs} Cflags: -I${includedir} ${freetypecflags} ${xrendercflags} |