Remove freetype, xft and expat locally since it's not needed anymore. r=cls

git-svn-id: svn://10.0.0.236/trunk@133672 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
blizzard%redhat.com 2002-11-12 19:11:14 +00:00
parent 104b450b14
commit 30c98e4851
540 changed files with 0 additions and 191770 deletions

View File

@ -1,11 +0,0 @@
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = Xrender fontconfig Xft
include $(topsrcdir)/config/rules.mk

View File

@ -1,47 +0,0 @@
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = Xft/X11/Xft
LIBRARY_NAME = Xft
EXPORT_LIBRARY = 1
EXPORTS = \
Xft.h \
XftCompat.h
REQUIRES = \
freetype2 \
fontconfig \
Xrender
CSRCS = \
xftcolor.c \
xftdbg.c \
xftdpy.c \
xftdraw.c \
xftextent.c \
xftfont.c \
xftinit.c \
xftlist.c \
xftname.c \
xftstr.c \
xftswap.c \
xftxlfd.c \
xftfreetype.c \
xftglyphs.c \
xftrender.c \
xftcore.c
# make it a static lib only
FORCE_STATIC_LIB=1
include $(topsrcdir)/config/rules.mk
ifdef MOZ_XFT_SYSTEM_FREETYPE2
CFLAGS += $(FT2_CFLAGS)
endif

View File

@ -1,150 +0,0 @@
LIBRARY Xft
VERSION LIBRARY_VERSION
EXPORTS
XftConfigAddDir
XftConfigAddEdit
XftConfigGetCache
XftConfigSetCache
XftConfigSubstitute
_XftConfigCompareValue
XftColorAllocName
XftColorAllocValue
XftColorFree
XftCoreConvert16
XftCoreConvert32
XftCoreConvertUtf8
XftCoreExtents16
XftCoreExtents32
XftCoreExtents8
XftCoreExtentsUtf8
XftCoreGlyphExists
XftEditPrint
XftExprPrint
XftFontSetPrint
XftOpPrint
XftPatternPrint
XftSubstPrint
XftTestPrint
XftValueListPrint
XftValuePrint
XftDefaultGetBool
XftDefaultGetDouble
XftDefaultGetInteger
XftDefaultHasRender
XftDefaultParseBool
XftDefaultSet
XftDefaultSubstitute
XftDisplayGetFontSet
XftDrawChange
XftDrawCorePrepare
XftDrawCreate
XftDrawCreateBitmap
XftDrawDestroy
XftDrawRect
XftDrawRenderPrepare
XftDrawSetClip
XftDrawString16
XftDrawString32
XftDrawString8
XftDrawStringUtf8
XftTextExtents16
XftTextExtents32
XftTextExtents8
XftTextExtentsUtf8
XftFontClose
XftFontMatch
XftFontOpen
XftFontOpenName
XftFontOpenPattern
XftFontOpenXlfd
XftGlyphExists
_XftFontDebug
XftFontSetAdd
XftFontSetCreate
XftFontSetDestroy
XftConfigSaveField
XftConfigerror
XftConfigparse
XftConfigwrap
XftEditCreate
XftEditDestroy
XftExprCreateBool
XftExprCreateDouble
XftExprCreateField
XftExprCreateInteger
XftExprCreateNil
XftExprCreateOp
XftExprCreateString
XftExprDestroy
XftTestCreate
XftInit
XftConfigLexFile
XftConfigPushInput
XftConfig_create_buffer
XftConfig_delete_buffer
XftConfig_flush_buffer
XftConfig_init_buffer
XftConfig_load_buffer_state
XftConfig_scan_buffer
XftConfig_scan_bytes
XftConfig_scan_string
XftConfig_switch_to_buffer
XftConfiglex
XftConfigrestart
XftListAppend
XftListFontSets
XftListFonts
XftListFontsPatternObjects
XftListMatch
XftListValueCompare
XftListValueListCompare
XftObjectSetAdd
XftObjectSetBuild
XftObjectSetCreate
XftObjectSetDestroy
XftObjectSetVaBuild
XftFontSetMatch
XftNameConstant
XftNameParse
XftNameUnparse
XftPatternAdd
XftPatternAddBool
XftPatternAddDouble
XftPatternAddInteger
XftPatternAddString
XftPatternBuild
XftPatternCreate
XftPatternDel
XftPatternDestroy
XftPatternDuplicate
XftPatternFind
XftPatternGet
XftPatternGetBool
XftPatternGetDouble
XftPatternGetInteger
XftPatternGetString
XftPatternVaBuild
XftValueDestroy
XftValueListDestroy
XftUtf8Len
XftUtf8ToUcs4
_XftDownStr
_XftGetInt
_XftMatchSymbolic
_XftSaveString
_XftSplitField
_XftSplitStr
_XftSplitValue
_XftStrCmpIgnoreCase
XftCoreAddFonts
XftCoreClose
XftCoreOpen
XftXlfdParse
XftInitFtLibrary
XftConfigDirs
XftDirScan
XftDirSave
/* $XFree86: xc/lib/Xft/Xft-def.cpp,v 1.2 2001/04/05 19:29:38 dawes Exp $ */

View File

@ -1,561 +0,0 @@
/*
* $XFree86: xc/lib/Xft/Xft.h,v 1.22 2002/02/21 05:30:31 keithp Exp $
*
* 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
* 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.
*/
#ifndef _XFT_H_
#define _XFT_H_
#define XftVersion 20000
#include <stdarg.h>
#include <freetype/freetype.h>
#include <fontconfig/fontconfig.h>
#include <X11/extensions/Xrender.h>
#include <X11/Xfuncproto.h>
/* #include <X11/Xosdefs.h>*/
#ifndef _XFT_NO_COMPAT_
#include <X11/Xft/XftCompat.h>
#endif
#define XFT_CORE "core"
#define XFT_RENDER "render"
#define XFT_XLFD "xlfd"
#define XFT_MAX_GLYPH_MEMORY "maxglyphmemory"
extern FT_Library _XftFTlibrary;
typedef struct _XftFont {
int ascent;
int descent;
int height;
int max_advance_width;
FcCharSet *charset;
FcPattern *pattern;
} XftFont;
typedef struct _XftDraw XftDraw;
typedef struct _XftColor {
unsigned long pixel;
XRenderColor color;
} XftColor;
typedef struct _XftCharSpec {
FcChar32 ucs4;
short x;
short y;
} XftCharSpec;
typedef struct _XftCharFontSpec {
XftFont *font;
FcChar32 ucs4;
short x;
short y;
} XftCharFontSpec;
typedef struct _XftGlyphSpec {
FT_UInt glyph;
short x;
short y;
} XftGlyphSpec;
typedef struct _XftGlyphFontSpec {
XftFont *font;
FT_UInt glyph;
short x;
short y;
} XftGlyphFontSpec;
_XFUNCPROTOBEGIN
/* xftcolor.c */
Bool
XftColorAllocName (Display *dpy,
Visual *visual,
Colormap cmap,
char *name,
XftColor *result);
Bool
XftColorAllocValue (Display *dpy,
Visual *visual,
Colormap cmap,
XRenderColor *color,
XftColor *result);
void
XftColorFree (Display *dpy,
Visual *visual,
Colormap cmap,
XftColor *color);
/* xftcore.c */
/* xftdir.c */
FcBool
XftDirScan (FcFontSet *set, const char *dir, FcBool force);
FcBool
XftDirSave (FcFontSet *set, const char *dir);
/* xftdpy.c */
Bool
XftDefaultHasRender (Display *dpy);
Bool
XftDefaultSet (Display *dpy, FcPattern *defaults);
void
XftDefaultSubstitute (Display *dpy, int screen, FcPattern *pattern);
/* xftdraw.c */
XftDraw *
XftDrawCreate (Display *dpy,
Drawable drawable,
Visual *visual,
Colormap colormap);
XftDraw *
XftDrawCreateBitmap (Display *dpy,
Pixmap bitmap);
XftDraw *
XftDrawCreateAlpha (Display *dpy,
Pixmap pixmap,
int depth);
void
XftDrawChange (XftDraw *draw,
Drawable drawable);
Display *
XftDrawDisplay (XftDraw *draw);
Drawable
XftDrawDrawable (XftDraw *draw);
Colormap
XftDrawColormap (XftDraw *draw);
Visual *
XftDrawVisual (XftDraw *draw);
void
XftDrawDestroy (XftDraw *draw);
Picture
XftDrawPicture (XftDraw *draw);
void
XftDrawGlyphs (XftDraw *draw,
XftColor *color,
XftFont *pub,
int x,
int y,
FT_UInt *glyphs,
int nglyphs);
void
XftDrawString8 (XftDraw *d,
XftColor *color,
XftFont *font,
int x,
int y,
FcChar8 *string,
int len);
void
XftDrawString16 (XftDraw *draw,
XftColor *color,
XftFont *font,
int x,
int y,
FcChar16 *string,
int len);
void
XftDrawString32 (XftDraw *draw,
XftColor *color,
XftFont *font,
int x,
int y,
FcChar32 *string,
int len);
void
XftDrawStringUtf8 (XftDraw *d,
XftColor *color,
XftFont *font,
int x,
int y,
FcChar8 *string,
int len);
void
XftDrawCharSpec (XftDraw *d,
XftColor *color,
XftFont *font,
XftCharSpec *chars,
int len);
void
XftDrawCharFontSpec (XftDraw *d,
XftColor *color,
XftCharFontSpec *chars,
int len);
void
XftDrawGlyphSpec (XftDraw *d,
XftColor *color,
XftFont *font,
XftGlyphSpec *glyphs,
int len);
void
XftDrawGlyphFontSpec (XftDraw *d,
XftColor *color,
XftGlyphFontSpec *glyphs,
int len);
void
XftDrawRect (XftDraw *d,
XftColor *color,
int x,
int y,
unsigned int width,
unsigned int height);
Bool
XftDrawSetClip (XftDraw *d,
Region r);
/* xftextent.c */
void
XftGlyphExtents (Display *dpy,
XftFont *pub,
FT_UInt *glyphs,
int nglyphs,
XGlyphInfo *extents);
void
XftTextExtents8 (Display *dpy,
XftFont *font,
FcChar8 *string,
int len,
XGlyphInfo *extents);
void
XftTextExtents16 (Display *dpy,
XftFont *font,
FcChar16 *string,
int len,
XGlyphInfo *extents);
void
XftTextExtents32 (Display *dpy,
XftFont *font,
FcChar32 *string,
int len,
XGlyphInfo *extents);
void
XftTextExtentsUtf8 (Display *dpy,
XftFont *font,
FcChar8 *string,
int len,
XGlyphInfo *extents);
/* xftfont.c */
FcPattern *
XftFontMatch (Display *dpy, int screen, FcPattern *pattern, FcResult *result);
XftFont *
XftFontOpen (Display *dpy, int screen, ...);
XftFont *
XftFontOpenName (Display *dpy, int screen, const char *name);
XftFont *
XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd);
/* xftfreetype.c */
FT_Face
XftLockFace (XftFont *font);
void
XftUnlockFace (XftFont *font);
XftFont *
XftFontOpenPattern (Display *dpy, FcPattern *pattern);
XftFont *
XftFontCopy (Display *dpy, XftFont *font);
void
XftFontClose (Display *dpy, XftFont *font);
FcBool
XftInitFtLibrary(void);
/* xftglyphs.c */
void
XftFontLoadGlyphs (Display *dpy,
XftFont *font,
FcBool need_bitmaps,
FT_UInt *glyphs,
int nglyph);
void
XftFontUnloadGlyphs (Display *dpy,
XftFont *pub,
FT_UInt *glyphs,
int nglyph);
#define XFT_NMISSING 256
FcBool
XftFontCheckGlyph (Display *dpy,
XftFont *font,
FcBool need_bitmaps,
FT_UInt glyph,
FT_UInt *missing,
int *nmissing);
FcBool
XftCharExists (Display *dpy,
XftFont *pub,
FcChar32 ucs4);
FT_UInt
XftCharIndex (Display *dpy,
XftFont *pub,
FcChar32 ucs4);
/* xftgram.y */
/* xftinit.c */
FcBool
XftInit (char *config);
/* xftlex.l */
/* xftlist.c */
FcFontSet *
XftListFonts (Display *dpy,
int screen,
...);
/* xftmatch.c */
/* xftmatrix.c */
/* xftname.c */
FcPattern
*XftNameParse (const char *name);
/* xftpat.c */
/* xftrender.c */
void
XftGlyphRender (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FT_UInt *glyphs,
int nglyphs);
void
XftGlyphSpecRender (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
XftGlyphSpec *glyphs,
int nglyphs);
void
XftCharSpecRender (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
XftCharSpec *chars,
int len);
void
XftGlyphFontSpecRender (Display *dpy,
int op,
Picture src,
Picture dst,
int srcx,
int srcy,
XftGlyphFontSpec *glyphs,
int nglyphs);
void
XftCharFontSpecRender (Display *dpy,
int op,
Picture src,
Picture dst,
int srcx,
int srcy,
XftCharFontSpec *chars,
int len);
void
XftTextRender8 (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len);
void
XftTextRender16 (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar16 *string,
int len);
void
XftTextRender16BE (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len);
void
XftTextRender16LE (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len);
void
XftTextRender32 (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar32 *string,
int len);
void
XftTextRender32BE (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len);
void
XftTextRender32LE (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len);
void
XftTextRenderUtf8 (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len);
/* xftstr.c */
/* xftxlfd.c */
FcPattern *
XftXlfdParse (const char *xlfd_orig, Bool ignore_scalable, Bool complete);
XFontStruct *
XftCoreOpen (Display *dpy, FcPattern *pattern);
void
XftCoreClose (Display *dpy, XFontStruct *font);
_XFUNCPROTOEND
#endif /* _XFT_H_ */

View File

@ -1,181 +0,0 @@
.\"
.\" $XFree86: xc/lib/Xft/Xft.man,v 1.2 2000/11/30 06:59:45 keithp Exp $
.\"
.\" 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
.\" 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 1.0" "XFree86"
.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 0, 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);
.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 XtDrawCreate
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 XftConfig
The
.B XftConfig
file contains configuration information for the Xft library consisting of
directories to look at for font information as well as instructions on
editing program specified font patterns before attempting to match the
available fonts.
.PP
.nf
config : "dir" STRING
| "include" STRING
| "includeif" STRING
| "match" tests "edit" edits
;
test : qual FIELD-NAME COMPARE CONSTANT
;
qual : "any"
| "all"
;
edit : FIELD-NAME ASSIGN expr SEMI
;
.fi
.PP
STRINGs are double-quote delimited. FIELD-NAMEs are identifiers,
ASSIGN is one of "=", "+=" or "=+". expr can contain the usual
arithmetic operators and can include FIELD-NAMEs.
.PP
"dir" adds a directory to the list of places Xft will look for fonts.
There is no particular order implied by the list; Xft treats all fonts about
the same.
.PP
"include" and "includeif" cause Xft to load more configuration parameters
from the indicated file. "includeif" doesn't elicit a complaint if the file
doesn't exist. If the file name begins with a '~' character, it refers to a
path relative to the home directory of the user.
.PP
If the tests in a "match" statement all match a user-specified pattern, the
pattern will be edited with the specified instructions.
.PP
Where ASSIGN is "=", the matching value in the pattern will be replaced by
the given expression. "+="/"=+" will prepend/append a new value to the list
of values for the indicated field.
.SH RESTRICTIONS
.B Xft
will probably change radically in the future; weak attempts will be made to
retain some level of source-file compatibility.
.SH AUTHOR
Keith Packard, member of the XFree86 Project, Inc.

View File

@ -1,166 +0,0 @@
/*
* $XFree86: xc/lib/Xft/XftCompat.h,v 1.2 2002/02/19 07:51:20 keithp Exp $
*
* 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
* 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.
*/
#ifndef _XFTCOMPAT_H_
#define _XFTCOMPAT_H_
#include <X11/Xfuncproto.h>
/*
* Compatibility definitions -- map Fc names to Xft names
*/
typedef FcChar8 XftChar8;
typedef FcChar16 XftChar16;
typedef FcChar32 XftChar32;
#define XFT_FAMILY FC_FAMILY
#define XFT_STYLE FC_STYLE
#define XFT_SLANT FC_SLANT
#define XFT_WEIGHT FC_WEIGHT
#define XFT_SIZE FC_SIZE
#define XFT_PIXEL_SIZE FC_PIXEL_SIZE
#define XFT_SPACING FC_SPACING
#define XFT_FOUNDRY FC_FOUNDRY
#define XFT_ANTIALIAS FC_ANTIALIAS
#define XFT_FILE FC_FILE
#define XFT_INDEX FC_INDEX
#define XFT_RASTERIZER FC_RASTERIZER
#define XFT_OUTLINE FC_OUTLINE
#define XFT_SCALABLE FC_SCALABLE
#define XFT_RGBA FC_RGBA
/* defaults from resources */
#define XFT_SCALE FC_SCALE
#define XFT_MINSPACE FC_MINSPACE
#define XFT_DPI FC_DPI
/* specific to FreeType rasterizer */
#define XFT_CHAR_WIDTH FC_CHAR_WIDTH
#define XFT_CHAR_HEIGHT FC_CHAR_HEIGHT
#define XFT_MATRIX FC_MATRIX
#define XFT_WEIGHT_LIGHT FC_WEIGHT_LIGHT
#define XFT_WEIGHT_MEDIUM FC_WEIGHT_MEDIUM
#define XFT_WEIGHT_DEMIBOLD FC_WEIGHT_DEMIBOLD
#define XFT_WEIGHT_BOLD FC_WEIGHT_BOLD
#define XFT_WEIGHT_BLACK FC_WEIGHT_BLACK
#define XFT_SLANT_ROMAN FC_SLANT_ROMAN
#define XFT_SLANT_ITALIC FC_SLANT_ITALIC
#define XFT_SLANT_OBLIQUE FC_SLANT_OBLIQUE
#define XFT_PROPORTIONAL FC_PROPORTIONAL
#define XFT_MONO FC_MONO
#define XFT_CHARCELL FC_CHARCELL
#define XFT_RGBA_NONE FC_RGBA_NONE
#define XFT_RGBA_RGB FC_RGBA_RGB
#define XFT_RGBA_BGR FC_RGBA_BGR
#define XFT_RGBA_VRGB FC_RGBA_VRGB
#define XFT_RGBA_VBGR FC_RGBA_VBGR
/*
* Old constants
*/
#define XFT_ENCODING "encoding"
typedef FcType XftType;
typedef FcMatrix XftMatrix;
#define XftMatrixInit(m) FcMatrixInit(m)
typedef FcResult XftResult;
#define XftResultMatch FcResultMatch
#define XftResultNoMatch FcResultNoMatch
#define XftResultTypeMismatch FcResultTypeMismatch
#define XftResultNoId FcResultNoId
typedef FcValue XftValue;
typedef FcPattern XftPattern;
typedef FcFontSet XftFontSet;
typedef FcObjectSet XftObjectSet;
#define XftGlyphExists XftCharExists
#define XftObjectSetCreate FcObjectSetCreate
#define XftObjectSetAdd FcObjectSetAdd
#define XftObjectSetDestroy FcObjectSetDestroy
#define XftObjectSetVaBuild FcObjectSetVaBuild
#define XftObjectSetBuild FcObjectSetBuild
#define XftListFontsPatternObjects FcListFontsPatternObjects
#define XftFontSetMatch FcFontSetMatch
#define XftFontSetDestroy FcFontSetDestroy
#define XftMatrixEqual FcMatrixEqual
#define XftMatrixMultiply FcMatrixMultiply
#define XftMatrixRotate FcMatrixRotate
#define XftMatrixScale FcMatrixScale
#define XftMatrixShear FcMatrixShear
#define XftPatternCreate FcPatternCreate
#define XftPatternDuplicate FcPatternDuplicate
#define XftValueDestroy FcValueDestroy
#define XftValueListDestroy FcValueListDestroy
#define XftPatternDestroy FcPatternDestroy
#define XftPatternFind FcPatternFind
#define XftPatternAdd FcPatternAdd
#define XftPatternGet FcPatternGet
#define XftPatternDel FcPatternDel
#define XftPatternAddInteger FcPatternAddInteger
#define XftPatternAddDouble FcPatternAddDouble
#define XftPatternAddString FcPatternAddString
#define XftPatternAddMatrix FcPatternAddMatrix
#define XftPatternAddBool FcPatternAddBool
#define XftPatternGetInteger FcPatternGetInteger
#define XftPatternGetDouble FcPatternGetDouble
#define XftPatternGetString FcPatternGetString
#define XftPatternGetMatrix FcPatternGetMatrix
#define XftPatternGetBool FcPatternGetBool
#define XftPatternVaBuild FcPatternVaBuild
#define XftPatternBuild FcPatternBuild
#define XftUtf8ToUcs4 FcUtf8ToUcs4
#define XftUtf8Len FcUtf8Len
#define XftTypeVoid FcTypeVoid
#define XftTypeInteger FcTypeInteger
#define XftTypeDouble FcTypeDouble
#define XftTypeString FcTypeString
#define XftTypeBool FcTypeBool
#define XftTypeMatrix FcTypeMatrix
#define XftConfigSubstitute(p) FcConfigSubstitute (0, p, FcMatchPattern)
_XFUNCPROTOBEGIN
FcBool
XftNameUnparse (XftPattern *pat, char *dest, int len);
_XFUNCPROTOEND
#endif /* _XFTCOMPAT_H_ */

View File

@ -1,164 +0,0 @@
/*
* $XFree86: xc/lib/Xft/XftFreetype.h,v 1.16 2002/02/15 07:36:10 keithp Exp $
*
* 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
* 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.
*/
/*
* This file is strictly for backwards compatibility with
* old Xft applications
*/
#ifndef _XFTFREETYPE_H_
#define _XFTFREETYPE_H_
/* #include <Xft/Xft.h> */
/* #include <X11/Xft/Xft.h>*/
#include "Xft.h"
#include <X11/Xfuncproto.h>
#include <X11/Xosdefs.h>
typedef struct _XftFontStruct {
FT_Face __DEPRECATED_face; /* handle to face object */
GlyphSet __DEPRECATED_glyphset;
int min_char;
int max_char;
FT_F26Dot6 size;
int ascent;
int descent;
int height;
int max_advance_width;
int __DEPRECATED_spacing;
int __DEPRECATED_rgba;
Bool __DEPRECATED_antialias;
int __DEPRECATED_charmap; /* -1 for unencoded */
XRenderPictFormat *__DEPRECATED_format;
XGlyphInfo **__DEPRECATED_realized;
int __DEPRECATED_nrealized;
FcBool __DEPRECATED_transform;
FT_Matrix __DEPRECATED_matrix;
/* private field */
XftFont *font;
} XftFontStruct;
_XFUNCPROTOBEGIN
XftFontStruct *
XftFreeTypeOpen (Display *dpy, FcPattern *pattern);
XftFontStruct *
XftFreeTypeGet (XftFont *font);
void
XftFreeTypeClose (Display *dpy, XftFontStruct *font);
void
XftGlyphLoad (Display *dpy,
XftFontStruct *font,
FcChar32 *glyphs,
int nglyph);
void
XftGlyphCheck (Display *dpy,
XftFontStruct *font,
FcChar32 glyph,
FcChar32 *missing,
int *nmissing);
void
XftGlyphLoad (Display *dpy,
XftFontStruct *font,
FcChar32 *glyphs,
int nglyph);
void
XftGlyphCheck (Display *dpy,
XftFontStruct *font,
FcChar32 glyph,
FcChar32 *missing,
int *nmissing);
Bool
XftFreeTypeGlyphExists (Display *dpy,
XftFontStruct *font,
FcChar32 glyph);
/* xftrender.c */
void
XftRenderString8 (Display *dpy, Picture src,
XftFontStruct *font, Picture dst,
int srcx, int srcy,
int x, int y,
FcChar8 *string, int len);
void
XftRenderString16 (Display *dpy, Picture src,
XftFontStruct *font, Picture dst,
int srcx, int srcy,
int x, int y,
FcChar16 *string, int len);
void
XftRenderString32 (Display *dpy, Picture src,
XftFontStruct *font, Picture dst,
int srcx, int srcy,
int x, int y,
FcChar32 *string, int len);
void
XftRenderStringUtf8 (Display *dpy, Picture src,
XftFontStruct *font, Picture dst,
int srcx, int srcy,
int x, int y,
FcChar8 *string, int len);
void
XftRenderExtents8 (Display *dpy,
XftFontStruct *font,
FcChar8 *string,
int len,
XGlyphInfo *extents);
void
XftRenderExtents16 (Display *dpy,
XftFontStruct *font,
FcChar16 *string,
int len,
XGlyphInfo *extents);
void
XftRenderExtents32 (Display *dpy,
XftFontStruct *font,
FcChar32 *string,
int len,
XGlyphInfo *extents);
void
XftRenderExtentsUtf8 (Display *dpy,
XftFontStruct *font,
FcChar8 *string,
int len,
XGlyphInfo *extents);
_XFUNCPROTOEND
#endif /* _XFTFREETYPE_H_ */

View File

@ -1,125 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftcolor.c,v 1.2 2001/05/16 17:20:06 keithp Exp $
*
* 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
* 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.
*/
#include "xftint.h"
Bool
XftColorAllocName (Display *dpy,
Visual *visual,
Colormap cmap,
char *name,
XftColor *result)
{
XColor screen, exact;
if (!XAllocNamedColor (dpy, cmap, name, &screen, &exact))
{
/* XXX stick standard colormap stuff here */
return False;
}
result->pixel = screen.pixel;
result->color.red = exact.red;
result->color.green = exact.green;
result->color.blue = exact.blue;
result->color.alpha = 0xffff;
return True;
}
static short
maskbase (unsigned long m)
{
short i;
if (!m)
return 0;
i = 0;
while (!(m&1))
{
m>>=1;
i++;
}
return i;
}
static short
masklen (unsigned long m)
{
unsigned long y;
y = (m >> 1) &033333333333;
y = m - y - ((y >>1) & 033333333333);
return (short) (((y + (y >> 3)) & 030707070707) % 077);
}
Bool
XftColorAllocValue (Display *dpy,
Visual *visual,
Colormap cmap,
XRenderColor *color,
XftColor *result)
{
if (visual->class == TrueColor)
{
int red_shift, red_len;
int green_shift, green_len;
int blue_shift, blue_len;
red_shift = maskbase (visual->red_mask);
red_len = masklen (visual->red_mask);
green_shift = maskbase (visual->green_mask);
green_len = masklen (visual->green_mask);
blue_shift = maskbase (visual->blue_mask);
blue_len = masklen (visual->blue_mask);
result->pixel = (((color->red >> (16 - red_len)) << red_shift) |
((color->green >> (16 - green_len)) << green_shift) |
((color->blue >> (16 - blue_len)) << blue_shift));
}
else
{
XColor xcolor;
xcolor.red = color->red;
xcolor.green = color->green;
xcolor.blue = color->blue;
if (!XAllocColor (dpy, cmap, &xcolor))
return False;
result->pixel = xcolor.pixel;
}
result->color.red = color->red;
result->color.green = color->green;
result->color.blue = color->blue;
result->color.alpha = color->alpha;
return True;
}
void
XftColorFree (Display *dpy,
Visual *visual,
Colormap cmap,
XftColor *color)
{
if (visual->class != TrueColor)
XFreeColors (dpy, cmap, &color->pixel, 1, 0);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,50 +0,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.
*
* 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.
*/
#include <stdlib.h>
#include <stdio.h>
#include "xftint.h"
int
XftDebug (void)
{
static int initialized;
static int debug;
if (!initialized)
{
char *e;
initialized = 1;
e = getenv ("XFT_DEBUG");
if (e)
{
printf ("XFT_DEBUG=%s\n", e);
debug = atoi (e);
if (debug <= 0)
debug = 1;
}
}
return debug;
}

View File

@ -1,442 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftdpy.c,v 1.10 2002/03/04 21:15:26 tsi Exp $
*
* 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
* 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <X11/Xlibint.h>
#include "xftint.h"
XftDisplayInfo *_XftDisplayInfo;
static int
_XftCloseDisplay (Display *dpy, XExtCodes *codes)
{
XftDisplayInfo *info, **prev;
for (prev = &_XftDisplayInfo; (info = *prev); prev = &(*prev)->next)
if (info->codes == codes)
break;
if (!info)
return 0;
*prev = info->next;
if (info->defaults)
FcPatternDestroy (info->defaults);
free (info);
return 0;
}
XftDisplayInfo *
_XftDisplayInfoGet (Display *dpy)
{
XftDisplayInfo *info, **prev;
XRenderPictFormat pf;
int i;
for (prev = &_XftDisplayInfo; (info = *prev); prev = &(*prev)->next)
{
if (info->display == dpy)
{
/*
* MRU the list
*/
if (prev != &_XftDisplayInfo)
{
*prev = info->next;
info->next = _XftDisplayInfo;
_XftDisplayInfo = info;
}
return info;
}
}
info = (XftDisplayInfo *) malloc (sizeof (XftDisplayInfo));
if (!info)
goto bail0;
info->codes = XAddExtension (dpy);
if (!info->codes)
goto bail1;
(void) XESetCloseDisplay (dpy, info->codes->extension, _XftCloseDisplay);
info->display = dpy;
info->defaults = 0;
info->hasRender = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, DefaultScreen (dpy))) != 0;
info->use_free_glyphs = FcTrue;
if (info->hasRender)
{
int major, minor;
XRenderQueryVersion (dpy, &major, &minor);
if (major < 0 || (major == 0 && minor <= 2))
info->use_free_glyphs = FcFalse;
}
pf.type = PictTypeDirect;
pf.depth = 32;
pf.direct.redMask = 0xff;
pf.direct.greenMask = 0xff;
pf.direct.blueMask = 0xff;
pf.direct.alphaMask = 0xff;
info->solidFormat = XRenderFindFormat (dpy,
(PictFormatType|
PictFormatDepth|
PictFormatRedMask|
PictFormatGreenMask|
PictFormatBlueMask|
PictFormatAlphaMask),
&pf,
0);
if (XftDebug () & XFT_DBG_RENDER)
{
Visual *visual = DefaultVisual (dpy, DefaultScreen (dpy));
XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
printf ("XftDisplayInfoGet Default visual 0x%x ",
(int) visual->visualid);
if (format)
{
if (format->type == PictTypeDirect)
{
printf ("format %d,%d,%d,%d\n",
format->direct.alpha,
format->direct.red,
format->direct.green,
format->direct.blue);
}
else
{
printf ("format indexed\n");
}
}
else
printf ("No Render format for default visual\n");
printf ("XftDisplayInfoGet initialized, hasRender set to \"%s\"\n",
info->hasRender ? "True" : "False");
}
for (i = 0; i < XFT_NUM_SOLID_COLOR; i++)
{
info->colors[i].screen = -1;
info->colors[i].pict = 0;
}
info->fonts = 0;
info->next = _XftDisplayInfo;
_XftDisplayInfo = info;
info->glyph_memory = 0;
info->max_glyph_memory = XftDefaultGetInteger (dpy,
XFT_MAX_GLYPH_MEMORY, 0,
XFT_DPY_MAX_GLYPH_MEMORY);
if (XftDebug () & XFT_DBG_CACHE)
printf ("global max cache memory %ld\n", info->max_glyph_memory);
return info;
bail1:
free (info);
bail0:
if (XftDebug () & XFT_DBG_RENDER)
{
printf ("XftDisplayInfoGet failed to initialize, Xft unhappy\n");
}
return 0;
}
/*
* Reduce memory usage in X server
*/
void
_XftDisplayManageMemory (Display *dpy)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
unsigned long glyph_memory;
XftFont *public;
XftFontInt *font;
if (!info || !info->max_glyph_memory)
return;
if (XftDebug () & XFT_DBG_CACHE)
{
if (info->glyph_memory > info->max_glyph_memory)
printf ("Reduce global memory from %ld to %ld\n",
info->glyph_memory, info->max_glyph_memory);
}
while (info->glyph_memory > info->max_glyph_memory)
{
glyph_memory = rand () % info->glyph_memory;
public = info->fonts;
while (public)
{
font = (XftFontInt *) public;
if (font->glyph_memory > glyph_memory)
{
_XftFontUncacheGlyph (dpy, public);
break;
}
public = font->next;
glyph_memory -= font->glyph_memory;
}
}
}
Bool
XftDefaultHasRender (Display *dpy)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
if (!info)
return False;
return info->hasRender;
}
Bool
XftDefaultSet (Display *dpy, FcPattern *defaults)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
if (!info)
return False;
if (info->defaults)
FcPatternDestroy (info->defaults);
info->defaults = defaults;
if (!info->max_glyph_memory)
info->max_glyph_memory = XFT_DPY_MAX_GLYPH_MEMORY;
info->max_glyph_memory = XftDefaultGetInteger (dpy,
XFT_MAX_GLYPH_MEMORY, 0,
info->max_glyph_memory);
return True;
}
int
XftDefaultParseBool (char *v)
{
char c0, c1;
c0 = *v;
if (isupper ((int)c0))
c0 = tolower (c0);
if (c0 == 't' || c0 == 'y' || c0 == '1')
return 1;
if (c0 == 'f' || c0 == 'n' || c0 == '0')
return 0;
if (c0 == 'o')
{
c1 = v[1];
if (isupper ((int)c1))
c1 = tolower (c1);
if (c1 == 'n')
return 1;
if (c1 == 'f')
return 0;
}
return -1;
}
static Bool
_XftDefaultInitBool (Display *dpy, FcPattern *pat, char *option)
{
char *v;
int i;
v = XGetDefault (dpy, "Xft", option);
if (v && (i = XftDefaultParseBool (v)) >= 0)
return FcPatternAddBool (pat, option, i != 0);
return True;
}
static Bool
_XftDefaultInitDouble (Display *dpy, FcPattern *pat, char *option)
{
char *v, *e;
double d;
v = XGetDefault (dpy, "Xft", option);
if (v)
{
d = strtod (v, &e);
if (e != v)
return FcPatternAddDouble (pat, option, d);
}
return True;
}
static Bool
_XftDefaultInitInteger (Display *dpy, FcPattern *pat, char *option)
{
char *v, *e;
int i;
v = XGetDefault (dpy, "Xft", option);
if (v)
{
if (FcNameConstant ((FcChar8 *) v, &i))
return FcPatternAddInteger (pat, option, i);
i = strtol (v, &e, 0);
if (e != v)
return FcPatternAddInteger (pat, option, i);
}
return True;
}
static FcPattern *
_XftDefaultInit (Display *dpy)
{
FcPattern *pat;
pat = FcPatternCreate ();
if (!pat)
goto bail0;
if (!_XftDefaultInitDouble (dpy, pat, FC_SCALE))
goto bail1;
if (!_XftDefaultInitDouble (dpy, pat, FC_DPI))
goto bail1;
if (!_XftDefaultInitBool (dpy, pat, XFT_RENDER))
goto bail1;
if (!_XftDefaultInitInteger (dpy, pat, FC_RGBA))
goto bail1;
if (!_XftDefaultInitBool (dpy, pat, FC_ANTIALIAS))
goto bail1;
if (!_XftDefaultInitBool (dpy, pat, FC_MINSPACE))
goto bail1;
if (!_XftDefaultInitInteger (dpy, pat, XFT_MAX_GLYPH_MEMORY))
goto bail1;
return pat;
bail1:
FcPatternDestroy (pat);
bail0:
return 0;
}
static FcResult
_XftDefaultGet (Display *dpy, const char *object, int screen, FcValue *v)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
FcResult r;
if (!info)
return FcResultNoMatch;
if (!info->defaults)
{
info->defaults = _XftDefaultInit (dpy);
if (!info->defaults)
return FcResultNoMatch;
}
r = FcPatternGet (info->defaults, object, screen, v);
if (r == FcResultNoId && screen > 0)
r = FcPatternGet (info->defaults, object, 0, v);
return r;
}
Bool
XftDefaultGetBool (Display *dpy, const char *object, int screen, Bool def)
{
FcResult r;
FcValue v;
r = _XftDefaultGet (dpy, object, screen, &v);
if (r != FcResultMatch || v.type != FcTypeBool)
return def;
return v.u.b;
}
int
XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def)
{
FcResult r;
FcValue v;
r = _XftDefaultGet (dpy, object, screen, &v);
if (r != FcResultMatch || v.type != FcTypeInteger)
return def;
return v.u.i;
}
double
XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def)
{
FcResult r;
FcValue v;
r = _XftDefaultGet (dpy, object, screen, &v);
if (r != FcResultMatch || v.type != FcTypeDouble)
return def;
return v.u.d;
}
void
XftDefaultSubstitute (Display *dpy, int screen, FcPattern *pattern)
{
FcValue v;
double dpi;
if (FcPatternGet (pattern, XFT_RENDER, 0, &v) == FcResultNoMatch)
{
FcPatternAddBool (pattern, XFT_RENDER,
XftDefaultGetBool (dpy, XFT_RENDER, screen,
XftDefaultHasRender (dpy)));
}
if (FcPatternGet (pattern, FC_ANTIALIAS, 0, &v) == FcResultNoMatch)
{
FcPatternAddBool (pattern, FC_ANTIALIAS,
XftDefaultGetBool (dpy, FC_ANTIALIAS, screen,
True));
}
if (FcPatternGet (pattern, FC_RGBA, 0, &v) == FcResultNoMatch)
{
FcPatternAddInteger (pattern, FC_RGBA,
XftDefaultGetInteger (dpy, FC_RGBA, screen,
FC_RGBA_NONE));
}
if (FcPatternGet (pattern, FC_MINSPACE, 0, &v) == FcResultNoMatch)
{
FcPatternAddBool (pattern, FC_MINSPACE,
XftDefaultGetBool (dpy, FC_MINSPACE, screen,
False));
}
if (FcPatternGet (pattern, FC_DPI, 0, &v) == FcResultNoMatch)
{
dpi = (((double) DisplayHeight (dpy, screen) * 25.4) /
(double) DisplayHeightMM (dpy, screen));
FcPatternAddDouble (pattern, FC_DPI,
XftDefaultGetDouble (dpy, FC_DPI, screen,
dpi));
}
if (FcPatternGet (pattern, FC_SCALE, 0, &v) == FcResultNoMatch)
{
FcPatternAddDouble (pattern, FC_SCALE,
XftDefaultGetDouble (dpy, FC_SCALE, screen, 1.0));
}
if (FcPatternGet (pattern, XFT_MAX_GLYPH_MEMORY, 0, &v) == FcResultNoMatch)
{
FcPatternAddInteger (pattern, XFT_MAX_GLYPH_MEMORY,
XftDefaultGetInteger (dpy, XFT_MAX_GLYPH_MEMORY,
screen,
XFT_FONT_MAX_GLYPH_MEMORY));
}
FcDefaultSubstitute (pattern);
}

View File

@ -1,774 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftdraw.c,v 1.17 2002/02/19 07:56:29 keithp Exp $
*
* 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
* 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xftint.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
/*
* Ok, this is a pain. To share source pictures across multiple destinations,
* the screen for each drawable must be discovered.
*/
static int
_XftDrawScreen (Display *dpy, Drawable drawable, Visual *visual)
{
int s;
Window root;
int x, y;
unsigned int width, height, borderWidth, depth;
/* Special case the most common environment */
if (ScreenCount (dpy) == 1)
return 0;
/*
* If we've got a visual, look for the screen that points at it.
* This requires no round trip.
*/
if (visual)
{
for (s = 0; s < ScreenCount (dpy); s++)
{
XVisualInfo template, *ret;
int nret;
template.visualid = visual->visualid;
template.screen = s;
ret = XGetVisualInfo (dpy, VisualIDMask|VisualScreenMask,
&template, &nret);
if (ret)
{
XFree (ret);
return s;
}
}
}
/*
* Otherwise, as the server for the drawable geometry and find
* the screen from the root window.
* This takes a round trip.
*/
if (XGetGeometry (dpy, drawable, &root, &x, &y, &width, &height,
&borderWidth, &depth))
{
for (s = 0; s < ScreenCount (dpy); s++)
{
if (RootWindow (dpy, s) == root)
return s;
}
}
/*
* Make a guess -- it's probably wrong, but then the app probably
* handed us a bogus drawable in this case
*/
return 0;
}
unsigned int
XftDrawDepth (XftDraw *draw)
{
if (!draw->depth)
{
Window root;
int x, y;
unsigned int width, height, borderWidth, depth;
if (XGetGeometry (draw->dpy, draw->drawable,
&root, &x, &y, &width, &height,
&borderWidth, &depth))
draw->depth = depth;
}
return draw->depth;
}
unsigned int
XftDrawBitsPerPixel (XftDraw *draw)
{
if (!draw->bits_per_pixel)
{
XPixmapFormatValues *formats;
int nformats;
unsigned int depth;
if ((depth = XftDrawDepth (draw)) &&
(formats = XListPixmapFormats (draw->dpy, &nformats)))
{
int i;
for (i = 0; i < nformats; i++)
{
if (formats[i].depth == depth)
{
draw->bits_per_pixel = formats[i].bits_per_pixel;
break;
}
}
XFree (formats);
}
}
return draw->bits_per_pixel;
}
XftDraw *
XftDrawCreate (Display *dpy,
Drawable drawable,
Visual *visual,
Colormap colormap)
{
XftDraw *draw;
draw = (XftDraw *) malloc (sizeof (XftDraw));
if (!draw)
return 0;
draw->dpy = dpy;
draw->drawable = drawable;
draw->screen = _XftDrawScreen (dpy, drawable, visual);
draw->depth = 0; /* don't find out unless we need to know */
draw->bits_per_pixel = 0; /* don't find out unless we need to know */
draw->visual = visual;
draw->colormap = colormap;
draw->render.pict = 0;
draw->core.gc = 0;
draw->core.use_pixmap = 0;
draw->clip = 0;
XftMemAlloc (XFT_MEM_DRAW, sizeof (XftDraw));
return draw;
}
XftDraw *
XftDrawCreateBitmap (Display *dpy,
Pixmap bitmap)
{
XftDraw *draw;
draw = (XftDraw *) malloc (sizeof (XftDraw));
if (!draw)
return 0;
draw->dpy = dpy;
draw->drawable = (Drawable) bitmap;
draw->screen = _XftDrawScreen (dpy, bitmap, 0);
draw->depth = 1;
draw->bits_per_pixel = 1;
draw->visual = 0;
draw->colormap = 0;
draw->render.pict = 0;
draw->core.gc = 0;
draw->clip = 0;
XftMemAlloc (XFT_MEM_DRAW, sizeof (XftDraw));
return draw;
}
XftDraw *
XftDrawCreateAlpha (Display *dpy,
Pixmap pixmap,
int depth)
{
XftDraw *draw;
draw = (XftDraw *) malloc (sizeof (XftDraw));
if (!draw)
return 0;
draw->dpy = dpy;
draw->drawable = (Drawable) pixmap;
draw->screen = _XftDrawScreen (dpy, pixmap, 0);
draw->depth = depth;
draw->bits_per_pixel = 0; /* don't find out until we need it */
draw->visual = 0;
draw->colormap = 0;
draw->render.pict = 0;
draw->core.gc = 0;
draw->clip = 0;
XftMemAlloc (XFT_MEM_DRAW, sizeof (XftDraw));
return draw;
}
static XRenderPictFormat *
_XftDrawFormat (XftDraw *draw)
{
XftDisplayInfo *info = _XftDisplayInfoGet (draw->dpy);
if (!info->hasRender)
return 0;
if (draw->visual == 0)
{
XRenderPictFormat pf;
pf.type = PictTypeDirect;
pf.depth = XftDrawDepth (draw);
pf.direct.alpha = 0;
pf.direct.alphaMask = (1 << pf.depth) - 1;
return XRenderFindFormat (draw->dpy,
(PictFormatType|
PictFormatDepth|
PictFormatAlpha|
PictFormatAlphaMask),
&pf,
0);
}
else
return XRenderFindVisualFormat (draw->dpy, draw->visual);
}
void
XftDrawChange (XftDraw *draw,
Drawable drawable)
{
draw->drawable = drawable;
if (draw->render.pict)
{
XRenderFreePicture (draw->dpy, draw->render.pict);
draw->render.pict = 0;
}
if (draw->core.gc)
{
XFreeGC (draw->dpy, draw->core.gc);
draw->core.gc = 0;
}
}
Display *
XftDrawDisplay (XftDraw *draw)
{
return draw->dpy;
}
Drawable
XftDrawDrawable (XftDraw *draw)
{
return draw->drawable;
}
Colormap
XftDrawColormap (XftDraw *draw)
{
return draw->colormap;
}
Visual *
XftDrawVisual (XftDraw *draw)
{
return draw->visual;
}
void
XftDrawDestroy (XftDraw *draw)
{
if (draw->render.pict)
XRenderFreePicture (draw->dpy, draw->render.pict);
if (draw->core.gc)
XFreeGC (draw->dpy, draw->core.gc);
if (draw->clip)
XDestroyRegion (draw->clip);
XftMemFree (XFT_MEM_DRAW, sizeof (XftDraw));
free (draw);
}
static Picture
_XftDrawSrcPicture (XftDraw *draw, XftColor *color)
{
Display *dpy = draw->dpy;
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
int i;
XftColor bitmapColor;
if (!info)
return 0;
/*
* Monochrome targets require special handling; the PictOp controls
* the color, and the color must be opaque
*/
if (!draw->visual && draw->depth == 1)
{
bitmapColor.color.alpha = 0xffff;
bitmapColor.color.red = 0xffff;
bitmapColor.color.green = 0xffff;
bitmapColor.color.blue = 0xffff;
color = &bitmapColor;
}
/*
* See if there's one already available
*/
for (i = 0; i < XFT_NUM_SOLID_COLOR; i++)
{
if (info->colors[i].pict &&
info->colors[i].screen == draw->screen &&
!memcmp ((void *) &color->color,
(void *) &info->colors[i].color,
sizeof (XRenderColor)))
return info->colors[i].pict;
}
/*
* Pick one to replace at random
*/
i = (unsigned int) rand () % XFT_NUM_SOLID_COLOR;
/*
* Recreate if it was for the wrong screen
*/
if (info->colors[i].screen != draw->screen && info->colors[i].pict)
{
XRenderFreePicture (dpy, info->colors[i].pict);
info->colors[i].pict = 0;
}
/*
* Create picture if necessary
*/
if (!info->colors[i].pict)
{
Pixmap pix;
XRenderPictureAttributes pa;
pix = XCreatePixmap (dpy, RootWindow (dpy, draw->screen), 1, 1,
info->solidFormat->depth);
pa.repeat = True;
info->colors[i].pict = XRenderCreatePicture (draw->dpy,
pix,
info->solidFormat,
CPRepeat, &pa);
XFreePixmap (dpy, pix);
}
/*
* Set to the new color
*/
info->colors[i].color = color->color;
info->colors[i].screen = draw->screen;
XRenderFillRectangle (dpy, PictOpSrc,
info->colors[i].pict,
&color->color, 0, 0, 1, 1);
return info->colors[i].pict;
}
static int
_XftDrawOp (XftDraw *draw, XftColor *color)
{
if (draw->visual || draw->depth != 1)
return PictOpOver;
if (color->color.alpha >= 0x8000)
return PictOpOver;
return PictOpOutReverse;
}
static FcBool
_XftDrawRenderPrepare (XftDraw *draw)
{
if (!draw->render.pict)
{
XRenderPictFormat *format;
format = _XftDrawFormat (draw);
if (!format)
return FcFalse;
draw->render.pict = XRenderCreatePicture (draw->dpy, draw->drawable,
format, 0, 0);
if (!draw->render.pict)
return FcFalse;
if (draw->clip)
XRenderSetPictureClipRegion (draw->dpy, draw->render.pict,
draw->clip);
}
return FcTrue;
}
static FcBool
_XftDrawCorePrepare (XftDraw *draw, XftColor *color)
{
if (!draw->core.gc)
{
draw->core.gc = XCreateGC (draw->dpy, draw->drawable, 0, 0);
if (!draw->core.gc)
return FcFalse;
if (draw->clip)
XSetRegion (draw->dpy, draw->core.gc, draw->clip);
}
XSetForeground (draw->dpy, draw->core.gc, color->pixel);
return FcTrue;
}
Picture
XftDrawPicture (XftDraw *draw)
{
if (!_XftDrawRenderPrepare (draw))
return 0;
return draw->render.pict;
}
#define NUM_LOCAL 1024
void
XftDrawGlyphs (XftDraw *draw,
XftColor *color,
XftFont *public,
int x,
int y,
FT_UInt *glyphs,
int nglyphs)
{
XftFontInt *font = (XftFontInt *) public;
if (font->format)
{
Picture src;
if (_XftDrawRenderPrepare (draw) &&
(src = _XftDrawSrcPicture (draw, color)))
XftGlyphRender (draw->dpy, _XftDrawOp (draw, color),
src, public, draw->render.pict,
0, 0, x, y, glyphs, nglyphs);
}
else
{
if (_XftDrawCorePrepare (draw, color))
XftGlyphCore (draw, color, public, x, y, glyphs, nglyphs);
}
}
void
XftDrawString8 (XftDraw *draw,
XftColor *color,
XftFont *public,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (XftDebug () & XFT_DBG_DRAW)
printf ("DrawString \"%*.*s\"\n", len, len, string);
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (draw->dpy, public, string[i]);
XftDrawGlyphs (draw, color, public, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftDrawString16 (XftDraw *draw,
XftColor *color,
XftFont *public,
int x,
int y,
FcChar16 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (draw->dpy, public, string[i]);
XftDrawGlyphs (draw, color, public, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftDrawString32 (XftDraw *draw,
XftColor *color,
XftFont *public,
int x,
int y,
FcChar32 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (draw->dpy, public, string[i]);
XftDrawGlyphs (draw, color, public, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftDrawStringUtf8 (XftDraw *draw,
XftColor *color,
XftFont *public,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
FcChar32 ucs4;
int i;
int l;
int size;
i = 0;
glyphs = glyphs_local;
size = NUM_LOCAL;
while (len && (l = FcUtf8ToUcs4 (string, &ucs4, len)) > 0)
{
if (i == size)
{
glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
if (!glyphs_new)
{
if (glyphs != glyphs_local)
free (glyphs);
return;
}
memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
size *= 2;
if (glyphs != glyphs_local)
free (glyphs);
glyphs = glyphs_new;
}
glyphs[i++] = ucs4;
string += l;
len -= l;
}
XftDrawGlyphs (draw, color, public, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftDrawGlyphSpec (XftDraw *draw,
XftColor *color,
XftFont *public,
XftGlyphSpec *glyphs,
int len)
{
XftFontInt *font = (XftFontInt *) public;
if (font->format)
{
Picture src;
if (_XftDrawRenderPrepare (draw) &&
(src = _XftDrawSrcPicture (draw, color)))
{
XftGlyphSpecRender (draw->dpy, _XftDrawOp (draw, color),
src, public, draw->render.pict,
0, 0, glyphs, len);
}
}
else
{
if (_XftDrawCorePrepare (draw, color))
XftGlyphSpecCore (draw, color, public, glyphs, len);
}
}
void
XftDrawGlyphFontSpec (XftDraw *draw,
XftColor *color,
XftGlyphFontSpec *glyphs,
int len)
{
int i;
int start;
i = 0;
while (i < len);
{
start = i;
if (((XftFontInt *) glyphs[i].font)->format)
{
Picture src;
while (((XftFontInt *) glyphs[i].font)->format)
{
i++;
}
if (_XftDrawRenderPrepare (draw) &&
(src = _XftDrawSrcPicture (draw, color)))
{
XftGlyphFontSpecRender (draw->dpy, _XftDrawOp (draw, color),
src, draw->render.pict,
0, 0, glyphs, i - start);
}
}
else
{
while (!((XftFontInt *) glyphs[i].font)->format)
{
i++;
}
if (_XftDrawCorePrepare (draw, color))
XftGlyphFontSpecCore (draw, color, glyphs, len);
}
}
}
void
XftDrawCharSpec (XftDraw *draw,
XftColor *color,
XftFont *public,
XftCharSpec *chars,
int len)
{
XftGlyphSpec *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (XftGlyphSpec));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
{
glyphs[i].glyph = XftCharIndex(draw->dpy, public, chars[i].ucs4);
glyphs[i].x = chars[i].x;
glyphs[i].y = chars[i].y;
}
XftDrawGlyphSpec (draw, color, public, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftDrawCharFontSpec (XftDraw *draw,
XftColor *color,
XftCharFontSpec *chars,
int len)
{
XftGlyphFontSpec *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (XftGlyphFontSpec));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
{
glyphs[i].font = chars[i].font;
glyphs[i].glyph = XftCharIndex(draw->dpy, glyphs[i].font, chars[i].ucs4);
glyphs[i].x = chars[i].x;
glyphs[i].y = chars[i].y;
}
XftDrawGlyphFontSpec (draw, color, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftDrawRect (XftDraw *draw,
XftColor *color,
int x,
int y,
unsigned int width,
unsigned int height)
{
if (_XftDrawRenderPrepare (draw))
{
XRenderFillRectangle (draw->dpy, PictOpOver, draw->render.pict,
&color->color, x, y, width, height);
}
else if (_XftDrawCorePrepare (draw, color))
{
XftRectCore (draw, color, x, y, width, height);
}
}
Bool
XftDrawSetClip (XftDraw *draw,
Region r)
{
Region n = 0;
if (!r && !draw->clip)
return True;
if (r && draw->clip && XEqualRegion (r, draw->clip))
return True;
if (r)
{
n = XCreateRegion ();
if (n)
{
if (!XUnionRegion (n, r, n))
{
XDestroyRegion (n);
return False;
}
}
}
if (draw->clip)
XDestroyRegion (draw->clip);
draw->clip = n;
if (draw->render.pict)
{
if (n)
XRenderSetPictureClipRegion (draw->dpy, draw->render.pict, n);
else
{
XRenderPictureAttributes pa;
pa.clip_mask = None;
XRenderChangePicture (draw->dpy, draw->render.pict,
CPClipMask, &pa);
}
}
if (draw->core.gc)
{
if (n)
XSetRegion (draw->dpy, draw->core.gc, draw->clip);
else
XSetClipMask (draw->dpy, draw->core.gc, None);
}
return True;
}

View File

@ -1,247 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftextent.c,v 1.7 2002/02/15 07:36:11 keithp Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include <string.h>
#include "xftint.h"
void
XftGlyphExtents (Display *dpy,
XftFont *public,
FT_UInt *glyphs,
int nglyphs,
XGlyphInfo *extents)
{
XftFontInt *font = (XftFontInt *) public;
FT_UInt missing[XFT_NMISSING];
int nmissing;
int n;
FT_UInt *g;
FT_UInt glyph;
XftGlyph *xftg;
FcBool glyphs_loaded;
int x, y;
int left, right, top, bottom;
int overall_left, overall_right;
int overall_top, overall_bottom;
g = glyphs;
n = nglyphs;
nmissing = 0;
glyphs_loaded = FcFalse;
while (n--)
if (XftFontCheckGlyph (dpy, public, FcFalse, *g++, missing, &nmissing))
glyphs_loaded = FcTrue;
if (nmissing)
XftFontLoadGlyphs (dpy, public, FcFalse, missing, nmissing);
g = glyphs;
n = nglyphs;
xftg = 0;
while (n)
{
glyph = *g++;
n--;
if (glyph < font->num_glyphs &&
(xftg = font->glyphs[glyph]))
break;
}
if (n == 0 && !xftg)
{
extents->width = 0;
extents->height = 0;
extents->x = 0;
extents->y = 0;
extents->yOff = 0;
extents->xOff = 0;
}
else
{
x = 0;
y = 0;
overall_left = x - xftg->metrics.x;
overall_top = y - xftg->metrics.y;
overall_right = overall_left + (int) xftg->metrics.width;
overall_bottom = overall_top + (int) xftg->metrics.height;
x += xftg->metrics.xOff;
y += xftg->metrics.yOff;
while (n--)
{
glyph = *g++;
if (glyph < font->num_glyphs && (xftg = font->glyphs[glyph]))
{
left = x - xftg->metrics.x;
top = y - xftg->metrics.y;
right = left + (int) xftg->metrics.width;
bottom = top + (int) xftg->metrics.height;
if (left < overall_left)
overall_left = left;
if (top < overall_top)
overall_top = top;
if (right > overall_right)
overall_right = right;
if (bottom > overall_bottom)
overall_bottom = bottom;
x += xftg->metrics.xOff;
y += xftg->metrics.yOff;
}
}
extents->x = -overall_left;
extents->y = -overall_top;
extents->width = overall_right - overall_left;
extents->height = overall_bottom - overall_top;
extents->xOff = x;
extents->yOff = y;
}
if (glyphs_loaded)
_XftFontManageMemory (dpy, public);
}
#define NUM_LOCAL 1024
void
XftTextExtents8 (Display *dpy,
XftFont *public,
FcChar8 *string,
int len,
XGlyphInfo *extents)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
{
memset (extents, '\0', sizeof (XGlyphInfo));
return;
}
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public, string[i]);
XftGlyphExtents (dpy, public, glyphs, len, extents);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextExtents16 (Display *dpy,
XftFont *public,
FcChar16 *string,
int len,
XGlyphInfo *extents)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
{
memset (extents, '\0', sizeof (XGlyphInfo));
return;
}
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public, string[i]);
XftGlyphExtents (dpy, public, glyphs, len, extents);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextExtents32 (Display *dpy,
XftFont *public,
FcChar32 *string,
int len,
XGlyphInfo *extents)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
{
memset (extents, '\0', sizeof (XGlyphInfo));
return;
}
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public, string[i]);
XftGlyphExtents (dpy, public, glyphs, len, extents);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextExtentsUtf8 (Display *dpy,
XftFont *public,
FcChar8 *string,
int len,
XGlyphInfo *extents)
{
FT_UInt *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
FcChar32 ucs4;
int i;
int l;
int size;
i = 0;
glyphs = glyphs_local;
size = NUM_LOCAL;
while (len && (l = FcUtf8ToUcs4 (string, &ucs4, len)) > 0)
{
if (i == size)
{
glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
if (!glyphs_new)
{
if (glyphs != glyphs_local)
free (glyphs);
memset (extents, '\0', sizeof (XGlyphInfo));
return;
}
memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
size *= 2;
if (glyphs != glyphs_local)
free (glyphs);
glyphs = glyphs_new;
}
glyphs[i++] = ucs4;
string += l;
len -= l;
}
XftGlyphExtents (dpy, public, glyphs, i, extents);
if (glyphs != glyphs_local)
free (glyphs);
}

View File

@ -1,199 +0,0 @@
/*
* $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.
*
* 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include "xftint.h"
FcPattern *
XftFontMatch (Display *dpy, int screen, FcPattern *pattern, FcResult *result)
{
FcPattern *new;
FcPattern *match;
if (!XftInit (0))
return 0;
new = FcPatternDuplicate (pattern);
if (!new)
return 0;
if (XftDebug () & XFT_DBG_OPENV)
{
printf ("XftFontMatch pattern ");
FcPatternPrint (new);
}
FcConfigSubstitute (0, new, FcMatchPattern);
if (XftDebug () & XFT_DBG_OPENV)
{
printf ("XftFontMatch after FcConfig substitutions ");
FcPatternPrint (new);
}
XftDefaultSubstitute (dpy, screen, new);
if (XftDebug () & XFT_DBG_OPENV)
{
printf ("XftFontMatch after X resource substitutions ");
FcPatternPrint (new);
}
match = FcFontMatch (0, new, result);
if (XftDebug () & XFT_DBG_OPENV)
{
printf ("XftFontMatch result ");
FcPatternPrint (match);
}
FcPatternDestroy (new);
return match;
}
XftFont *
XftFontOpen (Display *dpy, int screen, ...)
{
va_list va;
FcPattern *pat;
FcPattern *match;
FcResult result;
XftFont *font;
va_start (va, screen);
pat = FcPatternVaBuild (0, va);
va_end (va);
if (!pat)
{
if (XftDebug () & XFT_DBG_OPEN)
printf ("XftFontOpen: Invalid pattern argument\n");
return 0;
}
match = XftFontMatch (dpy, screen, pat, &result);
if (XftDebug () & XFT_DBG_OPEN)
{
printf ("Pattern ");
FcPatternPrint (pat);
if (match)
{
printf ("Match ");
FcPatternPrint (match);
}
else
printf ("No Match\n");
}
FcPatternDestroy (pat);
if (!match)
return 0;
font = XftFontOpenPattern (dpy, match);
if (!font)
{
if (XftDebug () & XFT_DBG_OPEN)
printf ("No Font\n");
FcPatternDestroy (match);
}
return font;
}
XftFont *
XftFontOpenName (Display *dpy, int screen, const char *name)
{
FcPattern *pat;
FcPattern *match;
FcResult result;
XftFont *font;
pat = FcNameParse ((FcChar8 *) name);
if (XftDebug () & XFT_DBG_OPEN)
{
printf ("XftFontOpenName \"%s\": ", name);
if (pat)
FcPatternPrint (pat);
else
printf ("Invalid name\n");
}
if (!pat)
return 0;
match = XftFontMatch (dpy, screen, pat, &result);
if (XftDebug () & XFT_DBG_OPEN)
{
if (match)
{
printf ("Match ");
FcPatternPrint (match);
}
else
printf ("No Match\n");
}
FcPatternDestroy (pat);
if (!match)
return 0;
font = XftFontOpenPattern (dpy, match);
if (!font)
FcPatternDestroy (match);
return font;
}
XftFont *
XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd)
{
FcPattern *pat;
FcPattern *match;
FcResult result;
XftFont *font;
pat = XftXlfdParse (xlfd, FcFalse, FcFalse);
if (XftDebug () & XFT_DBG_OPEN)
{
printf ("XftFontOpenXlfd \"%s\": ", xlfd);
if (pat)
printf ("Invalid xlfd\n");
else
FcPatternPrint (pat);
}
if (!pat)
return 0;
match = XftFontMatch (dpy, screen, pat, &result);
if (XftDebug () & XFT_DBG_OPEN)
{
if (match)
{
printf ("Match ");
FcPatternPrint (match);
}
else
printf ("No Match\n");
}
FcPatternDestroy (pat);
if (!match)
return 0;
font = XftFontOpenPattern (dpy, match);
if (!font)
FcPatternDestroy (match);
return font;
}

View File

@ -1,788 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftfreetype.c,v 1.19 2002/04/10 16:20:06 tsi Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "xftint.h"
#include <X11/Xlibint.h>
FT_Library _XftFTlibrary;
#define FT_Matrix_Equal(a,b) ((a)->xx == (b)->xx && \
(a)->yy == (b)->yy && \
(a)->xy == (b)->xy && \
(a)->yx == (b)->yx)
/*
* List of all open files (each face in a file is managed separately)
*/
static XftFtFile *_XftFtFiles;
int XftMaxFreeTypeFiles = 5;
static XftFtFile *
_XftGetFile (const FcChar8 *file, int id)
{
XftFtFile *f;
if (!XftInitFtLibrary ())
return 0;
for (f = _XftFtFiles; f; f = f->next)
{
if (!strcmp (f->file, (void *) file) && f->id == id)
{
++f->ref;
if (XftDebug () & XFT_DBG_REF)
printf ("FontFile %s/%d matches existing (%d)\n",
file, id, f->ref);
return f;
}
}
f = malloc (sizeof (XftFtFile) + strlen ((char *) file) + 1);
if (!f)
return 0;
XftMemAlloc (XFT_MEM_FILE, sizeof (XftFtFile) + strlen ((char *) file) + 1);
if (XftDebug () & XFT_DBG_REF)
printf ("FontFile %s/%d matches new\n",
file, id);
f->next = _XftFtFiles;
_XftFtFiles = f;
f->ref = 1;
f->file = (char *) (f+1);
strcpy (f->file, (void *) file);
f->id = id;
f->lock = 0;
f->face = 0;
f->size = 0;
return f;
}
static int
_XftNumFiles (void)
{
XftFtFile *f;
int count = 0;
for (f = _XftFtFiles; f; f = f->next)
if (f->face && !f->lock)
++count;
return count;
}
static XftFtFile *
_XftNthFile (int n)
{
XftFtFile *f;
int count = 0;
for (f = _XftFtFiles; f; f = f->next)
if (f->face && !f->lock)
if (count++ == n)
break;
return f;
}
static void
_XftUncacheFiles (void)
{
int n;
XftFtFile *f;
while ((n = _XftNumFiles ()) > XftMaxFreeTypeFiles)
{
f = _XftNthFile (rand () % n);
if (f)
{
if (XftDebug() & XFT_DBG_REF)
printf ("Discard file %s/%d from cache\n",
f->file, f->id);
FT_Done_Face (f->face);
f->face = 0;
}
}
}
static FT_Face
_XftLockFile (XftFtFile *f)
{
++f->lock;
if (!f->face)
{
if (XftDebug() & XFT_DBG_REF)
printf ("Loading file %s/%d\n", f->file, f->id);
if (FT_New_Face (_XftFTlibrary, f->file, f->id, &f->face))
--f->lock;
f->size = 0;
f->matrix.xx = f->matrix.xy = f->matrix.yx = f->matrix.yy = 0;
_XftUncacheFiles ();
}
return f->face;
}
static void
_XftLockError (char *reason)
{
fprintf (stderr, "Xft: locking error %s\n", reason);
}
static void
_XftUnlockFile (XftFtFile *f)
{
if (--f->lock < 0)
_XftLockError ("too many file unlocks");
}
FcBool
_XftSetFace (XftFtFile *f, FT_F26Dot6 size, FT_Matrix *matrix)
{
FT_Face face = f->face;
if (f->size != size)
{
if (XftDebug() & XFT_DBG_GLYPH)
printf ("Set face size to %d (%d)\n",
(int) (size >> 6), (int) size);
if (FT_Set_Char_Size (face, size, size, 0, 0))
return False;
f->size = size;
}
if (!FT_Matrix_Equal (&f->matrix, matrix))
{
if (XftDebug() & XFT_DBG_GLYPH)
printf ("Set face matrix to (%g,%g,%g,%g)\n",
(double) matrix->xx / 0x10000,
(double) matrix->xy / 0x10000,
(double) matrix->yx / 0x10000,
(double) matrix->yy / 0x10000);
FT_Set_Transform (face, matrix, 0);
f->matrix = *matrix;
}
return True;
}
static void
_XftReleaseFile (XftFtFile *f)
{
XftFtFile **prev;
if (--f->ref != 0)
return;
if (f->lock)
_XftLockError ("Attempt to close locked file");
for (prev = &_XftFtFiles; *prev; prev = &(*prev)->next)
{
if (*prev == f)
{
*prev = f->next;
break;
}
}
if (f->face)
FT_Done_Face (f->face);
XftMemFree (XFT_MEM_FILE, sizeof (XftFtFile) + strlen (f->file) + 1);
free (f);
}
/*
* Find a prime larger than the minimum reasonable hash size
*/
static FcChar32
_XftSqrt (FcChar32 a)
{
FcChar32 l, h, m;
l = 2;
h = a/2;
while ((h-l) > 1)
{
m = (h+l) >> 1;
if (m * m < a)
l = m;
else
h = m;
}
return h;
}
static FcBool
_XftIsPrime (FcChar32 i)
{
FcChar32 l, t;
if (i < 2)
return FcFalse;
if ((i & 1) == 0)
{
if (i == 2)
return FcTrue;
return FcFalse;
}
l = _XftSqrt (i) + 1;
for (t = 3; t <= l; t += 2)
if (i % t == 0)
return FcFalse;
return FcTrue;
}
static FcChar32
_XftHashSize (FcChar32 num_unicode)
{
/* at least 31.25 % extra space */
FcChar32 hash = num_unicode + (num_unicode >> 2) + (num_unicode >> 4);
if ((hash & 1) == 0)
hash++;
while (!_XftIsPrime (hash))
hash += 2;
return hash;
}
FT_Face
XftLockFace (XftFont *public)
{
XftFontInt *font = (XftFontInt *) public;
return _XftLockFile (font->file);
}
void
XftUnlockFace (XftFont *public)
{
XftFontInt *font = (XftFontInt *) public;
_XftUnlockFile (font->file);
}
XftFont *
XftFontOpenPattern (Display *dpy, FcPattern *pattern)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
XftFtFile *file;
FT_Face face;
FcChar8 *filename;
int id;
double dsize;
FT_F26Dot6 size;
int spacing;
int char_width;
Bool minspace;
XftFont *public;
XftFontInt *font;
FcBool render;
int i;
FcCharSet *charset;
FcChar32 num_unicode;
FcChar32 hash_value;
FcChar32 rehash_value;
int max_glyph_memory;
int alloc_size;
/*
* Font information placed in XftFontInt
*/
FcBool antialias;
int rgba;
FcBool transform;
FT_Matrix matrix;
FT_Int load_flags;
FcBool hinting, vertical_layout, autohint, global_advance;
FcMatrix *font_matrix;
int height, ascent, descent;
XRenderPictFormat pf, *format;
if (!info)
goto bail0;
/*
* Find the associated file
*/
if (FcPatternGetString (pattern, FC_FILE, 0, &filename) != FcResultMatch)
goto bail0;
if (FcPatternGetInteger (pattern, FC_INDEX, 0, &id) != FcResultMatch)
goto bail0;
file = _XftGetFile (filename, id);
if (!file)
goto bail0;
face = _XftLockFile (file);
if (!face)
goto bail1;
/*
* Extract the glyphset information from the pattern
*/
if (FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &dsize) != FcResultMatch)
goto bail2;
switch (FcPatternGetBool (pattern, FC_MINSPACE, 0, &minspace)) {
case FcResultNoMatch:
minspace = False;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
switch (FcPatternGetInteger (pattern, FC_SPACING, 0, &spacing)) {
case FcResultNoMatch:
spacing = FC_PROPORTIONAL;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
if (FcPatternGetInteger (pattern, FC_CHAR_WIDTH,
0, &char_width) != FcResultMatch)
{
char_width = 0;
}
else if (char_width)
spacing = FC_MONO;
if (face->face_flags & FT_FACE_FLAG_SCALABLE)
{
switch (FcPatternGetBool (pattern, FC_ANTIALIAS, 0, &antialias)) {
case FcResultNoMatch:
antialias = True;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
}
else
antialias = False;
switch (FcPatternGetInteger (pattern, FC_RGBA, 0, &rgba)) {
case FcResultNoMatch:
rgba = FC_RGBA_NONE;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
matrix.xx = matrix.yy = 0x10000;
matrix.xy = matrix.yx = 0;
switch (FcPatternGetMatrix (pattern, FC_MATRIX, 0, &font_matrix)) {
case FcResultNoMatch:
break;
case FcResultMatch:
matrix.xx = 0x10000L * font_matrix->xx;
matrix.yy = 0x10000L * font_matrix->yy;
matrix.xy = 0x10000L * font_matrix->xy;
matrix.yx = 0x10000L * font_matrix->yx;
break;
default:
goto bail2;
}
transform = (matrix.xx != 0x10000 || matrix.xy != 0 ||
matrix.yx != 0 || matrix.yy != 0x10000);
if (FcPatternGetCharSet (pattern, FC_CHARSET, 0, &charset) != FcResultMatch)
{
charset = 0;
}
if (FcPatternGetInteger (pattern, FC_CHAR_WIDTH,
0, &char_width) != FcResultMatch)
{
char_width = 0;
}
else if (char_width)
spacing = FC_MONO;
switch (FcPatternGetBool (pattern, XFT_RENDER, 0, &render)) {
case FcResultNoMatch:
render = info->hasRender;
break;
case FcResultMatch:
if (render && !info->hasRender)
render = FcFalse;
break;
default:
goto bail2;
}
/*
* Compute glyph load flags
*/
load_flags = FT_LOAD_DEFAULT;
/* disable bitmaps when anti-aliasing or transforming glyphs */
if (antialias || transform)
load_flags |= FT_LOAD_NO_BITMAP;
/* disable hinting if requested */
switch (FcPatternGetBool (pattern, FC_HINTING, 0, &hinting)) {
case FcResultNoMatch:
hinting = FcTrue;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
if (!hinting)
load_flags |= FT_LOAD_NO_HINTING;
/* set vertical layout if requested */
switch (FcPatternGetBool (pattern, FC_VERTICAL_LAYOUT, 0, &vertical_layout)) {
case FcResultNoMatch:
vertical_layout = FcFalse;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
if (vertical_layout)
load_flags |= FT_LOAD_VERTICAL_LAYOUT;
/* force autohinting if requested */
switch (FcPatternGetBool (pattern, FC_AUTOHINT, 0, &autohint)) {
case FcResultNoMatch:
autohint = FcFalse;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
if (autohint)
load_flags |= FT_LOAD_FORCE_AUTOHINT;
/* disable global advance width (for broken DynaLab TT CJK fonts) */
switch (FcPatternGetBool (pattern, FC_GLOBAL_ADVANCE, 0, &global_advance)) {
case FcResultNoMatch:
global_advance = FcTrue;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
if (!global_advance)
load_flags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
if (FcPatternGetInteger (pattern, XFT_MAX_GLYPH_MEMORY,
0, &max_glyph_memory) != FcResultMatch)
{
max_glyph_memory = XFT_FONT_MAX_GLYPH_MEMORY;
}
size = (FT_F26Dot6) (dsize * 64.0);
/*
* Match an existing font
*/
for (public = info->fonts; public; public = font->next)
{
font = (XftFontInt *) public;
if (font->file == file &&
font->minspace == minspace &&
font->char_width == char_width &&
font->size == size &&
font->spacing == spacing &&
font->rgba == rgba &&
font->antialias == antialias &&
font->load_flags == load_flags &&
(font->format != 0) == render &&
FT_Matrix_Equal (&font->matrix, &matrix))
{
++font->ref;
if (XftDebug () & XFT_DBG_REF)
{
printf ("Face size %g matches existing (%d)\n",
dsize, font->ref);
}
_XftUnlockFile (file);
_XftReleaseFile (file);
FcPatternDestroy (pattern);
return &font->public;
}
}
if (XftDebug () & XFT_DBG_REF)
printf ("Face size %g matches new\n", dsize);
/*
* No existing glyphset, create another.
*/
if (render)
{
if (antialias)
{
if (rgba)
{
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);
}
else
{
pf.depth = 8;
pf.type = PictTypeDirect;
pf.direct.alpha = 0;
pf.direct.alphaMask = 0xff;
format = XRenderFindFormat(dpy,
PictFormatType|
PictFormatDepth|
PictFormatAlpha|
PictFormatAlphaMask,
&pf, 0);
}
}
else
{
pf.depth = 1;
pf.type = PictTypeDirect;
pf.direct.alpha = 0;
pf.direct.alphaMask = 0x1;
format = XRenderFindFormat(dpy,
PictFormatType|
PictFormatDepth|
PictFormatAlpha|
PictFormatAlphaMask,
&pf, 0);
}
if (!format)
goto bail2;
}
else
format = 0;
if (!_XftSetFace (file, size, &matrix))
goto bail2;
if (charset)
{
num_unicode = FcCharSetCount (charset);
hash_value = _XftHashSize (num_unicode);
rehash_value = hash_value - 2;
}
else
{
num_unicode = 0;
hash_value = 0;
rehash_value = 0;
}
alloc_size = (sizeof (XftFontInt) +
face->num_glyphs * sizeof (XftGlyph *) +
hash_value * sizeof (XftUcsHash));
font = malloc (alloc_size);
if (!font)
goto bail2;
XftMemAlloc (XFT_MEM_FONT, alloc_size);
/*
* Public fields
*/
descent = -(face->size->metrics.descender >> 6);
ascent = face->size->metrics.ascender >> 6;
if (minspace)
{
height = ascent + descent;
}
else
{
height = face->size->metrics.height >> 6;
}
font->public.ascent = ascent;
font->public.descent = descent;
font->public.height = height;
if (char_width)
font->public.max_advance_width = char_width;
else
font->public.max_advance_width = face->size->metrics.max_advance >> 6;
font->public.charset = charset;
font->public.pattern = pattern;
/*
* Management fields
*/
font->next = info->fonts;
info->fonts = &font->public;
font->file = file;
font->ref = 1;
/*
* Per glyph information
*/
font->glyphs = (XftGlyph **) (font + 1);
memset (font->glyphs, '\0', face->num_glyphs * sizeof (XftGlyph *));
font->num_glyphs = face->num_glyphs;
/*
* Unicode hash table information
*/
font->hash_table = (XftUcsHash *) (font->glyphs + font->num_glyphs);
for (i = 0; i < hash_value; i++)
{
font->hash_table[i].ucs4 = ((FcChar32) ~0);
font->hash_table[i].glyph = 0;
}
font->hash_value = hash_value;
font->rehash_value = rehash_value;
/*
* X specific fields
*/
font->glyphset = 0;
font->format = format;
/*
* Rendering options
*/
font->size = size;
font->antialias = antialias;
font->rgba = rgba;
font->transform = transform;
font->matrix = matrix;
font->load_flags = load_flags;
font->minspace = minspace;
font->char_width = char_width;
font->spacing = spacing;
/*
* Glyph memory management fields
*/
font->glyph_memory = 0;
font->max_glyph_memory = max_glyph_memory;
font->use_free_glyphs = info->use_free_glyphs;
_XftUnlockFile (file);
return &font->public;
bail2:
_XftUnlockFile (file);
bail1:
_XftReleaseFile (file);
bail0:
return 0;
}
XftFont *
XftFontCopy (Display *dpy, XftFont *public)
{
XftFontInt *font = (XftFontInt *) public;
font->ref++;
return public;
}
void
XftFontClose (Display *dpy, XftFont *public)
{
XftFontInt *font = (XftFontInt *) public;
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
XftFont **prev;
int i;
if (--font->ref == 0)
{
if (info)
{
/* Unhook from display list */
for (prev = &info->fonts; *prev; prev = &(*(XftFontInt **) prev)->next)
{
if (*prev == public)
{
*prev = font->next;
break;
}
}
}
/* Free resources */
/* Dereference the file */
_XftReleaseFile (font->file);
/* Free the glyphset */
if (font->glyphset)
XRenderFreeGlyphSet (dpy, font->glyphset);
/* Free the glyphs */
for (i = 0; i < font->num_glyphs; i++)
{
XftGlyph *xftg = font->glyphs[i];
if (xftg)
{
if (xftg->bitmap)
free (xftg->bitmap);
free (xftg);
}
}
/* Finally, free the font structure */
XftMemFree (XFT_MEM_FONT, sizeof (XftFontInt) +
font->num_glyphs * sizeof (XftGlyph *) +
font->hash_value * sizeof (XftUcsHash));
free (font);
}
}
FcBool
XftInitFtLibrary (void)
{
if (_XftFTlibrary)
return FcTrue;
if (FT_Init_FreeType (&_XftFTlibrary))
return FcFalse;
return FcTrue;
}

View File

@ -1,769 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftglyphs.c,v 1.15 2002/02/15 07:36:11 keithp Exp $
*
* 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
* 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xftint.h"
#include <freetype/ftoutln.h>
#include <fontconfig/fcfreetype.h>
static const int filters[3][3] = {
/* red */
#if 0
{ 65538*4/7,65538*2/7,65538*1/7 },
/* green */
{ 65536*1/4, 65536*2/4, 65537*1/4 },
/* blue */
{ 65538*1/7,65538*2/7,65538*4/7 },
#endif
{ 65538*9/13,65538*3/13,65538*1/13 },
/* green */
{ 65538*1/6, 65538*4/6, 65538*1/6 },
/* blue */
{ 65538*1/13,65538*3/13,65538*9/13 },
};
void
XftFontLoadGlyphs (Display *dpy,
XftFont *public,
FcBool need_bitmaps,
FT_UInt *glyphs,
int nglyph)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
XftFontInt *font = (XftFontInt *) public;
FT_Error error;
FT_UInt glyphindex;
FT_GlyphSlot glyphslot;
XftGlyph *xftg;
Glyph glyph;
unsigned char bufLocal[4096];
unsigned char *bufBitmap = bufLocal;
int bufSize = sizeof (bufLocal);
int size, pitch;
unsigned char bufLocalRgba[4096];
unsigned char *bufBitmapRgba = bufLocalRgba;
int bufSizeRgba = sizeof (bufLocalRgba);
int sizergba, pitchrgba, widthrgba;
int width;
int height;
int left, right, top, bottom;
int hmul = 1;
int vmul = 1;
FT_Bitmap ftbit;
FT_Matrix matrix;
FT_Vector vector;
Bool subpixel = False;
FT_Face face;
if (!info)
return;
face = XftLockFace (&font->public);
if (!_XftSetFace (font->file, font->size, &font->matrix))
{
XftUnlockFace (&font->public);
return;
}
matrix.xx = matrix.yy = 0x10000L;
matrix.xy = matrix.yx = 0;
if (font->antialias)
{
switch (font->rgba) {
case FC_RGBA_RGB:
case FC_RGBA_BGR:
matrix.xx *= 3;
subpixel = True;
hmul = 3;
break;
case FC_RGBA_VRGB:
case FC_RGBA_VBGR:
matrix.yy *= 3;
vmul = 3;
subpixel = True;
break;
}
}
while (nglyph--)
{
glyphindex = *glyphs++;
xftg = font->glyphs[glyphindex];
if (!xftg)
continue;
error = FT_Load_Glyph (face, glyphindex, font->load_flags);
if (error)
{
/*
* If anti-aliasing or transforming glyphs and
* no outline version exists, fallback to the
* bitmap and let things look bad instead of
* missing the glyph
*/
if (font->load_flags & FT_LOAD_NO_BITMAP)
error = FT_Load_Glyph (face, glyphindex,
font->load_flags & ~FT_LOAD_NO_BITMAP);
if (error)
continue;
}
#define FLOOR(x) ((x) & -64)
#define CEIL(x) (((x)+63) & -64)
#define TRUNC(x) ((x) >> 6)
#define ROUND(x) (((x)+32) & -64)
glyphslot = face->glyph;
/*
* Compute glyph metrics from FreeType information
*/
if(font->transform && glyphslot->format != ft_glyph_format_bitmap)
{
/*
* calculate the true width by transforming all four corners.
*/
int xc, yc;
left = right = top = bottom = 0;
for(xc = 0; xc <= 1; xc ++) {
for(yc = 0; yc <= 1; yc++) {
vector.x = glyphslot->metrics.horiBearingX + xc * glyphslot->metrics.width;
vector.y = glyphslot->metrics.horiBearingY - yc * glyphslot->metrics.height;
FT_Vector_Transform(&vector, &font->matrix);
if (XftDebug() & XFT_DBG_GLYPH)
printf("Trans %d %d: %d %d\n", (int) xc, (int) yc,
(int) vector.x, (int) vector.y);
if(xc == 0 && yc == 0) {
left = right = vector.x;
top = bottom = vector.y;
} else {
if(left > vector.x) left = vector.x;
if(right < vector.x) right = vector.x;
if(bottom > vector.y) bottom = vector.y;
if(top < vector.y) top = vector.y;
}
}
}
left = FLOOR(left);
right = CEIL(right);
bottom = FLOOR(bottom);
top = CEIL(top);
} else {
left = FLOOR( glyphslot->metrics.horiBearingX );
right = CEIL( glyphslot->metrics.horiBearingX + glyphslot->metrics.width );
top = CEIL( glyphslot->metrics.horiBearingY );
bottom = FLOOR( glyphslot->metrics.horiBearingY - glyphslot->metrics.height );
}
width = TRUNC(right - left);
height = TRUNC( top - bottom );
/*
* Try to keep monospace fonts ink-inside
* XXX transformed?
*/
if (font->spacing != FC_PROPORTIONAL && !font->transform)
{
if (font->load_flags & FT_LOAD_VERTICAL_LAYOUT)
{
if (TRUNC(bottom) > font->public.max_advance_width)
{
int adjust;
adjust = bottom - (font->public.max_advance_width << 6);
if (adjust > top)
adjust = top;
top -= adjust;
bottom -= adjust;
height = font->public.max_advance_width;
}
}
else
{
if (TRUNC(right) > font->public.max_advance_width)
{
int adjust;
adjust = right - (font->public.max_advance_width << 6);
if (adjust > left)
adjust = left;
left -= adjust;
right -= adjust;
width = font->public.max_advance_width;
}
}
}
if (font->antialias)
pitch = (width * hmul + 3) & ~3;
else
pitch = ((width + 31) & ~31) >> 3;
size = pitch * height * vmul;
xftg->metrics.width = width;
xftg->metrics.height = height;
xftg->metrics.x = -TRUNC(left);
xftg->metrics.y = TRUNC(top);
if (font->spacing != FC_PROPORTIONAL)
{
if (font->transform)
{
if (font->load_flags & FT_LOAD_VERTICAL_LAYOUT)
{
vector.x = 0;
vector.y = -font->public.max_advance_width;
}
else
{
vector.x = font->public.max_advance_width;
vector.y = 0;
}
FT_Vector_Transform (&vector, &font->matrix);
xftg->metrics.xOff = vector.x;
xftg->metrics.yOff = -vector.y;
}
else
{
if (font->load_flags & FT_LOAD_VERTICAL_LAYOUT)
{
xftg->metrics.xOff = 0;
xftg->metrics.yOff = -font->public.max_advance_width;
}
else
{
xftg->metrics.xOff = font->public.max_advance_width;
xftg->metrics.yOff = 0;
}
}
}
else
{
xftg->metrics.xOff = TRUNC(ROUND(glyphslot->advance.x));
xftg->metrics.yOff = -TRUNC(ROUND(glyphslot->advance.y));
}
/*
* If the glyph is relatively large (> 1% of server memory),
* don't send it until necessary
*/
if (!need_bitmaps && size > info->max_glyph_memory / 100)
continue;
/*
* Make sure there's enough buffer space for the glyph
*/
if (size > bufSize)
{
if (bufBitmap != bufLocal)
free (bufBitmap);
bufBitmap = (unsigned char *) malloc (size);
if (!bufBitmap)
continue;
bufSize = size;
}
memset (bufBitmap, 0, size);
/*
* Rasterize into the local buffer
*/
switch (glyphslot->format) {
case ft_glyph_format_outline:
ftbit.width = width * hmul;
ftbit.rows = height * vmul;
ftbit.pitch = pitch;
if (font->antialias)
ftbit.pixel_mode = ft_pixel_mode_grays;
else
ftbit.pixel_mode = ft_pixel_mode_mono;
ftbit.buffer = bufBitmap;
if (subpixel)
FT_Outline_Transform (&glyphslot->outline, &matrix);
FT_Outline_Translate ( &glyphslot->outline, -left*hmul, -bottom*vmul );
FT_Outline_Get_Bitmap( _XftFTlibrary, &glyphslot->outline, &ftbit );
break;
case ft_glyph_format_bitmap:
if (font->antialias)
{
unsigned char *srcLine, *dstLine;
int height;
int x;
int h, v;
srcLine = glyphslot->bitmap.buffer;
dstLine = bufBitmap;
height = glyphslot->bitmap.rows;
while (height--)
{
for (x = 0; x < glyphslot->bitmap.width; x++)
{
/* always MSB bitmaps */
unsigned char a = ((srcLine[x >> 3] & (0x80 >> (x & 7))) ?
0xff : 0x00);
if (subpixel)
{
for (v = 0; v < vmul; v++)
for (h = 0; h < hmul; h++)
dstLine[v * pitch + x*hmul + h] = a;
}
else
dstLine[x] = a;
}
dstLine += pitch * vmul;
}
}
else
{
unsigned char *srcLine, *dstLine;
int h, bytes;
srcLine = glyphslot->bitmap.buffer;
dstLine = bufBitmap;
h = glyphslot->bitmap.rows;
bytes = (glyphslot->bitmap.width + 7) >> 3;
while (h--)
{
memcpy (dstLine, srcLine, bytes);
dstLine += pitch;
srcLine += glyphslot->bitmap.pitch;
}
}
break;
default:
if (XftDebug() & XFT_DBG_GLYPH)
printf ("glyph %d is not in a usable format\n",
(int) glyphindex);
continue;
}
if (XftDebug() & XFT_DBG_GLYPH)
{
printf ("glyph %d:\n", (int) glyphindex);
printf (" xywh (%d %d %d %d), trans (%d %d %d %d) wh (%d %d)\n",
(int) glyphslot->metrics.horiBearingX,
(int) glyphslot->metrics.horiBearingY,
(int) glyphslot->metrics.width,
(int) glyphslot->metrics.height,
left, right, top, bottom,
width, height);
if (XftDebug() & XFT_DBG_GLYPHV)
{
int x, y;
unsigned char *line;
line = bufBitmap;
for (y = 0; y < height * vmul; y++)
{
if (font->antialias)
{
static char den[] = { " .:;=+*#" };
for (x = 0; x < pitch; x++)
printf ("%c", den[line[x] >> 5]);
}
else
{
for (x = 0; x < pitch * 8; x++)
{
printf ("%c", line[x>>3] & (1 << (x & 7)) ? '#' : ' ');
}
}
printf ("|\n");
line += pitch;
}
printf ("\n");
}
}
/*
* Use the glyph index as the wire encoding; it
* might be more efficient for some locales to map
* these by first usage to smaller values, but that
* would require persistently storing the map when
* glyphs were freed.
*/
glyph = (Glyph) glyphindex;
if (subpixel)
{
int x, y;
unsigned char *in_line, *out_line, *in;
unsigned int *out;
unsigned int red, green, blue;
int rf, gf, bf;
int s;
int o, os;
/*
* Filter the glyph to soften the color fringes
*/
widthrgba = width;
pitchrgba = (widthrgba * 4 + 3) & ~3;
sizergba = pitchrgba * height;
os = 1;
switch (font->rgba) {
case FC_RGBA_VRGB:
os = pitch;
case FC_RGBA_RGB:
default:
rf = 0;
gf = 1;
bf = 2;
break;
case FC_RGBA_VBGR:
os = pitch;
case FC_RGBA_BGR:
bf = 0;
gf = 1;
rf = 2;
break;
}
if (sizergba > bufSizeRgba)
{
if (bufBitmapRgba != bufLocalRgba)
free (bufBitmapRgba);
bufBitmapRgba = (unsigned char *) malloc (sizergba);
if (!bufBitmapRgba)
continue;
bufSizeRgba = sizergba;
}
memset (bufBitmapRgba, 0, sizergba);
in_line = bufBitmap;
out_line = bufBitmapRgba;
for (y = 0; y < height; y++)
{
in = in_line;
out = (unsigned int *) out_line;
in_line += pitch * vmul;
out_line += pitchrgba;
for (x = 0; x < width * hmul; x += hmul)
{
red = green = blue = 0;
o = 0;
for (s = 0; s < 3; s++)
{
red += filters[rf][s]*in[x+o];
green += filters[gf][s]*in[x+o];
blue += filters[bf][s]*in[x+o];
o += os;
}
red = red / 65536;
green = green / 65536;
blue = blue / 65536;
*out++ = (green << 24) | (red << 16) | (green << 8) | blue;
}
}
xftg->glyph_memory = sizergba + sizeof (XftGlyph);
if (font->format)
{
if (!font->glyphset)
font->glyphset = XRenderCreateGlyphSet (dpy, font->format);
if (ImageByteOrder (dpy) != XftNativeByteOrder ())
XftSwapCARD32 ((CARD32 *) bufBitmapRgba, sizergba >> 2);
XRenderAddGlyphs (dpy, font->glyphset, &glyph,
&xftg->metrics, 1,
(char *) bufBitmapRgba, sizergba);
}
else
{
xftg->bitmap = malloc (sizergba);
if (xftg->bitmap)
memcpy (xftg->bitmap, bufBitmapRgba, sizergba);
}
}
else
{
xftg->glyph_memory = size + sizeof (XftGlyph);
if (font->format)
{
/*
* swap bit order around; FreeType is always MSBFirst
*/
if (!font->antialias)
{
if (BitmapBitOrder (dpy) != MSBFirst)
{
unsigned char *line;
unsigned char c;
int i;
line = (unsigned char *) bufBitmap;
i = size;
while (i--)
{
c = *line;
c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55);
c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33);
c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f);
*line++ = c;
}
}
}
if (!font->glyphset)
font->glyphset = XRenderCreateGlyphSet (dpy, font->format);
XRenderAddGlyphs (dpy, font->glyphset, &glyph,
&xftg->metrics, 1,
(char *) bufBitmap, size);
}
else
{
xftg->bitmap = malloc (size);
if (xftg->bitmap)
memcpy (xftg->bitmap, bufBitmap, size);
}
}
font->glyph_memory += xftg->glyph_memory;
info->glyph_memory += xftg->glyph_memory;
if (XftDebug() & XFT_DBG_CACHEV)
printf ("Caching glyph 0x%x size %ld\n", glyphindex,
xftg->glyph_memory);
}
if (bufBitmap != bufLocal)
free (bufBitmap);
if (bufBitmapRgba != bufLocalRgba)
free (bufBitmapRgba);
XftUnlockFace (&font->public);
}
void
XftFontUnloadGlyphs (Display *dpy,
XftFont *public,
FT_UInt *glyphs,
int nglyph)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
XftFontInt *font = (XftFontInt *) public;
XftGlyph *xftg;
FT_UInt glyphindex;
Glyph glyphBuf[1024];
int nused;
nused = 0;
while (nglyph--)
{
glyphindex = *glyphs++;
xftg = font->glyphs[glyphindex];
if (!xftg)
continue;
if (xftg->glyph_memory)
{
if (font->format)
{
if (font->glyphset)
{
glyphBuf[nused++] = (Glyph) glyphindex;
if (nused == sizeof (glyphBuf) / sizeof (glyphBuf[0]))
{
XRenderFreeGlyphs (dpy, font->glyphset, glyphBuf, nused);
nused = 0;
}
}
}
else
{
if (xftg->bitmap)
free (xftg->bitmap);
}
font->glyph_memory -= xftg->glyph_memory;
if (info)
info->glyph_memory -= xftg->glyph_memory;
}
free (xftg);
XftMemFree (XFT_MEM_GLYPH, sizeof (XftGlyph));
font->glyphs[glyphindex] = 0;
}
if (font->glyphset && nused)
XRenderFreeGlyphs (dpy, font->glyphset, glyphBuf, nused);
}
FcBool
XftFontCheckGlyph (Display *dpy,
XftFont *public,
FcBool need_bitmaps,
FT_UInt glyph,
FT_UInt *missing,
int *nmissing)
{
XftFontInt *font = (XftFontInt *) public;
XftGlyph *xftg;
int n;
if (glyph >= font->num_glyphs)
return FcFalse;
xftg = font->glyphs[glyph];
if (!xftg || (need_bitmaps && !xftg->glyph_memory))
{
if (!xftg)
{
xftg = (XftGlyph *) malloc (sizeof (XftGlyph));
if (!xftg)
return FcFalse;
XftMemAlloc (XFT_MEM_GLYPH, sizeof (XftGlyph));
xftg->bitmap = 0;
xftg->glyph_memory = 0;
font->glyphs[glyph] = xftg;
}
n = *nmissing;
missing[n++] = glyph;
if (n == XFT_NMISSING)
{
XftFontLoadGlyphs (dpy, public, need_bitmaps, missing, n);
n = 0;
}
*nmissing = n;
return FcTrue;
}
else
return FcFalse;
}
FcBool
XftCharExists (Display *dpy,
XftFont *public,
FcChar32 ucs4)
{
if (public->charset)
return FcCharSetHasChar (public->charset, ucs4);
return FcFalse;
}
#define Missing ((FT_UInt) ~0)
FT_UInt
XftCharIndex (Display *dpy,
XftFont *public,
FcChar32 ucs4)
{
XftFontInt *font = (XftFontInt *) public;
FcChar32 ent, offset;
FT_Face face;
ent = ucs4 % font->hash_value;
offset = 0;
while (font->hash_table[ent].ucs4 != ucs4)
{
if (font->hash_table[ent].ucs4 == (FcChar32) ~0)
{
if (!XftCharExists (dpy, public, ucs4))
return 0;
face = XftLockFace (public);
if (!face)
return 0;
font->hash_table[ent].ucs4 = ucs4;
font->hash_table[ent].glyph = FcFreeTypeCharIndex (face, ucs4);
XftUnlockFace (public);
break;
}
if (!offset)
{
offset = ucs4 % font->rehash_value;
if (!offset)
offset = 1;
}
ent = ent + offset;
if (ent > font->hash_value)
ent -= font->hash_value;
}
return font->hash_table[ent].glyph;
}
/*
* Pick a random glyph from the font and remove it from the cache
*/
void
_XftFontUncacheGlyph (Display *dpy, XftFont *public)
{
XftFontInt *font = (XftFontInt *) public;
unsigned long glyph_memory;
FT_UInt glyphindex;
XftGlyph *xftg;
if (!font->glyph_memory)
return;
if (font->use_free_glyphs)
{
glyph_memory = rand() % font->glyph_memory;
}
else
{
if (font->glyphset)
{
XRenderFreeGlyphSet (dpy, font->glyphset);
font->glyphset = 0;
}
glyph_memory = 0;
}
for (glyphindex = 0; glyphindex < font->num_glyphs; glyphindex++)
{
xftg = font->glyphs[glyphindex];
if (xftg)
{
if (xftg->glyph_memory > glyph_memory)
{
if (XftDebug() & XFT_DBG_CACHEV)
printf ("Uncaching glyph 0x%x size %ld\n",
glyphindex, xftg->glyph_memory);
XftFontUnloadGlyphs (dpy, public, &glyphindex, 1);
if (!font->use_free_glyphs)
continue;
break;
}
glyph_memory -= xftg->glyph_memory;
}
}
}
void
_XftFontManageMemory (Display *dpy, XftFont *public)
{
XftFontInt *font = (XftFontInt *) public;
if (font->max_glyph_memory)
{
if (XftDebug() & XFT_DBG_CACHE)
{
if (font->glyph_memory > font->max_glyph_memory)
printf ("Reduce memory for font 0x%lx from %ld to %ld\n",
font->glyphset ? font->glyphset : (unsigned long) font,
font->glyph_memory, font->max_glyph_memory);
}
while (font->glyph_memory > font->max_glyph_memory)
_XftFontUncacheGlyph (dpy, public);
}
_XftDisplayManageMemory (dpy);
}

View File

@ -1,112 +0,0 @@
/*
* $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.
*
* 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.
*/
#include <stdlib.h>
#include <stdio.h>
#include "xftint.h"
#include <X11/Xlibint.h>
Bool _XftConfigInitialized;
Bool
XftInit (char *config)
{
if (_XftConfigInitialized)
return True;
_XftConfigInitialized = True;
if (!FcInit ())
return False;
_XftNameInit ();
return True;
}
static struct {
char *name;
int alloc_count;
int alloc_mem;
int free_count;
int free_mem;
} XftInUse[XFT_MEM_NUM] = {
{ "XftDraw", 0, 0 },
{ "XftFont", 0 ,0 },
{ "XftFtFile", 0, 0 },
{ "XftGlyph", 0, 0 },
};
static int XftAllocCount, XftAllocMem;
static int XftFreeCount, XftFreeMem;
static int XftMemNotice = 1*1024*1024;
static int XftAllocNotify, XftFreeNotify;
void
XftMemReport (void)
{
int i;
printf ("Xft Memory Usage:\n");
printf ("\t Which Alloc Free\n");
printf ("\t count bytes count bytes\n");
for (i = 0; i < XFT_MEM_NUM; i++)
printf ("\t%8.8s%8d%8d%8d%8d\n",
XftInUse[i].name,
XftInUse[i].alloc_count, XftInUse[i].alloc_mem,
XftInUse[i].free_count, XftInUse[i].free_mem);
printf ("\t%8.8s%8d%8d%8d%8d\n",
"Total",
XftAllocCount, XftAllocMem,
XftFreeCount, XftFreeMem);
XftAllocNotify = 0;
XftFreeNotify = 0;
}
void
XftMemAlloc (int kind, int size)
{
if (XftDebug() & XFT_DBG_MEMORY)
{
XftInUse[kind].alloc_count++;
XftInUse[kind].alloc_mem += size;
XftAllocCount++;
XftAllocMem += size;
XftAllocNotify += size;
if (XftAllocNotify > XftMemNotice)
XftMemReport ();
}
}
void
XftMemFree (int kind, int size)
{
if (XftDebug() & XFT_DBG_MEMORY)
{
XftInUse[kind].free_count++;
XftInUse[kind].free_mem += size;
XftFreeCount++;
XftFreeMem += size;
XftFreeNotify += size;
if (XftFreeNotify > XftMemNotice)
XftMemReport ();
}
}

View File

@ -1,380 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftint.h,v 1.29 2002/02/15 07:36:11 keithp Exp $
*
* 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
* 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.
*/
/*
* These definitions are solely for use by the implementation of Xft
* and constitute no kind of standard. If you need any of these functions,
* please drop me a note. Either the library needs new functionality,
* or there's a way to do what you need using the existing published
* interfaces. keithp@xfree86.org
*/
#ifndef _XFTINT_H_
#define _XFTINT_H_
#include <X11/Xlib.h>
#include <X11/Xmd.h>
#define _XFT_NO_COMPAT_
#include "Xft.h"
#include <fontconfig/fcprivate.h>
typedef struct _XftMatcher {
char *object;
double (*compare) (char *object, FcValue value1, FcValue value2);
} XftMatcher;
typedef struct _XftSymbolic {
const char *name;
int value;
} XftSymbolic;
/*
* Glyphs are stored in this structure
*/
typedef struct _XftGlyph {
XGlyphInfo metrics;
void *bitmap;
unsigned long glyph_memory;
} XftGlyph;
/*
* A hash table translates Unicode values into glyph indicies
*/
typedef struct _XftUcsHash {
FcChar32 ucs4;
FT_UInt glyph;
} XftUcsHash;
/*
* Many fonts can share the same underlying face data; this
* structure references that. Note that many faces may in fact
* live in the same font file; that is irrelevant to this structure
* which is concerned only with the individual faces themselves
*/
typedef struct _XftFtFile {
struct _XftFtFile *next;
int ref; /* number of fonts using this file */
char *file; /* file name */
int id; /* font index within that file */
FT_F26Dot6 size; /* current size setting */
FT_Matrix matrix; /* current matrix setting */
int lock; /* lock count; can't unload unless 0 */
FT_Face face; /* pointer to face; only valid when lock */
} XftFtFile;
/*
* Internal version of the font with private data
*/
typedef struct _XftFontInt {
XftFont public; /* public fields */
XftFont *next; /* list of fonts for this display */
XftFtFile *file; /* Associated free type file */
int ref; /* reference count */
/*
* Per-glyph information, indexed by glyph ID
* This array follows the font in memory
*/
XftGlyph **glyphs;
int num_glyphs; /* size of glyphs/bitmaps arrays */
/*
* Hash table to get from Unicode value to glyph ID
* This array follows the glyphs in memory
*/
XftUcsHash *hash_table;
int hash_value;
int rehash_value;
/*
* X specific fields
*/
GlyphSet glyphset; /* Render glyphset */
XRenderPictFormat *format; /* Render format for glyphs */
/*
* Rendering options
*/
FT_F26Dot6 size;
FcBool antialias; /* doing antialiasing */
int rgba; /* subpixel order */
FcBool transform; /* non-identity matrix */
FT_Matrix matrix; /* glyph transformation matrix */
FT_Int load_flags; /* glyph load flags */
/*
* Internal fields
*/
FcBool minspace;
int char_width;
int spacing;
unsigned long glyph_memory;
unsigned long max_glyph_memory;
FcBool use_free_glyphs; /* Use XRenderFreeGlyphs */
} XftFontInt;
struct _XftDraw {
Display *dpy;
int screen;
unsigned int bits_per_pixel;
unsigned int depth;
Drawable drawable;
Visual *visual; /* NULL for bitmaps */
Colormap colormap;
Region clip;
struct {
Picture pict;
} render;
struct {
GC gc;
int use_pixmap;
} core;
};
/*
* Instead of taking two round trips for each blending request,
* assume that if a particular drawable fails GetImage that it will
* fail for a "while"; use temporary pixmaps to avoid the errors
*/
#define XFT_ASSUME_PIXMAP 20
typedef struct _XftSolidColor {
XRenderColor color;
int screen;
Picture pict;
} XftSolidColor;
#define XFT_NUM_SOLID_COLOR 16
typedef struct _XftDisplayInfo {
struct _XftDisplayInfo *next;
Display *display;
XExtCodes *codes;
FcPattern *defaults;
FcBool hasRender;
XftFont *fonts;
XRenderPictFormat *solidFormat;
XftSolidColor colors[XFT_NUM_SOLID_COLOR];
unsigned long glyph_memory;
unsigned long max_glyph_memory;
FcBool use_free_glyphs;
} XftDisplayInfo;
/*
* By default, use no more than 4 meg of server memory total, and no
* more than 1 meg for any one font
*/
#define XFT_DPY_MAX_GLYPH_MEMORY (4 * 1024 * 1024)
#define XFT_FONT_MAX_GLYPH_MEMORY (1024 * 1024)
extern XftDisplayInfo *_XftDisplayInfo;
#define XFT_DBG_OPEN 1
#define XFT_DBG_OPENV 2
#define XFT_DBG_RENDER 4
#define XFT_DBG_DRAW 8
#define XFT_DBG_REF 16
#define XFT_DBG_GLYPH 32
#define XFT_DBG_GLYPHV 64
#define XFT_DBG_CACHE 128
#define XFT_DBG_CACHEV 256
#define XFT_DBG_MEMORY 512
#define XFT_MEM_DRAW 0
#define XFT_MEM_FONT 1
#define XFT_MEM_FILE 2
#define XFT_MEM_GLYPH 3
#define XFT_MEM_NUM 4
/* xftcompat.c */
void XftFontSetDestroy (FcFontSet *s);
FcBool XftMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2);
void XftMatrixMultiply (FcMatrix *result, FcMatrix *a, FcMatrix *b);
void XftMatrixRotate (FcMatrix *m, double c, double s);
void XftMatrixScale (FcMatrix *m, double sx, double sy);
void XftMatrixShear (FcMatrix *m, double sh, double sv);
FcPattern *XftPatternCreate (void);
void XftValueDestroy (FcValue v);
void XftPatternDestroy (FcPattern *p);
FcBool XftPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append);
FcBool XftPatternDel (FcPattern *p, const char *object);
FcBool XftPatternAddInteger (FcPattern *p, const char *object, int i);
FcBool XftPatternAddDouble (FcPattern *p, const char *object, double i);
FcBool XftPatternAddMatrix (FcPattern *p, const char *object, FcMatrix *i);
FcBool XftPatternAddString (FcPattern *p, const char *object, char *i);
FcBool XftPatternAddBool (FcPattern *p, const char *object, FcBool i);
FcResult XftPatternGet (FcPattern *p, const char *object, int id, FcValue *v);
FcResult XftPatternGetInteger (FcPattern *p, const char *object, int id, int *i);
FcResult XftPatternGetDouble (FcPattern *p, const char *object, int id, double *i);
FcResult XftPatternGetString (FcPattern *p, const char *object, int id, char **i);
FcResult XftPatternGetMatrix (FcPattern *p, const char *object, int id, FcMatrix **i);
FcResult XftPatternGetBool (FcPattern *p, const char *object, int id, FcBool *i);
FcPattern *XftPatternDuplicate (FcPattern *orig);
FcPattern *XftPatternVaBuild (FcPattern *orig, va_list va);
FcPattern *XftPatternBuild (FcPattern *orig, ...);
FcBool XftNameUnparse (FcPattern *pat, char *dest, int len);
FcBool XftGlyphExists (Display *dpy, XftFont *font, FcChar32 ucs4);
FcObjectSet *XftObjectSetCreate (void);
Bool XftObjectSetAdd (FcObjectSet *os, const char *object);
void XftObjectSetDestroy (FcObjectSet *os);
FcObjectSet *XftObjectSetVaBuild (const char *first, va_list va);
FcObjectSet *XftObjectSetBuild (const char *first, ...);
FcFontSet *XftListFontSets (FcFontSet **sets, int nsets, FcPattern *p, FcObjectSet *os);
/* xftcore.c */
void
XftRectCore (XftDraw *draw,
XftColor *color,
int x,
int y,
unsigned int width,
unsigned int height);
void
XftGlyphCore (XftDraw *draw,
XftColor *color,
XftFont *public,
int x,
int y,
FT_UInt *glyphs,
int nglyphs);
void
XftGlyphSpecCore (XftDraw *draw,
XftColor *color,
XftFont *public,
XftGlyphSpec *glyphs,
int nglyphs);
void
XftGlyphFontSpecCore (XftDraw *draw,
XftColor *color,
XftGlyphFontSpec *glyphs,
int nglyphs);
/* xftdbg.c */
int
XftDebug (void);
/* xftdpy.c */
XftDisplayInfo *
_XftDisplayInfoGet (Display *dpy);
void
_XftDisplayManageMemory (Display *dpy);
int
XftDefaultParseBool (char *v);
FcBool
XftDefaultGetBool (Display *dpy, const char *object, int screen, FcBool def);
int
XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def);
double
XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def);
FcFontSet *
XftDisplayGetFontSet (Display *dpy);
/* xftdraw.c */
unsigned int
XftDrawDepth (XftDraw *draw);
unsigned int
XftDrawBitsPerPixel (XftDraw *draw);
FcBool
XftDrawRenderPrepare (XftDraw *draw);
/* xftextent.c */
/* xftfont.c */
/* xftfreetype.c */
FcBool
_XftSetFace (XftFtFile *f, FT_F26Dot6 size, FT_Matrix *matrix);
/* xftglyph.c */
void
_XftFontUncacheGlyph (Display *dpy, XftFont *public);
void
_XftFontManageMemory (Display *dpy, XftFont *public);
/* xftinit.c */
int
XftNativeByteOrder (void);
void
XftMemReport (void);
void
XftMemAlloc (int kind, int size);
void
XftMemFree (int kind, int size);
/* xftlist.c */
FcFontSet *
XftListFontsPatternObjects (Display *dpy,
int screen,
FcPattern *pattern,
FcObjectSet *os);
FcFontSet *
XftListFonts (Display *dpy,
int screen,
...);
/* xftname.c */
void
_XftNameInit (void);
/* xftrender.c */
/* xftstr.c */
int
_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def);
/* xftswap.c */
int
XftNativeByteOrder (void);
void
XftSwapCARD32 (CARD32 *data, int n);
void
XftSwapCARD24 (CARD8 *data, int width, int height);
void
XftSwapCARD16 (CARD16 *data, int n);
void
XftSwapImage (XImage *image);
/* xftxlfd.c */
#endif /* _XFT_INT_H_ */

View File

@ -1,61 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftlist.c,v 1.3 2002/02/15 07:36:11 keithp Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include "xftint.h"
FcFontSet *
XftListFontsPatternObjects (Display *dpy,
int screen,
FcPattern *pattern,
FcObjectSet *os)
{
return FcFontList (0, pattern, os);
}
FcFontSet *
XftListFonts (Display *dpy,
int screen,
...)
{
va_list va;
FcFontSet *fs;
FcObjectSet *os;
FcPattern *pattern;
const char *first;
va_start (va, screen);
FcPatternVapBuild (pattern, 0, va);
first = va_arg (va, const char *);
FcObjectSetVapBuild (os, first, va);
va_end (va);
fs = XftListFontsPatternObjects (dpy, screen, pattern, os);
FcPatternDestroy (pattern);
FcObjectSetDestroy (os);
return fs;
}

View File

@ -1,50 +0,0 @@
/*
* $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.
*
* 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.
*/
#include "xftint.h"
static const FcObjectType _XftObjectTypes[] = {
{ XFT_CORE, FcTypeBool, },
{ XFT_XLFD, FcTypeString, },
{ XFT_RENDER, FcTypeBool, },
};
#define NUM_OBJECT_TYPES (sizeof _XftObjectTypes / sizeof _XftObjectTypes[0])
Bool _XftNameInitialized;
void
_XftNameInit (void)
{
if (_XftNameInitialized)
return;
FcNameRegisterObjectTypes (_XftObjectTypes, NUM_OBJECT_TYPES);
}
FcPattern
*XftNameParse (const char *name)
{
_XftNameInit ();
return FcNameParse ((FcChar8 *) name);
}

View File

@ -1,293 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftpat.c,v 1.7 2002/02/15 07:36:11 keithp Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include <string.h>
#include "xftint.h"
FcPattern *
XftPatternCreate (void)
{
FcPattern *p;
p = (FcPattern *) malloc (sizeof (FcPattern));
if (!p)
return 0;
p->num = 0;
p->size = 0;
p->elts = 0;
return p;
}
void
XftValueDestroy (FcValue v)
{ FcValueDestroy (v); }
void
XftValueListDestroy (XftValueList *l)
{ FcValueListDestroy (l); }
void
XftPatternDestroy (FcPattern *p)
{ FcPatternDestroy (p); }
XftPatternElt *
XftPatternFind (FcPattern *p, const char *object, Bool insert)
{ return FcPatternFind (p, object, insert); }
Bool
XftPatternAdd (FcPattern *p, const char *object, FcValue value, Bool append)
{ return FcPatternAdd (p, object, value, append); }
Bool
XftPatternDel (FcPattern *p, const char *object)
{
XftPatternElt *e;
int i;
e = XftPatternFind (p, object, False);
if (!e)
return False;
i = e - p->elts;
/* destroy value */
XftValueListDestroy (e->values);
/* shuffle existing ones down */
memmove (e, e+1, (p->elts + p->num - (e + 1)) * sizeof (XftPatternElt));
p->num--;
p->elts[p->num].object = 0;
p->elts[p->num].values = 0;
return True;
}
Bool
XftPatternAddInteger (FcPattern *p, const char *object, int i)
{
FcValue v;
v.type = FcTypeInteger;
v.u.i = i;
return XftPatternAdd (p, object, v, True);
}
Bool
XftPatternAddDouble (FcPattern *p, const char *object, double d)
{
FcValue v;
v.type = FcTypeDouble;
v.u.d = d;
return XftPatternAdd (p, object, v, True);
}
Bool
XftPatternAddString (FcPattern *p, const char *object, const char *s)
{
FcValue v;
v.type = FcTypeString;
v.u.s = (char *) s;
return XftPatternAdd (p, object, v, True);
}
Bool
XftPatternAddMatrix (FcPattern *p, const char *object, const XftMatrix *s)
{
FcValue v;
v.type = FcTypeMatrix;
v.u.m = (XftMatrix *) s;
return XftPatternAdd (p, object, v, True);
}
Bool
XftPatternAddBool (FcPattern *p, const char *object, Bool b)
{
FcValue v;
v.type = FcTypeBool;
v.u.b = b;
return XftPatternAdd (p, object, v, True);
}
XftResult
XftPatternGet (FcPattern *p, const char *object, int id, FcValue *v)
{
XftPatternElt *e;
XftValueList *l;
e = XftPatternFind (p, object, False);
if (!e)
return XftResultNoMatch;
for (l = e->values; l; l = l->next)
{
if (!id)
{
*v = l->value;
return XftResultMatch;
}
id--;
}
return XftResultNoId;
}
XftResult
XftPatternGetInteger (FcPattern *p, const char *object, int id, int *i)
{
FcValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
switch (v.type) {
case FcTypeDouble:
*i = (int) v.u.d;
break;
case FcTypeInteger:
*i = v.u.i;
break;
default:
return XftResultTypeMismatch;
}
return XftResultMatch;
}
XftResult
XftPatternGetDouble (FcPattern *p, const char *object, int id, double *d)
{
FcValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
switch (v.type) {
case FcTypeDouble:
*d = v.u.d;
break;
case FcTypeInteger:
*d = (double) v.u.i;
break;
default:
return XftResultTypeMismatch;
}
return XftResultMatch;
}
XftResult
XftPatternGetString (FcPattern *p, const char *object, int id, char **s)
{
FcValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
if (v.type != FcTypeString)
return XftResultTypeMismatch;
*s = v.u.s;
return XftResultMatch;
}
XftResult
XftPatternGetMatrix (FcPattern *p, const char *object, int id, XftMatrix **m)
{
FcValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
if (v.type != FcTypeMatrix)
return XftResultTypeMismatch;
*m = v.u.m;
return XftResultMatch;
}
XftResult
XftPatternGetBool (FcPattern *p, const char *object, int id, Bool *b)
{
FcValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
if (v.type != FcTypeBool)
return XftResultTypeMismatch;
*b = v.u.b;
return XftResultMatch;
}
FcPattern *
XftPatternDuplicate (FcPattern *orig)
{
FcPattern *new;
int i;
XftValueList *l;
new = XftPatternCreate ();
if (!new)
goto bail0;
for (i = 0; i < orig->num; i++)
{
for (l = orig->elts[i].values; l; l = l->next)
if (!XftPatternAdd (new, orig->elts[i].object, l->value, True))
goto bail1;
}
return new;
bail1:
XftPatternDestroy (new);
bail0:
return 0;
}
FcPattern *
XftPatternVaBuild (FcPattern *orig, va_list va)
{
FcPattern *ret;
_XftPatternVapBuild (ret, orig, va);
return ret;
}
FcPattern *
XftPatternBuild (FcPattern *orig, ...)
{
va_list va;
va_start (va, orig);
_XftPatternVapBuild (orig, orig, va);
va_end (va);
return orig;
}

View File

@ -1,930 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftrender.c,v 1.10 2002/02/19 07:51:20 keithp Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include "xftint.h"
#define NUM_LOCAL 1024
#define NUM_ELT_LOCAL 128
/*
* Use the Render extension to draw the glyphs
*/
void
XftGlyphRender (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FT_UInt *glyphs,
int nglyphs)
{
XftFontInt *font = (XftFontInt *) public;
int i;
FT_UInt missing[XFT_NMISSING];
int nmissing;
FT_UInt g, max;
int size, width;
Glyph wire;
char *char8;
unsigned short *char16;
unsigned int *char32;
unsigned int char_local[NUM_LOCAL];
unsigned int *chars;
FcBool glyphs_loaded;
if (!font->format)
return;
/*
* Load missing glyphs
*/
nmissing = 0;
max = 0;
glyphs_loaded = FcFalse;
for (i = 0; i < nglyphs; i++)
{
g = glyphs[i];
if (g > max)
max = g;
if (XftFontCheckGlyph (dpy, public, FcTrue, g, missing, &nmissing))
glyphs_loaded = FcTrue;
}
if (nmissing)
XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
if (!font->glyphset)
goto bail1;
if (max < 0x100)
{
width = 1;
size = sizeof (char);
}
else if (max < 0x10000)
{
width = 2;
size = sizeof (unsigned short);
}
else
{
width = 4;
size = sizeof (unsigned int);
}
chars = char_local;
if (nglyphs * size > sizeof (char_local))
{
chars = malloc (nglyphs * size);
if (!chars)
goto bail1;
}
char8 = (char *) chars;
char16 = (unsigned short *) chars;
char32 = (unsigned int *) chars;
for (i = 0; i < nglyphs; i++)
{
wire = (Glyph) glyphs[i];
if (wire > font->num_glyphs || !font->glyphs[wire])
wire = 0;
switch (width) {
case 1: char8[i] = (char) wire; break;
case 2: char16[i] = (unsigned short) wire; break;
case 4: char32[i] = (unsigned long) wire; break;
}
}
switch (width) {
case 1:
default:
XRenderCompositeString8 (dpy, op,
src, dst, font->format, font->glyphset,
srcx, srcy, x, y, char8, nglyphs);
break;
case 2:
XRenderCompositeString16(dpy, op,
src, dst, font->format, font->glyphset,
srcx, srcy, x, y, char16, nglyphs);
break;
case 4:
XRenderCompositeString32(dpy, op,
src, dst, font->format, font->glyphset,
srcx, srcy, x, y, char32, nglyphs);
break;
}
if (chars != char_local)
free (chars);
bail1:
if (glyphs_loaded)
_XftFontManageMemory (dpy, public);
}
void
XftGlyphSpecRender (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
XftGlyphSpec *glyphs,
int nglyphs)
{
XftFontInt *font = (XftFontInt *) public;
int i, j;
FT_UInt missing[XFT_NMISSING];
int nmissing;
int n;
FT_UInt g;
XftGlyph *glyph;
FT_UInt max;
int size, width;
char *char8;
unsigned short *char16;
unsigned int *char32;
unsigned int char_local[NUM_LOCAL];
unsigned int *chars;
XGlyphElt8 *elts;
XGlyphElt8 elts_local[NUM_ELT_LOCAL];
FcBool glyphs_loaded;
int nelt;
int x, y;
if (!font->format)
return;
if (!nglyphs)
return;
/*
* Load missing glyphs
*/
max = 0;
nmissing = 0;
glyphs_loaded = FcFalse;
g = glyphs[0].glyph;
for (i = 0; i < nglyphs; i++)
{
g = glyphs[i].glyph;
if (g > max)
max = g;
if (XftFontCheckGlyph (dpy, public, FcTrue, g, missing, &nmissing))
glyphs_loaded = FcTrue;
}
if (nmissing)
XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
if (!font->glyphset)
goto bail1;
/*
* See what encoding size is needed
*/
if (max < 0x100)
{
size = sizeof (char);
width = 1;
}
else if (max < 0x10000)
{
size = sizeof (unsigned short);
width = 2;
}
else
{
size = sizeof (unsigned int);
width = 4;
}
chars = char_local;
if (nglyphs * size > NUM_LOCAL)
{
chars = malloc (nglyphs * size);
if (!chars)
goto bail1;
}
char8 = (char *) chars;
char16 = (unsigned short *) chars;
char32 = (unsigned int *) chars;
/*
* Compute the number of glyph elts needed
*/
nelt = 1;
for (i = 0; i < nglyphs; i++)
{
g = glyphs[i].glyph;
/* Substitute default for non-existant glyphs */
if (g > font->num_glyphs || !font->glyphs[g])
g = 0;
if (font->glyphs[g])
break;
}
if (i == nglyphs)
goto bail2;
glyph = font->glyphs[g];
x = glyphs[i].x + glyph->metrics.xOff;
y = glyphs[i].y + glyph->metrics.yOff;
while (++i < nglyphs)
{
g = glyphs[i].glyph;
/* Substitute default for non-existant glyphs */
if (g > font->num_glyphs || !font->glyphs[g])
g = 0;
/*
* check to see if the glyph is placed where it would
* fall using the normal spacing
*/
if ((glyph = font->glyphs[g]))
{
if (x != glyphs[i].x || y != glyphs[i].y)
{
x = glyphs[i].x;
y = glyphs[i].y;
++nelt;
}
x += glyph->metrics.xOff;
y += glyph->metrics.yOff;
}
}
elts = elts_local;
if (nelt > NUM_ELT_LOCAL)
{
elts = malloc (nelt * sizeof (XGlyphElt8));
if (!elts)
goto bail2;
}
/*
* Generate the list of glyph elts
*/
nelt = 0;
x = y = 0;
n = 0;
j = 0;
for (i = 0; i < nglyphs; i++)
{
g = glyphs[i].glyph;
/* Substitute default for non-existant glyphs */
if (g > font->num_glyphs || !font->glyphs[g])
g = 0;
if ((glyph = font->glyphs[g]))
{
if (!i || x != glyphs[i].x || y != glyphs[i].y)
{
if (n)
{
elts[nelt].nchars = n;
nelt++;
}
elts[nelt].glyphset = font->glyphset;
elts[nelt].chars = char8 + size * j;
elts[nelt].xOff = glyphs[i].x - x;
elts[nelt].yOff = glyphs[i].y - y;
x = glyphs[i].x;
y = glyphs[i].y;
n = 0;
}
switch (width) {
case 1: char8[j] = (char) g; break;
case 2: char16[j] = (unsigned short) g; break;
case 4: char32[j] = (unsigned int) g; break;
}
x += glyph->metrics.xOff;
y += glyph->metrics.yOff;
j++;
n++;
}
}
if (n)
{
elts[nelt].nchars = n;
nelt++;
}
switch (width) {
case 1:
XRenderCompositeText8 (dpy, op, src, dst, font->format,
srcx, srcy, glyphs[0].x, glyphs[0].y,
elts, nelt);
break;
case 2:
XRenderCompositeText16 (dpy, op, src, dst, font->format,
srcx, srcy, glyphs[0].x, glyphs[0].y,
(XGlyphElt16 *) elts, nelt);
break;
case 4:
XRenderCompositeText32 (dpy, op, src, dst, font->format,
srcx, srcy, glyphs[0].x, glyphs[0].y,
(XGlyphElt32 *) elts, nelt);
break;
}
if (elts != elts_local)
free (elts);
bail2:
if (chars != char_local)
free (chars);
bail1:
if (glyphs_loaded)
_XftFontManageMemory (dpy, public);
}
void
XftCharSpecRender (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
XftCharSpec *chars,
int len)
{
XftGlyphSpec *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (XftGlyphSpec));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
{
glyphs[i].glyph = XftCharIndex(dpy, public, chars[i].ucs4);
glyphs[i].x = chars[i].x;
glyphs[i].y = chars[i].y;
}
XftGlyphSpecRender (dpy, op, src, public, dst, srcx, srcy, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftGlyphFontSpecRender (Display *dpy,
int op,
Picture src,
Picture dst,
int srcx,
int srcy,
XftGlyphFontSpec *glyphs,
int nglyphs)
{
int i, j;
XftFont *prevPublic;
XftFontInt *firstFont;
FT_UInt missing[XFT_NMISSING];
int nmissing;
int n;
FT_UInt g;
XftGlyph *glyph;
FT_UInt max;
int size, width;
char *char8;
unsigned short *char16;
unsigned int *char32;
unsigned int char_local[NUM_LOCAL];
unsigned int *chars;
XGlyphElt8 *elts;
XGlyphElt8 elts_local[NUM_ELT_LOCAL];
FcBool glyphs_loaded;
int nelt;
int x, y;
if (!nglyphs)
return;
/*
* Load missing glyphs
*/
max = 0;
nmissing = 0;
glyphs_loaded = FcFalse;
g = glyphs[0].glyph;
for (i = 0; i < nglyphs; i++)
{
XftFont *public = glyphs[i].font;
XftFontInt *font = (XftFontInt *) public;
g = glyphs[i].glyph;
if (g > max)
max = g;
if (XftFontCheckGlyph (dpy, public, FcTrue, g, missing, &nmissing))
glyphs_loaded = FcTrue;
if (nmissing)
XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
if (!font->format)
goto bail1;
if (!font->glyphset)
goto bail1;
}
/*
* See what encoding size is needed
*/
if (max < 0x100)
{
size = sizeof (char);
width = 1;
}
else if (max < 0x10000)
{
size = sizeof (unsigned short);
width = 2;
}
else
{
size = sizeof (unsigned int);
width = 4;
}
chars = char_local;
if (nglyphs * size > NUM_LOCAL)
{
chars = malloc (nglyphs * size);
if (!chars)
goto bail1;
}
char8 = (char *) chars;
char16 = (unsigned short *) chars;
char32 = (unsigned int *) chars;
/*
* Compute the number of glyph elts needed
*/
nelt = 1;
firstFont = 0;
for (i = 0; i < nglyphs; i++)
{
XftFont *public = glyphs[i].font;
XftFontInt *font = (XftFontInt *) public;
g = glyphs[i].glyph;
/* Substitute default for non-existant glyphs */
if (g > font->num_glyphs || !font->glyphs[g])
g = 0;
if (font->glyphs[g])
{
firstFont = font;
break;
}
}
if (i == nglyphs)
goto bail2;
glyph = firstFont->glyphs[g];
x = glyphs[i].x + glyph->metrics.xOff;
y = glyphs[i].y + glyph->metrics.yOff;
prevPublic = 0;
while (++i < nglyphs)
{
XftFont *public = glyphs[i].font;
XftFontInt *font = (XftFontInt *) public;
g = glyphs[i].glyph;
/* Substitute default for non-existant glyphs */
if (g > font->num_glyphs || !font->glyphs[g])
g = 0;
/*
* check to see if the glyph is placed where it would
* fall using the normal spacing
*/
if ((glyph = font->glyphs[g]))
{
if (public != prevPublic || x != glyphs[i].x || y != glyphs[i].y)
{
prevPublic = public;
x = glyphs[i].x;
y = glyphs[i].y;
++nelt;
}
x += glyph->metrics.xOff;
y += glyph->metrics.yOff;
}
}
elts = elts_local;
if (nelt > NUM_ELT_LOCAL)
{
elts = malloc (nelt * sizeof (XGlyphElt8));
if (!elts)
goto bail2;
}
/*
* Generate the list of glyph elts
*/
nelt = 0;
x = y = 0;
n = 0;
j = 0;
prevPublic = 0;
for (i = 0; i < nglyphs; i++)
{
XftFont *public = glyphs[i].font;
XftFontInt *font = (XftFontInt *) public;
g = glyphs[i].glyph;
/* Substitute default for non-existant glyphs */
if (g > font->num_glyphs || !font->glyphs[g])
g = 0;
if ((glyph = font->glyphs[g]))
{
if (!i || public != prevPublic || x != glyphs[i].x || y != glyphs[i].y)
{
if (n)
{
elts[nelt].nchars = n;
nelt++;
}
elts[nelt].glyphset = font->glyphset;
elts[nelt].chars = char8 + size * j;
elts[nelt].xOff = glyphs[i].x - x;
elts[nelt].yOff = glyphs[i].y - y;
prevPublic = public;
x = glyphs[i].x;
y = glyphs[i].y;
n = 0;
}
switch (width) {
case 1: char8[j] = (char) g; break;
case 2: char16[j] = (unsigned short) g; break;
case 4: char32[j] = (unsigned int) g; break;
}
x += glyph->metrics.xOff;
y += glyph->metrics.yOff;
j++;
n++;
}
}
if (n)
{
elts[nelt].nchars = n;
nelt++;
}
switch (width) {
case 1:
XRenderCompositeText8 (dpy, op, src, dst, firstFont->format,
srcx, srcy, glyphs[0].x, glyphs[0].y,
elts, nelt);
break;
case 2:
XRenderCompositeText16 (dpy, op, src, dst, firstFont->format,
srcx, srcy, glyphs[0].x, glyphs[0].y,
(XGlyphElt16 *) elts, nelt);
break;
case 4:
XRenderCompositeText32 (dpy, op, src, dst, firstFont->format,
srcx, srcy, glyphs[0].x, glyphs[0].y,
(XGlyphElt32 *) elts, nelt);
break;
}
if (elts != elts_local)
free (elts);
bail2:
if (chars != char_local)
free (chars);
bail1:
if (glyphs_loaded)
for (i = 0; i < nglyphs; i++)
_XftFontManageMemory (dpy, glyphs[i].font);
}
void
XftCharFontSpecRender (Display *dpy,
int op,
Picture src,
Picture dst,
int srcx,
int srcy,
XftCharFontSpec *chars,
int len)
{
XftGlyphFontSpec *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (XftGlyphFontSpec));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
{
glyphs[i].font = chars[i].font;
glyphs[i].glyph = XftCharIndex(dpy, glyphs[i].font, chars[i].ucs4);
glyphs[i].x = chars[i].x;
glyphs[i].y = chars[i].y;
}
XftGlyphFontSpecRender (dpy, op, src, dst, srcx, srcy, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender8 (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public, string[i]);
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender16 (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar16 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public, string[i]);
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender16BE (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public,
(string[i*2]<<8) | string[i*2+1]);
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender16LE (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public,
string[i*2] | (string[i*2+1]<<8));
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender32 (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar32 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public, string[i]);
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender32BE (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public,
(string[i*4] << 24) |
(string[i*4+1] << 16) |
(string[i*4+2] << 8) |
(string[i*4+3]));
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender32LE (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public,
(string[i*4]) |
(string[i*4+1] << 8) |
(string[i*4+2] << 16) |
(string[i*4+3] << 24));
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRenderUtf8 (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
FcChar32 ucs4;
int i;
int l;
int size;
i = 0;
glyphs = glyphs_local;
size = NUM_LOCAL;
while (len && (l = FcUtf8ToUcs4 (string, &ucs4, len)) > 0)
{
if (i == size)
{
glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
if (!glyphs_new)
{
if (glyphs != glyphs_local)
free (glyphs);
return;
}
memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
size *= 2;
if (glyphs != glyphs_local)
free (glyphs);
glyphs = glyphs_new;
}
glyphs[i++] = XftCharIndex (dpy, public, ucs4);
string += l;
len -= l;
}
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}

View File

@ -1,40 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftstr.c,v 1.7 2002/02/15 07:36:11 keithp Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "xftint.h"
int
_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def)
{
while (n--)
{
if (!FcStrCmpIgnoreCase ((FcChar8 *) s->name, (FcChar8 *) name))
return s->value;
s++;
}
return def;
}

View File

@ -1,122 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftswap.c,v 1.1 2002/02/15 07:37:35 keithp Exp $
*
* 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
* 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.
*/
#include <X11/Xlib.h>
#include "xftint.h"
int
XftNativeByteOrder (void)
{
int whichbyte = 1;
if (*((char *) &whichbyte))
return LSBFirst;
return MSBFirst;
}
/* byte swap a 32-bit value */
#define swapl(x, n) { \
n = ((char *) (x))[0];\
((char *) (x))[0] = ((char *) (x))[3];\
((char *) (x))[3] = n;\
n = ((char *) (x))[1];\
((char *) (x))[1] = ((char *) (x))[2];\
((char *) (x))[2] = n; }
/* byte swap a short */
#define swaps(x, n) { \
n = ((char *) (x))[0];\
((char *) (x))[0] = ((char *) (x))[1];\
((char *) (x))[1] = n; }
/* byte swap a three-byte unit */
#define swapt(x, n) { \
n = ((char *) (x))[0];\
((char *) (x))[0] = ((char *) (x))[2];\
((char *) (x))[2] = n; }
void
XftSwapCARD32 (CARD32 *data, int u)
{
char n;
while (u--)
{
swapl (data, n);
data++;
}
}
void
XftSwapCARD24 (CARD8 *data, int width, int height)
{
int units, u;
char n;
CARD8 *d;
units = width / 3;
while (height--)
{
d = data;
data += width;
u = units;
while (u--)
{
swapt (d, n);
d += 3;
}
}
}
void
XftSwapCARD16 (CARD16 *data, int u)
{
char n;
while (u--)
{
swaps (data, n);
data++;
}
}
void
XftSwapImage (XImage *image)
{
switch (image->bits_per_pixel) {
case 32:
XftSwapCARD32 ((CARD32 *) image->data,
image->height * image->bytes_per_line >> 2);
break;
case 24:
XftSwapCARD24 ((CARD8 *) image->data,
image->bytes_per_line,
image->height);
break;
case 16:
XftSwapCARD16 ((CARD16 *) image->data,
image->height * image->bytes_per_line >> 1);
break;
default:
break;
}
}

View File

@ -1,187 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftxlfd.c,v 1.8 2002/02/15 07:36:11 keithp Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "xftint.h"
static XftSymbolic XftXlfdWeights[] = {
{ "light", FC_WEIGHT_LIGHT },
{ "medium", FC_WEIGHT_MEDIUM },
{ "regular", FC_WEIGHT_MEDIUM },
{ "demibold", FC_WEIGHT_DEMIBOLD },
{ "bold", FC_WEIGHT_BOLD },
{ "black", FC_WEIGHT_BLACK },
};
#define NUM_XLFD_WEIGHTS (sizeof XftXlfdWeights/sizeof XftXlfdWeights[0])
static XftSymbolic XftXlfdSlants[] = {
{ "r", FC_SLANT_ROMAN },
{ "i", FC_SLANT_ITALIC },
{ "o", FC_SLANT_OBLIQUE },
};
#define NUM_XLFD_SLANTS (sizeof XftXlfdSlants/sizeof XftXlfdSlants[0])
/*
* Cut out one XLFD field, placing it in 'save' and return
* the start of 'save'
*/
static char *
XftSplitStr (const char *field, char *save)
{
char *s = save;
char c;
while (*field)
{
if (*field == '-')
break;
c = *field++;
*save++ = c;
}
*save = 0;
return s;
}
/*
* convert one XLFD numeric field. Return -1 if the field is '*'
*/
static const char *
XftGetInt(const char *ptr, int *val)
{
if (*ptr == '*') {
*val = -1;
ptr++;
} else
for (*val = 0; *ptr >= '0' && *ptr <= '9';)
*val = *val * 10 + *ptr++ - '0';
if (*ptr == '-')
return ptr;
return (char *) 0;
}
FcPattern *
XftXlfdParse (const char *xlfd_orig, FcBool ignore_scalable, FcBool complete)
{
FcPattern *pat;
const char *xlfd = xlfd_orig;
const char *foundry;
const char *family;
const char *weight_name;
const char *slant;
const char *registry;
const char *encoding;
char *save;
int pixel;
int point;
int resx;
int resy;
int slant_value, weight_value;
double dpixel;
if (*xlfd != '-')
return 0;
if (!(xlfd = strchr (foundry = ++xlfd, '-'))) return 0;
if (!(xlfd = strchr (family = ++xlfd, '-'))) return 0;
if (!(xlfd = strchr (weight_name = ++xlfd, '-'))) return 0;
if (!(xlfd = strchr (slant = ++xlfd, '-'))) return 0;
if (!(xlfd = strchr (/* setwidth_name = */ ++xlfd, '-'))) return 0;
if (!(xlfd = strchr (/* add_style_name = */ ++xlfd, '-'))) return 0;
if (!(xlfd = XftGetInt (++xlfd, &pixel))) return 0;
if (!(xlfd = XftGetInt (++xlfd, &point))) return 0;
if (!(xlfd = XftGetInt (++xlfd, &resx))) return 0;
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;
/* make sure no fields follow this one */
if ((xlfd = strchr (encoding = ++xlfd, '-'))) return 0;
if (!pixel)
return 0;
pat = FcPatternCreate ();
if (!pat)
return 0;
save = (char *) malloc (strlen (foundry) + 1);
if (!save)
return 0;
if (!FcPatternAddString (pat, XFT_XLFD, (FcChar8 *) xlfd_orig)) goto bail;
XftSplitStr (foundry, save);
if (save[0] && strcmp (save, "*") != 0)
if (!FcPatternAddString (pat, FC_FOUNDRY, (FcChar8 *) save)) goto bail;
XftSplitStr (family, save);
if (save[0] && strcmp (save, "*") != 0)
if (!FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) save)) goto bail;
weight_value = _XftMatchSymbolic (XftXlfdWeights, NUM_XLFD_WEIGHTS,
XftSplitStr (weight_name, save),
FC_WEIGHT_MEDIUM);
if (!FcPatternAddInteger (pat, FC_WEIGHT, weight_value))
goto bail;
slant_value = _XftMatchSymbolic (XftXlfdSlants, NUM_XLFD_SLANTS,
XftSplitStr (slant, save),
FC_SLANT_ROMAN);
if (!FcPatternAddInteger (pat, FC_SLANT, slant_value))
goto bail;
dpixel = (double) pixel;
if (point > 0)
{
if (!FcPatternAddDouble (pat, FC_SIZE, ((double) point) / 10.0)) goto bail;
if (pixel <= 0 && resy > 0)
{
dpixel = (double) point * (double) resy / 720.0;
}
}
if (dpixel > 0)
if (!FcPatternAddDouble (pat, FC_PIXEL_SIZE, dpixel)) goto bail;
strcpy ((char *) registry, save);
if (registry[0] && !strchr (registry, '*'))
{
;
/* XXX map registry to charset */
}
free (save);
return pat;
bail:
free (save);
FcPatternDestroy (pat);
return 0;
}

View File

@ -1,65 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/Composite.c,v 1.2 2000/08/28 02:43:13 tsi Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
#include "Xrenderint.h"
void
XRenderComposite (Display *dpy,
int op,
Picture src,
Picture mask,
Picture dst,
int src_x,
int src_y,
int mask_x,
int mask_y,
int dst_x,
int dst_y,
unsigned int width,
unsigned int height)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeReq *req;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderComposite, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderComposite;
req->op = (CARD8) op;
req->src = src;
req->mask = mask;
req->dst = dst;
req->xSrc = src_x;
req->ySrc = src_y;
req->xMask = mask_x;
req->yMask = mask_y;
req->xDst = dst_x;
req->yDst = dst_y;
req->width = width;
req->height = height;
UnlockDisplay(dpy);
SyncHandle();
}

View File

@ -1,104 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/FillRect.c,v 1.2 2001/12/16 18:27:55 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
#include "Xrenderint.h"
/* precompute the maximum size of batching request allowed */
#define size (SIZEOF(xRenderFillRectanglesReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
void
XRenderFillRectangle (Display *dpy,
int op,
Picture dst,
_Xconst XRenderColor *color,
int x,
int y,
unsigned int width,
unsigned int height)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRectangle *rect;
xRenderFillRectanglesReq *req;
#ifdef MUSTCOPY
xRectangle rectdata;
long len = SIZEOF(xRectangle);
rect = &rectdata;
#endif /* MUSTCOPY */
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
req = (xRenderFillRectanglesReq *) dpy->last_req;
/* if same as previous request, with same drawable, batch requests */
if (req->reqType == info->codes->major_opcode &&
req->renderReqType == X_RenderFillRectangles &&
req->op == op &&
req->dst == dst &&
req->color.red == color->red &&
req->color.green == color->green &&
req->color.blue == color->blue &&
req->color.alpha == color->alpha &&
dpy->bufptr + SIZEOF(xRectangle) <= dpy->bufmax &&
(char *)dpy->bufptr - (char *)req < size)
{
req->length += SIZEOF(xRectangle) >> 2;
#ifndef MUSTCOPY
rect = (xRectangle *) dpy->bufptr;
dpy->bufptr += SIZEOF(xRectangle);
#endif /* not MUSTCOPY */
}
else
{
GetReqExtra(RenderFillRectangles, SIZEOF(xRectangle), req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderFillRectangles;
req->op = op;
req->dst = dst;
req->color.red = color->red;
req->color.green = color->green;
req->color.blue = color->blue;
req->color.alpha = color->alpha;
#ifdef MUSTCOPY
dpy->bufptr -= SIZEOF(xRectangle);
#else
rect = (xRectangle *) NEXTPTR(req,xRenderFillRectanglesReq);
#endif /* MUSTCOPY */
}
rect->x = x;
rect->y = y;
rect->width = width;
rect->height = height;
#ifdef MUSTCOPY
Data (dpy, (char *) rect, len);
#endif /* MUSTCOPY */
UnlockDisplay(dpy);
SyncHandle();
}

View File

@ -1,77 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/FillRects.c,v 1.2 2001/12/16 18:27:55 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
#include "Xrenderint.h"
/* precompute the maximum size of batching request allowed */
#define size (SIZEOF(xRenderFillRectanglesReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
void
XRenderFillRectangles (Display *dpy,
int op,
Picture dst,
_Xconst XRenderColor *color,
_Xconst XRectangle *rectangles,
int n_rects)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFillRectanglesReq *req;
long len;
int n;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
while (n_rects)
{
GetReq(RenderFillRectangles, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderFillRectangles;
req->op = op;
req->dst = dst;
req->color.red = color->red;
req->color.green = color->green;
req->color.blue = color->blue;
req->color.alpha = color->alpha;
n = n_rects;
len = ((long)n) << 1;
if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length))
{
n = (dpy->max_request_size - req->length) >> 1;
len = ((long)n) << 1;
}
SetReqLen(req, len, len);
len <<= 2; /* watch out for macros... */
Data16 (dpy, (short *) rectangles, len);
n_rects -= n;
rectangles += n;
}
UnlockDisplay(dpy);
SyncHandle();
}

View File

@ -1,678 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/Glyph.c,v 1.8 2002/02/12 07:17:37 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
#include "Xrenderint.h"
GlyphSet
XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
GlyphSet gsid;
xRenderCreateGlyphSetReq *req;
RenderCheckExtension (dpy, info, 0);
LockDisplay(dpy);
GetReq(RenderCreateGlyphSet, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCreateGlyphSet;
req->gsid = gsid = XAllocID(dpy);
req->format = format->id;
UnlockDisplay(dpy);
SyncHandle();
return gsid;
}
GlyphSet
XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
GlyphSet gsid;
xRenderReferenceGlyphSetReq *req;
RenderCheckExtension (dpy, info, 0);
LockDisplay(dpy);
GetReq(RenderReferenceGlyphSet, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderReferenceGlyphSet;
req->gsid = gsid = XAllocID(dpy);
req->existing = existing;
UnlockDisplay(dpy);
SyncHandle();
return gsid;
}
void
XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFreeGlyphSetReq *req;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderFreeGlyphSet, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderFreeGlyphSet;
req->glyphset = glyphset;
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderAddGlyphs (Display *dpy,
GlyphSet glyphset,
_Xconst Glyph *gids,
_Xconst XGlyphInfo *glyphs,
int nglyphs,
_Xconst char *images,
int nbyte_images)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderAddGlyphsReq *req;
long len;
if (nbyte_images & 3)
nbyte_images += 4 - (nbyte_images & 3);
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderAddGlyphs, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderAddGlyphs;
req->glyphset = glyphset;
req->nglyphs = nglyphs;
len = (nglyphs * (SIZEOF (xGlyphInfo) + 4) + nbyte_images) >> 2;
SetReqLen(req, len, len);
Data32 (dpy, (long *) gids, nglyphs * 4);
Data16 (dpy, (short *) glyphs, nglyphs * SIZEOF (xGlyphInfo));
Data (dpy, images, nbyte_images);
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderFreeGlyphs (Display *dpy,
GlyphSet glyphset,
_Xconst Glyph *gids,
int nglyphs)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFreeGlyphsReq *req;
long len;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderFreeGlyphs, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderFreeGlyphs;
req->glyphset = glyphset;
len = nglyphs;
SetReqLen(req, len, len);
len <<= 2;
Data32 (dpy, (long *) gids, len);
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderCompositeString8 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
GlyphSet glyphset,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst char *string,
int nchar)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs8Req *req;
long len;
xGlyphElt *elt;
int nbytes;
if (!nchar)
return;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderCompositeGlyphs8, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCompositeGlyphs8;
req->op = op;
req->src = src;
req->dst = dst;
req->maskFormat = maskFormat ? maskFormat->id : None;
req->glyphset = glyphset;
req->xSrc = xSrc;
req->ySrc = ySrc;
/*
* xGlyphElt must be aligned on a 32-bit boundary; this is
* easily done by filling no more than 252 glyphs in each
* bucket
*/
#define MAX_8 252
len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar;
req->length += (len + 3)>>2; /* convert to number of 32-bit words */
/*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first.
*/
if (dpy->bufptr + len > dpy->bufmax)
_XFlush (dpy);
while(nchar > MAX_8)
{
nbytes = MAX_8 + SIZEOF(xGlyphElt);
BufAlloc (xGlyphElt *, elt, nbytes);
elt->len = MAX_8;
elt->deltax = xDst;
elt->deltay = yDst;
xDst = 0;
yDst = 0;
memcpy ((char *) (elt + 1), string, MAX_8);
nchar = nchar - MAX_8;
string += MAX_8;
}
if (nchar)
{
nbytes = (nchar + SIZEOF(xGlyphElt) + 3) & ~3;
BufAlloc (xGlyphElt *, elt, nbytes);
elt->len = nchar;
elt->deltax = xDst;
elt->deltay = yDst;
memcpy ((char *) (elt + 1), string, nchar);
}
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderCompositeString16 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
GlyphSet glyphset,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst unsigned short *string,
int nchar)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs8Req *req;
long len;
xGlyphElt *elt;
int nbytes;
if (!nchar)
return;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderCompositeGlyphs16, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCompositeGlyphs16;
req->op = op;
req->src = src;
req->dst = dst;
req->maskFormat = maskFormat ? maskFormat->id : None;
req->glyphset = glyphset;
req->xSrc = xSrc;
req->ySrc = ySrc;
#define MAX_16 254
len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar * 2;
req->length += (len + 3)>>2; /* convert to number of 32-bit words */
/*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first.
*/
if (dpy->bufptr + len > dpy->bufmax)
_XFlush (dpy);
while(nchar > MAX_16)
{
nbytes = MAX_16 * 2 + SIZEOF(xGlyphElt);
BufAlloc (xGlyphElt *, elt, nbytes);
elt->len = MAX_16;
elt->deltax = xDst;
elt->deltay = yDst;
xDst = 0;
yDst = 0;
memcpy ((char *) (elt + 1), (char *) string, MAX_16 * 2);
nchar = nchar - MAX_16;
string += MAX_16;
}
if (nchar)
{
nbytes = (nchar * 2 + SIZEOF(xGlyphElt) + 3) & ~3;
BufAlloc (xGlyphElt *, elt, nbytes);
elt->len = nchar;
elt->deltax = xDst;
elt->deltay = yDst;
memcpy ((char *) (elt + 1), (char *) string, nchar * 2);
}
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderCompositeString32 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
GlyphSet glyphset,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst unsigned int *string,
int nchar)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs8Req *req;
long len;
xGlyphElt *elt;
int nbytes;
if (!nchar)
return;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderCompositeGlyphs32, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCompositeGlyphs32;
req->op = op;
req->src = src;
req->dst = dst;
req->maskFormat = maskFormat ? maskFormat->id : None;
req->glyphset = glyphset;
req->xSrc = xSrc;
req->ySrc = ySrc;
#define MAX_32 254
len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar * 4;
req->length += (len + 3)>>2; /* convert to number of 32-bit words */
/*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first.
*/
if (dpy->bufptr + len > dpy->bufmax)
_XFlush (dpy);
while(nchar > MAX_32)
{
nbytes = MAX_32 * 4 + SIZEOF(xGlyphElt);
BufAlloc (xGlyphElt *, elt, nbytes);
elt->len = MAX_32;
elt->deltax = xDst;
elt->deltay = yDst;
xDst = 0;
yDst = 0;
memcpy ((char *) (elt + 1), (char *) string, MAX_32 * 4);
nchar = nchar - MAX_32;
string += MAX_32;
}
if (nchar)
{
nbytes = nchar * 4 + SIZEOF(xGlyphElt);
BufAlloc (xGlyphElt *, elt, nbytes);
elt->len = nchar;
elt->deltax = xDst;
elt->deltay = yDst;
memcpy ((char *) (elt + 1), (char *) string, nchar * 4);
}
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderCompositeText8 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst XGlyphElt8 *elts,
int nelt)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs8Req *req;
long len;
long elen;
xGlyphElt *elt;
int i;
_Xconst char *chars;
int nchars;
if (!nelt)
return;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderCompositeGlyphs8, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCompositeGlyphs8;
req->op = op;
req->src = src;
req->dst = dst;
req->maskFormat = maskFormat ? maskFormat->id : None;
req->glyphset = elts[0].glyphset;
req->xSrc = xSrc;
req->ySrc = ySrc;
/*
* Compute the space necessary
*/
len = 0;
for (i = 0; i < nelt; i++)
{
if (elts[i].glyphset != req->glyphset)
len += (SIZEOF (xGlyphElt) + 4) >> 2;
nchars = elts[i].nchars;
/*
* xGlyphElt must be aligned on a 32-bit boundary; this is
* easily done by filling no more than 252 glyphs in each
* bucket
*/
elen = SIZEOF(xGlyphElt) * ((nchars + MAX_8-1) / MAX_8) + nchars;
len += (elen + 3) >> 2;
}
req->length += len;
/*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first.
*/
if (dpy->bufptr + (len << 2) > dpy->bufmax)
_XFlush (dpy);
for (i = 0; i < nelt; i++)
{
/*
* Switch glyphsets
*/
if (elts[i].glyphset != req->glyphset)
{
BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
elt->len = 0xff;
elt->deltax = 0;
elt->deltay = 0;
Data32(dpy, &elts[i].glyphset, 4);
}
nchars = elts[i].nchars;
xDst = elts[i].xOff;
yDst = elts[i].yOff;
chars = elts[i].chars;
while (nchars)
{
BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
elt->len = nchars > MAX_8 ? MAX_8 : nchars;
elt->deltax = xDst;
elt->deltay = yDst;
xDst = 0;
yDst = 0;
Data (dpy, chars, elt->len);
nchars -= elt->len;
chars += elt->len;
}
}
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderCompositeText16 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst XGlyphElt16 *elts,
int nelt)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs16Req *req;
long len;
long elen;
xGlyphElt *elt;
int i;
_Xconst unsigned short *chars;
int nchars;
if (!nelt)
return;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderCompositeGlyphs16, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCompositeGlyphs16;
req->op = op;
req->src = src;
req->dst = dst;
req->maskFormat = maskFormat ? maskFormat->id : None;
req->glyphset = elts[0].glyphset;
req->xSrc = xSrc;
req->ySrc = ySrc;
/*
* Compute the space necessary
*/
len = 0;
for (i = 0; i < nelt; i++)
{
if (elts[i].glyphset != req->glyphset)
len += (SIZEOF (xGlyphElt) + 4) >> 2;
nchars = elts[i].nchars;
/*
* xGlyphElt must be aligned on a 32-bit boundary; this is
* easily done by filling no more than 254 glyphs in each
* bucket
*/
elen = SIZEOF(xGlyphElt) * ((nchars + MAX_16-1) / MAX_16) + nchars * 2;
len += (elen + 3) >> 2;
}
req->length += len;
/*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first.
*/
if (dpy->bufptr + (len << 2) > dpy->bufmax)
_XFlush (dpy);
for (i = 0; i < nelt; i++)
{
/*
* Switch glyphsets
*/
if (elts[i].glyphset != req->glyphset)
{
BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
elt->len = 0xff;
elt->deltax = 0;
elt->deltay = 0;
Data32(dpy, &elts[i].glyphset, 4);
}
nchars = elts[i].nchars;
xDst = elts[i].xOff;
yDst = elts[i].yOff;
chars = elts[i].chars;
while (nchars)
{
BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
elt->len = nchars > MAX_16 ? MAX_16 : nchars;
elt->deltax = xDst;
elt->deltay = yDst;
xDst = 0;
yDst = 0;
Data16 (dpy, chars, elt->len * 2);
nchars -= elt->len;
chars += elt->len;
}
}
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderCompositeText32 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst XGlyphElt32 *elts,
int nelt)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs32Req *req;
long len;
long elen;
xGlyphElt *elt;
int i;
_Xconst unsigned int *chars;
int nchars;
if (!nelt)
return;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderCompositeGlyphs32, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCompositeGlyphs32;
req->op = op;
req->src = src;
req->dst = dst;
req->maskFormat = maskFormat ? maskFormat->id : None;
req->glyphset = elts[0].glyphset;
req->xSrc = xSrc;
req->ySrc = ySrc;
/*
* Compute the space necessary
*/
len = 0;
for (i = 0; i < nelt; i++)
{
if (elts[i].glyphset != req->glyphset)
len += (SIZEOF (xGlyphElt) + 4) >> 2;
nchars = elts[i].nchars;
elen = SIZEOF(xGlyphElt) * ((nchars + MAX_32) / MAX_32) + nchars *4;
len += (elen + 3) >> 2;
}
req->length += len;
/*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first.
*/
if (dpy->bufptr + (len << 2) > dpy->bufmax)
_XFlush (dpy);
for (i = 0; i < nelt; i++)
{
/*
* Switch glyphsets
*/
if (elts[i].glyphset != req->glyphset)
{
BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
elt->len = 0xff;
elt->deltax = 0;
elt->deltay = 0;
Data32(dpy, &elts[i].glyphset, 4);
}
nchars = elts[i].nchars;
xDst = elts[i].xOff;
yDst = elts[i].yOff;
chars = elts[i].chars;
while (nchars)
{
BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
elt->len = nchars > MAX_32 ? MAX_32 : nchars;
elt->deltax = xDst;
elt->deltay = yDst;
xDst = 0;
yDst = 0;
Data32 (dpy, chars, elt->len * 4);
nchars -= elt->len;
chars += elt->len;
}
}
UnlockDisplay(dpy);
SyncHandle();
}

View File

@ -1,27 +0,0 @@
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = Xrender/X11/extensions
LIBRARY_NAME = Xrender
EXPORTS = Xrender.h
CSRCS = \
Composite.c \
FillRect.c \
FillRects.c \
Glyph.c \
Picture.c \
Xrender.c
# make it a static lib only
FORCE_STATIC_LIB=1
include $(topsrcdir)/config/rules.mk
CFLAGS = $(MOZ_XFT_CFLAGS) -I$(srcdir)/extensions

View File

@ -1,213 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/Picture.c,v 1.8 2001/12/16 18:27:55 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
#include "Xrenderint.h"
#include "region.h"
static void
_XRenderProcessPictureAttributes (Display *dpy,
xRenderChangePictureReq *req,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes)
{
unsigned long values[32];
register unsigned long *value = values;
unsigned int nvalues;
if (valuemask & CPRepeat)
*value++ = attributes->repeat;
if (valuemask & CPAlphaMap)
*value++ = attributes->alpha_map;
if (valuemask & CPAlphaXOrigin)
*value++ = attributes->alpha_x_origin;
if (valuemask & CPAlphaYOrigin)
*value++ = attributes->alpha_y_origin;
if (valuemask & CPClipXOrigin)
*value++ = attributes->clip_x_origin;
if (valuemask & CPClipYOrigin)
*value++ = attributes->clip_y_origin;
if (valuemask & CPClipMask)
*value++ = attributes->clip_mask;
if (valuemask & CPGraphicsExposure)
*value++ = attributes->graphics_exposures;
if (valuemask & CPSubwindowMode)
*value++ = attributes->subwindow_mode;
if (valuemask & CPPolyEdge)
*value++ = attributes->poly_edge;
if (valuemask & CPPolyMode)
*value++ = attributes->poly_mode;
if (valuemask & CPDither)
*value++ = attributes->dither;
if (valuemask & CPComponentAlpha)
*value++ = attributes->component_alpha;
req->length += (nvalues = value - values);
nvalues <<= 2; /* watch out for macros... */
Data32 (dpy, (long *) values, (long)nvalues);
}
Picture
XRenderCreatePicture (Display *dpy,
Drawable drawable,
_Xconst XRenderPictFormat *format,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
Picture pid;
xRenderCreatePictureReq *req;
RenderCheckExtension (dpy, info, 0);
LockDisplay(dpy);
GetReq(RenderCreatePicture, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCreatePicture;
req->pid = pid = XAllocID(dpy);
req->drawable = drawable;
req->format = format->id;
if ((req->mask = valuemask))
_XRenderProcessPictureAttributes (dpy,
(xRenderChangePictureReq *) req,
valuemask,
attributes);
UnlockDisplay(dpy);
SyncHandle();
return pid;
}
void
XRenderChangePicture (Display *dpy,
Picture picture,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderChangePictureReq *req;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderChangePicture, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderChangePicture;
req->picture = picture;
req->mask = valuemask;
_XRenderProcessPictureAttributes (dpy,
req,
valuemask,
attributes);
UnlockDisplay(dpy);
SyncHandle();
}
static void
_XRenderSetPictureClipRectangles (Display *dpy,
XExtDisplayInfo *info,
Picture picture,
int xOrigin,
int yOrigin,
_Xconst XRectangle *rects,
int n)
{
xRenderSetPictureClipRectanglesReq *req;
long len;
GetReq (RenderSetPictureClipRectangles, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderSetPictureClipRectangles;
req->picture = picture;
req->xOrigin = xOrigin;
req->yOrigin = yOrigin;
len = ((long) n) << 1;
SetReqLen (req, len, 1);
len <<= 2;
Data16 (dpy, (short *) rects, len);
}
void
XRenderSetPictureClipRectangles (Display *dpy,
Picture picture,
int xOrigin,
int yOrigin,
_Xconst XRectangle *rects,
int n)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
_XRenderSetPictureClipRectangles (dpy, info, picture,
xOrigin, yOrigin, rects, n);
UnlockDisplay (dpy);
SyncHandle ();
}
void
XRenderSetPictureClipRegion (Display *dpy,
Picture picture,
Region r)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
int i;
XRectangle *xr, *pr;
BOX *pb;
unsigned long total;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
total = r->numRects * sizeof (XRectangle);
if ((xr = (XRectangle *) _XAllocTemp(dpy, total))) {
for (pr = xr, pb = r->rects, i = r->numRects; --i >= 0; pr++, pb++) {
pr->x = pb->x1;
pr->y = pb->y1;
pr->width = pb->x2 - pb->x1;
pr->height = pb->y2 - pb->y1;
}
}
if (xr || !r->numRects)
_XRenderSetPictureClipRectangles (dpy, info, picture, 0, 0,
xr, r->numRects);
if (xr)
_XFreeTemp(dpy, (char *)xr, total);
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderFreePicture (Display *dpy,
Picture picture)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFreePictureReq *req;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderFreePicture, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderFreePicture;
req->picture = picture;
UnlockDisplay(dpy);
SyncHandle();
}

View File

@ -1,29 +0,0 @@
LIBRARY Xrender
VERSION LIBRARY_VERSION
EXPORTS
XRenderComposite
XRenderFillRectangle
XRenderFillRectangles
XRenderAddGlyphs
XRenderCompositeString16
XRenderCompositeString32
XRenderCompositeString8
XRenderCreateGlyphSet
XRenderFreeGlyphSet
XRenderFreeGlyphs
XRenderReferenceGlyphSet
XRenderChangePicture
XRenderCreatePicture
XRenderFreePicture
; _XRenderProcessPictureAttributes
XRenderFindDisplay
XRenderFindFormat
XRenderFindVisualFormat
XRenderQueryExtension
XRenderQueryFormats
XRenderQueryVersion
; _XRenderFindFormat
; _XRenderFindVisual
XRenderSetPictureClipRegion
/* $XFree86: xc/lib/Xrender/Xrender-def.cpp,v 1.3 2001/02/13 19:19:12 dawes Exp $ */

View File

@ -1,327 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/Xrender.c,v 1.8 2001/12/16 18:27:55 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
#include "Xrenderint.h"
XExtensionInfo XRenderExtensionInfo;
char XRenderExtensionName[] = RENDER_NAME;
static int XRenderCloseDisplay(Display *dpy, XExtCodes *codes);
static /* const */ XExtensionHooks render_extension_hooks = {
NULL, /* create_gc */
NULL, /* copy_gc */
NULL, /* flush_gc */
NULL, /* free_gc */
NULL, /* create_font */
NULL, /* free_font */
XRenderCloseDisplay, /* close_display */
NULL, /* wire_to_event */
NULL, /* event_to_wire */
NULL, /* error */
NULL, /* error_string */
};
XExtDisplayInfo *
XRenderFindDisplay (Display *dpy)
{
XExtDisplayInfo *dpyinfo;
dpyinfo = XextFindDisplay (&XRenderExtensionInfo, dpy);
if (!dpyinfo)
dpyinfo = XextAddDisplay (&XRenderExtensionInfo, dpy,
XRenderExtensionName,
&render_extension_hooks,
0, 0);
return dpyinfo;
}
static int
XRenderCloseDisplay (Display *dpy, XExtCodes *codes)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
if (info->data) XFree (info->data);
return XextRemoveDisplay (&XRenderExtensionInfo, dpy);
}
/****************************************************************************
* *
* Render public interfaces *
* *
****************************************************************************/
Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
if (XextHasExtension(info)) {
*event_basep = info->codes->first_event;
*error_basep = info->codes->first_error;
return True;
} else {
return False;
}
}
Status XRenderQueryVersion (Display *dpy,
int *major_versionp,
int *minor_versionp)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderQueryVersionReply rep;
xRenderQueryVersionReq *req;
RenderCheckExtension (dpy, info, 0);
LockDisplay (dpy);
GetReq (RenderQueryVersion, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderQueryVersion;
req->majorVersion = RENDER_MAJOR;
req->minorVersion = RENDER_MINOR;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return 0;
}
*major_versionp = rep.majorVersion;
*minor_versionp = rep.minorVersion;
UnlockDisplay (dpy);
SyncHandle ();
return 1;
}
static XRenderPictFormat *
_XRenderFindFormat (XRenderInfo *xri, PictFormat format)
{
int nf;
for (nf = 0; nf < xri->nformat; nf++)
if (xri->format[nf].id == format)
return &xri->format[nf];
return 0;
}
static Visual *
_XRenderFindVisual (Display *dpy, VisualID vid)
{
return _XVIDtoVisual (dpy, vid);
}
Status
XRenderQueryFormats (Display *dpy)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderQueryPictFormatsReply rep;
xRenderQueryPictFormatsReq *req;
XRenderInfo *xri;
XRenderPictFormat *format;
XRenderScreen *screen;
XRenderDepth *depth;
XRenderVisual *visual;
xPictFormInfo *xFormat;
xPictScreen *xScreen;
xPictDepth *xDepth;
xPictVisual *xVisual;
void *xData;
int nf, ns, nd, nv;
int rlength;
RenderCheckExtension (dpy, info, 0);
LockDisplay (dpy);
if (info->data)
{
UnlockDisplay (dpy);
return 1;
}
GetReq (RenderQueryPictFormats, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderQueryPictFormats;
if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
UnlockDisplay (dpy);
SyncHandle ();
return 0;
}
xri = (XRenderInfo *) Xmalloc (sizeof (XRenderInfo) +
rep.numFormats * sizeof (XRenderPictFormat) +
rep.numScreens * sizeof (XRenderScreen) +
rep.numDepths * sizeof (XRenderDepth) +
rep.numVisuals * sizeof (XRenderVisual));
xri->format = (XRenderPictFormat *) (xri + 1);
xri->nformat = rep.numFormats;
xri->screen = (XRenderScreen *) (xri->format + rep.numFormats);
xri->nscreen = rep.numScreens;
xri->depth = (XRenderDepth *) (xri->screen + rep.numScreens);
xri->ndepth = rep.numDepths;
xri->visual = (XRenderVisual *) (xri->depth + rep.numDepths);
xri->nvisual = rep.numVisuals;
rlength = (rep.numFormats * sizeof (xPictFormInfo) +
rep.numScreens * sizeof (xPictScreen) +
rep.numDepths * sizeof (xPictDepth) +
rep.numVisuals * sizeof (xPictVisual));
xData = (void *) Xmalloc (rlength);
if (!xri || !xData)
{
if (xri) Xfree (xri);
if (xData) Xfree (xData);
_XEatData (dpy, rlength);
UnlockDisplay (dpy);
SyncHandle ();
return 0;
}
_XRead (dpy, (char *) xData, rlength);
format = xri->format;
xFormat = (xPictFormInfo *) xData;
for (nf = 0; nf < rep.numFormats; nf++)
{
format->id = xFormat->id;
format->type = xFormat->type;
format->depth = xFormat->depth;
format->direct.red = xFormat->direct.red;
format->direct.redMask = xFormat->direct.redMask;
format->direct.green = xFormat->direct.green;
format->direct.greenMask = xFormat->direct.greenMask;
format->direct.blue = xFormat->direct.blue;
format->direct.blueMask = xFormat->direct.blueMask;
format->direct.alpha = xFormat->direct.alpha;
format->direct.alphaMask = xFormat->direct.alphaMask;
format->colormap = xFormat->colormap;
format++;
xFormat++;
}
xScreen = (xPictScreen *) xFormat;
screen = xri->screen;
depth = xri->depth;
visual = xri->visual;
for (ns = 0; ns < xri->nscreen; ns++)
{
screen->depths = depth;
screen->ndepths = xScreen->nDepth;
screen->fallback = _XRenderFindFormat (xri, xScreen->fallback);
xDepth = (xPictDepth *) (xScreen + 1);
for (nd = 0; nd < screen->ndepths; nd++)
{
depth->depth = xDepth->depth;
depth->nvisuals = xDepth->nPictVisuals;
depth->visuals = visual;
xVisual = (xPictVisual *) (xDepth + 1);
for (nv = 0; nv < depth->nvisuals; nv++)
{
visual->visual = _XRenderFindVisual (dpy, xVisual->visual);
visual->format = _XRenderFindFormat (xri, xVisual->format);
visual++;
xVisual++;
}
depth++;
xDepth = (xPictDepth *) xVisual;
}
xScreen = (xPictScreen *) xDepth;
}
info->data = (XPointer) xri;
UnlockDisplay (dpy);
SyncHandle ();
Xfree (xData);
return 1;
}
XRenderPictFormat *
XRenderFindVisualFormat (Display *dpy, _Xconst Visual *visual)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
int nv;
XRenderInfo *xri;
XRenderVisual *xrv;
RenderCheckExtension (dpy, info, 0);
if (!XRenderQueryFormats (dpy))
return 0;
xri = (XRenderInfo *) info->data;
for (nv = 0, xrv = xri->visual; nv < xri->nvisual; nv++, xrv++)
if (xrv->visual == visual)
return xrv->format;
return 0;
}
XRenderPictFormat *
XRenderFindFormat (Display *dpy,
unsigned long mask,
_Xconst XRenderPictFormat *template,
int count)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
int nf;
XRenderInfo *xri;
RenderCheckExtension (dpy, info, 0);
if (!XRenderQueryFormats (dpy))
return 0;
xri = (XRenderInfo *) info->data;
for (nf = 0; nf < xri->nformat; nf++)
{
if (mask & PictFormatID)
if (template->id != xri->format[nf].id)
continue;
if (mask & PictFormatType)
if (template->type != xri->format[nf].type)
continue;
if (mask & PictFormatDepth)
if (template->depth != xri->format[nf].depth)
continue;
if (mask & PictFormatRed)
if (template->direct.red != xri->format[nf].direct.red)
continue;
if (mask & PictFormatRedMask)
if (template->direct.redMask != xri->format[nf].direct.redMask)
continue;
if (mask & PictFormatGreen)
if (template->direct.green != xri->format[nf].direct.green)
continue;
if (mask & PictFormatGreenMask)
if (template->direct.greenMask != xri->format[nf].direct.greenMask)
continue;
if (mask & PictFormatBlue)
if (template->direct.blue != xri->format[nf].direct.blue)
continue;
if (mask & PictFormatBlueMask)
if (template->direct.blueMask != xri->format[nf].direct.blueMask)
continue;
if (mask & PictFormatAlpha)
if (template->direct.alpha != xri->format[nf].direct.alpha)
continue;
if (mask & PictFormatAlphaMask)
if (template->direct.alphaMask != xri->format[nf].direct.alphaMask)
continue;
if (mask & PictFormatColormap)
if (template->colormap != xri->format[nf].colormap)
continue;
if (count-- == 0)
return &xri->format[nf];
}
return 0;
}

View File

@ -1,340 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/Xrender.h,v 1.10 2001/12/27 01:16:00 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
#ifndef _XRENDER_H_
#define _XRENDER_H_
#include <X11/extensions/render.h>
#include <X11/Xfuncproto.h>
#include <X11/Xosdefs.h>
#include <X11/Xutil.h>
typedef struct {
short red;
short redMask;
short green;
short greenMask;
short blue;
short blueMask;
short alpha;
short alphaMask;
} XRenderDirectFormat;
typedef struct {
PictFormat id;
int type;
int depth;
XRenderDirectFormat direct;
Colormap colormap;
} XRenderPictFormat;
#define PictFormatID (1 << 0)
#define PictFormatType (1 << 1)
#define PictFormatDepth (1 << 2)
#define PictFormatRed (1 << 3)
#define PictFormatRedMask (1 << 4)
#define PictFormatGreen (1 << 5)
#define PictFormatGreenMask (1 << 6)
#define PictFormatBlue (1 << 7)
#define PictFormatBlueMask (1 << 8)
#define PictFormatAlpha (1 << 9)
#define PictFormatAlphaMask (1 << 10)
#define PictFormatColormap (1 << 11)
typedef struct {
Visual *visual;
XRenderPictFormat *format;
} XRenderVisual;
typedef struct {
int depth;
int nvisuals;
XRenderVisual *visuals;
} XRenderDepth;
typedef struct {
XRenderDepth *depths;
int ndepths;
XRenderPictFormat *fallback;
} XRenderScreen;
typedef struct _XRenderInfo {
XRenderPictFormat *format;
int nformat;
XRenderScreen *screen;
int nscreen;
XRenderDepth *depth;
int ndepth;
XRenderVisual *visual;
int nvisual;
} XRenderInfo;
typedef struct _XRenderPictureAttributes {
Bool repeat;
Picture alpha_map;
int alpha_x_origin;
int alpha_y_origin;
int clip_x_origin;
int clip_y_origin;
Pixmap clip_mask;
Bool graphics_exposures;
int subwindow_mode;
int poly_edge;
int poly_mode;
Atom dither;
Bool component_alpha;
} XRenderPictureAttributes;
typedef struct {
unsigned short red;
unsigned short green;
unsigned short blue;
unsigned short alpha;
} XRenderColor;
typedef struct _XGlyphInfo {
unsigned short width;
unsigned short height;
short x;
short y;
short xOff;
short yOff;
} XGlyphInfo;
typedef struct _XGlyphElt8 {
GlyphSet glyphset;
_Xconst char *chars;
int nchars;
int xOff;
int yOff;
} XGlyphElt8;
typedef struct _XGlyphElt16 {
GlyphSet glyphset;
_Xconst unsigned short *chars;
int nchars;
int xOff;
int yOff;
} XGlyphElt16;
typedef struct _XGlyphElt32 {
GlyphSet glyphset;
_Xconst unsigned int *chars;
int nchars;
int xOff;
int yOff;
} XGlyphElt32;
_XFUNCPROTOBEGIN
Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep);
Status XRenderQueryVersion (Display *dpy,
int *major_versionp,
int *minor_versionp);
Status XRenderQueryFormats (Display *dpy);
XRenderPictFormat *
XRenderFindVisualFormat (Display *dpy, _Xconst Visual *visual);
XRenderPictFormat *
XRenderFindFormat (Display *dpy,
unsigned long mask,
_Xconst XRenderPictFormat *templ,
int count);
Picture
XRenderCreatePicture (Display *dpy,
Drawable drawable,
_Xconst XRenderPictFormat *format,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes);
void
XRenderChangePicture (Display *dpy,
Picture picture,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes);
void
XRenderSetPictureClipRectangles (Display *dpy,
Picture picture,
int xOrigin,
int yOrigin,
_Xconst XRectangle *rects,
int n);
void
XRenderSetPictureClipRegion (Display *dpy,
Picture picture,
Region r);
void
XRenderFreePicture (Display *dpy,
Picture picture);
void
XRenderComposite (Display *dpy,
int op,
Picture src,
Picture mask,
Picture dst,
int src_x,
int src_y,
int mask_x,
int mask_y,
int dst_x,
int dst_y,
unsigned int width,
unsigned int height);
GlyphSet
XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format);
GlyphSet
XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing);
void
XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset);
void
XRenderAddGlyphs (Display *dpy,
GlyphSet glyphset,
_Xconst Glyph *gids,
_Xconst XGlyphInfo *glyphs,
int nglyphs,
_Xconst char *images,
int nbyte_images);
void
XRenderFreeGlyphs (Display *dpy,
GlyphSet glyphset,
_Xconst Glyph *gids,
int nglyphs);
void
XRenderCompositeString8 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
GlyphSet glyphset,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst char *string,
int nchar);
void
XRenderCompositeString16 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
GlyphSet glyphset,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst unsigned short *string,
int nchar);
void
XRenderCompositeString32 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
GlyphSet glyphset,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst unsigned int *string,
int nchar);
void
XRenderCompositeText8 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst XGlyphElt8 *elts,
int nelt);
void
XRenderCompositeText16 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst XGlyphElt16 *elts,
int nelt);
void
XRenderCompositeText32 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst XGlyphElt32 *elts,
int nelt);
void
XRenderFillRectangle (Display *dpy,
int op,
Picture dst,
_Xconst XRenderColor *color,
int x,
int y,
unsigned int width,
unsigned int height);
void
XRenderFillRectangles (Display *dpy,
int op,
Picture dst,
_Xconst XRenderColor *color,
_Xconst XRectangle *rectangles,
int n_rects);
_XFUNCPROTOEND
#endif /* _XRENDER_H_ */

View File

@ -1,50 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/Xrenderint.h,v 1.2 2000/08/28 02:43:13 tsi Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
#ifndef _XRENDERINT_H_
#define _XRENDERINT_H_
#define NEED_EVENTS
#define NEED_REPLIES
#include <X11/Xlibint.h>
#include <X11/Xutil.h>
#include "Xext.h" /* in ../include */
#include "extutil.h" /* in ../include */
#include "Xrender.h"
#include "renderproto.h"
extern XExtensionInfo XRenderExtensionInfo;
extern char XRenderExtensionName[];
#define RenderCheckExtension(dpy,i,val) \
XextCheckExtension (dpy, i, XRenderExtensionName, val)
#define RenderSimpleCheckExtension(dpy,i) \
XextSimpleCheckExtension (dpy, i, XRenderExtensionName)
XExtDisplayInfo *
XRenderFindDisplay (Display *dpy);
#endif /* _XRENDERINT_H_ */

View File

@ -1,224 +0,0 @@
/*
* $Xorg: extutil.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $
*
Copyright 1989, 1998 The Open Group
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.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*
* Author: Jim Fulton, MIT The Open Group
*
* Xlib Extension-Writing Utilities
*
* This package contains utilities for writing the client API for various
* protocol extensions. THESE INTERFACES ARE NOT PART OF THE X STANDARD AND
* ARE SUBJECT TO CHANGE!
*/
/* $XFree86: xc/include/extensions/extutil.h,v 1.9 2001/12/14 19:53:28 dawes Exp $ */
#ifndef _EXTUTIL_H_
#define _EXTUTIL_H_
#include <X11/extensions/Xext.h>
/*
* We need to keep a list of open displays since the Xlib display list isn't
* public. We also have to per-display info in a separate block since it isn't
* stored directly in the Display structure.
*/
typedef struct _XExtDisplayInfo {
struct _XExtDisplayInfo *next; /* keep a linked list */
Display *display; /* which display this is */
XExtCodes *codes; /* the extension protocol codes */
XPointer data; /* extra data for extension to use */
} XExtDisplayInfo;
typedef struct _XExtensionInfo {
XExtDisplayInfo *head; /* start of list */
XExtDisplayInfo *cur; /* most recently used */
int ndisplays; /* number of displays */
} XExtensionInfo;
typedef struct _XExtensionHooks {
int (*create_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*copy_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*flush_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*free_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*create_font)(
#if NeedNestedPrototypes
Display* /* display */,
XFontStruct* /* fs */,
XExtCodes* /* codes */
#endif
);
int (*free_font)(
#if NeedNestedPrototypes
Display* /* display */,
XFontStruct* /* fs */,
XExtCodes* /* codes */
#endif
);
int (*close_display)(
#if NeedNestedPrototypes
Display* /* display */,
XExtCodes* /* codes */
#endif
);
Bool (*wire_to_event)(
#if NeedNestedPrototypes
Display* /* display */,
XEvent* /* re */,
xEvent* /* event */
#endif
);
Status (*event_to_wire)(
#if NeedNestedPrototypes
Display* /* display */,
XEvent* /* re */,
xEvent* /* event */
#endif
);
int (*error)(
#if NeedNestedPrototypes
Display* /* display */,
xError* /* err */,
XExtCodes* /* codes */,
int* /* ret_code */
#endif
);
char *(*error_string)(
#if NeedNestedPrototypes
Display* /* display */,
int /* code */,
XExtCodes* /* codes */,
char* /* buffer */,
int /* nbytes */
#endif
);
} XExtensionHooks;
extern XExtensionInfo *XextCreateExtension(
#if NeedFunctionPrototypes
void
#endif
);
extern void XextDestroyExtension(
#if NeedFunctionPrototypes
XExtensionInfo* /* info */
#endif
);
extern XExtDisplayInfo *XextAddDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* /* extinfo */,
Display* /* dpy */,
char* /* ext_name */,
XExtensionHooks* /* hooks */,
int /* nevents */,
XPointer /* data */
#endif
);
extern int XextRemoveDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* /* extinfo */,
Display* /* dpy */
#endif
);
extern XExtDisplayInfo *XextFindDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* /* extinfo */,
Display* /* dpy */
#endif
);
#define XextHasExtension(i) ((i) && ((i)->codes))
#define XextCheckExtension(dpy,i,name,val) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; }
#define XextSimpleCheckExtension(dpy,i,name) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; }
/*
* helper macros to generate code that is common to all extensions; caller
* should prefix it with static if extension source is in one file; this
* could be a utility function, but have to stack 6 unused arguments for
* something that is called many, many times would be bad.
*/
#define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \
XExtDisplayInfo *proc (Display *dpy) \
{ \
XExtDisplayInfo *dpyinfo; \
if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
return dpyinfo; \
}
#define XEXT_FIND_DISPLAY_PROTO(proc) \
XExtDisplayInfo *proc(Display *dpy)
#define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
int proc (Display *dpy, XExtCodes *codes) \
{ \
return XextRemoveDisplay (extinfo, dpy); \
}
#define XEXT_CLOSE_DISPLAY_PROTO(proc) \
int proc(Display *dpy, XExtCodes *codes)
#define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \
char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
{ \
code -= codes->first_error; \
if (code >= 0 && code < nerr) { \
char tmp[256]; \
sprintf (tmp, "%s.%d", extname, code); \
XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
return buf; \
} \
return (char *)0; \
}
#define XEXT_ERROR_STRING_PROTO(proc) \
char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n)
#endif

View File

@ -1,190 +0,0 @@
/* $Xorg: region.h,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
/************************************************************************
Copyright 1987, 1998 The Open Group
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.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
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 Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL 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.
************************************************************************/
#ifndef _XREGION_H
#define _XREGION_H
typedef struct {
short x1, x2, y1, y2;
} Box, BOX, BoxRec, *BoxPtr;
typedef struct {
short x, y, width, height;
}RECTANGLE, RectangleRec, *RectanglePtr;
#define TRUE 1
#define FALSE 0
#define MAXSHORT 32767
#define MINSHORT -MAXSHORT
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
/*
* clip region
*/
typedef struct _XRegion {
long size;
long numRects;
BOX *rects;
BOX extents;
} REGION;
/* Xutil.h contains the declaration:
* typedef struct _XRegion *Region;
*/
/* 1 if two BOXs overlap.
* 0 if two BOXs do not overlap.
* Remember, x2 and y2 are not in the region
*/
#define EXTENTCHECK(r1, r2) \
((r1)->x2 > (r2)->x1 && \
(r1)->x1 < (r2)->x2 && \
(r1)->y2 > (r2)->y1 && \
(r1)->y1 < (r2)->y2)
/*
* update region extents
*/
#define EXTENTS(r,idRect){\
if((r)->x1 < (idRect)->extents.x1)\
(idRect)->extents.x1 = (r)->x1;\
if((r)->y1 < (idRect)->extents.y1)\
(idRect)->extents.y1 = (r)->y1;\
if((r)->x2 > (idRect)->extents.x2)\
(idRect)->extents.x2 = (r)->x2;\
if((r)->y2 > (idRect)->extents.y2)\
(idRect)->extents.y2 = (r)->y2;\
}
/*
* Check to see if there is enough memory in the present region.
*/
#define MEMCHECK(reg, rect, firstrect){\
if ((reg)->numRects >= ((reg)->size - 1)){\
(firstrect) = (BOX *) Xrealloc \
((char *)(firstrect), (unsigned) (2 * (sizeof(BOX)) * ((reg)->size)));\
if ((firstrect) == 0)\
return(0);\
(reg)->size *= 2;\
(rect) = &(firstrect)[(reg)->numRects];\
}\
}
/* this routine checks to see if the previous rectangle is the same
* or subsumes the new rectangle to add.
*/
#define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
(!(((Reg)->numRects > 0)&&\
((R-1)->y1 == (Ry1)) &&\
((R-1)->y2 == (Ry2)) &&\
((R-1)->x1 <= (Rx1)) &&\
((R-1)->x2 >= (Rx2))))
/* add a rectangle to the given Region */
#define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
EXTENTS((r), (reg));\
(reg)->numRects++;\
(r)++;\
}\
}
/* add a rectangle to the given Region */
#define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
if ((rx1 < rx2) && (ry1 < ry2) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
(reg)->numRects++;\
(r)++;\
}\
}
#define EMPTY_REGION(pReg) pReg->numRects = 0
#define REGION_NOT_EMPTY(pReg) pReg->numRects
#define INBOX(r, x, y) \
( ( ((r).x2 > x)) && \
( ((r).x1 <= x)) && \
( ((r).y2 > y)) && \
( ((r).y1 <= y)) )
/*
* number of points to buffer before sending them off
* to scanlines() : Must be an even number
*/
#define NUMPTSTOBUFFER 200
/*
* used to allocate buffers for points and link
* the buffers together
*/
typedef struct _POINTBLOCK {
XPoint pts[NUMPTSTOBUFFER];
struct _POINTBLOCK *next;
} POINTBLOCK;
#endif

View File

@ -1 +0,0 @@
Keith Packard <keithp@keithp.com>

View File

@ -1,22 +0,0 @@
$XFree86: xc/lib/fontconfig/COPYING,v 1.1.1.1 2002/02/14 23:34:11 keithp Exp $
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
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.

View File

@ -1,3 +0,0 @@
The configuration files (fonts.conf, fonts.dtd) go in a new directory
/etc/fonts, the install step doesn't current create this directory or copy
the config files.

View File

@ -1,11 +0,0 @@
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS=fontconfig src
include $(topsrcdir)/config/rules.mk

View File

@ -1,2 +0,0 @@
Fontconfig
Font configuration and customization library

View File

@ -1,55 +0,0 @@
\documentclass[10pt]{article}
\usepackage{latexsym}
\usepackage{epsfig}
\usepackage{times}
\begin{document}
\date{}
\title{The Fontconfig Library:\\
Architecture and Users Guide}
\author{Keith Packard\\
{\em XFree86 Core Team}\\
keithp@keithp.com}
\maketitle
\thispagestyle{empty}
\abstract
The Fontconfig library provides for central administration and configuration
of fonts in a POSIX system. All font consumers can share a common database
of fonts and use common matching rules for font names. The set of available
fonts can be configured for each user and a set of configurable matching
rules allow for customizing the selection of fonts and configuring various
parameters related to rasterizing of those fonts for display in a variety of
media. The Fontconfig library is designed to co-exist peacefully with
existing font configuration and rasterization mechanisms; while it uses the
FreeType library to discover characteristics of available fonts, there
is no requirement to use FreeType for rasterization.
\section {Introduction}
\section {Configuration Files}
\section {Application Interface}
\subsection {Datatypes}
\subsection {Font Set Interface}
\subsection {Font Patterns}
\subsection {Listing Available Fonts}
\subsection {Using Font Names}
\subsection {Manipulating Matrices}
\subsection {UTF-8 Helper Functions}
\section {Font Sub-System Interface}
\subsection {Extending Font Names}
\subsection {Executing Configuration Rules}
\end{document}

View File

@ -1,13 +0,0 @@
INCLUDES=$(FREETYPE2INCLUDES) $(LIBXML2INCLUDES) -I..
LOCAL_LIBRARIES=FontconfigClientLibs
DEPLIBS=FontconfigClientDepLibs
SRCS=fc-cache.c
OBJS=fc-cache.o
ComplexProgramTarget(fc-cache)
LinkBuildBinary(ProgramTargetName(fc-cache))
install::
FC_DEBUG=128 $(FCCACHE) -v

View File

@ -1,5 +0,0 @@
bin_PROGRAMS=fc-cache
fc_cache_SOURCES=fc-cache.c
fc_cache_LDADD=../src/.libs/libfontconfig.so

View File

@ -1,157 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/fc-cache/fc-cache.c,v 1.3 2002/02/26 05:10:30 tsi Exp $
*
* 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
* 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.
*/
#include <fontconfig/fontconfig.h>
#include <stdio.h>
#include <unistd.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#else
#ifdef linux
#define HAVE_GETOPT_LONG 1
#endif
#define HAVE_GETOPT 1
#endif
#ifndef HAVE_GETOPT
#define HAVE_GETOPT 0
#endif
#ifndef HAVE_GETOPT_LONG
#define HAVE_GETOPT_LONG 0
#endif
#if HAVE_GETOPT_LONG
#undef _GNU_SOURCE
#define _GNU_SOURCE
#include <getopt.h>
const struct option longopts[] = {
{"version", 0, 0, 'V'},
{"verbose", 0, 0, 'v'},
{"help", 0, 0, '?'},
{NULL,0,0,0},
};
#else
#if HAVE_GETOPT
extern char *optarg;
extern int optind, opterr, optopt;
#endif
#endif
static void
usage (char *program)
{
fprintf (stderr, "usage: %s [-vV?] [--verbose] [--version] [--help] [dirs]\n",
program);
fprintf (stderr, "Build font information caches in [dirs]\n"
"(all directories in font configuration by default).\n");
fprintf (stderr, "\n");
fprintf (stderr, " -v, --verbose display status information while busy\n");
fprintf (stderr, " -V, --version display font config version and exit\n");
fprintf (stderr, " -?, --help display this help and exit\n");
exit (1);
}
int
main (int argc, char **argv)
{
int ret = 0;
FcFontSet *set;
FcChar8 **dirs;
int verbose = 0;
int i;
#if HAVE_GETOPT_LONG || HAVE_GETOPT
int c;
#if HAVE_GETOPT_LONG
while ((c = getopt_long (argc, argv, "Vv?", longopts, NULL)) != -1)
#else
while ((c = getopt (argc, argv, "Vv?")) != -1)
#endif
{
switch (c) {
case 'V':
fprintf (stderr, "fontconfig version %d.%d.%d\n",
FC_MAJOR, FC_MINOR, FC_REVISION);
exit (0);
case 'v':
verbose = 1;
break;
default:
usage (argv[0]);
}
}
i = optind;
#else
i = 1;
#endif
if (!FcInitConfig ())
{
fprintf (stderr, "Can't init font config library\n");
return 1;
}
if (argv[i])
dirs = (FcChar8 **) (argv+i);
else
dirs = FcConfigGetDirs (0);
/*
* Now scan all of the directories into separate databases
* and write out the results
*/
while (dirs && *dirs)
{
if (verbose)
printf ("%s: Scanning directory \"%s\"\n", argv[0], *dirs);
set = FcFontSetCreate ();
if (!set)
{
fprintf (stderr, "Out of memory in \"%s\"\n", *dirs);
ret++;
}
else
{
if (!FcDirScan (set, 0, FcConfigGetBlanks (0), *dirs, FcTrue))
{
fprintf (stderr, "Can't scan directory \"%s\"\n", *dirs);
ret++;
}
else
{
if (verbose)
printf ("%s: Saving %d font names for \"%s\"\n",
argv[0], set->nfont, *dirs);
if (!FcDirSave (set, *dirs))
{
fprintf (stderr, "Can't save cache in \"%s\"\n", *dirs);
ret++;
}
}
FcFontSetDestroy (set);
}
++dirs;
}
if (verbose)
printf ("%s: %s\n", argv[0], ret ? "failed" : "succeeded");
return ret;
}

View File

@ -1,45 +0,0 @@
.\"
.\" 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
.\" 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.
.\"
.\"
.\" $XFree86: xc/lib/fontconfig/fc-cache/fc-cache.man,v 1.1.1.1 2002/02/14 23:34:11 keithp Exp $
.\"
.TH FC-CACHE 1 __vendorversion__
.SH NAME
fc-cache, fonts.cache \- create an index of FreeType font files in a directory
.SH SYNOPSIS
.B "fc-cache"
.RI [ directory-name
\|.\|.\|. ]
.SH DESCRIPTION
If directory arguments are not given,
.I fc-cache
uses each directory in the current font configuration. Each directory is
scanned for font files readable by FreeType. A cache is created which
contains properties of each font and the associated filename. This cache is
used to speed application startup when using the fontconfig library.
.SH FILES
.TP 15
.B fonts.cache
Maps file names to font properties. Read by the fontconfig library at
application startup to locate appropriate fonts.
.SH "SEE ALSO"
fontconfig(3)

View File

@ -1,10 +0,0 @@
INCLUDES=$(FREETYPE2INCLUDES) $(LIBXML2INCLUDES) -I..
LOCAL_LIBRARIES=FontconfigClientLibs
DEPLIBS=FontconfigClientDepLibs
SRCS=fc-list.c
OBJS=fc-list.o
ComplexProgramTarget(fc-list)
LinkBuildBinary(ProgramTargetName(fc-list))

View File

@ -1,5 +0,0 @@
bin_PROGRAMS=fc-list
fc_list_SOURCES=fc-list.c
fc_list_LDADD=../src/.libs/libfontconfig.so

View File

@ -1,138 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/fc-list/fc-list.c,v 1.4 2002/02/28 16:51:46 keithp Exp $
*
* 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
* 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.
*/
#include <fontconfig/fontconfig.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#else
#ifdef linux
#define HAVE_GETOPT_LONG 1
#endif
#define HAVE_GETOPT 1
#endif
#ifndef HAVE_GETOPT
#define HAVE_GETOPT 0
#endif
#ifndef HAVE_GETOPT_LONG
#define HAVE_GETOPT_LONG 0
#endif
#if HAVE_GETOPT_LONG
#undef _GNU_SOURCE
#define _GNU_SOURCE
#include <getopt.h>
const struct option longopts[] = {
{"version", 0, 0, 'V'},
{"verbose", 0, 0, 'v'},
{"help", 0, 0, '?'},
{NULL,0,0,0},
};
#else
#if HAVE_GETOPT
extern char *optarg;
extern int optind, opterr, optopt;
#endif
#endif
static void usage (char *program)
{
fprintf (stderr, "usage: %s [-vV?] [--verbose] [--version] [--help] [dirs]\n",
program);
fprintf (stderr, "Build font information caches in [dirs]\n"
"(all directories in font configuration by default).\n");
fprintf (stderr, "\n");
fprintf (stderr, " -v, --verbose display status information while busy\n");
fprintf (stderr, " -V, --version display font config version and exit\n");
fprintf (stderr, " -?, --help display this help and exit\n");
exit (1);
}
int
main (int argc, char **argv)
{
int verbose = 0;
int i;
FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_LANG, 0);
FcFontSet *fs;
FcPattern *pat;
#if HAVE_GETOPT_LONG || HAVE_GETOPT
int c;
#if HAVE_GETOPT_LONG
while ((c = getopt_long (argc, argv, "Vv?", longopts, NULL)) != -1)
#else
while ((c = getopt (argc, argv, "Vv?")) != -1)
#endif
{
switch (c) {
case 'V':
fprintf (stderr, "fontconfig version %d.%d.%d\n",
FC_MAJOR, FC_MINOR, FC_REVISION);
exit (0);
case 'v':
verbose = 1;
break;
default:
usage (argv[0]);
}
}
i = optind;
#else
i = 1;
#endif
if (!FcInit ())
{
fprintf (stderr, "Can't init font config library\n");
return 1;
}
if (argv[i])
pat = FcNameParse ((FcChar8 *) argv[i]);
else
pat = FcPatternCreate ();
fs = FcFontList (0, pat, os);
if (pat)
FcPatternDestroy (pat);
if (fs)
{
int j;
for (j = 0; j < fs->nfont; j++)
{
FcChar8 *font;
font = FcNameUnparse (fs->fonts[j]);
printf ("%s\n", font);
free (font);
}
FcFontSetDestroy (fs);
}
return 0;
}

View File

@ -1,36 +0,0 @@
.\"
.\" 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
.\" 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.
.\"
.\"
.\" $XFree86: xc/lib/fontconfig/fc-list/fc-list.man,v 1.1.1.1 2002/02/14 23:34:13 keithp Exp $
.\"
.TH FC-LIST 1 __vendorversion__
.SH NAME
fc-list \- list available fonts
.SH SYNOPSIS
.B "fc-list"
.RI [ font-pattern ]
.SH DESCRIPTION
If font pattern is not given,
.I fc-list
lists all available faces and styles in the current font configuration.
.SH "SEE ALSO"
fontconfig(3)

View File

@ -1,8 +0,0 @@
#!/bin/sh
dirs="/usr/share/fonts /usr/X11R6/lib/X11/fonts"
for d in $dirs; do
find $d \( -name '*.[Tt][Tt][Ff]' -o -name '*.[Pp][Ff][BbAa]' \) -print
done | while read f; do
dir=`dirname $f`
echo $dir
done | sort -u | sed 's/^/ <dir>/' | sed 's;$;</dir>;'

View File

@ -1,16 +0,0 @@
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = fontconfig
EXPORTS = \
fontconfig.h \
fcprivate.h \
fcfreetype.h
include $(topsrcdir)/config/rules.mk

View File

@ -1,35 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/fontconfig/fcfreetype.h,v 1.2 2002/02/15 06:01:27 keithp Exp $
*
* 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
* 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.
*/
#ifndef _FCFREETYPE_H_
#define _FCFREETYPE_H_
#include <freetype/freetype.h>
FT_UInt
FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4);
FcCharSet *
FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks);
#endif

View File

@ -1,117 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/fontconfig/fcprivate.h,v 1.2 2002/02/15 06:01:27 keithp Exp $
*
* 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
* 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.
*/
#ifndef _FCPRIVATE_H_
#define _FCPRIVATE_H_
/*
* I tried this with functions that took va_list* arguments
* but portability concerns made me change these functions
* into macros (sigh).
*/
#define FcPatternVapBuild(result, orig, va) \
{ \
FcPattern *__p__ = (orig); \
const char *__o__; \
FcValue __v__; \
\
if (!__p__) \
{ \
__p__ = FcPatternCreate (); \
if (!__p__) \
goto _FcPatternVapBuild_bail0; \
} \
for (;;) \
{ \
__o__ = va_arg (va, const char *); \
if (!__o__) \
break; \
__v__.type = va_arg (va, FcType); \
switch (__v__.type) { \
case FcTypeVoid: \
goto _FcPatternVapBuild_bail1; \
case FcTypeInteger: \
__v__.u.i = va_arg (va, int); \
break; \
case FcTypeDouble: \
__v__.u.d = va_arg (va, double); \
break; \
case FcTypeString: \
__v__.u.s = va_arg (va, FcChar8 *); \
break; \
case FcTypeBool: \
__v__.u.b = va_arg (va, FcBool); \
break; \
case FcTypeMatrix: \
__v__.u.m = va_arg (va, FcMatrix *); \
break; \
case FcTypeCharSet: \
__v__.u.c = va_arg (va, FcCharSet *); \
break; \
} \
if (!FcPatternAdd (__p__, __o__, __v__, FcTrue)) \
goto _FcPatternVapBuild_bail1; \
} \
result = __p__; \
goto _FcPatternVapBuild_return; \
\
_FcPatternVapBuild_bail1: \
if (!orig) \
FcPatternDestroy (__p__); \
_FcPatternVapBuild_bail0: \
result = 0; \
\
_FcPatternVapBuild_return: \
; \
}
#define FcObjectSetVapBuild(__ret__, __first__, __va__) \
{ \
FcObjectSet *__os__; \
const char *__ob__; \
\
__ret__ = 0; \
__os__ = FcObjectSetCreate (); \
if (!__os__) \
goto _FcObjectSetVapBuild_bail0; \
__ob__ = __first__; \
while (__ob__) \
{ \
if (!FcObjectSetAdd (__os__, __ob__)) \
goto _FcObjectSetVapBuild_bail1; \
__ob__ = va_arg (__va__, const char *); \
} \
__ret__ = __os__; \
\
_FcObjectSetVapBuild_bail1: \
if (!__ret__ && __os__) \
FcObjectSetDestroy (__os__); \
_FcObjectSetVapBuild_bail0: \
; \
}
#endif /* _FCPRIVATE_H_ */

View File

@ -1,617 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.7 2002/03/03 18:39:04 keithp Exp $
*
* 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
* 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.
*/
#ifndef _FONTCONFIG_H_
#define _FONTCONFIG_H_
#include <stdarg.h>
typedef unsigned char FcChar8;
typedef unsigned short FcChar16;
typedef unsigned int FcChar32;
typedef int FcBool;
/*
* Current Fontconfig version number
*/
#define FC_MAJOR 1
#define FC_MINOR 0
#define FC_REVISION 0
#define FC_VERSION ((FC_MAJOR * 10000) + (FC_MINOR * 100) + (FC_REVISION))
#define FcTrue 1
#define FcFalse 0
#define FC_FAMILY "family" /* String */
#define FC_STYLE "style" /* String */
#define FC_SLANT "slant" /* Int */
#define FC_WEIGHT "weight" /* Int */
#define FC_SIZE "size" /* Double */
#define FC_PIXEL_SIZE "pixelsize" /* Double */
#define FC_SPACING "spacing" /* Int */
#define FC_FOUNDRY "foundry" /* String */
#define FC_ANTIALIAS "antialias" /* Bool (depends) */
#define FC_HINTING "hinting" /* Bool (true) */
#define FC_VERTICAL_LAYOUT "verticallayout" /* Bool (false) */
#define FC_AUTOHINT "autohint" /* Bool (false) */
#define FC_GLOBAL_ADVANCE "globaladvance" /* Bool (true) */
#define FC_FILE "file" /* String */
#define FC_INDEX "index" /* Int */
#define FC_RASTERIZER "rasterizer" /* String */
#define FC_OUTLINE "outline" /* Bool */
#define FC_SCALABLE "scalable" /* Bool */
#define FC_SCALE "scale" /* double */
#define FC_DPI "dpi" /* double */
#define FC_RGBA "rgba" /* Int */
#define FC_MINSPACE "minspace" /* Bool use minimum line spacing */
#define FC_SOURCE "source" /* String (X11, freetype) */
#define FC_CHARSET "charset" /* CharSet */
#define FC_LANG "lang" /* String OS/2 CodePageRange */
#define FC_DIR_CACHE_FILE "fonts.cache"
#define FC_USER_CACHE_FILE ".fonts.cache"
/* Adjust outline rasterizer */
#define FC_CHAR_WIDTH "charwidth" /* Int */
#define FC_CHAR_HEIGHT "charheight"/* Int */
#define FC_MATRIX "matrix" /* FcMatrix */
#define FC_WEIGHT_LIGHT 0
#define FC_WEIGHT_MEDIUM 100
#define FC_WEIGHT_DEMIBOLD 180
#define FC_WEIGHT_BOLD 200
#define FC_WEIGHT_BLACK 210
#define FC_SLANT_ROMAN 0
#define FC_SLANT_ITALIC 100
#define FC_SLANT_OBLIQUE 110
#define FC_PROPORTIONAL 0
#define FC_MONO 100
#define FC_CHARCELL 110
/* sub-pixel order */
#define FC_RGBA_NONE 0
#define FC_RGBA_RGB 1
#define FC_RGBA_BGR 2
#define FC_RGBA_VRGB 3
#define FC_RGBA_VBGR 4
/* language groups from the OS/2 CodePageRange bits */
#define FC_LANG_LATIN_1 "latin1" /* 0 */
#define FC_LANG_LATIN_2_EASTERN_EUROPE "latin2easterneurope" /* 1 */
#define FC_LANG_CYRILLIC "cyrillic" /* 2 */
#define FC_LANG_GREEK "greek" /* 3 */
#define FC_LANG_TURKISH "turkish" /* 4 */
#define FC_LANG_HEBREW "hebrew" /* 5 */
#define FC_LANG_ARABIC "arabic" /* 6 */
#define FC_LANG_WINDOWS_BALTIC "windowsbaltic" /* 7 */
#define FC_LANG_VIETNAMESE "vietnamese" /* 8 */
/* 9-15 reserved for Alternate ANSI */
#define FC_LANG_THAI "thai" /* 16 */
#define FC_LANG_JAPANESE "japanese" /* 17 */
#define FC_LANG_SIMPLIFIED_CHINESE "simplifiedchinese" /* 18 */
#define FC_LANG_KOREAN_WANSUNG "koreanwansung" /* 19 */
#define FC_LANG_TRADITIONAL_CHINESE "traditionalchinese" /* 20 */
#define FC_LANG_KOREAN_JOHAB "koreanjohab" /* 21 */
/* 22-28 reserved for Alternate ANSI & OEM */
#define FC_LANG_MACINTOSH "macintosh" /* 29 */
#define FC_LANG_OEM "oem" /* 30 */
#define FC_LANG_SYMBOL "symbol" /* 31 */
/* 32-47 reserved for OEM */
#define FC_LANG_IBM_GREEK "ibmgreek" /* 48 */
#define FC_LANG_MSDOS_RUSSIAN "msdosrussian" /* 49 */
#define FC_LANG_MSDOS_NORDIC "msdosnordic" /* 50 */
#define FC_LANG_ARABIC_864 "arabic864" /* 51 */
#define FC_LANG_MSDOS_CANADIAN_FRENCH "msdoscanadianfrench" /* 52 */
#define FC_LANG_HEBREW_862 "hebrew862" /* 53 */
#define FC_LANG_MSDOS_ICELANDIC "msdosicelandic" /* 54 */
#define FC_LANG_MSDOS_PORTUGUESE "msdosportuguese" /* 55 */
#define FC_LANG_IBM_TURKISH "ibmturkish" /* 56 */
#define FC_LANG_IBM_CYRILLIC "ibmcyrillic" /* 57 */
#define FC_LANG_LATIN_2 "latin2" /* 58 */
#define FC_LANG_MSDOS_BALTIC "msdosbaltic" /* 59 */
#define FC_LANG_GREEK_437_G "greek437g" /* 60 */
#define FC_LANG_ARABIC_ASMO_708 "arabicasmo708" /* 61 */
#define FC_LANG_WE_LATIN_1 "welatin1" /* 62 */
#define FC_LANG_US "us" /* 63 */
typedef enum _FcType {
FcTypeVoid,
FcTypeInteger,
FcTypeDouble,
FcTypeString,
FcTypeBool,
FcTypeMatrix,
FcTypeCharSet
} FcType;
typedef struct _FcMatrix {
double xx, xy, yx, yy;
} FcMatrix;
#define FcMatrixInit(m) ((m)->xx = (m)->yy = 1, \
(m)->xy = (m)->yx = 0)
/*
* A data structure to represent the available glyphs in a font.
* This is represented as a sparse boolean btree.
*/
typedef struct _FcCharSet FcCharSet;
typedef struct _FcObjectType {
const char *object;
FcType type;
} FcObjectType;
typedef struct _FcConstant {
const FcChar8 *name;
const char *object;
int value;
} FcConstant;
typedef enum _FcResult {
FcResultMatch, FcResultNoMatch, FcResultTypeMismatch, FcResultNoId
} FcResult;
typedef struct _FcValue {
FcType type;
union {
const FcChar8 *s;
int i;
FcBool b;
double d;
const FcMatrix *m;
const FcCharSet *c;
} u;
} FcValue;
typedef struct _FcPattern FcPattern;
typedef struct _FcFontSet {
int nfont;
int sfont;
FcPattern **fonts;
} FcFontSet;
typedef struct _FcObjectSet {
int nobject;
int sobject;
const char **objects;
} FcObjectSet;
typedef enum _FcMatchKind {
FcMatchPattern, FcMatchFont
} FcMatchKind;
typedef enum _FcSetName {
FcSetSystem = 0,
FcSetApplication = 1
} FcSetName;
typedef struct _FcAtomic FcAtomic;
#if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */
#define _FCFUNCPROTOBEGIN extern "C" { /* do not leave open across includes */
#define _FCFUNCPROTOEND }
#else
#define _FCFUNCPROTOBEGIN
#define _FCFUNCPROTOEND
#endif
typedef struct _FcConfig FcConfig;
typedef struct _FcFileCache FcFileCache;
typedef struct _FcBlanks FcBlanks;
_FCFUNCPROTOBEGIN
/* fcblanks.c */
FcBlanks *
FcBlanksCreate (void);
void
FcBlanksDestroy (FcBlanks *b);
FcBool
FcBlanksAdd (FcBlanks *b, FcChar32 ucs4);
FcBool
FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4);
/* fccfg.c */
FcChar8 *
FcConfigFilename (const FcChar8 *url);
FcConfig *
FcConfigCreate (void);
void
FcConfigDestroy (FcConfig *config);
FcBool
FcConfigSetCurrent (FcConfig *config);
FcConfig *
FcConfigGetCurrent (void);
FcBool
FcConfigBuildFonts (FcConfig *config);
FcChar8 **
FcConfigGetDirs (FcConfig *config);
FcChar8 **
FcConfigGetConfigFiles (FcConfig *config);
FcChar8 *
FcConfigGetCache (FcConfig *config);
FcBlanks *
FcConfigGetBlanks (FcConfig *config);
FcFontSet *
FcConfigGetFonts (FcConfig *config,
FcSetName set);
FcBool
FcConfigAppFontAddFile (FcConfig *config,
const FcChar8 *file);
FcBool
FcConfigAppFontAddDir (FcConfig *config,
const FcChar8 *dir);
void
FcConfigAppFontClear (FcConfig *config);
FcBool
FcConfigSubstitute (FcConfig *config,
FcPattern *p,
FcMatchKind kind);
/* fccharset.c */
FcCharSet *
FcCharSetCreate (void);
void
FcCharSetDestroy (FcCharSet *fcs);
FcBool
FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4);
FcCharSet *
FcCharSetCopy (FcCharSet *src);
FcBool
FcCharSetEqual (const FcCharSet *a, const FcCharSet *b);
FcCharSet *
FcCharSetIntersect (const FcCharSet *a, const FcCharSet *b);
FcCharSet *
FcCharSetUnion (const FcCharSet *a, const FcCharSet *b);
FcCharSet *
FcCharSetSubtract (const FcCharSet *a, const FcCharSet *b);
FcBool
FcCharSetHasChar (const FcCharSet *fcs, FcChar32 ucs4);
FcChar32
FcCharSetCount (const FcCharSet *a);
FcChar32
FcCharSetIntersectCount (const FcCharSet *a, const FcCharSet *b);
FcChar32
FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b);
FcChar32
FcCharSetCoverage (const FcCharSet *a, FcChar32 page, FcChar32 *result);
/* fcdbg.c */
void
FcValuePrint (FcValue v);
void
FcPatternPrint (FcPattern *p);
void
FcFontSetPrint (FcFontSet *s);
/* fcdefault.c */
void
FcDefaultSubstitute (FcPattern *pattern);
/* fcdir.c */
FcBool
FcFileScan (FcFontSet *set,
FcFileCache *cache,
FcBlanks *blanks,
const FcChar8 *file,
FcBool force);
FcBool
FcDirScan (FcFontSet *set,
FcFileCache *cache,
FcBlanks *blanks,
const FcChar8 *dir,
FcBool force);
FcBool
FcDirSave (FcFontSet *set, const FcChar8 *dir);
/* fcfreetype.c */
FcPattern *
FcFreeTypeQuery (const FcChar8 *file, int id, FcBlanks *blanks, int *count);
/* fcfs.c */
FcFontSet *
FcFontSetCreate (void);
void
FcFontSetDestroy (FcFontSet *s);
FcBool
FcFontSetAdd (FcFontSet *s, FcPattern *font);
/* fcinit.c */
FcBool
FcInitFonts (void);
FcBool
FcInitConfig (void);
FcBool
FcInit (void);
/* fclist.c */
FcObjectSet *
FcObjectSetCreate (void);
FcBool
FcObjectSetAdd (FcObjectSet *os, const char *object);
void
FcObjectSetDestroy (FcObjectSet *os);
FcObjectSet *
FcObjectSetVaBuild (const char *first, va_list va);
FcObjectSet *
FcObjectSetBuild (const char *first, ...);
FcFontSet *
FcFontSetList (FcConfig *config,
FcFontSet **sets,
int nsets,
FcPattern *p,
FcObjectSet *os);
FcFontSet *
FcFontList (FcConfig *config,
FcPattern *p,
FcObjectSet *os);
/* fcatomic.c */
FcAtomic *
FcAtomicCreate (const FcChar8 *file);
FcBool
FcAtomicLock (FcAtomic *atomic);
FcChar8 *
FcAtomicNewFile (FcAtomic *atomic);
FcChar8 *
FcAtomicOrigFile (FcAtomic *atomic);
FcBool
FcAtomicReplaceOrig (FcAtomic *atomic);
void
FcAtomicDeleteNew (FcAtomic *atomic);
void
FcAtomicUnlock (FcAtomic *atomic);
void
FcAtomicDestroy (FcAtomic *atomic);
/* fcmatch.c */
FcPattern *
FcFontSetMatch (FcConfig *config,
FcFontSet **sets,
int nsets,
FcPattern *p,
FcResult *result);
FcPattern *
FcFontMatch (FcConfig *config,
FcPattern *p,
FcResult *result);
FcPattern *
FcFontRenderPrepare (FcConfig *config,
FcPattern *pat,
FcPattern *font);
FcFontSet *
FcFontSetSort (FcConfig *config,
FcFontSet **sets,
int nsets,
FcPattern *p,
FcBool trim,
FcCharSet **csp,
FcResult *result);
/* fcmatrix.c */
FcMatrix *
FcMatrixCopy (const FcMatrix *mat);
FcBool
FcMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2);
void
FcMatrixMultiply (FcMatrix *result, const FcMatrix *a, const FcMatrix *b);
void
FcMatrixRotate (FcMatrix *m, double c, double s);
void
FcMatrixScale (FcMatrix *m, double sx, double sy);
void
FcMatrixShear (FcMatrix *m, double sh, double sv);
/* fcname.c */
FcBool
FcNameRegisterObjectTypes (const FcObjectType *types, int ntype);
FcBool
FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype);
const FcObjectType *
FcNameGetObjectType (const char *object);
FcBool
FcNameRegisterConstants (const FcConstant *consts, int nconsts);
FcBool
FcNameUnregisterConstants (const FcConstant *consts, int nconsts);
const FcConstant *
FcNameGetConstant (FcChar8 *string);
FcBool
FcNameConstant (FcChar8 *string, int *result);
FcPattern *
FcNameParse (const FcChar8 *name);
FcChar8 *
FcNameUnparse (FcPattern *pat);
/* fcpat.c */
FcPattern *
FcPatternCreate (void);
FcPattern *
FcPatternDuplicate (FcPattern *p);
void
FcValueDestroy (FcValue v);
FcValue
FcValueSave (FcValue v);
void
FcPatternDestroy (FcPattern *p);
FcBool
FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append);
FcResult
FcPatternGet (FcPattern *p, const char *object, int id, FcValue *v);
FcBool
FcPatternDel (FcPattern *p, const char *object);
FcBool
FcPatternAddInteger (FcPattern *p, const char *object, int i);
FcBool
FcPatternAddDouble (FcPattern *p, const char *object, double d);
FcBool
FcPatternAddString (FcPattern *p, const char *object, const FcChar8 *s);
FcBool
FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s);
FcBool
FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c);
FcBool
FcPatternAddBool (FcPattern *p, const char *object, FcBool b);
FcResult
FcPatternGetInteger (FcPattern *p, const char *object, int n, int *i);
FcResult
FcPatternGetDouble (FcPattern *p, const char *object, int n, double *d);
FcResult
FcPatternGetString (FcPattern *p, const char *object, int n, FcChar8 ** s);
FcResult
FcPatternGetMatrix (FcPattern *p, const char *object, int n, FcMatrix **s);
FcResult
FcPatternGetCharSet (FcPattern *p, const char *object, int n, FcCharSet **c);
FcResult
FcPatternGetBool (FcPattern *p, const char *object, int n, FcBool *b);
FcPattern *
FcPatternVaBuild (FcPattern *orig, va_list va);
FcPattern *
FcPatternBuild (FcPattern *orig, ...);
/* fcstr.c */
FcChar8 *
FcStrCopy (const FcChar8 *s);
#define FcToLower(c) (('A' <= (c) && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
int
FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
int
FcUtf8ToUcs4 (FcChar8 *src_orig,
FcChar32 *dst,
int len);
FcBool
FcUtf8Len (FcChar8 *string,
int len,
int *nchar,
int *wchar);
/* fcxml.c */
FcBool
FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain);
_FCFUNCPROTOEND
#endif /* _FONTCONFIG_H_ */

View File

@ -1,191 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts.conf file to configure system font access -->
<fontconfig>
<!-- FONTPATH_START -->
<!--
Common X11R6 font directories
-->
<dir>/usr/X11R6/lib/X11/fonts/truetype</dir>
<dir>/usr/X11R6/lib/X11/fonts/Type1</dir>
<dir>/usr/X11R6/lib/X11/fonts/TrueType</dir>
<!-- FONTPATH_END -->
<!--
Accept deprecated 'mono' alias, replacing it with 'monospace'
-->
<match target="pattern">
<test qual="any" name="family">
<string>mono</string>
</test>
<edit name="family" mode="assign">
<string>monospace</string>
</edit>
</match>
<!--
Accept deprecated 'sans' alias, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans</string>
</test>
<edit name="family" mode="assign">
<string>sans-serif</string>
</edit>
</match>
<!--
Mark common families with their generics so we'll get
something reasonable
-->
<!--
Serif faces
-->
<alias>
<family>Times</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>Times New Roman</family>
<default><family>serif</family></default>
</alias>
<!--
Sans-serif faces
-->
<alias>
<family>Helvetica</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Arial</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Verdana</family>
<default><family>sans-serif</family></default>
</alias>
<!--
Monospace faces
-->
<alias>
<family>Courier</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Courier New</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Andale Mono</family>
<default><family>monospace</family></default>
</alias>
<!--
If the font still has no generic name, add sans-serif
-->
<match target="pattern">
<test qual="all" name="family" compare="not_eq">
<string>sans-serif</string>
</test>
<test qual="all" name="family" compare="not_eq">
<string>serif</string>
</test>
<test qual="all" name="family" compare="not_eq">
<string>monospace</string>
</test>
<edit name="family" mode="append_last">
<string>sans-serif</string>
</edit>
</match>
<!--
Load per-user customization file
-->
<include ignore_missing="yes">~/.fonts.conf</include>
<!--
Alias well known font names to available TrueType fonts
-->
<alias>
<family>Times</family>
<prefer><family>Times New Roman</family></prefer>
<default><family>serif</family></default>
</alias>
<alias>
<family>Helvetica</family>
<prefer><family>Verdana</family></prefer>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Arial</family>
<prefer><family>Verdana</family></prefer>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Courier</family>
<prefer><family>Courier New</family></prefer>
<default><family>monospace</family></default>
</alias>
<!--
Provide required aliases for standard names
-->
<alias>
<family>serif</family>
<prefer>
<family>Times New Roman</family>
<family>Nimbus Roman No9 L</family>
<family>Luxi Serif</family>
<family>Times</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>Verdana</family>
<family>Nimbus Sans L</family>
<family>Luxi Sans</family>
<family>Arial</family>
<family>Helvetica</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Andale Mono</family>
<family>Courier New</family>
<family>Nimbus Mono L</family>
<family>Luxi Mono</family>
</prefer>
</alias>
<!--
These are the default Unicode chars that are expected to be blank
in fonts. All other blank chars are assumed to be broken and
won't appear in the resulting charsets
-->
<config><blank>
<int>0x20</int> <!-- space -->
<int>0xa0</int> <!-- nsbp -->
<int>0x2000</int> <!-- general punctuation spaces -->
<int>0x2001</int>
<int>0x2002</int>
<int>0x2003</int>
<int>0x2004</int>
<int>0x2005</int>
<int>0x2005</int>
<int>0x2006</int>
<int>0x2007</int>
<int>0x2008</int>
<int>0x2009</int>
<int>0x200a</int>
<int>0x200b</int>
<int>0x3000</int> <!-- CJK space -->
</blank></config>
</fontconfig>

View File

@ -1,165 +0,0 @@
<!-- This is the Document Type Definition for font configuration files -->
<!ELEMENT fontconfig (dir |
cache |
include |
config |
match |
alias)* >
<!--
Add a directory that provides fonts
-->
<!ELEMENT dir (#PCDATA)>
<!ATTLIST dir xml:space (default|preserve) 'preserve'>
<!--
Define the per-user file that holds cache font information.
If the filename begins with '~', it is replaced with the users
home directory path.
-->
<!ELEMENT cache (#PCDATA)>
<!ATTLIST cache xml:space (default|preserve) 'preserve'>
<!--
Reference another configuration file; note that this
is another complete font configuration file and not
just a file included by the XML parser.
Set 'ignore_missing' to 'yes' if errors are to be ignored.
If the filename begins with '~', it is replaced with the users
home directory path.
-->
<!ELEMENT include (#PCDATA)>
<!ATTLIST include
ignore_missing (no|yes) "no"
xml:space (default|preserve) "preserve">
<!--
Global library configuration data
-->
<!ELEMENT config (blanks)*>
<!--
Specify the set of Unicode encoding values which
represent glyphs that are allowed to contain no
data. With this list, fontconfig can examine
fonts for broken glyphs and eliminate them from
the set of valid Unicode chars. This idea
was borrowed from Mozilla
-->
<!ELEMENT blanks (int)*>
<!--
Aliases are just a special case for multiple match elements
They are syntactically equivalent to:
<match>
<test name="family">
<string value=[family]/>
</test>
<edit name="family" mode="prepend">
<string value=[prefer]/>
...
</edit>
<edit name="family" mode="append">
<string value=[accept]/>
...
</edit>
<edit name="family" mode="append_last">
<string value=[default]/>
...
</edit>
</match>
-->
<!ELEMENT alias (family, prefer?, accept?, default?)>
<!ELEMENT prefer (family)*>
<!ELEMENT accept (family)*>
<!ELEMENT default (family)*>
<!ELEMENT family (#PCDATA)>
<!ATTLIST family xml:space (default|preserve) 'preserve'>
<!ENTITY % expr 'int|double|string|matrix|bool|charset
|name|const
|or|and|eq|not_eq|less|less_eq|more|more_eq
|plus|minus|times|divide|not|if'>
<!--
Match and edit patterns.
If 'target' is 'pattern', execute the match before selecting a font.
if 'target' is 'font', execute the match on the result of a font
selection.
-->
<!ELEMENT match (test*, edit*)>
<!ATTLIST match
target (pattern|font) "pattern">
<!--
Match a field in a pattern
if 'qual' is 'any', then the match succeeds if any value in the field matches.
if 'qual' is 'all', then the match succeeds only if all values match.
-->
<!ELEMENT test (%expr;)>
<!ATTLIST test
qual (any|all) "any"
name CDATA #REQUIRED
compare (eq|not_eq|less|less_eq|more|more_eq) "eq">
<!--
Edit a field in a pattern
The enclosed values are used together to edit the list of values
associated with 'name'.
If 'name' matches one of those used in a test element for this match element:
if 'mode' is 'assign', replace the matched value.
if 'mode' is 'assign_replace', replace all of the values
if 'mode' is 'prepend', insert before the matched value
if 'mode' is 'append', insert after the matched value
if 'mode' is 'prepend_first', insert before all of the values
if 'mode' is 'append_last', insert after all of the values
If 'name' doesn't match any of those used in a test element:
if 'mode' is 'assign' or 'assign_replace, replace all of the values
if 'mode' is 'prepend' or 'prepend_first', insert before all of the values
if 'mode' is 'append' or 'append_last', insert after all of the values
-->
<!ELEMENT edit (%expr;)*>
<!ATTLIST edit
name CDATA #REQUIRED
mode (assign|assign_replace|prepend|append|prepend_first|append_last) "assign">
<!--
Elements of expressions follow
-->
<!ELEMENT int (#PCDATA)>
<!ATTLIST int xml:space (default|preserve) 'preserve'>
<!ELEMENT double (#PCDATA)>
<!ATTLIST double xml:space (default|preserve) 'preserve'>
<!ELEMENT string (#PCDATA)>
<!ATTLIST string xml:space (default|preserve) 'preserve'>
<!ELEMENT matrix (double,double,double,double)>
<!ELEMENT bool (true|false)>
<!ELEMENT charset (#PCDATA)>
<!ATTLIST charset xml:space (default|preserve) 'preserve'>
<!ELEMENT name (#PCDATA)>
<!ATTLIST name xml:space (default|preserve) 'preserve'>
<!ELEMENT const (#PCDATA)>
<!ATTLIST const xml:space (default|preserve) 'preserve'>
<!ELEMENT or (%expr;)*>
<!ELEMENT and (%expr;)*>
<!ELEMENT eq ((%expr;), (%expr;))>
<!ELEMENT not_eq ((%expr;), (%expr;))>
<!ELEMENT less ((%expr;), (%expr;))>
<!ELEMENT less_eq ((%expr;), (%expr;))>
<!ELEMENT more ((%expr;), (%expr;))>
<!ELEMENT more_eq ((%expr;), (%expr;))>
<!ELEMENT plus (%expr;)*>
<!ELEMENT minus (%expr;)*>
<!ELEMENT times (%expr;)*>
<!ELEMENT divide (%expr;)*>
<!ELEMENT not (%expr;)>
<!ELEMENT if ((%expr;), (%expr;), (%expr;))>

View File

@ -1,19 +0,0 @@
#!/bin/sh
FONTDIRS=fontdirs$$
trap "rm $FONTDIRS" 0
sh ./findfonts > $FONTDIRS
cp fonts.conf.in fonts.conf
chmod +w fonts.conf
ed fonts.conf << EOF
/FONTPATH_END/a
<!-- Font directories found on `date` -->
.
+r $FONTDIRS
a
.
/FONTPATH_START/,/FONTPATH_END/d
w
q
EOF

View File

@ -1,48 +0,0 @@
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = fontconfig
LIBRARY_NAME = fontconfig
EXPORT_LIBRARY = 1
REQUIRES = \
freetype2 \
fontconfig \
expat
CSRCS = \
fcatomic.c \
fcavl.c \
fcblanks.c \
fccache.c \
fccfg.c \
fccharset.c \
fcdbg.c \
fcdefault.c \
fcdir.c \
fcfreetype.c \
fcfs.c \
fcinit.c \
fclist.c \
fcmatch.c \
fcmatrix.c \
fcname.c \
fcpat.c \
fcstr.c \
fcxml.c
# make it a static lib only
FORCE_STATIC_LIB=1
include $(topsrcdir)/config/rules.mk
DEFINES +=-DFC_FALLBACK_FONTS=\"/usr/X11R6/lib/X11/fonts/Type1\"
ifdef MOZ_XFT_SYSTEM_FREETYPE2
CFLAGS += $(FT2_CFLAGS)
endif

View File

@ -1,183 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcatomic.c,v 1.2 2002/03/04 21:15:28 tsi Exp $
*
* 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
* 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.
*/
/*
* fcatomic.c
*
* Lock cache and configuration files for atomic update
*
* Uses only regular filesystem calls so it should
* work even in the absense of functioning file locking
*
* Four files:
* file - the data file accessed by other apps.
* new - a new version of the data file while it's being written
* lck - the lock file
* tmp - a temporary file made unique with mkstemp
*
* Here's how it works:
* Create 'tmp' and store our PID in it
* Attempt to link it to 'lck'
* Unlink 'tmp'
* If the link succeeded, the lock is held
*/
#include "fcint.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#define NEW_NAME ".NEW"
#define LCK_NAME ".LCK"
#define TMP_NAME ".TMP-XXXXXX"
FcAtomic *
FcAtomicCreate (const FcChar8 *file)
{
int file_len = strlen ((char *) file);
int new_len = file_len + sizeof (NEW_NAME);
int lck_len = file_len + sizeof (LCK_NAME);
int tmp_len = file_len + sizeof (TMP_NAME);
int total_len = (sizeof (FcAtomic) +
file_len + 1 +
new_len + 1 +
lck_len + 1 +
tmp_len + 1);
FcAtomic *atomic = malloc (total_len);
if (!atomic)
return 0;
atomic->file = (FcChar8 *) (atomic + 1);
strcpy ((char *) atomic->file, (char *) file);
atomic->new = atomic->file + file_len + 1;
strcpy ((char *) atomic->new, (char *) file);
strcat ((char *) atomic->new, NEW_NAME);
atomic->lck = atomic->new + new_len + 1;
strcpy ((char *) atomic->lck, (char *) file);
strcat ((char *) atomic->lck, LCK_NAME);
atomic->tmp = atomic->lck + lck_len + 1;
return atomic;
}
FcBool
FcAtomicLock (FcAtomic *atomic)
{
int fd = -1;
FILE *f = 0;
int ret;
struct stat lck_stat;
strcpy ((char *) atomic->tmp, (char *) atomic->file);
strcat ((char *) atomic->tmp, TMP_NAME);
fd = mkstemp ((char *) atomic->tmp);
if (fd < 0)
return FcFalse;
f = fdopen (fd, "w");
if (!f)
{
close (fd);
unlink ((char *) atomic->tmp);
return FcFalse;
}
ret = fprintf (f, "%ld\n", (long)getpid());
if (ret <= 0)
{
fclose (f);
unlink ((char *) atomic->tmp);
return FcFalse;
}
if (fclose (f) == EOF)
{
unlink ((char *) atomic->tmp);
return FcFalse;
}
ret = link ((char *) atomic->tmp, (char *) atomic->lck);
(void) unlink ((char *) atomic->tmp);
if (ret < 0)
{
/*
* If the file is around and old (> 10 minutes),
* assume the lock is stale. This assumes that any
* machines sharing the same filesystem will have clocks
* reasonably close to each other.
*/
if (stat ((char *) atomic->lck, &lck_stat) >= 0)
{
time_t now = time (0);
if ((long int) (now - lck_stat.st_mtime) > 10 * 60)
{
if (unlink ((char *) atomic->lck) == 0)
return FcAtomicLock (atomic);
}
}
return FcFalse;
}
(void) unlink ((char *) atomic->new);
return FcTrue;
}
FcChar8 *
FcAtomicNewFile (FcAtomic *atomic)
{
return atomic->new;
}
FcChar8 *
FcAtomicOrigFile (FcAtomic *atomic)
{
return atomic->file;
}
FcBool
FcAtomicReplaceOrig (FcAtomic *atomic)
{
if (rename ((char *) atomic->new, (char *) atomic->file) < 0)
return FcFalse;
return FcTrue;
}
void
FcAtomicDeleteNew (FcAtomic *atomic)
{
unlink ((char *) atomic->new);
}
void
FcAtomicUnlock (FcAtomic *atomic)
{
unlink ((char *) atomic->lck);
}
void
FcAtomicDestroy (FcAtomic *atomic)
{
free (atomic);
}

View File

@ -1,419 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcavl.c,v 1.1 2002/03/03 18:39:05 keithp Exp $
*
* 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
* 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.
*/
/*
* Semi-Balanced trees (avl). This only contains two
* routines - insert and delete. Searching is
* reserved for the client to write.
*/
#include "fcint.h"
#include "fcavl.h"
static FcBool
FcAvlRebalanceRight (FcAvlNode **);
static FcBool
FcAvlRebalanceLeft (FcAvlNode **);
/*
* insert a new node
*
* this routine returns FcTrue if the tree has grown
* taller
*/
FcBool
FcAvlInsert (FcAvlMore more, FcAvlNode **treep, FcAvlNode *new)
{
if (!(*treep))
{
new->left = 0;
new->right = 0;
new->balance = 0;
*treep = new;
return FcTrue;
}
else
{
if ((*more) (new, *treep))
{
if (FcAvlInsert (more, &(*treep)->right, new))
switch (++(*treep)->balance) {
case 0:
return FcFalse;
case 1:
return FcTrue;
case 2:
(void) FcAvlRebalanceRight (treep);
}
}
else
{
if (FcAvlInsert (more, &(*treep)->left, new))
switch (--(*treep)->balance) {
case 0:
return FcFalse;
case -1:
return FcTrue;
case -2:
(void) FcAvlRebalanceLeft (treep);
}
}
}
return 0;
}
/*
* delete a node from a tree
*
* this routine return FcTrue if the tree has been shortened
*/
FcBool
FcAvlDelete (FcAvlMore more, FcAvlNode **treep, FcAvlNode *old)
{
if (!*treep)
return FcFalse; /* node not found */
if (old == *treep)
{
FcAvlNode *replacement;
FcAvlNode *replacement_parent;
int replacement_direction;
int delete_direction;
FcAvlNode *swap_temp;
int balance_temp;
/*
* find an empty down pointer (if any)
* and rehook the tree
*/
if (!old->right) {
(*treep) = old->left;
return FcTrue;
} else if (!old->left) {
(*treep) = old->right;
return FcTrue;
} else {
/*
* if both down pointers are full, then
* move a node from the bottom of the tree up here.
*
* This builds an incorrect tree -- the replacement
* node and the old node will not
* be in correct order. This doesn't matter as
* the old node will obviously not leave
* this routine alive.
*/
/*
* if the tree is left heavy, then go left
* else go right
*/
replacement_parent = old;
if (old->balance == -1) {
delete_direction = -1;
replacement_direction = -1;
replacement = old->left;
while (replacement->right) {
replacement_parent = replacement;
replacement_direction = 1;
replacement = replacement->right;
}
} else {
delete_direction = 1;
replacement_direction = 1;
replacement = old->right;
while (replacement->left) {
replacement_parent = replacement;
replacement_direction = -1;
replacement = replacement->left;
}
}
/*
* swap the replacement node into
* the tree where the node is to be removed
*
* this would be faster if only the data
* element was swapped -- but that
* won't work for kalypso. The alternate
* code would be:
data_temp = old->data;
to _be_deleted->data = replacement->data;
replacement->data = data_temp;
*/
swap_temp = old->left;
old->left = replacement->left;
replacement->left = swap_temp;
swap_temp = old->right;
old->right = replacement->right;
replacement->right = swap_temp;
balance_temp = old->balance;
old->balance = replacement->balance;
replacement->balance = balance_temp;
/*
* if the replacement node is directly below
* the to-be-removed node, hook the old
* node below it (instead of below itself!)
*/
if (replacement_parent == old)
replacement_parent = replacement;
if (replacement_direction == -1)
replacement_parent->left = old;
else
replacement_parent->right = old;
(*treep) = replacement;
/*
* delete the node from the sub-tree
*/
if (delete_direction == -1)
{
if (FcAvlDelete (more, &(*treep)->left, old))
{
switch (++(*treep)->balance) {
case 2:
abort ();
case 1:
return FcFalse;
case 0:
return FcTrue;
}
}
return 0;
}
else
{
if (FcAvlDelete (more, &(*treep)->right, old))
{
switch (--(*treep)->balance) {
case -2:
abort ();
case -1:
return FcFalse;
case 0:
return FcTrue;
}
}
return 0;
}
}
}
else if ((*more) (old, *treep))
{
if (FcAvlDelete (more, &(*treep)->right, old))
{
/*
* check the balance factors
* Note that the conditions are
* inverted from the insertion case
*/
switch (--(*treep)->balance) {
case 0:
return FcFalse;
case -1:
return FcTrue;
case -2:
return FcAvlRebalanceLeft (treep);
}
}
return 0;
}
else
{
if (FcAvlDelete (more, &(*treep)->left, old))
{
switch (++(*treep)->balance) {
case 0:
return FcTrue;
case 1:
return FcFalse;
case 2:
return FcAvlRebalanceRight (treep);
}
}
return 0;
}
/*NOTREACHED*/
}
/*
* two routines to rebalance the tree.
*
* rebalance_right -- the right sub-tree is too long
* rebalance_left -- the left sub-tree is too long
*
* These routines are the heart of avl trees, I've tried
* to make their operation reasonably clear with comments,
* but some study will be necessary to understand the
* algorithm.
*
* these routines return FcTrue if the resultant
* tree is shorter than the un-balanced version. This
* is only of interest to the delete routine as the
* balance after insertion can never actually shorten
* the tree.
*/
static FcBool
FcAvlRebalanceRight (FcAvlNode **treep)
{
FcAvlNode *temp;
/*
* rebalance the tree
*/
if ((*treep)->right->balance == -1) {
/*
* double whammy -- the inner sub-sub tree
* is longer than the outer sub-sub tree
*
* this is the "double rotation" from
* knuth. Scheme: replace the tree top node
* with the inner sub-tree top node and
* adjust the maze of pointers and balance
* factors accordingly.
*/
temp = (*treep)->right->left;
(*treep)->right->left = temp->right;
temp->right = (*treep)->right;
switch (temp->balance) {
case -1:
temp->right->balance = 1;
(*treep)->balance = 0;
break;
case 0:
temp->right->balance = 0;
(*treep)->balance = 0;
break;
case 1:
temp->right->balance = 0;
(*treep)->balance = -1;
break;
}
temp->balance = 0;
(*treep)->right = temp->left;
temp->left = (*treep);
(*treep) = temp;
return FcTrue;
} else {
/*
* a simple single rotation
*
* Scheme: replace the tree top node
* with the sub-tree top node
*/
temp = (*treep)->right->left;
(*treep)->right->left = (*treep);
(*treep) = (*treep)->right;
(*treep)->left->right = temp;
/*
* only two possible configurations --
* if the right sub-tree was balanced, then
* *both* sides of it were longer than the
* left side, so the resultant tree will
* have a long leg (the left inner leg being
* the same length as the right leg)
*/
if ((*treep)->balance == 0) {
(*treep)->balance = -1;
(*treep)->left->balance = 1;
return FcFalse;
} else {
(*treep)->balance = 0;
(*treep)->left->balance = 0;
return FcTrue;
}
}
}
static FcBool
FcAvlRebalanceLeft (FcAvlNode **treep)
{
FcAvlNode *temp;
/*
* rebalance the tree
*/
if ((*treep)->left->balance == 1) {
/*
* double whammy -- the inner sub-sub tree
* is longer than the outer sub-sub tree
*
* this is the "double rotation" from
* knuth. Scheme: replace the tree top node
* with the inner sub-tree top node and
* adjust the maze of pointers and balance
* factors accordingly.
*/
temp = (*treep)->left->right;
(*treep)->left->right = temp->left;
temp->left = (*treep)->left;
switch (temp->balance) {
case 1:
temp->left->balance = -1;
(*treep)->balance = 0;
break;
case 0:
temp->left->balance = 0;
(*treep)->balance = 0;
break;
case -1:
temp->left->balance = 0;
(*treep)->balance = 1;
break;
}
temp->balance = 0;
(*treep)->left = temp->right;
temp->right = (*treep);
(*treep) = temp;
return FcTrue;
} else {
/*
* a simple single rotation
*
* Scheme: replace the tree top node
* with the sub-tree top node
*/
temp = (*treep)->left->right;
(*treep)->left->right = (*treep);
(*treep) = (*treep)->left;
(*treep)->right->left = temp;
/*
* only two possible configurations --
* if the left sub-tree was balanced, then
* *both* sides of it were longer than the
* right side, so the resultant tree will
* have a long leg (the right inner leg being
* the same length as the left leg)
*/
if ((*treep)->balance == 0) {
(*treep)->balance = 1;
(*treep)->right->balance = -1;
return FcTrue;
} else {
(*treep)->balance = 0;
(*treep)->right->balance = 0;
return FcFalse;
}
}
}

View File

@ -1,46 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcavl.h,v 1.1 2002/03/03 18:39:05 keithp Exp $
*
* 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
* 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.
*/
#ifndef _FCAVL_H_
#define _FCAVL_H_
/*
* fcavl.h
*
* balanced binary tree
*/
typedef struct _FcAvlNode FcAvlNode;
struct _FcAvlNode {
FcAvlNode *left, *right;
short balance;
};
typedef FcBool (*FcAvlMore) (FcAvlNode *a, FcAvlNode *b);
FcBool FcAvlInsert (FcAvlMore more, FcAvlNode **tree, FcAvlNode *leaf);
int FcAvlDelete (FcAvlMore more, FcAvlNode **tree, FcAvlNode *leaf);
#endif /* _FCAVL_H_ */

View File

@ -1,84 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcblanks.c,v 1.1.1.1 2002/02/14 23:34:13 keithp Exp $
*
* 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
* 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.
*/
#include "fcint.h"
FcBlanks *
FcBlanksCreate (void)
{
FcBlanks *b;
b = malloc (sizeof (FcBlanks));
if (!b)
return 0;
b->nblank = 0;
b->sblank = 0;
b->blanks = 0;
return b;
}
void
FcBlanksDestroy (FcBlanks *b)
{
if (b->blanks)
free (b->blanks);
free (b);
}
FcBool
FcBlanksAdd (FcBlanks *b, FcChar32 ucs4)
{
FcChar32 *c;
int sblank;
for (sblank = 0; sblank < b->nblank; sblank++)
if (b->blanks[sblank] == ucs4)
return FcTrue;
if (b->nblank == b->sblank)
{
sblank = b->sblank + 32;
if (b->blanks)
c = (FcChar32 *) realloc (b->blanks, sblank * sizeof (FcChar32));
else
c = (FcChar32 *) malloc (sblank * sizeof (FcChar32));
if (!c)
return FcFalse;
b->sblank = sblank;
b->blanks = c;
}
b->blanks[b->nblank++] = ucs4;
return FcTrue;
}
FcBool
FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4)
{
int i;
for (i = 0; i < b->nblank; i++)
if (b->blanks[i] == ucs4)
return FcTrue;
return FcFalse;
}

View File

@ -1,633 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fccache.c,v 1.6 2002/03/03 00:19:43 keithp Exp $
*
* 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
* 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.
*/
#include "fcint.h"
static unsigned int
FcFileCacheHash (const FcChar8 *string)
{
unsigned int h = 0;
FcChar8 c;
while ((c = *string++))
h = (h << 1) ^ c;
return h;
}
FcChar8 *
FcFileCacheFind (FcFileCache *cache,
const FcChar8 *file,
int id,
int *count)
{
unsigned int hash;
const FcChar8 *match;
FcFileCacheEnt *c, *name;
int maxid;
struct stat statb;
match = file;
hash = FcFileCacheHash (match);
name = 0;
maxid = -1;
for (c = cache->ents[hash % FC_FILE_CACHE_HASH_SIZE]; c; c = c->next)
{
if (c->hash == hash && !strcmp ((const char *) match, (const char *) c->file))
{
if (c->id > maxid)
maxid = c->id;
if (c->id == id)
{
if (stat ((char *) file, &statb) < 0)
{
if (FcDebug () & FC_DBG_CACHE)
printf (" file missing\n");
return 0;
}
if (statb.st_mtime != c->time)
{
if (FcDebug () & FC_DBG_CACHE)
printf (" timestamp mismatch (was %d is %d)\n",
(int) c->time, (int) statb.st_mtime);
return 0;
}
if (!c->referenced)
{
cache->referenced++;
c->referenced = FcTrue;
}
name = c;
}
}
}
if (!name)
return 0;
*count = maxid + 1;
return name->name;
}
/*
* Cache file syntax is quite simple:
*
* "file_name" id time "font_name" \n
*/
static FcChar8 *
FcFileCacheReadString (FILE *f, FcChar8 *dest, int len)
{
int c;
FcBool escape;
FcChar8 *d;
int size;
int i;
while ((c = getc (f)) != EOF)
if (c == '"')
break;
if (c == EOF)
return FcFalse;
if (len == 0)
return FcFalse;
size = len;
i = 0;
d = dest;
escape = FcFalse;
while ((c = getc (f)) != EOF)
{
if (!escape)
{
switch (c) {
case '"':
c = '\0';
break;
case '\\':
escape = FcTrue;
continue;
}
}
if (i == size)
{
FcChar8 *new = malloc (size * 2);
if (!new)
break;
memcpy (new, d, size);
size *= 2;
if (d != dest)
free (d);
d = new;
}
d[i++] = c;
if (c == '\0')
return d;
escape = FcFalse;
}
if (d != dest)
free (d);
return 0;
}
static FcBool
FcFileCacheReadUlong (FILE *f, unsigned long *dest)
{
unsigned long t;
int c;
while ((c = getc (f)) != EOF)
{
if (!isspace (c))
break;
}
if (c == EOF)
return FcFalse;
t = 0;
for (;;)
{
if (c == EOF || isspace (c))
break;
if (!isdigit (c))
return FcFalse;
t = t * 10 + (c - '0');
c = getc (f);
}
*dest = t;
return FcTrue;
}
static FcBool
FcFileCacheReadInt (FILE *f, int *dest)
{
unsigned long t;
FcBool ret;
ret = FcFileCacheReadUlong (f, &t);
if (ret)
*dest = (int) t;
return ret;
}
static FcBool
FcFileCacheReadTime (FILE *f, time_t *dest)
{
unsigned long t;
FcBool ret;
ret = FcFileCacheReadUlong (f, &t);
if (ret)
*dest = (time_t) t;
return ret;
}
static FcBool
FcFileCacheAdd (FcFileCache *cache,
const FcChar8 *file,
int id,
time_t time,
const FcChar8 *name,
FcBool replace)
{
FcFileCacheEnt *c;
FcFileCacheEnt **prev, *old;
unsigned int hash;
if (FcDebug () & FC_DBG_CACHE)
{
printf ("%s face %s/%d as %s\n", replace ? "Replace" : "Add",
file, id, name);
}
hash = FcFileCacheHash (file);
for (prev = &cache->ents[hash % FC_FILE_CACHE_HASH_SIZE];
(old = *prev);
prev = &(*prev)->next)
{
if (old->hash == hash && old->id == id && !strcmp ((const char *) old->file,
(const char *) file))
break;
}
if (*prev)
{
if (!replace)
return FcFalse;
old = *prev;
if (old->referenced)
cache->referenced--;
*prev = old->next;
free (old);
cache->entries--;
}
c = malloc (sizeof (FcFileCacheEnt) +
strlen ((char *) file) + 1 +
strlen ((char *) name) + 1);
if (!c)
return FcFalse;
c->next = *prev;
*prev = c;
c->hash = hash;
c->file = (FcChar8 *) (c + 1);
c->id = id;
c->name = c->file + strlen ((char *) file) + 1;
strcpy ((char *) c->file, (const char *) file);
c->time = time;
c->referenced = replace;
strcpy ((char *) c->name, (const char *) name);
cache->entries++;
return FcTrue;
}
FcFileCache *
FcFileCacheCreate (void)
{
FcFileCache *cache;
int h;
cache = malloc (sizeof (FcFileCache));
if (!cache)
return 0;
for (h = 0; h < FC_FILE_CACHE_HASH_SIZE; h++)
cache->ents[h] = 0;
cache->entries = 0;
cache->referenced = 0;
cache->updated = FcFalse;
return cache;
}
void
FcFileCacheDestroy (FcFileCache *cache)
{
FcFileCacheEnt *c, *next;
int h;
for (h = 0; h < FC_FILE_CACHE_HASH_SIZE; h++)
{
for (c = cache->ents[h]; c; c = next)
{
next = c->next;
free (c);
}
}
free (cache);
}
void
FcFileCacheLoad (FcFileCache *cache,
const FcChar8 *cache_file)
{
FILE *f;
FcChar8 file_buf[8192], *file;
int id;
time_t time;
FcChar8 name_buf[8192], *name;
f = fopen ((char *) cache_file, "r");
if (!f)
return;
cache->updated = FcFalse;
file = 0;
name = 0;
while ((file = FcFileCacheReadString (f, file_buf, sizeof (file_buf))) &&
FcFileCacheReadInt (f, &id) &&
FcFileCacheReadTime (f, &time) &&
(name = FcFileCacheReadString (f, name_buf, sizeof (name_buf))))
{
(void) FcFileCacheAdd (cache, file, id, time, name, FcFalse);
if (file != file_buf)
free (file);
if (name != name_buf)
free (name);
file = 0;
name = 0;
}
if (file && file != file_buf)
free (file);
if (name && name != name_buf)
free (name);
fclose (f);
}
FcBool
FcFileCacheUpdate (FcFileCache *cache,
const FcChar8 *file,
int id,
const FcChar8 *name)
{
const FcChar8 *match;
struct stat statb;
FcBool ret;
match = file;
if (stat ((char *) file, &statb) < 0)
return FcFalse;
ret = FcFileCacheAdd (cache, match, id,
statb.st_mtime, name, FcTrue);
if (ret)
cache->updated = FcTrue;
return ret;
}
static FcBool
FcFileCacheWriteString (FILE *f, const FcChar8 *string)
{
char c;
if (putc ('"', f) == EOF)
return FcFalse;
while ((c = *string++))
{
switch (c) {
case '"':
case '\\':
if (putc ('\\', f) == EOF)
return FcFalse;
/* fall through */
default:
if (putc (c, f) == EOF)
return FcFalse;
}
}
if (putc ('"', f) == EOF)
return FcFalse;
return FcTrue;
}
static FcBool
FcFileCacheWriteUlong (FILE *f, unsigned long t)
{
int pow;
unsigned long temp, digit;
temp = t;
pow = 1;
while (temp >= 10)
{
temp /= 10;
pow *= 10;
}
temp = t;
while (pow)
{
digit = temp / pow;
if (putc ((char) digit + '0', f) == EOF)
return FcFalse;
temp = temp - pow * digit;
pow = pow / 10;
}
return FcTrue;
}
static FcBool
FcFileCacheWriteInt (FILE *f, int i)
{
return FcFileCacheWriteUlong (f, (unsigned long) i);
}
static FcBool
FcFileCacheWriteTime (FILE *f, time_t t)
{
return FcFileCacheWriteUlong (f, (unsigned long) t);
}
FcBool
FcFileCacheSave (FcFileCache *cache,
const FcChar8 *cache_file)
{
FILE *f;
int h;
FcFileCacheEnt *c;
FcAtomic *atomic;
if (!cache->updated && cache->referenced == cache->entries)
return FcTrue;
/* Set-UID programs can't safely update the cache */
if (getuid () != geteuid ())
return FcFalse;
atomic = FcAtomicCreate (cache_file);
if (!atomic)
goto bail0;
if (!FcAtomicLock (atomic))
goto bail1;
f = fopen ((char *) FcAtomicNewFile(atomic), "w");
if (!f)
goto bail2;
for (h = 0; h < FC_FILE_CACHE_HASH_SIZE; h++)
{
for (c = cache->ents[h]; c; c = c->next)
{
if (!c->referenced)
continue;
if (!FcFileCacheWriteString (f, c->file))
goto bail4;
if (putc (' ', f) == EOF)
goto bail4;
if (!FcFileCacheWriteInt (f, c->id))
goto bail4;
if (putc (' ', f) == EOF)
goto bail4;
if (!FcFileCacheWriteTime (f, c->time))
goto bail4;
if (putc (' ', f) == EOF)
goto bail4;
if (!FcFileCacheWriteString (f, c->name))
goto bail4;
if (putc ('\n', f) == EOF)
goto bail4;
}
}
if (fclose (f) == EOF)
goto bail3;
if (!FcAtomicReplaceOrig (atomic))
goto bail3;
FcAtomicUnlock (atomic);
FcAtomicDestroy (atomic);
cache->updated = FcFalse;
return FcTrue;
bail4:
fclose (f);
bail3:
FcAtomicDeleteNew (atomic);
bail2:
FcAtomicUnlock (atomic);
bail1:
FcAtomicDestroy (atomic);
bail0:
return FcFalse;
}
FcBool
FcFileCacheReadDir (FcFontSet *set, const FcChar8 *cache_file)
{
FcPattern *font;
FILE *f;
FcChar8 *path;
FcChar8 *base;
FcChar8 file_buf[8192], *file;
int id;
FcChar8 name_buf[8192], *name;
FcBool ret = FcFalse;
if (FcDebug () & FC_DBG_CACHE)
{
printf ("FcFileCacheReadDir cache_file \"%s\"\n", cache_file);
}
f = fopen ((char *) cache_file, "r");
if (!f)
{
if (FcDebug () & FC_DBG_CACHE)
{
printf (" no cache file\n");
}
goto bail0;
}
base = (FcChar8 *) strrchr ((char *) cache_file, '/');
if (!base)
goto bail1;
base++;
path = malloc (base - cache_file + 8192 + 1);
if (!path)
goto bail1;
memcpy (path, cache_file, base - cache_file);
base = path + (base - cache_file);
file = 0;
name = 0;
while ((file = FcFileCacheReadString (f, file_buf, sizeof (file_buf))) &&
FcFileCacheReadInt (f, &id) &&
(name = FcFileCacheReadString (f, name_buf, sizeof (name_buf))))
{
font = FcNameParse (name);
if (font)
{
strcpy ((char *) base, (const char *) file);
if (FcDebug () & FC_DBG_CACHEV)
{
printf (" dir cache file \"%s\"\n", file);
}
FcPatternAddString (font, FC_FILE, path);
if (!FcFontSetAdd (set, font))
goto bail2;
}
if (file != file_buf)
free (file);
if (name != name_buf)
free (name);
file = name = 0;
}
if (FcDebug () & FC_DBG_CACHE)
{
printf (" cache loaded\n");
}
ret = FcTrue;
bail2:
free (path);
if (file && file != file_buf)
free (file);
if (name && name != name_buf)
free (name);
bail1:
fclose (f);
bail0:
return ret;
}
FcBool
FcFileCacheWriteDir (FcFontSet *set, const FcChar8 *cache_file)
{
FcPattern *font;
FILE *f;
FcChar8 *name;
const FcChar8 *file, *base;
int n;
int id;
FcBool ret;
if (FcDebug () & FC_DBG_CACHE)
printf ("FcFileCacheWriteDir cache_file \"%s\"\n", cache_file);
f = fopen ((char *) cache_file, "w");
if (!f)
{
if (FcDebug () & FC_DBG_CACHE)
printf (" can't create \"%s\"\n", cache_file);
goto bail0;
}
for (n = 0; n < set->nfont; n++)
{
font = set->fonts[n];
if (FcPatternGetString (font, FC_FILE, 0, (FcChar8 **) &file) != FcResultMatch)
goto bail1;
base = (FcChar8 *) strrchr ((char *) file, '/');
if (base)
base = base + 1;
else
base = file;
if (FcPatternGetInteger (font, FC_INDEX, 0, &id) != FcResultMatch)
goto bail1;
if (FcDebug () & FC_DBG_CACHEV)
printf (" write file \"%s\"\n", base);
if (!FcFileCacheWriteString (f, base))
goto bail1;
if (putc (' ', f) == EOF)
goto bail1;
if (!FcFileCacheWriteInt (f, id))
goto bail1;
if (putc (' ', f) == EOF)
goto bail1;
name = FcNameUnparse (font);
if (!name)
goto bail1;
ret = FcFileCacheWriteString (f, name);
free (name);
if (!ret)
goto bail1;
if (putc ('\n', f) == EOF)
goto bail1;
}
if (fclose (f) == EOF)
goto bail0;
if (FcDebug () & FC_DBG_CACHE)
printf (" cache written\n");
return FcTrue;
bail1:
fclose (f);
bail0:
unlink ((char *) cache_file);
return FcFalse;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,288 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcdbg.c,v 1.2 2002/02/18 22:29:28 keithp Exp $
*
* 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
* 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include "fcint.h"
void
FcValuePrint (FcValue v)
{
switch (v.type) {
case FcTypeVoid:
printf (" <void>");
break;
case FcTypeInteger:
printf (" %d", v.u.i);
break;
case FcTypeDouble:
printf (" %g", v.u.d);
break;
case FcTypeString:
printf (" \"%s\"", v.u.s);
break;
case FcTypeBool:
printf (" %s", v.u.b ? "FcTrue" : "FcFalse");
break;
case FcTypeMatrix:
printf (" (%f %f; %f %f)", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
break;
case FcTypeCharSet: /* XXX */
printf (" set");
break;
}
}
void
FcValueListPrint (FcValueList *l)
{
for (; l; l = l->next)
FcValuePrint (l->value);
}
void
FcPatternPrint (FcPattern *p)
{
int i;
FcPatternElt *e;
if (!p)
{
printf ("Null pattern\n");
return;
}
printf ("Pattern %d of %d\n", p->num, p->size);
for (i = 0; i < p->num; i++)
{
e = &p->elts[i];
printf ("\t%s:", e->object);
FcValueListPrint (e->values);
printf ("\n");
}
printf ("\n");
}
void
FcOpPrint (FcOp op)
{
switch (op) {
case FcOpInteger: printf ("Integer"); break;
case FcOpDouble: printf ("Double"); break;
case FcOpString: printf ("String"); break;
case FcOpMatrix: printf ("Matrix"); break;
case FcOpBool: printf ("Bool"); break;
case FcOpCharSet: printf ("CharSet"); break;
case FcOpField: printf ("Field"); break;
case FcOpConst: printf ("Const"); break;
case FcOpAssign: printf ("Assign"); break;
case FcOpAssignReplace: printf ("AssignReplace"); break;
case FcOpPrepend: printf ("Prepend"); break;
case FcOpPrependFirst: printf ("PrependFirst"); break;
case FcOpAppend: printf ("Append"); break;
case FcOpAppendLast: printf ("AppendLast"); break;
case FcOpQuest: printf ("Quest"); break;
case FcOpOr: printf ("Or"); break;
case FcOpAnd: printf ("And"); break;
case FcOpEqual: printf ("Equal"); break;
case FcOpContains: printf ("Contains"); break;
case FcOpNotEqual: printf ("NotEqual"); break;
case FcOpLess: printf ("Less"); break;
case FcOpLessEqual: printf ("LessEqual"); break;
case FcOpMore: printf ("More"); break;
case FcOpMoreEqual: printf ("MoreEqual"); break;
case FcOpPlus: printf ("Plus"); break;
case FcOpMinus: printf ("Minus"); break;
case FcOpTimes: printf ("Times"); break;
case FcOpDivide: printf ("Divide"); break;
case FcOpNot: printf ("Not"); break;
case FcOpNil: printf ("Nil"); break;
case FcOpComma: printf ("Comma"); break;
case FcOpInvalid: printf ("Invalid"); break;
}
}
void
FcExprPrint (FcExpr *expr)
{
switch (expr->op) {
case FcOpInteger: printf ("%d", expr->u.ival); break;
case FcOpDouble: printf ("%g", expr->u.dval); break;
case FcOpString: printf ("\"%s\"", expr->u.sval); break;
case FcOpMatrix: printf ("[%g %g %g %g]",
expr->u.mval->xx,
expr->u.mval->xy,
expr->u.mval->yx,
expr->u.mval->yy);
case FcOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break;
case FcOpCharSet: printf ("charset\n"); break;
case FcOpNil: printf ("nil\n");
case FcOpField: printf ("%s", expr->u.field); break;
case FcOpConst: printf ("%s", expr->u.constant); break;
case FcOpQuest:
FcExprPrint (expr->u.tree.left);
printf (" quest ");
FcExprPrint (expr->u.tree.right->u.tree.left);
printf (" colon ");
FcExprPrint (expr->u.tree.right->u.tree.right);
break;
case FcOpAssign:
case FcOpAssignReplace:
case FcOpPrependFirst:
case FcOpPrepend:
case FcOpAppend:
case FcOpAppendLast:
case FcOpOr:
case FcOpAnd:
case FcOpEqual:
case FcOpContains:
case FcOpNotEqual:
case FcOpLess:
case FcOpLessEqual:
case FcOpMore:
case FcOpMoreEqual:
case FcOpPlus:
case FcOpMinus:
case FcOpTimes:
case FcOpDivide:
case FcOpComma:
FcExprPrint (expr->u.tree.left);
printf (" ");
switch (expr->op) {
case FcOpAssign: printf ("Assign"); break;
case FcOpAssignReplace: printf ("AssignReplace"); break;
case FcOpPrependFirst: printf ("PrependFirst"); break;
case FcOpPrepend: printf ("Prepend"); break;
case FcOpAppend: printf ("Append"); break;
case FcOpAppendLast: printf ("AppendLast"); break;
case FcOpOr: printf ("Or"); break;
case FcOpAnd: printf ("And"); break;
case FcOpEqual: printf ("Equal"); break;
case FcOpContains: printf ("Contains"); break;
case FcOpNotEqual: printf ("NotEqual"); break;
case FcOpLess: printf ("Less"); break;
case FcOpLessEqual: printf ("LessEqual"); break;
case FcOpMore: printf ("More"); break;
case FcOpMoreEqual: printf ("MoreEqual"); break;
case FcOpPlus: printf ("Plus"); break;
case FcOpMinus: printf ("Minus"); break;
case FcOpTimes: printf ("Times"); break;
case FcOpDivide: printf ("Divide"); break;
case FcOpComma: printf ("Comma"); break;
default: break;
}
printf (" ");
FcExprPrint (expr->u.tree.right);
break;
case FcOpNot:
printf ("Not ");
FcExprPrint (expr->u.tree.left);
break;
case FcOpInvalid: printf ("Invalid"); break;
}
}
void
FcTestPrint (FcTest *test)
{
switch (test->qual) {
case FcQualAny:
printf ("any ");
break;
case FcQualAll:
printf ("all ");
break;
}
printf ("%s ", test->field);
FcOpPrint (test->op);
printf (" ");
FcExprPrint (test->expr);
printf ("\n");
}
void
FcEditPrint (FcEdit *edit)
{
printf ("Edit %s ", edit->field);
FcOpPrint (edit->op);
printf (" ");
FcExprPrint (edit->expr);
}
void
FcSubstPrint (FcSubst *subst)
{
FcEdit *e;
FcTest *t;
printf ("match\n");
for (t = subst->test; t; t = t->next)
{
printf ("\t");
FcTestPrint (t);
}
printf ("edit\n");
for (e = subst->edit; e; e = e->next)
{
printf ("\t");
FcEditPrint (e);
printf (";\n");
}
printf ("\n");
}
void
FcFontSetPrint (FcFontSet *s)
{
int i;
printf ("FontSet %d of %d\n", s->nfont, s->sfont);
for (i = 0; i < s->nfont; i++)
{
printf ("Font %d ", i);
FcPatternPrint (s->fonts[i]);
}
}
int
FcDebug (void)
{
static int initialized;
static int debug;
if (!initialized)
{
char *e;
initialized = 1;
e = getenv ("FC_DEBUG");
if (e)
{
printf ("FC_DEBUG=%s\n", e);
debug = atoi (e);
if (debug < 0)
debug = 0;
}
}
return debug;
}

View File

@ -1,87 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcdefault.c,v 1.1.1.1 2002/02/14 23:34:12 keithp Exp $
*
* 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
* 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.
*/
#include "fcint.h"
static struct {
char *field;
FcBool value;
} FcBoolDefaults[] = {
{ FC_HINTING, FcTrue }, /* !FT_LOAD_NO_HINTING */
{ FC_VERTICAL_LAYOUT, FcFalse }, /* FC_LOAD_VERTICAL_LAYOUT */
{ FC_AUTOHINT, FcFalse }, /* FC_LOAD_FORCE_AUTOHINT */
{ FC_GLOBAL_ADVANCE, FcTrue }, /* !FC_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
};
#define NUM_FC_BOOL_DEFAULTS (sizeof FcBoolDefaults / sizeof FcBoolDefaults[0])
void
FcDefaultSubstitute (FcPattern *pattern)
{
FcValue v;
int i;
if (FcPatternGet (pattern, FC_STYLE, 0, &v) == FcResultNoMatch)
{
if (FcPatternGet (pattern, FC_WEIGHT, 0, &v) == FcResultNoMatch )
{
FcPatternAddInteger (pattern, FC_WEIGHT, FC_WEIGHT_MEDIUM);
}
if (FcPatternGet (pattern, FC_SLANT, 0, &v) == FcResultNoMatch)
{
FcPatternAddInteger (pattern, FC_SLANT, FC_SLANT_ROMAN);
}
}
for (i = 0; i < NUM_FC_BOOL_DEFAULTS; i++)
if (FcPatternGet (pattern, FcBoolDefaults[i].field, 0, &v) == FcResultNoMatch)
FcPatternAddBool (pattern, FcBoolDefaults[i].field, FcBoolDefaults[i].value);
if (FcPatternGet (pattern, FC_PIXEL_SIZE, 0, &v) == FcResultNoMatch)
{
double dpi, size, scale;
if (FcPatternGetDouble (pattern, FC_SIZE, 0, &size) != FcResultMatch)
{
size = 12.0;
(void) FcPatternDel (pattern, FC_SIZE);
FcPatternAddDouble (pattern, FC_SIZE, size);
}
if (FcPatternGetDouble (pattern, FC_SCALE, 0, &scale) != FcResultMatch)
{
scale = 1.0;
(void) FcPatternDel (pattern, FC_SCALE);
FcPatternAddDouble (pattern, FC_SCALE, scale);
}
size *= scale;
if (FcPatternGetDouble (pattern, FC_DPI, 0, &dpi) != FcResultMatch)
{
dpi = 75.0;
(void) FcPatternDel (pattern, FC_DPI);
FcPatternAddDouble (pattern, FC_DPI, dpi);
}
size *= dpi / 72.0;
FcPatternAddDouble (pattern, FC_PIXEL_SIZE, size);
}
}

View File

@ -1,178 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcdir.c,v 1.4 2002/03/03 18:35:22 keithp Exp $
*
* 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
* 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.
*/
#include <sys/types.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include "fcint.h"
#define FC_INVALID_FONT_FILE "."
FcBool
FcFileScan (FcFontSet *set,
FcFileCache *cache,
FcBlanks *blanks,
const FcChar8 *file,
FcBool force)
{
int id;
FcChar8 *name;
FcPattern *font;
FcBool ret = FcTrue;
int count;
id = 0;
do
{
if (!force && cache)
name = FcFileCacheFind (cache, file, id, &count);
else
name = 0;
if (name)
{
/* "." means the file doesn't contain a font */
if (strcmp ((const char *) name, FC_INVALID_FONT_FILE) != 0)
{
font = FcNameParse (name);
if (font)
FcPatternAddString (font, FC_FILE, file);
}
else
font = 0;
}
else
{
if (FcDebug () & FC_DBG_SCAN)
{
printf ("\tScanning file %s...", file);
fflush (stdout);
}
font = FcFreeTypeQuery (file, id, blanks, &count);
if (FcDebug () & FC_DBG_SCAN)
printf ("done\n");
if (!force && cache)
{
if (font)
{
FcChar8 *unparse;
unparse = FcNameUnparse (font);
if (unparse)
{
(void) FcFileCacheUpdate (cache, file, id, unparse);
free (unparse);
}
}
else
{
/* negative cache files not containing fonts */
FcFileCacheUpdate (cache, file, id, (FcChar8 *) FC_INVALID_FONT_FILE);
}
}
}
if (font)
{
if (!FcFontSetAdd (set, font))
{
FcPatternDestroy (font);
font = 0;
ret = FcFalse;
}
}
id++;
} while (font && ret && id < count);
return ret;
}
FcBool
FcDirScan (FcFontSet *set,
FcFileCache *cache,
FcBlanks *blanks,
const FcChar8 *dir,
FcBool force)
{
DIR *d;
struct dirent *e;
FcChar8 *file;
FcChar8 *base;
FcBool ret = FcTrue;
file = (FcChar8 *) malloc (strlen ((char *) dir) + 1 + 256 + 1);
if (!file)
return FcFalse;
strcpy ((char *) file, (char *) dir);
strcat ((char *) file, "/");
base = file + strlen ((char *) file);
if (!force)
{
strcpy ((char *) base, FC_DIR_CACHE_FILE);
if (FcFileCacheReadDir (set, file))
{
free (file);
return FcTrue;
}
}
d = opendir ((char *) dir);
if (!d)
{
free (file);
return FcFalse;
}
while (ret && (e = readdir (d)))
{
if (e->d_name[0] != '.')
{
strcpy ((char *) base, (char *) e->d_name);
ret = FcFileScan (set, cache, blanks, file, force);
}
}
free (file);
closedir (d);
return ret;
}
FcBool
FcDirSave (FcFontSet *set, const FcChar8 *dir)
{
FcChar8 *file;
FcChar8 *base;
FcBool ret;
file = (FcChar8 *) malloc (strlen ((char *) dir) + 1 + 256 + 1);
if (!file)
return FcFalse;
strcpy ((char *) file, (char *) dir);
strcat ((char *) file, "/");
base = file + strlen ((char *) file);
strcpy ((char *) base, FC_DIR_CACHE_FILE);
ret = FcFileCacheWriteDir (set, file);
free (file);
return ret;
}

View File

@ -1,236 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcfreetype.c,v 1.3 2002/02/22 18:54:07 keithp Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "fcint.h"
#include <freetype/freetype.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/tttables.h>
#include <fontconfig/fcfreetype.h>
static const struct {
int bit;
FcChar8 *name;
} FcCodePageRange[] = {
{ 0, (FcChar8 *) FC_LANG_LATIN_1 },
{ 1, (FcChar8 *) FC_LANG_LATIN_2_EASTERN_EUROPE },
{ 2, (FcChar8 *) FC_LANG_CYRILLIC },
{ 3, (FcChar8 *) FC_LANG_GREEK },
{ 4, (FcChar8 *) FC_LANG_TURKISH },
{ 5, (FcChar8 *) FC_LANG_HEBREW },
{ 6, (FcChar8 *) FC_LANG_ARABIC },
{ 7, (FcChar8 *) FC_LANG_WINDOWS_BALTIC },
{ 8, (FcChar8 *) FC_LANG_VIETNAMESE },
/* 9-15 reserved for Alternate ANSI */
{ 16, (FcChar8 *) FC_LANG_THAI },
{ 17, (FcChar8 *) FC_LANG_JAPANESE },
{ 18, (FcChar8 *) FC_LANG_SIMPLIFIED_CHINESE },
{ 19, (FcChar8 *) FC_LANG_KOREAN_WANSUNG },
{ 20, (FcChar8 *) FC_LANG_TRADITIONAL_CHINESE },
{ 21, (FcChar8 *) FC_LANG_KOREAN_JOHAB },
/* 22-28 reserved for Alternate ANSI & OEM */
{ 29, (FcChar8 *) FC_LANG_MACINTOSH },
{ 30, (FcChar8 *) FC_LANG_OEM },
{ 31, (FcChar8 *) FC_LANG_SYMBOL },
/* 32-47 reserved for OEM */
{ 48, (FcChar8 *) FC_LANG_IBM_GREEK },
{ 49, (FcChar8 *) FC_LANG_MSDOS_RUSSIAN },
{ 50, (FcChar8 *) FC_LANG_MSDOS_NORDIC },
{ 51, (FcChar8 *) FC_LANG_ARABIC_864 },
{ 52, (FcChar8 *) FC_LANG_MSDOS_CANADIAN_FRENCH },
{ 53, (FcChar8 *) FC_LANG_HEBREW_862 },
{ 54, (FcChar8 *) FC_LANG_MSDOS_ICELANDIC },
{ 55, (FcChar8 *) FC_LANG_MSDOS_PORTUGUESE },
{ 56, (FcChar8 *) FC_LANG_IBM_TURKISH },
{ 57, (FcChar8 *) FC_LANG_IBM_CYRILLIC },
{ 58, (FcChar8 *) FC_LANG_LATIN_2 },
{ 59, (FcChar8 *) FC_LANG_MSDOS_BALTIC },
{ 60, (FcChar8 *) FC_LANG_GREEK_437_G },
{ 61, (FcChar8 *) FC_LANG_ARABIC_ASMO_708 },
{ 62, (FcChar8 *) FC_LANG_WE_LATIN_1 },
{ 63, (FcChar8 *) FC_LANG_US },
};
#define NUM_CODE_PAGE_RANGE (sizeof FcCodePageRange / sizeof FcCodePageRange[0])
FcPattern *
FcFreeTypeQuery (const FcChar8 *file,
int id,
FcBlanks *blanks,
int *count)
{
FT_Face face;
FcPattern *pat;
int slant;
int weight;
int i;
FcCharSet *cs;
FT_Library ftLibrary;
const FcChar8 *family;
TT_OS2 *os2;
if (FT_Init_FreeType (&ftLibrary))
return 0;
if (FT_New_Face (ftLibrary, (char *) file, id, &face))
goto bail;
*count = face->num_faces;
pat = FcPatternCreate ();
if (!pat)
goto bail0;
if (!FcPatternAddBool (pat, FC_OUTLINE,
(face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
goto bail1;
if (!FcPatternAddBool (pat, FC_SCALABLE,
(face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
goto bail1;
slant = FC_SLANT_ROMAN;
if (face->style_flags & FT_STYLE_FLAG_ITALIC)
slant = FC_SLANT_ITALIC;
if (!FcPatternAddInteger (pat, FC_SLANT, slant))
goto bail1;
weight = FC_WEIGHT_MEDIUM;
if (face->style_flags & FT_STYLE_FLAG_BOLD)
weight = FC_WEIGHT_BOLD;
if (!FcPatternAddInteger (pat, FC_WEIGHT, weight))
goto bail1;
family = (FcChar8 *) face->family_name;
if (!family)
{
family = (FcChar8 *) strrchr ((char *) file, '/');
if (family)
family++;
else
family = file;
}
if (!FcPatternAddString (pat, FC_FAMILY, family))
goto bail1;
if (face->style_name)
{
if (!FcPatternAddString (pat, FC_STYLE, (FcChar8 *) face->style_name))
goto bail1;
}
if (!FcPatternAddString (pat, FC_FILE, file))
goto bail1;
if (!FcPatternAddInteger (pat, FC_INDEX, id))
goto bail1;
if (!FcPatternAddString (pat, FC_SOURCE, (FcChar8 *) "FreeType"))
goto bail1;
#if 1
if ((face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) != 0)
if (!FcPatternAddInteger (pat, FC_SPACING, FC_MONO))
goto bail1;
#endif
cs = FcFreeTypeCharSet (face, blanks);
if (!cs)
goto bail1;
/*
* Skip over PCF fonts that have no encoded characters; they're
* usually just Unicode fonts transcoded to some legacy encoding
*/
if (FcCharSetCount (cs) == 0)
{
if (!strcmp(FT_MODULE_CLASS(&face->driver->root)->module_name, "pcf"))
goto bail2;
}
if (!FcPatternAddCharSet (pat, FC_CHARSET, cs))
goto bail2;
/*
* Drop our reference to the charset
*/
FcCharSetDestroy (cs);
if (!(face->face_flags & FT_FACE_FLAG_SCALABLE))
{
for (i = 0; i < face->num_fixed_sizes; i++)
if (!FcPatternAddDouble (pat, FC_PIXEL_SIZE,
(double) face->available_sizes[i].height))
goto bail1;
if (!FcPatternAddBool (pat, FC_ANTIALIAS, FcFalse))
goto bail1;
}
/*
* Get the OS/2 table and poke about
*/
os2 = (TT_OS2 *) FT_Get_Sfnt_Table (face, ft_sfnt_os2);
if (os2 && os2->version >= 0x0001 && os2->version != 0xffff)
{
for (i = 0; i < NUM_CODE_PAGE_RANGE; i++)
{
FT_ULong bits;
int bit;
if (FcCodePageRange[i].bit < 32)
{
bits = os2->ulCodePageRange1;
bit = FcCodePageRange[i].bit;
}
else
{
bits = os2->ulCodePageRange2;
bit = FcCodePageRange[i].bit - 32;
}
if (bits & (1 << bit))
{
if (!FcPatternAddString (pat, FC_LANG,
FcCodePageRange[i].name))
goto bail1;
}
}
}
FT_Done_Face (face);
FT_Done_FreeType (ftLibrary);
return pat;
bail2:
FcCharSetDestroy (cs);
bail1:
FcPatternDestroy (pat);
bail0:
FT_Done_Face (face);
bail:
FT_Done_FreeType (ftLibrary);
return 0;
}

View File

@ -1,82 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcfs.c,v 1.1.1.1 2002/02/14 23:34:12 keithp Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include "fcint.h"
FcFontSet *
FcFontSetCreate (void)
{
FcFontSet *s;
s = (FcFontSet *) malloc (sizeof (FcFontSet));
if (!s)
return 0;
FcMemAlloc (FC_MEM_FONTSET, sizeof (FcFontSet));
s->nfont = 0;
s->sfont = 0;
s->fonts = 0;
return s;
}
void
FcFontSetDestroy (FcFontSet *s)
{
int i;
for (i = 0; i < s->nfont; i++)
FcPatternDestroy (s->fonts[i]);
if (s->fonts)
{
FcMemFree (FC_MEM_FONTPTR, s->sfont * sizeof (FcPattern *));
free (s->fonts);
}
FcMemFree (FC_MEM_FONTSET, sizeof (FcFontSet));
free (s);
}
FcBool
FcFontSetAdd (FcFontSet *s, FcPattern *font)
{
FcPattern **f;
int sfont;
if (s->nfont == s->sfont)
{
sfont = s->sfont + 32;
if (s->fonts)
f = (FcPattern **) realloc (s->fonts, sfont * sizeof (FcPattern *));
else
f = (FcPattern **) malloc (sfont * sizeof (FcPattern *));
if (!f)
return FcFalse;
if (s->sfont)
FcMemFree (FC_MEM_FONTPTR, s->sfont * sizeof (FcPattern *));
FcMemAlloc (FC_MEM_FONTPTR, sfont * sizeof (FcPattern *));
s->sfont = sfont;
s->fonts = f;
}
s->fonts[s->nfont++] = font;
return FcTrue;
}

View File

@ -1,174 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcinit.c,v 1.3 2002/02/19 08:33:23 keithp Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include "fcint.h"
FcBool
FcInitFonts (void)
{
FcConfig *config;
config = FcConfigGetCurrent ();
if (!config)
return FcFalse;
if (FcConfigGetFonts (config, FcSetSystem))
return FcTrue;
return FcConfigBuildFonts (config);
}
static FcBool
FcInitFallbackConfig (void)
{
FcConfig *config;
config = FcConfigCreate ();
if (!config)
goto bail0;
if (!FcConfigAddDir (config, (FcChar8 *) FC_FALLBACK_FONTS))
goto bail1;
FcConfigSetCurrent (config);
return FcTrue;
bail1:
FcConfigDestroy (config);
bail0:
return FcFalse;
}
/*
* Locate and parse the configuration file
*/
FcBool
FcInitConfig (void)
{
FcConfig *config;
if (_fcConfig)
return FcTrue;
config = FcConfigCreate ();
if (!config)
return FcFalse;
if (!FcConfigParseAndLoad (config, 0, FcTrue))
{
FcConfigDestroy (config);
return FcInitFallbackConfig ();
}
FcConfigSetCurrent (config);
return FcTrue;
}
FcBool
FcInit (void)
{
return FcInitConfig () && FcInitFonts ();
}
static struct {
char *name;
int alloc_count;
int alloc_mem;
int free_count;
int free_mem;
} FcInUse[FC_MEM_NUM] = {
{ "charset", 0, 0 },
{ "charnode", 0 ,0 },
{ "fontset", 0, 0 },
{ "fontptr", 0, 0 },
{ "objectset", 0, 0 },
{ "objectptr", 0, 0 },
{ "matrix", 0, 0 },
{ "pattern", 0, 0 },
{ "patelt", 0, 0 },
{ "vallist", 0, 0 },
{ "substate", 0, 0 },
{ "string", 0, 0 },
{ "listbuck", 0, 0 },
};
static int FcAllocCount, FcAllocMem;
static int FcFreeCount, FcFreeMem;
static int FcMemNotice = 1*1024*1024;
static int FcAllocNotify, FcFreeNotify;
void
FcMemReport (void)
{
int i;
printf ("Fc Memory Usage:\n");
printf ("\t Which Alloc Free Active\n");
printf ("\t count bytes count bytes count bytes\n");
for (i = 0; i < FC_MEM_NUM; i++)
printf ("\t%8.8s%8d%8d%8d%8d%8d%8d\n",
FcInUse[i].name,
FcInUse[i].alloc_count, FcInUse[i].alloc_mem,
FcInUse[i].free_count, FcInUse[i].free_mem,
FcInUse[i].alloc_count - FcInUse[i].free_count,
FcInUse[i].alloc_mem - FcInUse[i].free_mem);
printf ("\t%8.8s%8d%8d%8d%8d%8d%8d\n",
"Total",
FcAllocCount, FcAllocMem,
FcFreeCount, FcFreeMem,
FcAllocCount - FcFreeCount,
FcAllocMem - FcFreeMem);
FcAllocNotify = 0;
FcFreeNotify = 0;
}
void
FcMemAlloc (int kind, int size)
{
if (FcDebug() & FC_DBG_MEMORY)
{
FcInUse[kind].alloc_count++;
FcInUse[kind].alloc_mem += size;
FcAllocCount++;
FcAllocMem += size;
FcAllocNotify += size;
if (FcAllocNotify > FcMemNotice)
FcMemReport ();
}
}
void
FcMemFree (int kind, int size)
{
if (FcDebug() & FC_DBG_MEMORY)
{
FcInUse[kind].free_count++;
FcInUse[kind].free_mem += size;
FcFreeCount++;
FcFreeMem += size;
FcFreeNotify += size;
if (FcFreeNotify > FcMemNotice)
FcMemReport ();
}
}

View File

@ -1,472 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.7 2002/03/03 18:36:26 keithp Exp $
*
* 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
* 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.
*/
#ifndef _FCINT_H_
#define _FCINT_H_
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fontconfig/fontconfig.h>
#include <fontconfig/fcprivate.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
typedef struct _FcMatcher {
char *object;
double (*compare) (char *object, FcValue value1, FcValue value2);
} FcMatcher;
typedef struct _FcSymbolic {
const char *name;
int value;
} FcSymbolic;
#ifndef FC_CONFIG_PATH
#define FC_CONFIG_PATH "fonts.conf"
#endif
#define FC_DBG_MATCH 1
#define FC_DBG_MATCHV 2
#define FC_DBG_EDIT 4
#define FC_DBG_FONTSET 8
#define FC_DBG_CACHE 16
#define FC_DBG_CACHEV 32
#define FC_DBG_PARSE 64
#define FC_DBG_SCAN 128
#define FC_DBG_MEMORY 512
#define FC_MEM_CHARSET 0
#define FC_MEM_CHARNODE 1
#define FC_MEM_FONTSET 2
#define FC_MEM_FONTPTR 3
#define FC_MEM_OBJECTSET 4
#define FC_MEM_OBJECTPTR 5
#define FC_MEM_MATRIX 6
#define FC_MEM_PATTERN 7
#define FC_MEM_PATELT 8
#define FC_MEM_VALLIST 9
#define FC_MEM_SUBSTATE 10
#define FC_MEM_STRING 11
#define FC_MEM_LISTBUCK 12
#define FC_MEM_NUM 13
typedef struct _FcValueList {
struct _FcValueList *next;
FcValue value;
} FcValueList;
typedef struct _FcPatternElt {
const char *object;
FcValueList *values;
} FcPatternElt;
struct _FcPattern {
int num;
int size;
FcPatternElt *elts;
};
typedef enum _FcOp {
FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpBool, FcOpCharSet,
FcOpNil,
FcOpField, FcOpConst,
FcOpAssign, FcOpAssignReplace,
FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
FcOpQuest,
FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains,
FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
FcOpNot, FcOpComma, FcOpInvalid
} FcOp;
typedef struct _FcExpr {
FcOp op;
union {
int ival;
double dval;
FcChar8 *sval;
FcMatrix *mval;
FcBool bval;
FcCharSet *cval;
char *field;
FcChar8 *constant;
struct {
struct _FcExpr *left, *right;
} tree;
} u;
} FcExpr;
typedef enum _FcQual {
FcQualAny, FcQualAll
} FcQual;
typedef struct _FcTest {
struct _FcTest *next;
FcQual qual;
const char *field;
FcOp op;
FcExpr *expr;
} FcTest;
typedef struct _FcEdit {
struct _FcEdit *next;
const char *field;
FcOp op;
FcExpr *expr;
} FcEdit;
typedef struct _FcSubst {
struct _FcSubst *next;
FcTest *test;
FcEdit *edit;
} FcSubst;
typedef struct _FcCharLeaf FcCharLeaf;
typedef struct _FcCharBranch FcCharBranch;
typedef union _FcCharNode FcCharNode;
struct _FcCharLeaf {
FcChar32 map[256/32];
};
union _FcCharNode {
FcCharBranch *branch;
FcCharLeaf *leaf;
};
struct _FcCharBranch {
FcCharNode nodes[256];
};
struct _FcCharSet {
int levels;
int ref; /* reference count */
FcBool constant; /* shared constant */
FcCharNode node;
};
typedef struct _FcStrBuf {
FcChar8 *buf;
FcBool allocated;
FcBool failed;
int len;
int size;
} FcStrBuf;
typedef struct _FcFileCacheEnt {
struct _FcFileCacheEnt *next;
unsigned int hash;
FcChar8 *file;
int id;
time_t time;
FcChar8 *name;
FcBool referenced;
} FcFileCacheEnt;
#define FC_FILE_CACHE_HASH_SIZE 509
struct _FcFileCache {
FcFileCacheEnt *ents[FC_FILE_CACHE_HASH_SIZE];
FcBool updated;
int entries;
int referenced;
};
struct _FcAtomic {
FcChar8 *file; /* original file name */
FcChar8 *new; /* temp file name -- write data here */
FcChar8 *lck; /* lockfile name (used for locking) */
FcChar8 *tmp; /* tmpfile name (used for locking) */
};
struct _FcBlanks {
int nblank;
int sblank;
FcChar32 *blanks;
};
struct _FcConfig {
/*
* File names loaded from the configuration -- saved here as the
* cache file must be consulted before the directories are scanned,
* and those directives may occur in any order
*/
FcChar8 **dirs; /* directories containing fonts */
FcChar8 *cache; /* name of per-user cache file */
/*
* Set of allowed blank chars -- used to
* trim fonts of bogus glyphs
*/
FcBlanks *blanks;
/*
* Names of all of the configuration files used
* to create this configuration
*/
FcChar8 **configFiles; /* config files loaded */
/*
* Substitution instructions for patterns and fonts;
* maxObjects is used to allocate appropriate intermediate storage
* while performing a whole set of substitutions
*/
FcSubst *substPattern; /* substitutions for patterns */
FcSubst *substFont; /* substitutions for fonts */
int maxObjects; /* maximum number of tests in all substs */
/*
* The set of fonts loaded from the listed directories; the
* order within the set does not determine the font selection,
* except in the case of identical matches in which case earlier fonts
* match preferrentially
*/
FcFontSet *fonts[FcSetApplication + 1];
};
extern FcConfig *_fcConfig;
/* fcblanks.c */
/* fccache.c */
FcFileCache *
FcFileCacheCreate (void);
FcChar8 *
FcFileCacheFind (FcFileCache *cache,
const FcChar8 *file,
int id,
int *count);
void
FcFileCacheDestroy (FcFileCache *cache);
void
FcFileCacheLoad (FcFileCache *cache,
const FcChar8 *cache_file);
FcBool
FcFileCacheUpdate (FcFileCache *cache,
const FcChar8 *file,
int id,
const FcChar8 *name);
FcBool
FcFileCacheSave (FcFileCache *cache,
const FcChar8 *cache_file);
FcBool
FcFileCacheReadDir (FcFontSet *set, const FcChar8 *cache_file);
FcBool
FcFileCacheWriteDir (FcFontSet *set, const FcChar8 *cache_file);
/* fccfg.c */
FcBool
FcConfigAddDir (FcConfig *config,
const FcChar8 *d);
FcBool
FcConfigAddConfigFile (FcConfig *config,
const FcChar8 *f);
FcBool
FcConfigSetCache (FcConfig *config,
const FcChar8 *c);
FcBool
FcConfigAddBlank (FcConfig *config,
FcChar32 blank);
FcBool
FcConfigAddEdit (FcConfig *config,
FcTest *test,
FcEdit *edit,
FcMatchKind kind);
void
FcConfigSetFonts (FcConfig *config,
FcFontSet *fonts,
FcSetName set);
FcBool
FcConfigCompareValue (const FcValue m,
FcOp op,
const FcValue v);
/* fccharset.c */
FcBool
FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
FcCharSet *
FcNameParseCharSet (FcChar8 *string);
/* fcdbg.c */
void
FcValueListPrint (FcValueList *l);
void
FcOpPrint (FcOp op);
void
FcTestPrint (FcTest *test);
void
FcExprPrint (FcExpr *expr);
void
FcEditPrint (FcEdit *edit);
void
FcSubstPrint (FcSubst *subst);
int
FcDebug (void);
/* fcdir.c */
/* fcfont.c */
int
FcFontDebug (void);
/* fcfs.c */
/* fcgram.y */
int
FcConfigparse (void);
int
FcConfigwrap (void);
void
FcConfigerror (char *fmt, ...);
char *
FcConfigSaveField (const char *field);
FcTest *
FcTestCreate (FcQual qual, const FcChar8 *field, FcOp compare, FcExpr *expr);
void
FcTestDestroy (FcTest *test);
FcExpr *
FcExprCreateInteger (int i);
FcExpr *
FcExprCreateDouble (double d);
FcExpr *
FcExprCreateString (const FcChar8 *s);
FcExpr *
FcExprCreateMatrix (const FcMatrix *m);
FcExpr *
FcExprCreateBool (FcBool b);
FcExpr *
FcExprCreateNil (void);
FcExpr *
FcExprCreateField (const char *field);
FcExpr *
FcExprCreateConst (const FcChar8 *constant);
FcExpr *
FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
void
FcExprDestroy (FcExpr *e);
FcEdit *
FcEditCreate (const char *field, FcOp op, FcExpr *expr);
void
FcEditDestroy (FcEdit *e);
/* fcinit.c */
void
FcMemReport (void);
void
FcMemAlloc (int kind, int size);
void
FcMemFree (int kind, int size);
/* fclist.c */
/* fcmatch.c */
/* fcname.c */
FcBool
FcNameBool (FcChar8 *v, FcBool *result);
/* fcpat.c */
void
FcValueListDestroy (FcValueList *l);
FcPatternElt *
FcPatternFind (FcPattern *p, const char *object, FcBool insert);
/* fcrender.c */
/* fcmatrix.c */
void
FcMatrixFree (FcMatrix *mat);
/* fcstr.c */
FcChar8 *
FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
void
FcStrFree (FcChar8 *s);
void
FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
void
FcStrBufDestroy (FcStrBuf *buf);
FcChar8 *
FcStrBufDone (FcStrBuf *buf);
FcBool
FcStrBufChar (FcStrBuf *buf, FcChar8 c);
FcBool
FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
FcBool
FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
#endif /* _FC_INT_H_ */

View File

@ -1,466 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fclist.c,v 1.2 2002/02/28 16:51:48 keithp Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include "fcint.h"
FcObjectSet *
FcObjectSetCreate (void)
{
FcObjectSet *os;
os = (FcObjectSet *) malloc (sizeof (FcObjectSet));
if (!os)
return 0;
FcMemAlloc (FC_MEM_OBJECTSET, sizeof (FcObjectSet));
os->nobject = 0;
os->sobject = 0;
os->objects = 0;
return os;
}
FcBool
FcObjectSetAdd (FcObjectSet *os, const char *object)
{
int s;
const char **objects;
if (os->nobject == os->sobject)
{
s = os->sobject + 4;
if (os->objects)
objects = (const char **) realloc ((void *) os->objects,
s * sizeof (const char *));
else
objects = (const char **) malloc (s * sizeof (const char *));
if (!objects)
return FcFalse;
if (os->sobject)
FcMemFree (FC_MEM_OBJECTPTR, os->sobject * sizeof (const char *));
FcMemAlloc (FC_MEM_OBJECTPTR, s * sizeof (const char *));
os->objects = objects;
os->sobject = s;
}
os->objects[os->nobject++] = object;
return FcTrue;
}
void
FcObjectSetDestroy (FcObjectSet *os)
{
if (os->objects)
{
FcMemFree (FC_MEM_OBJECTPTR, os->sobject * sizeof (const char *));
free ((void *) os->objects);
}
FcMemFree (FC_MEM_OBJECTSET, sizeof (FcObjectSet));
free (os);
}
FcObjectSet *
FcObjectSetVaBuild (const char *first, va_list va)
{
FcObjectSet *ret;
FcObjectSetVapBuild (ret, first, va);
return ret;
}
FcObjectSet *
FcObjectSetBuild (const char *first, ...)
{
va_list va;
FcObjectSet *os;
va_start (va, first);
FcObjectSetVapBuild (os, first, va);
va_end (va);
return os;
}
static FcBool
FcListValueListMatchAny (FcValueList *v1orig,
FcValueList *v2orig)
{
FcValueList *v1, *v2;
for (v1 = v1orig; v1; v1 = v1->next)
for (v2 = v2orig; v2; v2 = v2->next)
if (FcConfigCompareValue (v2->value, FcOpContains, v1->value))
return FcTrue;
return FcFalse;
}
static FcBool
FcListValueListEqual (FcValueList *v1orig,
FcValueList *v2orig)
{
FcValueList *v1, *v2;
for (v1 = v1orig; v1; v1 = v1->next)
{
for (v2 = v2orig; v2; v2 = v2->next)
if (FcConfigCompareValue (v1->value, FcOpEqual, v2->value))
break;
if (!v2)
return FcFalse;
}
for (v2 = v2orig; v2; v2 = v2->next)
{
for (v1 = v1orig; v1; v1 = v1->next)
if (FcConfigCompareValue (v1->value, FcOpEqual, v2->value))
break;
if (!v1)
return FcFalse;
}
return FcTrue;
}
/*
* FcTrue iff all objects in "p" match "font"
*/
static FcBool
FcListPatternMatchAny (FcPattern *p,
FcPattern *font)
{
int i;
FcPatternElt *e;
for (i = 0; i < p->num; i++)
{
e = FcPatternFind (font, p->elts[i].object, FcFalse);
if (!e)
return FcFalse;
if (!FcListValueListMatchAny (p->elts[i].values, e->values))
return FcFalse;
}
return FcTrue;
}
static FcBool
FcListPatternEqual (FcPattern *p1,
FcPattern *p2,
FcObjectSet *os)
{
int i;
FcPatternElt *e1, *e2;
for (i = 0; i < os->nobject; i++)
{
e1 = FcPatternFind (p1, os->objects[i], FcFalse);
e2 = FcPatternFind (p2, os->objects[i], FcFalse);
if (!e1 && !e2)
return FcTrue;
if (!e1 || !e2)
return FcFalse;
if (!FcListValueListEqual (e1->values, e2->values))
return FcFalse;
}
return FcTrue;
}
static FcChar32
FcListStringHash (const FcChar8 *s)
{
FcChar32 h = 0;
FcChar8 c;
while ((c = *s++))
{
c = FcToLower (c);
h = ((h << 3) ^ (h >> 3)) ^ c;
}
return h;
}
static FcChar32
FcListMatrixHash (const FcMatrix *m)
{
int xx = (int) (m->xx * 100),
xy = (int) (m->xy * 100),
yx = (int) (m->yx * 100),
yy = (int) (m->yy * 100);
return ((FcChar32) xx) ^ ((FcChar32) xy) ^ ((FcChar32) yx) ^ ((FcChar32) yy);
}
static FcChar32
FcListValueHash (FcValue v)
{
switch (v.type) {
case FcTypeVoid:
return 0;
case FcTypeInteger:
return (FcChar32) v.u.i;
case FcTypeDouble:
return (FcChar32) (int) v.u.d;
case FcTypeString:
return FcListStringHash (v.u.s);
case FcTypeBool:
return (FcChar32) v.u.b;
case FcTypeMatrix:
return FcListMatrixHash (v.u.m);
case FcTypeCharSet:
return FcCharSetCount (v.u.c);
}
return 0;
}
static FcChar32
FcListValueListHash (FcValueList *list)
{
FcChar32 h = 0;
while (list)
{
h = h ^ FcListValueHash (list->value);
list = list->next;
}
return h;
}
static FcChar32
FcListPatternHash (FcPattern *font,
FcObjectSet *os)
{
int n;
FcPatternElt *e;
FcChar32 h = 0;
for (n = 0; n < os->nobject; n++)
{
e = FcPatternFind (font, os->objects[n], FcFalse);
if (e)
h = h ^ FcListValueListHash (e->values);
}
return h;
}
typedef struct _FcListBucket {
struct _FcListBucket *next;
FcChar32 hash;
FcPattern *pattern;
} FcListBucket;
#define FC_LIST_HASH_SIZE 4099
typedef struct _FcListHashTable {
int entries;
FcListBucket *buckets[FC_LIST_HASH_SIZE];
} FcListHashTable;
static void
FcListHashTableInit (FcListHashTable *table)
{
table->entries = 0;
memset (table->buckets, '\0', sizeof (table->buckets));
}
static void
FcListHashTableCleanup (FcListHashTable *table)
{
int i;
FcListBucket *bucket, *next;
for (i = 0; i < FC_LIST_HASH_SIZE; i++)
{
for (bucket = table->buckets[i]; bucket; bucket = next)
{
next = bucket->next;
FcPatternDestroy (bucket->pattern);
FcMemFree (FC_MEM_LISTBUCK, sizeof (FcListBucket));
free (bucket);
}
table->buckets[i] = 0;
}
table->entries = 0;
}
static FcBool
FcListAppend (FcListHashTable *table,
FcPattern *font,
FcObjectSet *os)
{
int o;
FcPatternElt *e;
FcValueList *v;
FcChar32 hash;
FcListBucket **prev, *bucket;
hash = FcListPatternHash (font, os);
for (prev = &table->buckets[hash % FC_LIST_HASH_SIZE];
(bucket = *prev); prev = &(bucket->next))
{
if (bucket->hash == hash &&
FcListPatternEqual (bucket->pattern, font, os))
return FcTrue;
}
bucket = (FcListBucket *) malloc (sizeof (FcListBucket));
if (!bucket)
goto bail0;
FcMemAlloc (FC_MEM_LISTBUCK, sizeof (FcListBucket));
bucket->next = 0;
bucket->hash = hash;
bucket->pattern = FcPatternCreate ();
if (!bucket->pattern)
goto bail1;
for (o = 0; o < os->nobject; o++)
{
e = FcPatternFind (font, os->objects[o], FcFalse);
if (e)
{
for (v = e->values; v; v = v->next)
{
if (!FcPatternAdd (bucket->pattern,
os->objects[o],
v->value, FcTrue))
goto bail2;
}
}
}
*prev = bucket;
++table->entries;
return FcTrue;
bail2:
FcPatternDestroy (bucket->pattern);
bail1:
FcMemFree (FC_MEM_LISTBUCK, sizeof (FcListBucket));
free (bucket);
bail0:
return FcFalse;
}
FcFontSet *
FcFontSetList (FcConfig *config,
FcFontSet **sets,
int nsets,
FcPattern *p,
FcObjectSet *os)
{
FcFontSet *ret;
FcFontSet *s;
int f;
int set;
FcListHashTable table;
int i;
FcListBucket *bucket;
if (!config)
{
config = FcConfigGetCurrent ();
if (!config)
goto bail0;
}
FcListHashTableInit (&table);
/*
* Walk all available fonts adding those that
* match to the hash table
*/
for (set = 0; set < nsets; set++)
{
s = sets[set];
if (!s)
continue;
for (f = 0; f < s->nfont; f++)
if (FcListPatternMatchAny (p, s->fonts[f]))
if (!FcListAppend (&table, s->fonts[f], os))
goto bail1;
}
#if 0
{
int max = 0;
int full = 0;
int ents = 0;
int len;
for (i = 0; i < FC_LIST_HASH_SIZE; i++)
{
if ((bucket = table.buckets[i]))
{
len = 0;
for (; bucket; bucket = bucket->next)
{
ents++;
len++;
}
if (len > max)
max = len;
full++;
}
}
printf ("used: %d max: %d avg: %g\n", full, max,
(double) ents / FC_LIST_HASH_SIZE);
}
#endif
/*
* Walk the hash table and build
* a font set
*/
ret = FcFontSetCreate ();
if (!ret)
goto bail0;
for (i = 0; i < FC_LIST_HASH_SIZE; i++)
while ((bucket = table.buckets[i]))
{
if (!FcFontSetAdd (ret, bucket->pattern))
goto bail2;
table.buckets[i] = bucket->next;
FcMemFree (FC_MEM_LISTBUCK, sizeof (FcListBucket));
free (bucket);
}
return ret;
bail2:
FcFontSetDestroy (ret);
bail1:
FcListHashTableCleanup (&table);
bail0:
return 0;
}
FcFontSet *
FcFontList (FcConfig *config,
FcPattern *p,
FcObjectSet *os)
{
FcFontSet *sets[2];
int nsets;
if (!config)
{
config = FcConfigGetCurrent ();
if (!config)
return 0;
}
nsets = 0;
if (config->fonts[FcSetSystem])
sets[nsets++] = config->fonts[FcSetSystem];
if (config->fonts[FcSetApplication])
sets[nsets++] = config->fonts[FcSetApplication];
return FcFontSetList (config, sets, nsets, p, os);
}

View File

@ -1,531 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcmatch.c,v 1.4 2002/03/03 18:39:05 keithp Exp $
*
* 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
* 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.
*/
#include <string.h>
#include <ctype.h>
#include "fcint.h"
#include <stdio.h>
static double
FcCompareInteger (char *object, FcValue value1, FcValue value2)
{
int v;
if (value2.type != FcTypeInteger || value1.type != FcTypeInteger)
return -1.0;
v = value2.u.i - value1.u.i;
if (v < 0)
v = -v;
return (double) v;
}
static double
FcCompareString (char *object, FcValue value1, FcValue value2)
{
if (value2.type != FcTypeString || value1.type != FcTypeString)
return -1.0;
return (double) FcStrCmpIgnoreCase (value1.u.s, value2.u.s) != 0;
}
static double
FcCompareBool (char *object, FcValue value1, FcValue value2)
{
if (value2.type != FcTypeBool || value1.type != FcTypeBool)
return -1.0;
return (double) value2.u.b != value1.u.b;
}
static double
FcCompareCharSet (char *object, FcValue value1, FcValue value2)
{
if (value2.type != FcTypeCharSet || value1.type != FcTypeCharSet)
return -1.0;
return (double) FcCharSetSubtractCount (value1.u.c, value2.u.c);
}
static double
FcCompareSize (char *object, FcValue value1, FcValue value2)
{
double v1, v2, v;
switch (value1.type) {
case FcTypeInteger:
v1 = value1.u.i;
break;
case FcTypeDouble:
v1 = value1.u.d;
break;
default:
return -1;
}
switch (value2.type) {
case FcTypeInteger:
v2 = value2.u.i;
break;
case FcTypeDouble:
v2 = value2.u.d;
break;
default:
return -1;
}
if (v2 == 0)
return 0;
v = v2 - v1;
if (v < 0)
v = -v;
return v;
}
/*
* Order is significant, it defines the precedence of
* each value, earlier values are more significant than
* later values
*/
static FcMatcher _FcMatchers [] = {
{ FC_FOUNDRY, FcCompareString, },
{ FC_CHARSET, FcCompareCharSet },
{ FC_ANTIALIAS, FcCompareBool, },
{ FC_LANG, FcCompareString },
{ FC_FAMILY, FcCompareString, },
{ FC_SPACING, FcCompareInteger, },
{ FC_PIXEL_SIZE, FcCompareSize, },
{ FC_STYLE, FcCompareString, },
{ FC_SLANT, FcCompareInteger, },
{ FC_WEIGHT, FcCompareInteger, },
{ FC_RASTERIZER, FcCompareString, },
{ FC_OUTLINE, FcCompareBool, },
};
#define NUM_MATCHER (sizeof _FcMatchers / sizeof _FcMatchers[0])
static FcBool
FcCompareValueList (const char *object,
FcValueList *v1orig, /* pattern */
FcValueList *v2orig, /* target */
FcValue *bestValue,
double *value,
FcResult *result)
{
FcValueList *v1, *v2;
double v, best;
int j;
int i;
for (i = 0; i < NUM_MATCHER; i++)
{
if (!FcStrCmpIgnoreCase ((FcChar8 *) _FcMatchers[i].object,
(FcChar8 *) object))
break;
}
if (i == NUM_MATCHER)
{
if (bestValue)
*bestValue = v2orig->value;
return FcTrue;
}
best = 1e99;
j = 0;
for (v1 = v1orig; v1; v1 = v1->next)
{
for (v2 = v2orig; v2; v2 = v2->next)
{
v = (*_FcMatchers[i].compare) (_FcMatchers[i].object,
v1->value,
v2->value);
if (v < 0)
{
*result = FcResultTypeMismatch;
return FcFalse;
}
if (FcDebug () & FC_DBG_MATCHV)
printf (" v %g j %d ", v, j);
v = v * 100 + j;
if (v < best)
{
if (bestValue)
*bestValue = v2->value;
best = v;
}
}
j++;
}
if (FcDebug () & FC_DBG_MATCHV)
{
printf (" %s: %g ", object, best);
FcValueListPrint (v1orig);
printf (", ");
FcValueListPrint (v2orig);
printf ("\n");
}
value[i] += best;
return FcTrue;
}
/*
* Return a value indicating the distance between the two lists of
* values
*/
static FcBool
FcCompare (FcPattern *pat,
FcPattern *fnt,
double *value,
FcResult *result)
{
int i, i1, i2;
for (i = 0; i < NUM_MATCHER; i++)
value[i] = 0.0;
for (i1 = 0; i1 < pat->num; i1++)
{
for (i2 = 0; i2 < fnt->num; i2++)
{
if (!FcStrCmpIgnoreCase ((FcChar8 *) pat->elts[i1].object,
(FcChar8 *) fnt->elts[i2].object))
{
if (!FcCompareValueList (pat->elts[i1].object,
pat->elts[i1].values,
fnt->elts[i2].values,
0,
value,
result))
return FcFalse;
break;
}
}
#if 0
/*
* Overspecified patterns are slightly penalized in
* case some other font includes the requested field
*/
if (i2 == fnt->num)
{
for (i2 = 0; i2 < NUM_MATCHER; i2++)
{
if (!FcStrCmpIgnoreCase (_FcMatchers[i2].object,
pat->elts[i1].object))
{
value[i2] = 1.0;
break;
}
}
}
#endif
}
return FcTrue;
}
FcPattern *
FcFontRenderPrepare (FcConfig *config,
FcPattern *pat,
FcPattern *font)
{
FcPattern *new;
int i;
FcPatternElt *fe, *pe;
FcValue v;
double score[NUM_MATCHER];
FcResult result;
new = FcPatternCreate ();
if (!new)
return 0;
for (i = 0; i < font->num; i++)
{
fe = &font->elts[i];
pe = FcPatternFind (pat, fe->object, FcFalse);
if (pe)
{
if (!FcCompareValueList (pe->object, pe->values,
fe->values, &v, score, &result))
{
FcPatternDestroy (new);
return 0;
}
}
else
v = fe->values->value;
FcPatternAdd (new, fe->object, v, FcTrue);
}
for (i = 0; i < pat->num; i++)
{
pe = &pat->elts[i];
fe = FcPatternFind (font, pe->object, FcFalse);
if (!fe)
FcPatternAdd (new, pe->object, pe->values->value, FcTrue);
}
FcConfigSubstitute (config, new, FcMatchFont);
return new;
}
FcPattern *
FcFontSetMatch (FcConfig *config,
FcFontSet **sets,
int nsets,
FcPattern *p,
FcResult *result)
{
double score[NUM_MATCHER], bestscore[NUM_MATCHER];
int f;
FcFontSet *s;
FcPattern *best;
int i;
int set;
for (i = 0; i < NUM_MATCHER; i++)
bestscore[i] = 0;
best = 0;
if (FcDebug () & FC_DBG_MATCH)
{
printf ("Match ");
FcPatternPrint (p);
}
if (!config)
{
config = FcConfigGetCurrent ();
if (!config)
return 0;
}
for (set = 0; set < nsets; set++)
{
s = sets[set];
if (!s)
continue;
for (f = 0; f < s->nfont; f++)
{
if (FcDebug () & FC_DBG_MATCHV)
{
printf ("Font %d ", f);
FcPatternPrint (s->fonts[f]);
}
if (!FcCompare (p, s->fonts[f], score, result))
return 0;
if (FcDebug () & FC_DBG_MATCHV)
{
printf ("Score");
for (i = 0; i < NUM_MATCHER; i++)
{
printf (" %g", score[i]);
}
printf ("\n");
}
for (i = 0; i < NUM_MATCHER; i++)
{
if (best && bestscore[i] < score[i])
break;
if (!best || score[i] < bestscore[i])
{
for (i = 0; i < NUM_MATCHER; i++)
bestscore[i] = score[i];
best = s->fonts[f];
break;
}
}
}
}
if (FcDebug () & FC_DBG_MATCH)
{
printf ("Best score");
for (i = 0; i < NUM_MATCHER; i++)
printf (" %g", bestscore[i]);
FcPatternPrint (best);
}
if (!best)
{
*result = FcResultNoMatch;
return 0;
}
return FcFontRenderPrepare (config, p, best);
}
FcPattern *
FcFontMatch (FcConfig *config,
FcPattern *p,
FcResult *result)
{
FcFontSet *sets[2];
int nsets;
if (!config)
{
config = FcConfigGetCurrent ();
if (!config)
return 0;
}
nsets = 0;
if (config->fonts[FcSetSystem])
sets[nsets++] = config->fonts[FcSetSystem];
if (config->fonts[FcSetApplication])
sets[nsets++] = config->fonts[FcSetApplication];
return FcFontSetMatch (config, sets, nsets, p, result);
}
#include "fcavl.h"
typedef struct _FcSortNode {
FcAvlNode avl;
FcPattern *pattern;
double score[NUM_MATCHER];
} FcSortNode;
static FcBool
FcSortMore (FcAvlNode *aa, FcAvlNode *ab)
{
FcSortNode *a = (FcSortNode *) aa;
FcSortNode *b = (FcSortNode *) ab;
int i;
for (i = 0; i < NUM_MATCHER; i++)
{
if (a->score[i] > b->score[i])
return FcTrue;
if (a->score[i] < b->score[i])
return FcFalse;
}
if (aa > ab)
return FcTrue;
return FcFalse;
}
static FcBool
FcSortWalk (FcSortNode *n, FcFontSet *fs, FcCharSet **cs, FcBool trim)
{
FcCharSet *ncs;
if (!n)
return FcTrue;
if (!FcSortWalk ((FcSortNode *) n->avl.left, fs, cs, trim))
return FcFalse;
if (FcPatternGetCharSet (n->pattern, FC_CHARSET, 0, &ncs) == FcResultMatch)
{
if (!trim || !*cs || FcCharSetSubtractCount (ncs, *cs) != 0)
{
if (*cs)
{
ncs = FcCharSetUnion (ncs, *cs);
if (!ncs)
return FcFalse;
FcCharSetDestroy (*cs);
}
else
ncs = FcCharSetCopy (ncs);
*cs = ncs;
if (!FcFontSetAdd (fs, n->pattern))
return FcFalse;
}
}
if (!FcSortWalk ((FcSortNode *) n->avl.right, fs, cs, trim))
return FcFalse;
return FcTrue;
}
FcFontSet *
FcFontSetSort (FcConfig *config,
FcFontSet **sets,
int nsets,
FcPattern *p,
FcBool trim,
FcCharSet **csp,
FcResult *result)
{
FcFontSet *ret;
FcFontSet *s;
FcSortNode *nodes;
int nnodes;
FcSortNode *root;
FcSortNode *new;
FcCharSet *cs;
int set;
int f;
int i;
nnodes = 0;
for (set = 0; set < nsets; set++)
{
s = sets[set];
if (!s)
continue;
nnodes += s->nfont;
}
if (!nnodes)
goto bail0;
nodes = malloc (nnodes * sizeof (FcSortNode));
if (!nodes)
goto bail0;
root = 0;
new = nodes;
for (set = 0; set < nsets; set++)
{
s = sets[set];
if (!s)
continue;
for (f = 0; f < s->nfont; f++)
{
if (FcDebug () & FC_DBG_MATCHV)
{
printf ("Font %d ", f);
FcPatternPrint (s->fonts[f]);
}
new->pattern = s->fonts[f];
if (!FcCompare (p, new->pattern, new->score, result))
goto bail1;
if (FcDebug () & FC_DBG_MATCHV)
{
printf ("Score");
for (i = 0; i < NUM_MATCHER; i++)
{
printf (" %g", new->score[i]);
}
printf ("\n");
}
FcAvlInsert (FcSortMore, (FcAvlNode **) &root, &new->avl);
new++;
}
}
ret = FcFontSetCreate ();
if (!ret)
goto bail1;
cs = 0;
if (!FcSortWalk (root, ret, &cs, trim))
goto bail2;
*csp = cs;
return ret;
bail2:
if (cs)
FcCharSetDestroy (cs);
FcFontSetDestroy (ret);
bail1:
free (nodes);
bail0:
return 0;
}

View File

@ -1,112 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcmatrix.c,v 1.1.1.1 2002/02/14 23:34:12 keithp Exp $
*
* Copyright © 2000 Tuomas J. Lukka
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Tuomas Lukka not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Tuomas Lukka makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* TUOMAS LUKKA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL TUOMAS LUKKA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include "fcint.h"
FcMatrix *
FcMatrixCopy (const FcMatrix *mat)
{
FcMatrix *r;
if(!mat)
return 0;
r = (FcMatrix *) malloc (sizeof (*r) );
if (!r)
return 0;
FcMemAlloc (FC_MEM_MATRIX, sizeof (FcMatrix));
*r = *mat;
return r;
}
void
FcMatrixFree (FcMatrix *mat)
{
FcMemFree (FC_MEM_MATRIX, sizeof (FcMatrix));
free (mat);
}
FcBool
FcMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2)
{
if(mat1 == mat2) return FcTrue;
if(mat1 == 0 || mat2 == 0) return FcFalse;
return mat1->xx == mat2->xx &&
mat1->xy == mat2->xy &&
mat1->yx == mat2->yx &&
mat1->yy == mat2->yy;
}
void
FcMatrixMultiply (FcMatrix *result, const FcMatrix *a, const FcMatrix *b)
{
FcMatrix r;
r.xx = a->xx * b->xx + a->xy * b->yx;
r.xy = a->xx * b->xy + a->xy * b->yy;
r.yx = a->yx * b->xx + a->yy * b->yx;
r.yy = a->yx * b->xy + a->yy * b->yy;
*result = r;
}
void
FcMatrixRotate (FcMatrix *m, double c, double s)
{
FcMatrix r;
/*
* X Coordinate system is upside down, swap to make
* rotations counterclockwise
*/
r.xx = c;
r.xy = -s;
r.yx = s;
r.yy = c;
FcMatrixMultiply (m, &r, m);
}
void
FcMatrixScale (FcMatrix *m, double sx, double sy)
{
FcMatrix r;
r.xx = sx;
r.xy = 0;
r.yx = 0;
r.yy = sy;
FcMatrixMultiply (m, &r, m);
}
void
FcMatrixShear (FcMatrix *m, double sh, double sv)
{
FcMatrix r;
r.xx = 1;
r.xy = sh;
r.yx = sv;
r.yy = 1;
FcMatrixMultiply (m, &r, m);
}

View File

@ -1,543 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcname.c,v 1.3 2002/02/18 22:29:28 keithp Exp $
*
* 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
* 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.
*/
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "fcint.h"
static const FcObjectType _FcBaseObjectTypes[] = {
{ FC_FAMILY, FcTypeString, },
{ FC_STYLE, FcTypeString, },
{ FC_SLANT, FcTypeInteger, },
{ FC_WEIGHT, FcTypeInteger, },
{ FC_SIZE, FcTypeDouble, },
{ FC_PIXEL_SIZE, FcTypeDouble, },
{ FC_SPACING, FcTypeInteger, },
{ FC_FOUNDRY, FcTypeString, },
/* { FC_CORE, FcTypeBool, }, */
{ FC_ANTIALIAS, FcTypeBool, },
/* { FC_XLFD, FcTypeString, }, */
{ FC_FILE, FcTypeString, },
{ FC_INDEX, FcTypeInteger, },
{ FC_RASTERIZER, FcTypeString, },
{ FC_OUTLINE, FcTypeBool, },
{ FC_SCALABLE, FcTypeBool, },
{ FC_RGBA, FcTypeInteger, },
{ FC_SCALE, FcTypeDouble, },
/* { FC_RENDER, FcTypeBool, },*/
{ FC_MINSPACE, FcTypeBool, },
{ FC_CHAR_WIDTH, FcTypeInteger },
{ FC_CHAR_HEIGHT, FcTypeInteger },
{ FC_MATRIX, FcTypeMatrix },
{ FC_CHARSET, FcTypeCharSet },
{ FC_LANG, FcTypeString },
};
#define NUM_OBJECT_TYPES (sizeof _FcBaseObjectTypes / sizeof _FcBaseObjectTypes[0])
typedef struct _FcObjectTypeList FcObjectTypeList;
struct _FcObjectTypeList {
const FcObjectTypeList *next;
const FcObjectType *types;
int ntypes;
};
static const FcObjectTypeList _FcBaseObjectTypesList = {
0,
_FcBaseObjectTypes,
NUM_OBJECT_TYPES
};
static const FcObjectTypeList *_FcObjectTypes = &_FcBaseObjectTypesList;
FcBool
FcNameRegisterObjectTypes (const FcObjectType *types, int ntypes)
{
FcObjectTypeList *l;
l = (FcObjectTypeList *) malloc (sizeof (FcObjectTypeList));
if (!l)
return FcFalse;
l->types = types;
l->ntypes = ntypes;
l->next = _FcObjectTypes;
_FcObjectTypes = l;
return FcTrue;
}
FcBool
FcNameUnregisterObjectTypes (const FcObjectType *types, int ntypes)
{
const FcObjectTypeList *l, **prev;
for (prev = &_FcObjectTypes;
(l = *prev);
prev = (const FcObjectTypeList **) &(l->next))
{
if (l->types == types && l->ntypes == ntypes)
{
*prev = l->next;
free ((void *) l);
return FcTrue;
}
}
return FcFalse;
}
const FcObjectType *
FcNameGetObjectType (const char *object)
{
int i;
const FcObjectTypeList *l;
const FcObjectType *t;
for (l = _FcObjectTypes; l; l = l->next)
{
for (i = 0; i < l->ntypes; i++)
{
t = &l->types[i];
if (!FcStrCmpIgnoreCase ((FcChar8 *) object, (FcChar8 *) t->object))
return t;
}
}
return 0;
}
static const FcConstant _FcBaseConstants[] = {
{ (FcChar8 *) "light", "weight", FC_WEIGHT_LIGHT, },
{ (FcChar8 *) "medium", "weight", FC_WEIGHT_MEDIUM, },
{ (FcChar8 *) "demibold", "weight", FC_WEIGHT_DEMIBOLD, },
{ (FcChar8 *) "bold", "weight", FC_WEIGHT_BOLD, },
{ (FcChar8 *) "black", "weight", FC_WEIGHT_BLACK, },
{ (FcChar8 *) "roman", "slant", FC_SLANT_ROMAN, },
{ (FcChar8 *) "italic", "slant", FC_SLANT_ITALIC, },
{ (FcChar8 *) "oblique", "slant", FC_SLANT_OBLIQUE, },
{ (FcChar8 *) "proportional", "spacing", FC_PROPORTIONAL, },
{ (FcChar8 *) "mono", "spacing", FC_MONO, },
{ (FcChar8 *) "charcell", "spacing", FC_CHARCELL, },
{ (FcChar8 *) "rgb", "rgba", FC_RGBA_RGB, },
{ (FcChar8 *) "bgr", "rgba", FC_RGBA_BGR, },
{ (FcChar8 *) "vrgb", "rgba", FC_RGBA_VRGB },
{ (FcChar8 *) "vbgr", "rgba", FC_RGBA_VBGR },
};
#define NUM_FC_CONSTANTS (sizeof _FcBaseConstants/sizeof _FcBaseConstants[0])
typedef struct _FcConstantList FcConstantList;
struct _FcConstantList {
const FcConstantList *next;
const FcConstant *consts;
int nconsts;
};
static const FcConstantList _FcBaseConstantList = {
0,
_FcBaseConstants,
NUM_FC_CONSTANTS
};
static const FcConstantList *_FcConstants = &_FcBaseConstantList;
FcBool
FcNameRegisterConstants (const FcConstant *consts, int nconsts)
{
FcConstantList *l;
l = (FcConstantList *) malloc (sizeof (FcConstantList));
if (!l)
return FcFalse;
l->consts = consts;
l->nconsts = nconsts;
l->next = _FcConstants;
_FcConstants = l;
return FcTrue;
}
FcBool
FcNameUnregisterConstants (const FcConstant *consts, int nconsts)
{
const FcConstantList *l, **prev;
for (prev = &_FcConstants;
(l = *prev);
prev = (const FcConstantList **) &(l->next))
{
if (l->consts == consts && l->nconsts == nconsts)
{
*prev = l->next;
free ((void *) l);
return FcTrue;
}
}
return FcFalse;
}
const FcConstant *
FcNameGetConstant (FcChar8 *string)
{
const FcConstantList *l;
int i;
for (l = _FcConstants; l; l = l->next)
{
for (i = 0; i < l->nconsts; i++)
if (!FcStrCmpIgnoreCase (string, l->consts[i].name))
return &l->consts[i];
}
return 0;
}
FcBool
FcNameConstant (FcChar8 *string, int *result)
{
const FcConstant *c;
if ((c = FcNameGetConstant(string)))
{
*result = c->value;
return FcTrue;
}
return FcFalse;
}
FcBool
FcNameBool (FcChar8 *v, FcBool *result)
{
char c0, c1;
c0 = *v;
if (isupper (c0))
c0 = tolower (c0);
if (c0 == 't' || c0 == 'y' || c0 == '1')
{
*result = FcTrue;
return FcTrue;
}
if (c0 == 'f' || c0 == 'n' || c0 == '0')
{
*result = FcFalse;
return FcTrue;
}
if (c0 == 'o')
{
c1 = v[1];
if (isupper (c1))
c1 = tolower (c1);
if (c1 == 'n')
{
*result = FcTrue;
return FcTrue;
}
if (c1 == 'f')
{
*result = FcFalse;
return FcTrue;
}
}
return FcFalse;
}
static FcValue
FcNameConvert (FcType type, FcChar8 *string, FcMatrix *m)
{
FcValue v;
v.type = type;
switch (v.type) {
case FcTypeInteger:
if (!FcNameConstant (string, &v.u.i))
v.u.i = atoi ((char *) string);
break;
case FcTypeString:
v.u.s = string;
break;
case FcTypeBool:
if (!FcNameBool (string, &v.u.b))
v.u.b = FcFalse;
break;
case FcTypeDouble:
v.u.d = strtod ((char *) string, 0);
break;
case FcTypeMatrix:
v.u.m = m;
sscanf ((char *) string, "%lg %lg %lg %lg", &m->xx, &m->xy, &m->yx, &m->yy);
break;
case FcTypeCharSet:
v.u.c = FcNameParseCharSet (string);
break;
default:
break;
}
return v;
}
static const FcChar8 *
FcNameFindNext (const FcChar8 *cur, const char *delim, FcChar8 *save, FcChar8 *last)
{
FcChar8 c;
while ((c = *cur))
{
if (c == '\\')
{
++cur;
if (!(c = *cur))
break;
}
else if (strchr (delim, c))
break;
++cur;
*save++ = c;
}
*save = 0;
*last = *cur;
if (*cur)
cur++;
return cur;
}
FcPattern *
FcNameParse (const FcChar8 *name)
{
FcChar8 *save;
FcPattern *pat;
double d;
FcChar8 *e;
FcChar8 delim;
FcValue v;
FcMatrix m;
const FcObjectType *t;
const FcConstant *c;
save = malloc (strlen ((char *) name) + 1);
if (!save)
goto bail0;
pat = FcPatternCreate ();
if (!pat)
goto bail1;
for (;;)
{
name = FcNameFindNext (name, "-,:", save, &delim);
if (save[0])
{
if (!FcPatternAddString (pat, FC_FAMILY, save))
goto bail2;
}
if (delim != ',')
break;
}
if (delim == '-')
{
for (;;)
{
name = FcNameFindNext (name, "-,:", save, &delim);
d = strtod ((char *) save, (char **) &e);
if (e != save)
{
if (!FcPatternAddDouble (pat, FC_SIZE, d))
goto bail2;
}
if (delim != ',')
break;
}
}
while (delim == ':')
{
name = FcNameFindNext (name, "=_:", save, &delim);
if (save[0])
{
if (delim == '=' || delim == '_')
{
t = FcNameGetObjectType ((char *) save);
for (;;)
{
name = FcNameFindNext (name, ":,", save, &delim);
if (save[0] && t)
{
v = FcNameConvert (t->type, save, &m);
if (!FcPatternAdd (pat, t->object, v, FcTrue))
{
if (v.type == FcTypeCharSet)
FcCharSetDestroy ((FcCharSet *) v.u.c);
goto bail2;
}
if (v.type == FcTypeCharSet)
FcCharSetDestroy ((FcCharSet *) v.u.c);
}
if (delim != ',')
break;
}
}
else
{
if ((c = FcNameGetConstant (save)))
{
if (!FcPatternAddInteger (pat, c->object, c->value))
goto bail2;
}
}
}
}
free (save);
return pat;
bail2:
FcPatternDestroy (pat);
bail1:
free (save);
bail0:
return 0;
}
static FcBool
FcNameUnparseString (FcStrBuf *buf,
const FcChar8 *string,
const FcChar8 *escape)
{
FcChar8 c;
while ((c = *string++))
{
if (escape && strchr ((char *) escape, (char) c))
{
if (!FcStrBufChar (buf, escape[0]))
return FcFalse;
}
if (!FcStrBufChar (buf, c))
return FcFalse;
}
return FcTrue;
}
static FcBool
FcNameUnparseValue (FcStrBuf *buf,
FcValue v,
FcChar8 *escape)
{
FcChar8 temp[1024];
switch (v.type) {
case FcTypeVoid:
return FcTrue;
case FcTypeInteger:
sprintf ((char *) temp, "%d", v.u.i);
return FcNameUnparseString (buf, temp, 0);
case FcTypeDouble:
sprintf ((char *) temp, "%g", v.u.d);
return FcNameUnparseString (buf, temp, 0);
case FcTypeString:
return FcNameUnparseString (buf, v.u.s, escape);
case FcTypeBool:
return FcNameUnparseString (buf, v.u.b ? (FcChar8 *) "True" : (FcChar8 *) "False", 0);
case FcTypeMatrix:
sprintf ((char *) temp, "%g %g %g %g",
v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
return FcNameUnparseString (buf, temp, 0);
case FcTypeCharSet:
return FcNameUnparseCharSet (buf, v.u.c);
}
return FcFalse;
}
static FcBool
FcNameUnparseValueList (FcStrBuf *buf,
FcValueList *v,
FcChar8 *escape)
{
while (v)
{
if (!FcNameUnparseValue (buf, v->value, escape))
return FcFalse;
if ((v = v->next))
if (!FcNameUnparseString (buf, (FcChar8 *) ",", 0))
return FcFalse;
}
return FcTrue;
}
#define FC_ESCAPE_FIXED "\\-:,"
#define FC_ESCAPE_VARIABLE "\\=_:,"
FcChar8 *
FcNameUnparse (FcPattern *pat)
{
FcStrBuf buf;
FcChar8 buf_static[8192];
int i;
FcPatternElt *e;
const FcObjectTypeList *l;
const FcObjectType *o;
FcStrBufInit (&buf, buf_static, sizeof (buf_static));
e = FcPatternFind (pat, FC_FAMILY, FcFalse);
if (e)
{
if (!FcNameUnparseValueList (&buf, e->values, (FcChar8 *) FC_ESCAPE_FIXED))
goto bail0;
}
e = FcPatternFind (pat, FC_SIZE, FcFalse);
if (e)
{
if (!FcNameUnparseString (&buf, (FcChar8 *) "-", 0))
goto bail0;
if (!FcNameUnparseValueList (&buf, e->values, (FcChar8 *) FC_ESCAPE_FIXED))
goto bail0;
}
for (l = _FcObjectTypes; l; l = l->next)
{
for (i = 0; i < l->ntypes; i++)
{
o = &l->types[i];
if (!strcmp (o->object, FC_FAMILY) ||
!strcmp (o->object, FC_SIZE) ||
!strcmp (o->object, FC_FILE))
continue;
e = FcPatternFind (pat, o->object, FcFalse);
if (e)
{
if (!FcNameUnparseString (&buf, (FcChar8 *) ":", 0))
goto bail0;
if (!FcNameUnparseString (&buf, (FcChar8 *) o->object, (FcChar8 *) FC_ESCAPE_VARIABLE))
goto bail0;
if (!FcNameUnparseString (&buf, (FcChar8 *) "=", 0))
goto bail0;
if (!FcNameUnparseValueList (&buf, e->values,
(FcChar8 *) FC_ESCAPE_VARIABLE))
goto bail0;
}
}
}
return FcStrBufDone (&buf);
bail0:
FcStrBufDestroy (&buf);
return 0;
}

View File

@ -1,491 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcpat.c,v 1.3 2002/02/19 07:50:44 keithp Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include <string.h>
#include "fcint.h"
FcPattern *
FcPatternCreate (void)
{
FcPattern *p;
p = (FcPattern *) malloc (sizeof (FcPattern));
if (!p)
return 0;
FcMemAlloc (FC_MEM_PATTERN, sizeof (FcPattern));
p->num = 0;
p->size = 0;
p->elts = 0;
return p;
}
void
FcValueDestroy (FcValue v)
{
switch (v.type) {
case FcTypeString:
FcStrFree ((FcChar8 *) v.u.s);
break;
case FcTypeMatrix:
FcMatrixFree ((FcMatrix *) v.u.m);
break;
case FcTypeCharSet:
FcCharSetDestroy ((FcCharSet *) v.u.c);
break;
default:
break;
}
}
FcValue
FcValueSave (FcValue v)
{
switch (v.type) {
case FcTypeString:
v.u.s = FcStrCopy (v.u.s);
if (!v.u.s)
v.type = FcTypeVoid;
break;
case FcTypeMatrix:
v.u.m = FcMatrixCopy (v.u.m);
if (!v.u.m)
v.type = FcTypeVoid;
break;
case FcTypeCharSet:
v.u.c = FcCharSetCopy ((FcCharSet *) v.u.c);
if (!v.u.c)
v.type = FcTypeVoid;
break;
default:
break;
}
return v;
}
void
FcValueListDestroy (FcValueList *l)
{
FcValueList *next;
for (; l; l = next)
{
switch (l->value.type) {
case FcTypeString:
FcStrFree ((FcChar8 *) l->value.u.s);
break;
case FcTypeMatrix:
FcMatrixFree ((FcMatrix *) l->value.u.m);
break;
case FcTypeCharSet:
FcCharSetDestroy ((FcCharSet *) l->value.u.c);
break;
default:
break;
}
next = l->next;
FcMemFree (FC_MEM_VALLIST, sizeof (FcValueList));
free (l);
}
}
void
FcPatternDestroy (FcPattern *p)
{
int i;
for (i = 0; i < p->num; i++)
FcValueListDestroy (p->elts[i].values);
p->num = 0;
if (p->elts)
{
FcMemFree (FC_MEM_PATELT, p->size * sizeof (FcPatternElt));
free (p->elts);
p->elts = 0;
}
p->size = 0;
FcMemFree (FC_MEM_PATTERN, sizeof (FcPattern));
free (p);
}
FcPatternElt *
FcPatternFind (FcPattern *p, const char *object, FcBool insert)
{
int i;
int s;
FcPatternElt *e;
/* match existing */
for (i = 0; i < p->num; i++)
{
if (!FcStrCmpIgnoreCase ((FcChar8 *) object, (FcChar8 *) p->elts[i].object))
return &p->elts[i];
}
if (!insert)
return FcFalse;
/* grow array */
if (i == p->size)
{
s = p->size + 16;
if (p->elts)
e = (FcPatternElt *) realloc (p->elts, s * sizeof (FcPatternElt));
else
e = (FcPatternElt *) malloc (s * sizeof (FcPatternElt));
if (!e)
return FcFalse;
p->elts = e;
if (p->size)
FcMemFree (FC_MEM_PATELT, p->size * sizeof (FcPatternElt));
FcMemAlloc (FC_MEM_PATELT, s * sizeof (FcPatternElt));
while (p->size < s)
{
p->elts[p->size].object = 0;
p->elts[p->size].values = 0;
p->size++;
}
}
/* bump count */
p->num++;
p->elts[i].object = object;
return &p->elts[i];
}
FcBool
FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append)
{
FcPatternElt *e;
FcValueList *new, **prev;
new = (FcValueList *) malloc (sizeof (FcValueList));
if (!new)
goto bail0;
FcMemAlloc (FC_MEM_VALLIST, sizeof (FcValueList));
/* dup string */
value = FcValueSave (value);
if (value.type == FcTypeVoid)
goto bail1;
new->value = value;
new->next = 0;
e = FcPatternFind (p, object, FcTrue);
if (!e)
goto bail2;
if (append)
{
for (prev = &e->values; *prev; prev = &(*prev)->next);
*prev = new;
}
else
{
new->next = e->values;
e->values = new;
}
return FcTrue;
bail2:
switch (value.type) {
case FcTypeString:
FcStrFree ((FcChar8 *) value.u.s);
break;
case FcTypeMatrix:
FcMatrixFree ((FcMatrix *) value.u.m);
break;
case FcTypeCharSet:
FcCharSetDestroy ((FcCharSet *) value.u.c);
break;
default:
break;
}
bail1:
FcMemFree (FC_MEM_VALLIST, sizeof (FcValueList));
free (new);
bail0:
return FcFalse;
}
FcBool
FcPatternDel (FcPattern *p, const char *object)
{
FcPatternElt *e;
int i;
e = FcPatternFind (p, object, FcFalse);
if (!e)
return FcFalse;
i = e - p->elts;
/* destroy value */
FcValueListDestroy (e->values);
/* shuffle existing ones down */
memmove (e, e+1, (p->elts + p->num - (e + 1)) * sizeof (FcPatternElt));
p->num--;
p->elts[p->num].object = 0;
p->elts[p->num].values = 0;
return FcTrue;
}
FcBool
FcPatternAddInteger (FcPattern *p, const char *object, int i)
{
FcValue v;
v.type = FcTypeInteger;
v.u.i = i;
return FcPatternAdd (p, object, v, FcTrue);
}
FcBool
FcPatternAddDouble (FcPattern *p, const char *object, double d)
{
FcValue v;
v.type = FcTypeDouble;
v.u.d = d;
return FcPatternAdd (p, object, v, FcTrue);
}
FcBool
FcPatternAddString (FcPattern *p, const char *object, const FcChar8 *s)
{
FcValue v;
v.type = FcTypeString;
v.u.s = s;
return FcPatternAdd (p, object, v, FcTrue);
}
FcBool
FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s)
{
FcValue v;
v.type = FcTypeMatrix;
v.u.m = (FcMatrix *) s;
return FcPatternAdd (p, object, v, FcTrue);
}
FcBool
FcPatternAddBool (FcPattern *p, const char *object, FcBool b)
{
FcValue v;
v.type = FcTypeBool;
v.u.b = b;
return FcPatternAdd (p, object, v, FcTrue);
}
FcBool
FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c)
{
FcValue v;
v.type = FcTypeCharSet;
v.u.c = (FcCharSet *) c;
return FcPatternAdd (p, object, v, FcTrue);
}
FcResult
FcPatternGet (FcPattern *p, const char *object, int id, FcValue *v)
{
FcPatternElt *e;
FcValueList *l;
e = FcPatternFind (p, object, FcFalse);
if (!e)
return FcResultNoMatch;
for (l = e->values; l; l = l->next)
{
if (!id)
{
*v = l->value;
return FcResultMatch;
}
id--;
}
return FcResultNoId;
}
FcResult
FcPatternGetInteger (FcPattern *p, const char *object, int id, int *i)
{
FcValue v;
FcResult r;
r = FcPatternGet (p, object, id, &v);
if (r != FcResultMatch)
return r;
switch (v.type) {
case FcTypeDouble:
*i = (int) v.u.d;
break;
case FcTypeInteger:
*i = v.u.i;
break;
default:
return FcResultTypeMismatch;
}
return FcResultMatch;
}
FcResult
FcPatternGetDouble (FcPattern *p, const char *object, int id, double *d)
{
FcValue v;
FcResult r;
r = FcPatternGet (p, object, id, &v);
if (r != FcResultMatch)
return r;
switch (v.type) {
case FcTypeDouble:
*d = v.u.d;
break;
case FcTypeInteger:
*d = (double) v.u.i;
break;
default:
return FcResultTypeMismatch;
}
return FcResultMatch;
}
FcResult
FcPatternGetString (FcPattern *p, const char *object, int id, FcChar8 ** s)
{
FcValue v;
FcResult r;
r = FcPatternGet (p, object, id, &v);
if (r != FcResultMatch)
return r;
if (v.type != FcTypeString)
return FcResultTypeMismatch;
*s = (FcChar8 *) v.u.s;
return FcResultMatch;
}
FcResult
FcPatternGetMatrix (FcPattern *p, const char *object, int id, FcMatrix **m)
{
FcValue v;
FcResult r;
r = FcPatternGet (p, object, id, &v);
if (r != FcResultMatch)
return r;
if (v.type != FcTypeMatrix)
return FcResultTypeMismatch;
*m = (FcMatrix *) v.u.m;
return FcResultMatch;
}
FcResult
FcPatternGetBool (FcPattern *p, const char *object, int id, FcBool *b)
{
FcValue v;
FcResult r;
r = FcPatternGet (p, object, id, &v);
if (r != FcResultMatch)
return r;
if (v.type != FcTypeBool)
return FcResultTypeMismatch;
*b = v.u.b;
return FcResultMatch;
}
FcResult
FcPatternGetCharSet (FcPattern *p, const char *object, int id, FcCharSet **c)
{
FcValue v;
FcResult r;
r = FcPatternGet (p, object, id, &v);
if (r != FcResultMatch)
return r;
if (v.type != FcTypeCharSet)
return FcResultTypeMismatch;
*c = (FcCharSet *) v.u.c;
return FcResultMatch;
}
FcPattern *
FcPatternDuplicate (FcPattern *orig)
{
FcPattern *new;
int i;
FcValueList *l;
new = FcPatternCreate ();
if (!new)
goto bail0;
for (i = 0; i < orig->num; i++)
{
for (l = orig->elts[i].values; l; l = l->next)
if (!FcPatternAdd (new, orig->elts[i].object, l->value, FcTrue))
goto bail1;
}
return new;
bail1:
FcPatternDestroy (new);
bail0:
return 0;
}
FcPattern *
FcPatternVaBuild (FcPattern *orig, va_list va)
{
FcPattern *ret;
FcPatternVapBuild (ret, orig, va);
return ret;
}
FcPattern *
FcPatternBuild (FcPattern *orig, ...)
{
va_list va;
va_start (va, orig);
FcPatternVapBuild (orig, orig, va);
va_end (va);
return orig;
}

View File

@ -1,278 +0,0 @@
/*
* $XFree86: xc/lib/fontconfig/src/fcstr.c,v 1.3 2002/02/18 22:29:28 keithp Exp $
*
* 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
* 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.
*/
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "fcint.h"
FcChar8 *
FcStrCopy (const FcChar8 *s)
{
FcChar8 *r;
if (!s)
return 0;
r = (FcChar8 *) malloc (strlen ((char *) s) + 1);
if (!r)
return 0;
FcMemAlloc (FC_MEM_STRING, strlen ((char *) s) + 1);
strcpy ((char *) r, (char *) s);
return r;
}
FcChar8 *
FcStrPlus (const FcChar8 *s1, const FcChar8 *s2)
{
int l = strlen ((char *)s1) + strlen ((char *) s2) + 1;
FcChar8 *s = malloc (l);
if (!s)
return 0;
FcMemAlloc (FC_MEM_STRING, l);
strcpy ((char *) s, (char *) s1);
strcat ((char *) s, (char *) s2);
return s;
}
void
FcStrFree (FcChar8 *s)
{
FcMemFree (FC_MEM_STRING, strlen ((char *) s) + 1);
free (s);
}
int
FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2)
{
FcChar8 c1, c2;
for (;;)
{
c1 = *s1++;
c2 = *s2++;
if (!c1 || !c2)
break;
c1 = FcToLower (c1);
c2 = FcToLower (c2);
if (c1 != c2)
break;
}
return (int) c2 - (int) c1;
}
int
FcUtf8ToUcs4 (FcChar8 *src_orig,
FcChar32 *dst,
int len)
{
FcChar8 *src = src_orig;
FcChar8 s;
int extra;
FcChar32 result;
if (len == 0)
return 0;
s = *src++;
len--;
if (!(s & 0x80))
{
result = s;
extra = 0;
}
else if (!(s & 0x40))
{
return -1;
}
else if (!(s & 0x20))
{
result = s & 0x1f;
extra = 1;
}
else if (!(s & 0x10))
{
result = s & 0xf;
extra = 2;
}
else if (!(s & 0x08))
{
result = s & 0x07;
extra = 3;
}
else if (!(s & 0x04))
{
result = s & 0x03;
extra = 4;
}
else if ( ! (s & 0x02))
{
result = s & 0x01;
extra = 5;
}
else
{
return -1;
}
if (extra > len)
return -1;
while (extra--)
{
result <<= 6;
s = *src++;
if ((s & 0xc0) != 0x80)
return -1;
result |= s & 0x3f;
}
*dst = result;
return src - src_orig;
}
FcBool
FcUtf8Len (FcChar8 *string,
int len,
int *nchar,
int *wchar)
{
int n;
int clen;
FcChar32 c;
FcChar32 max;
n = 0;
max = 0;
while (len)
{
clen = FcUtf8ToUcs4 (string, &c, len);
if (clen <= 0) /* malformed UTF8 string */
return FcFalse;
if (c > max)
max = c;
string += clen;
len -= clen;
n++;
}
*nchar = n;
if (max >= 0x10000)
*wchar = 4;
else if (max > 0x100)
*wchar = 2;
else
*wchar = 1;
return FcTrue;
}
void
FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size)
{
buf->buf = init;
buf->allocated = FcFalse;
buf->failed = FcFalse;
buf->len = 0;
buf->size = size;
}
void
FcStrBufDestroy (FcStrBuf *buf)
{
if (buf->allocated)
{
free (buf->buf);
FcStrBufInit (buf, 0, 0);
}
}
FcChar8 *
FcStrBufDone (FcStrBuf *buf)
{
FcChar8 *ret;
ret = malloc (buf->len + 1);
if (ret)
{
memcpy (ret, buf->buf, buf->len);
ret[buf->len] = '\0';
}
FcStrBufDestroy (buf);
return ret;
}
FcBool
FcStrBufChar (FcStrBuf *buf, FcChar8 c)
{
if (buf->len == buf->size)
{
FcChar8 *new;
int size;
if (buf->allocated)
{
size = buf->size * 2;
new = realloc (buf->buf, size);
}
else
{
size = buf->size + 1024;
new = malloc (size);
if (new)
{
buf->allocated = FcTrue;
memcpy (new, buf->buf, buf->len);
}
}
if (!new)
{
buf->failed = FcTrue;
return FcFalse;
}
buf->size = size;
buf->buf = new;
}
buf->buf[buf->len++] = c;
return FcTrue;
}
FcBool
FcStrBufString (FcStrBuf *buf, const FcChar8 *s)
{
FcChar8 c;
while ((c = *s++))
if (!FcStrBufChar (buf, c))
return FcFalse;
return FcTrue;
}
FcBool
FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len)
{
while (len-- > 0)
if (!FcStrBufChar (buf, *s++))
return FcFalse;
return FcTrue;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +0,0 @@
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
and Clark Cooper
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,46 +0,0 @@
Release 1.95.2 Fri Jul 27 2001
- Nore changes to make MSVC happy with the build; add a single
workspace to support both the library and xmlwf applicatiion.
- Added a Windows installer for Windows users; includes
xmlwf.exe.
- Added compile-time constants that can be used to determine the
Expat version
- Removed a lot of GNU-specific dependencies to aide portability
among the various Unix flavors.
- Fix the UTF-8 BOM bug.
- Cleaned up warning messages for several compilers.
- Added the -Wall, -Wstrict-prototypes options for GCC.
Release 1.95.1 Sun Oct 22 15:11:36 EDT 2000
- Changes to get expat to build under Microsoft compiler
- Removed all aborts and instead return an UNEXPECTED_STATE error.
- Fixed a bug where a stray '%' in an entity value would cause an
abort.
- Defined XML_SetEndNamespaceDeclHandler. Thanks to Darryl Miles for
finding this oversight.
- Changed default patterns in lib/Makefile.in to fit non-GNU makes
Thanks to robin@unrated.net for reporting and providing an
account to test on.
- The reference had the wrong label for XML_SetStartNamespaceDecl.
Reported by an anonymous user.
Release 1.95.0 Fri Sep 29 2000
- XML_ParserCreate_MM
Allows you to set a memory management suite to replace the
standard malloc,realloc, and free.
- XML_SetReturnNSTriplet
If you turn this feature on when namespace processing is in
effect, then qualified, prefixed element and attribute names
are returned as "uri|name|prefix" where '|' is whatever
separator character is used in namespace processing.
- Merged in features from perl-expat
o XML_SetElementDeclHandler
o XML_SetAttlistDeclHandler
o XML_SetXmlDeclHandler
o XML_SetEntityDeclHandler
o StartDoctypeDeclHandler takes 3 additional parameters:
sysid, pubid, has_internal_subset
o Many paired handler setters (like XML_SetElementHandler)
now have corresponding individual handler setters
o XML_GetInputContext for getting the input context of
the current parse position.
- Added reference material
- Packaged into a distribution that builds a sharable library

View File

@ -1,58 +0,0 @@
Changes
COPYING
MANIFEST
Makefile.in
README
config.h.in
configure
configure.in
conftools/PrintPath
conftools/ac_c_bigendian_cross.m4
conftools/config.guess
conftools/config.sub
conftools/install-sh
conftools/ltconfig
conftools/ltmain.sh
conftools/missing
conftools/mkinstalldirs
doc/reference.html
doc/style.css
examples/Makefile.in
examples/elements.c
examples/outline.c
lib/Makefile.in
lib/ascii.h
lib/asciitab.h
lib/expat.h.in
lib/iasciitab.h
lib/latin1tab.h
lib/nametab.h
lib/utf8tab.h
lib/xmlparse.c
lib/xmlrole.c
lib/xmlrole.h
lib/xmltok.c
lib/xmltok.h
lib/xmltok_impl.c
lib/xmltok_impl.h
lib/xmltok_ns.c
lib/winconfig.h
xmlwf/Makefile.in
xmlwf/codepage.c
xmlwf/codepage.h
xmlwf/ct.c
xmlwf/filemap.h
xmlwf/readfilemap.c
xmlwf/unixfilemap.c
xmlwf/wfcheck.c
xmlwf/wfcheck.h
xmlwf/wfcheckmessage.c
xmlwf/win32filemap.c
xmlwf/xmlfile.c
xmlwf/xmlfile.h
xmlwf/xmlmime.c
xmlwf/xmlmime.h
xmlwf/xmltchar.h
xmlwf/xmlurl.h
xmlwf/xmlwf.c
xmlwf/xmlwin32url.cxx

View File

@ -1,165 +0,0 @@
################################################################
# Process this file with top-level configure script to produce Makefile
#
# Copyright 2000 Clark Cooper
#
# This file is part of EXPAT.
#
# EXPAT is free software; you can redistribute it and/or modify it
# under the terms of the License (based on the MIT/X license) contained
# in the file COPYING that comes with this distribution.
#
# EXPAT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN EXPAT.
#
# ---
# I started using automake, but
# 1) it seemed like overkill
# 2) I don't want all the GNU policies
# 3) I wanted more explicit control over what gets built
#
# So I'm doing my Makefile.in files manually. But a fair part is based
# on what I learned from perusing the Makefile.in's generated by automake,
# and the automake authors still get my kudos.
#
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
top_builddir = .
AUTOCONF = autoconf
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
CC = @CC@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
SUBDIRS = lib examples xmlwf
INSTALLSUBDIRS = lib xmlwf
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
CONFIG_HEADERS = config.h
DISTDIR = $(PACKAGE)-$(VERSION)
DISTRIBUTION = $(DISTDIR).tar.gz
default: lib xmlwf
buildlib: lib
all: $(SUBDIRS)
Makefile: Makefile.in config.status
CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) config.status
config.status: configure
@if test -f $@; then \
$(SHELL) config.status --recheck ; \
else \
$(SHELL) configure ; \
fi
configure: configure.in
$(AUTOCONF)
config.h: config.h.in config.status
CONFIG_FILES= CONFIG_HEADERS=$(CONFIG_HEADERS) \
$(SHELL) ./config.status
$(SUBDIRS):
cd $@ && $(MAKE)
clean:
for dir in $(SUBDIRS); do \
(cd $$dir && $(MAKE) clean); \
done
rm -f core *~
distclean:
for dir in $(SUBDIRS); do \
(cd $$dir && $(MAKE) distclean); \
done
rm -f config.h config.status config.log config.cache libtool
rm -f Makefile examples/Makefile xmlwf/Makefile
extraclean: distclean
rm -f aclocal.m4 config.h.in configure
rm -f conftools/config.guess conftools/config.sub
rm -f conftools/ltconfig conftools/ltmain.sh
maintainer-clean: distclean
rm -f $(DISTRIBUTION)
rm -rf $(DISTDIR)
distdir: MANIFEST
test -d $(DISTDIR) && rm -rf $(DISTDIR); \
mkdir $(DISTDIR); \
flist=`sed -e "s/[ ]:.*$$//" MANIFEST`; for file in $$flist; do \
cp -P $$file $(DISTDIR); \
done
check: $(SUBDIRS)
@echo
@echo This package does not yet have a regression test.
@echo
$(DISTRIBUTION): distdir
tar cf - $(DISTDIR) | gzip -9 >$(DISTRIBUTION)
dist: $(DISTRIBUTION)
install:
for dir in $(INSTALLSUBDIRS); do \
(cd $$dir && $(MAKE) install); \
done
uninstall:
for dir in $(INSTALLSUBDIRS); do \
(cd $$dir && $(MAKE) uninstall); \
done
.PHONY: buildlib all $(SUBDIRS) \
clean distclean extraclean maintainer-clean \
dist distdir \
install uninstall

View File

@ -1,72 +0,0 @@
Expat, Release 1.95.2
This is expat, a C library for parsing XML, written by James Clark.
Expat is a stream-oriented XML parser. This means that you register
handlers with the parser before starting the parse. These handlers
are called when the parser discovers the associated structures in the
document being parsed. A start tag is an example of the kind of
structures for which you may register handlers.
Windows users should use the expat_win32bin package, which includes
both precompiled libraries and executalbes, and source code for
developers.
Expat is free software. You may copy, distribute, and modify it under
the terms of the License contained in the file COPYING distributed
with this package. This license is the same as the MIT/X Consortium
license.
Versions of expat that have an odd minor version (the middle number in
the release above), are development releases and should be considered
as beta software. Releases with even minor version numbers are
intended to be production grade software.
To build expat, you first run the configuration shell script in the
top level distribution directory:
./configure
There are many options which you may provide to configure (which you
can discover by running configure with the --help option). But the
one of most interest is the one that sets the installation directory.
By default, the configure script will set things up to install
libexpat into /usr/local/lib, expat.h into /usr/local/include, and
xmlwf into /usr/local/bin. If, for example, you'd prefer to install
into /home/me/mystuff/lib, /home/me/mystuff/include, and
/home/me/mystuff/bin, you can tell configure about that with:
./configure --prefix=/home/me/mystuff
After running the configure script, the "make" command will build
things and "make install" will install things into their proper
location. Note that you need to have write permission into the
directories into which things will be installed.
When building for use with C++, you may need to add additional
compiler flags to support proper interaction with exceptions. This
can be done by setting the CFLAGS environment variable. For example,
when using GCC, you can use:
CFLAGS=-fexceptions ./configure
Note for Solaris users: The "ar" command is usually located in
"/usr/ccs/bin", which is not in the default PATH. You will need to
add this to your path for the "make" command, and probably also switch
to GNU make (the "make" found in /usr/ccs/bin does not seem to work
properly -- appearantly it does not understand .PHONY directives). If
you're using ksh or bash, use this command to build:
PATH=/usr/ccs/bin:$PATH make
A reference manual is available in the file doc/reference.html in this
distribution.
The homepage for this project is http://expat.sourceforge.net/. There
are links there to connect you to the bug reports page. If you need
to report a bug when you don't have access to a browser, you may also
send a bug report by email to expat-bugs@lists.sourceforge.net.
Discussion related to the direction of future expat development takes
place on expat-discuss@lists.sourceforge.net. Archives of this list
may be found at http://www.geocrawler.com/redir-sf.php3?list=expat-discuss.

View File

@ -1,52 +0,0 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* Define to empty if the keyword does not work. */
#undef const
/* Define if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define to `long' if <sys/types.h> doesn't define. */
#undef off_t
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define if you have the bcopy function. */
#undef HAVE_BCOPY
/* Define if you have the getpagesize function. */
#undef HAVE_GETPAGESIZE
/* Define if you have the memmove function. */
#undef HAVE_MEMMOVE
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* whether byteorder is bigendian */
#undef WORDS_BIGENDIAN
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
#undef BYTEORDER
#define XML_NS
#define XML_DTD
#define XML_CONTEXT_BYTES 1024
#ifndef HAVE_MEMMOVE
#ifdef HAVE_BCOPY
#define memmove(d,s,l) bcopy((s),(d),(l))
#else
#define memmove(d,s,l) ;punting on memmove;
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,111 +0,0 @@
dnl configuration script for expat
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Copyright 2000 Clark Cooper
dnl
dnl This file is part of EXPAT.
dnl
dnl EXPAT is free software; you can redistribute it and/or modify it
dnl under the terms of the License (based on the MIT/X license) contained
dnl in the file COPYING that comes with this distribution.
dnl
AC_INIT(Makefile.in)
AC_CONFIG_AUX_DIR(conftools)
dnl
dnl Follow the GNU/Linux convention of odd number minor version for
dnl beta/development releases and even number minor version for stable
dnl releases. Edit is bumped with each release and set to 0 with
dnl change to major or minor version.
dnl
EXPAT_MAJOR_VERSION=1
EXPAT_MINOR_VERSION=95
EXPAT_EDIT=2
EXPAT_VERSION=$EXPAT_MAJOR_VERSION.$EXPAT_MINOR_VERSION.$EXPAT_EDIT
VERSION=$EXPAT_VERSION
PACKAGE=expat
dnl
dnl Increment LIBREVISION if source code has changed at all
dnl
dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0
dnl
dnl If the API changes compatibly (i.e. simply adding a new function
dnl without changing or removing earlier interfaces), then increment LIBAGE.
dnl
dnl If the API changes incompatibly set LIBAGE back to 0
dnl
LIBCURRENT=1
LIBREVISION=0
LIBAGE=1
AC_CONFIG_HEADER(config.h)
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_SUBST(EXPAT_MAJOR_VERSION)
AC_SUBST(EXPAT_MINOR_VERSION)
AC_SUBST(EXPAT_EDIT)
AC_SUBST(LIBCURRENT)
AC_SUBST(LIBREVISION)
AC_SUBST(LIBAGE)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
if test "$GCC" = yes ; then
CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions"
fi
dnl Checks for libraries.
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h unistd.h)
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Note: Avoid using AC_C_BIGENDIAN because it does not
dnl work in a cross compile.
AC_C_BIGENDIAN_CROSS
AC_C_CONST
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
dnl Checks for library functions.
AC_FUNC_MEMCMP
AC_FUNC_MMAP
if test -z "$HAVE_MMAP"; then
FILEMAP_OBJ=unixfilemap.o
else
FILEMAP_OBJ=readfilemap.o
fi
AC_SUBST(FILEMAP_OBJ)
AC_CHECK_FUNCS(memmove bcopy)
dnl Generate makefiles only for the directories that are present;
dnl this allows this (and the generated configure script) to work
dnl in "embedded distributions", where only part of the Expat sources
dnl are included in the sources for another project.
OUTPUT="Makefile lib/Makefile lib/expat.h"
if test -d ${srcdir}/xmlwf; then
OUTPUT="$OUTPUT xmlwf/Makefile"
fi
if test -d ${srcdir}/examples; then
OUTPUT="$OUTPUT examples/Makefile"
fi
AC_OUTPUT($OUTPUT)

View File

@ -1,116 +0,0 @@
#!/bin/sh
# Look for program[s] somewhere in $PATH.
#
# Options:
# -s
# Do not print out full pathname. (silent)
# -pPATHNAME
# Look in PATHNAME instead of $PATH
#
# Usage:
# PrintPath [-s] [-pPATHNAME] program [program ...]
#
# Initially written by Jim Jagielski for the Apache configuration mechanism
# (with kudos to Kernighan/Pike)
#
# This script falls under the Apache License.
# See http://www.apache.org/licenses/LICENSE
##
# Some "constants"
##
pathname=$PATH
echo="yes"
##
# Find out what OS we are running for later on
##
os=`(uname) 2>/dev/null`
##
# Parse command line
##
for args in $*
do
case $args in
-s ) echo="no" ;;
-p* ) pathname="`echo $args | sed 's/^..//'`" ;;
* ) programs="$programs $args" ;;
esac
done
##
# Now we make the adjustments required for OS/2 and everyone
# else :)
#
# First of all, all OS/2 programs have the '.exe' extension.
# Next, we adjust PATH (or what was given to us as PATH) to
# be whitespace seperated directories.
# Finally, we try to determine the best flag to use for
# test/[] to look for an executable file. OS/2 just has '-r'
# but with other OSs, we do some funny stuff to check to see
# if test/[] knows about -x, which is the prefered flag.
##
if [ "x$os" = "xOS/2" ]
then
ext=".exe"
pathname=`echo -E $pathname |
sed 's/^;/.;/
s/;;/;.;/g
s/;$/;./
s/;/ /g
s/\\\\/\\//g' `
test_exec_flag="-r"
else
ext="" # No default extensions
pathname=`echo $pathname |
sed 's/^:/.:/
s/::/:.:/g
s/:$/:./
s/:/ /g' `
# Here is how we test to see if test/[] can handle -x
testfile="pp.t.$$"
cat > $testfile <<ENDTEST
#!/bin/sh
if [ -x / ] || [ -x /bin ] || [ -x /bin/ls ]; then
exit 0
fi
exit 1
ENDTEST
if `/bin/sh $testfile 2>/dev/null`; then
test_exec_flag="-x"
else
test_exec_flag="-r"
fi
rm -f $testfile
fi
for program in $programs
do
for path in $pathname
do
if [ $test_exec_flag $path/${program}${ext} ] && \
[ ! -d $path/${program}${ext} ]; then
if [ "x$echo" = "xyes" ]; then
echo $path/${program}${ext}
fi
exit 0
fi
# Next try without extension (if one was used above)
if [ "x$ext" != "x" ]; then
if [ $test_exec_flag $path/${program} ] && \
[ ! -d $path/${program} ]; then
if [ "x$echo" = "xyes" ]; then
echo $path/${program}
fi
exit 0
fi
fi
done
done
exit 1

View File

@ -1,81 +0,0 @@
dnl @synopsis AC_C_BIGENDIAN_CROSS
dnl
dnl Check endianess even when crosscompiling
dnl (partially based on the original AC_C_BIGENDIAN).
dnl
dnl The implementation will create a binary, and instead of running
dnl the binary it will be grep'ed for some symbols that will look
dnl different for different endianess of the binary.
dnl
dnl @version $Id: ac_c_bigendian_cross.m4,v 1.1 2002-02-25 06:52:57 blizzard%redhat.com Exp $
dnl @author Guido Draheim <guidod@gmx.de>
dnl
AC_DEFUN([AC_C_BIGENDIAN_CROSS],
[AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
[ac_cv_c_bigendian=unknown
# See if sys/param.h defines the BYTE_ORDER macro.
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/param.h>], [
#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
bogus endian macros
#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/param.h>], [
#if BYTE_ORDER != BIG_ENDIAN
not big endian
#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
if test $ac_cv_c_bigendian = unknown; then
AC_TRY_RUN([main () {
/* Are we little or big endian? From Harbison&Steele. */
union
{
long l;
char c[sizeof (long)];
} u;
u.l = 1;
exit (u.c[sizeof (long) - 1] == 1);
}], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes,
[ echo $ac_n "cross-compiling... " 2>&AC_FD_MSG ])
fi])
if test $ac_cv_c_bigendian = unknown; then
AC_MSG_CHECKING(to probe for byte ordering)
[
cat >conftest.c <<EOF
short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
void _ascii() { char* s = (char*) ascii_mm; s = (char*) ascii_ii; }
short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
void _ebcdic() { char* s = (char*) ebcdic_mm; s = (char*) ebcdic_ii; }
int main() { _ascii (); _ebcdic (); return 0; }
EOF
] if test -f conftest.c ; then
if ${CC-cc} conftest.c -o conftest.o && test -f conftest.o ; then
if test `grep -l BIGenDianSyS conftest.o` ; then
echo $ac_n ' big endian probe OK, ' 1>&AC_FD_MSG
ac_cv_c_bigendian=yes
fi
if test `grep -l LiTTleEnDian conftest.o` ; then
echo $ac_n ' little endian probe OK, ' 1>&AC_FD_MSG
if test $ac_cv_c_bigendian = yes ; then
ac_cv_c_bigendian=unknown;
else
ac_cv_c_bigendian=no
fi
fi
echo $ac_n 'guessing bigendian ... ' >&AC_FD_MSG
fi
fi
AC_MSG_RESULT($ac_cv_c_bigendian)
fi
if test $ac_cv_c_bigendian = yes; then
AC_DEFINE(WORDS_BIGENDIAN, 1, [whether byteorder is bigendian])
BYTEORDER=4321
else
BYTEORDER=1234
fi
AC_DEFINE_UNQUOTED(BYTEORDER, $BYTEORDER, [1234 = LIL_ENDIAN, 4321 = BIGENDIAN])
if test $ac_cv_c_bigendian = unknown; then
AC_MSG_ERROR(unknown endianess - sorry, please pre-set ac_cv_c_bigendian)
fi
])

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,251 +0,0 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# 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 M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,190 +0,0 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing - GNU libit 0.0"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acinclude.m4' or \`configure.in'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`configure.in'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acconfig.h' or \`configure.in'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequirements for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0

Some files were not shown because too many files have changed in this diff Show More