summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgbert Eich <eich@suse.de>2004-03-11 14:16:10 +0000
committerEgbert Eich <eich@suse.de>2004-03-11 14:16:10 +0000
commit348ed2ba79027c6d176266955ab3a376900d3c8d (patch)
treee0c41ef91c71516a410df829a2e23caa0e2b8d46
parentde8c26ccbbf3bdfaeec7eedbbeb3d097c4d1431a (diff)
downloadxorg-lib-libXft-348ed2ba79027c6d176266955ab3a376900d3c8d.tar.gz
29. Fixing glitches in the Imake rules, Adding a '#define
InstallFontconfigLibrary YES/NO' to allow to disable installation of fontconfig (Egbert Eich). 28. Updating fontconfig to 2.2.2 and Xft to 2.1.4 (Egbert Eich).
-rw-r--r--AUTHORS10
-rw-r--r--NEWS0
-rw-r--r--README18
-rw-r--r--include/X11/Xft/Xft.h4
-rw-r--r--include/X11/Xft/XftCompat.h2
-rw-r--r--man/Xft.3.in141
-rw-r--r--src/xftdpy.c12
-rw-r--r--src/xftdraw.c7
-rw-r--r--src/xftfreetype.c128
-rw-r--r--src/xftint.h4
-rw-r--r--src/xftname.c19
11 files changed, 326 insertions, 19 deletions
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/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
index 3a94937..4dcab4d 100644
--- a/README
+++ b/README
@@ -1,11 +1,19 @@
Xft
X FreeType library
- Version 2.1.1
- 2003-4-21
+ Version 2.1.3
+ 2003-3-10
-This 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.
+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 32af176..49c5720 100644
--- a/include/X11/Xft/Xft.h
+++ b/include/X11/Xft/Xft.h
@@ -33,13 +33,13 @@
#define XFT_MAJOR 2
#define XFT_MINOR 1
-#define XFT_REVISION 2
+#define XFT_REVISION 4
#define XFT_VERSION ((XFT_MAJOR * 10000) + (XFT_MINOR * 100) + (XFT_REVISION))
#define XftVersion XFT_VERSION
#include <stdarg.h>
#include <ft2build.h>
-#include <freetype/freetype.h>
+#include FT_FREETYPE_H
#include <fontconfig/fontconfig.h>
#include <X11/extensions/Xrender.h>
diff --git a/include/X11/Xft/XftCompat.h b/include/X11/Xft/XftCompat.h
index a6328a3..30e08e7 100644
--- a/include/X11/Xft/XftCompat.h
+++ b/include/X11/Xft/XftCompat.h
@@ -112,8 +112,6 @@ typedef FcObjectSet XftObjectSet;
#define XftObjectSetVaBuild FcObjectSetVaBuild
#define XftObjectSetBuild FcObjectSetBuild
-#define XftListFontsPatternObjects FcListFontsPatternObjects
-
#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/xftdpy.c b/src/xftdpy.c
index 0ec49d7..86f9c2a 100644
--- a/src/xftdpy.c
+++ b/src/xftdpy.c
@@ -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 3d49959..2eb3306 100644
--- a/src/xftdraw.c
+++ b/src/xftdraw.c
@@ -809,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))
@@ -916,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/xftfreetype.c b/src/xftfreetype.c
index 40b14df..063f678 100644
--- a/src/xftfreetype.c
+++ b/src/xftfreetype.c
@@ -192,8 +192,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))
+ {
+ 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
+#warning using old freetype without y_ppem
+#else
+#warning using new freetype with y_ppem
+#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;
}
@@ -328,6 +376,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;
@@ -468,8 +519,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)) {
@@ -683,7 +791,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;
@@ -715,7 +825,7 @@ XftFontOpenInfo (Display *dpy,
}
if (!format)
- goto bail0;
+ goto bail2;
}
else
format = 0;
@@ -744,7 +854,7 @@ XftFontOpenInfo (Display *dpy,
font = malloc (alloc_size);
if (!font)
- goto bail1;
+ goto bail2;
XftMemAlloc (XFT_MEM_FONT, alloc_size);
@@ -866,6 +976,8 @@ XftFontOpenInfo (Display *dpy,
return &font->public;
+bail2:
+ FcCharSetDestroy (charset);
bail1:
_XftUnlockFile (fi->file);
bail0:
@@ -922,6 +1034,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/xftint.h b/src/xftint.h
index fb36041..9e69900 100644
--- a/src/xftint.h
+++ b/src/xftint.h
@@ -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/xftname.c b/src/xftname.c
index 8981a8c..a9b9ff4 100644
--- a/src/xftname.c
+++ b/src/xftname.c
@@ -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);