From db5107de2f1289e23dd21d4adb75f39485a2b8ee Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Thu, 15 Apr 2004 10:15:02 +0000 Subject: Merged changes from RELEASE-1 branch --- AUTHORS | 10 +++ COPYING | 22 +++++ INSTALL | 8 ++ NEWS | 0 README | 19 ++++ include/X11/Xft/Xft.h | 11 ++- include/X11/Xft/XftCompat.h | 4 +- man/Xft.3.in | 141 ++++++++++++++++++++++++++++++ src/xftcolor.c | 3 +- src/xftcore.c | 7 +- src/xftdbg.c | 3 +- src/xftdpy.c | 15 +++- src/xftdraw.c | 11 ++- src/xftextent.c | 2 +- src/xftfont.c | 2 +- src/xftfreetype.c | 205 ++++++++++++++++++++++++++++++++------------ src/xftglyphs.c | 30 ++++--- src/xftinit.c | 3 +- src/xftint.h | 7 +- src/xftlist.c | 3 +- src/xftname.c | 22 ++++- src/xftrender.c | 38 ++++++-- src/xftstr.c | 3 +- src/xftswap.c | 3 +- src/xftxlfd.c | 9 +- xft-config.in | 7 +- xft.pc.in | 5 +- 27 files changed, 479 insertions(+), 114 deletions(-) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 INSTALL create mode 100644 NEWS create mode 100644 README create mode 100644 man/Xft.3.in diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..c49ee49 --- /dev/null +++ b/AUTHORS @@ -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. diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..4ee13ed --- /dev/null +++ b/COPYING @@ -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. + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..85a6759 --- /dev/null +++ b/INSTALL @@ -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 diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..4dcab4d --- /dev/null +++ b/README @@ -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 5fe5545..d6199b1 100644 --- a/include/X11/Xft/Xft.h +++ b/include/X11/Xft/Xft.h @@ -1,7 +1,6 @@ /* - * $XFree86: xc/lib/Xft/Xft.h,v 1.32 2003/02/25 21:57:53 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 diff --git a/include/X11/Xft/XftCompat.h b/include/X11/Xft/XftCompat.h index 4f07ec1..34a6d08 100644 --- a/include/X11/Xft/XftCompat.h +++ b/include/X11/Xft/XftCompat.h @@ -1,7 +1,6 @@ /* - * $XFree86: xc/lib/Xft/XftCompat.h,v 1.4 2002/05/24 05:54:02 keithp 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 diff --git a/man/Xft.3.in b/man/Xft.3.in new file mode 100644 index 0000000..4c9f95c --- /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 diff --git a/src/xftcolor.c b/src/xftcolor.c index 05faf0d..7377c78 100644 --- a/src/xftcolor.c +++ b/src/xftcolor.c @@ -1,7 +1,6 @@ /* - * $XFree86: xc/lib/Xft/xftcolor.c,v 1.1 2000/12/01 03:27:57 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/xftcore.c b/src/xftcore.c index 7e3dc04..f43e467 100644 --- a/src/xftcore.c +++ b/src/xftcore.c @@ -1,7 +1,6 @@ /* - * $XFree86: xc/lib/Xft/xftcore.c,v 1.13tsi 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]; diff --git a/src/xftdbg.c b/src/xftdbg.c index 8c0c13c..c30c6d3 100644 --- a/src/xftdbg.c +++ b/src/xftdbg.c @@ -1,7 +1,6 @@ /* - * $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. + * 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 8384be5..1b38424 100644 --- a/src/xftdpy.c +++ b/src/xftdpy.c @@ -1,7 +1,6 @@ /* - * $XFree86: xc/lib/Xft/xftdpy.c,v 1.18 2002/10/02 07:02:32 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, diff --git a/src/xftdraw.c b/src/xftdraw.c index b6d8542..2eb3306 100644 --- a/src/xftdraw.c +++ b/src/xftdraw.c @@ -1,7 +1,7 @@ /* * $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 9e3e4e3..25e096e 100644 --- a/src/xftextent.c +++ b/src/xftextent.c @@ -1,7 +1,7 @@ /* * $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 de11c28..8c28d97 100644 --- a/src/xftfont.c +++ b/src/xftfont.c @@ -1,7 +1,7 @@ /* * $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 2846065..1a52c21 100644 --- a/src/xftfreetype.c +++ b/src/xftfreetype.c @@ -1,7 +1,7 @@ /* * $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 = XRenderFindStandardFormat (dpy, PictStandardA1); } if (!format) - goto bail0; + goto bail2; } else format = 0; @@ -769,13 +851,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 +954,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 +984,8 @@ XftFontOpenInfo (Display *dpy, return &font->public; +bail2: + FcCharSetDestroy (charset); bail1: _XftUnlockFile (fi->file); bail0: @@ -929,9 +1018,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 +1042,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 8fa633f..a9d1ecc 100644 --- a/src/xftglyphs.c +++ b/src/xftglyphs.c @@ -1,7 +1,6 @@ /* - * $XFree86: xc/lib/Xft/xftglyphs.c,v 1.23 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 @@ -26,8 +25,7 @@ #include #include #include "xftint.h" -#include -#include FT_OUTLINE_H +#include #include static const int filters[3][3] = { @@ -535,9 +533,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 +579,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 +743,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 5894725..a4ad682 100644 --- a/src/xftinit.c +++ b/src/xftinit.c @@ -1,7 +1,6 @@ /* - * $XFree86: xc/lib/Xft/xftinit.c,v 1.3 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/xftint.h b/src/xftint.h index 868360e..bf5e07c 100644 --- a/src/xftint.h +++ b/src/xftint.h @@ -1,7 +1,6 @@ /* - * $XFree86: xc/lib/Xft/xftint.h,v 1.36 2002/08/22 08:09:40 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 @@ -33,6 +32,10 @@ #ifndef _XFTINT_H_ #define _XFTINT_H_ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #define _XFT_NO_COMPAT_ diff --git a/src/xftlist.c b/src/xftlist.c index 3a4a312..edf2e52 100644 --- a/src/xftlist.c +++ b/src/xftlist.c @@ -1,7 +1,6 @@ /* - * $XFree86: xc/lib/Xft/xftlist.c,v 1.2 2000/12/07 23:57:28 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/xftname.c b/src/xftname.c index 687006b..cac2817 100644 --- a/src/xftname.c +++ b/src/xftname.c @@ -1,7 +1,6 @@ /* - * $XFree86: xc/lib/Xft/xftname.c,v 1.11 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 @@ -33,13 +32,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 +55,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 60ca222..1cf2882 100644 --- a/src/xftrender.c +++ b/src/xftrender.c @@ -1,7 +1,6 @@ /* - * $XFree86: xc/lib/Xft/xftrender.c,v 1.14 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 @@ -386,6 +385,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 +423,7 @@ XftGlyphFontSpecRender (Display *dpy, int i, j; XftFont *prevPublic; XftFontInt *firstFont; + XRenderPictFormat *format; FT_UInt missing[XFT_NMISSING]; int nmissing; int n; @@ -496,6 +521,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 +542,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 +614,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 33043cf..85aaf9a 100644 --- a/src/xftstr.c +++ b/src/xftstr.c @@ -1,7 +1,6 @@ /* - * $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. + * 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 ce813f5..e60a646 100644 --- a/src/xftswap.c +++ b/src/xftswap.c @@ -1,7 +1,6 @@ /* - * $XFree86: $ * - * 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 84e394b..55d9488 100644 --- a/src/xftxlfd.c +++ b/src/xftxlfd.c @@ -1,7 +1,6 @@ /* - * $XFree86: xc/lib/Xft/xftxlfd.c,v 1.9tsi 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 @@ -94,6 +93,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 +117,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 diff --git a/xft.pc.in b/xft.pc.in index 1ec7df8..4c1808b 100644 --- a/xft.pc.in +++ b/xft.pc.in @@ -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} -- cgit v1.2.1