aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/Xft1
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2011-10-10 17:43:39 +0200
committerReinhard Tartler <siretart@tauware.de>2011-10-10 17:43:39 +0200
commitf4092abdf94af6a99aff944d6264bc1284e8bdd4 (patch)
tree2ac1c9cc16ceb93edb2c4382c088dac5aeafdf0f /nx-X11/lib/Xft1
parenta840692edc9c6d19cd7c057f68e39c7d95eb767d (diff)
downloadnx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.gz
nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.bz2
nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.zip
Imported nx-X11-3.1.0-1.tar.gznx-X11/3.1.0-1
Summary: Imported nx-X11-3.1.0-1.tar.gz Keywords: Imported nx-X11-3.1.0-1.tar.gz into Git repository
Diffstat (limited to 'nx-X11/lib/Xft1')
-rw-r--r--nx-X11/lib/Xft1/Imakefile150
-rw-r--r--nx-X11/lib/Xft1/Xft-def.cpp171
-rw-r--r--nx-X11/lib/Xft1/Xft.h486
-rw-r--r--nx-X11/lib/Xft1/Xft.man180
-rw-r--r--nx-X11/lib/Xft1/XftConfig-OBSOLETE2
-rw-r--r--nx-X11/lib/Xft1/XftFreetype.h167
-rw-r--r--nx-X11/lib/Xft1/xftcache.c608
-rw-r--r--nx-X11/lib/Xft1/xftcfg.c36
-rw-r--r--nx-X11/lib/Xft1/xftcolor.c125
-rw-r--r--nx-X11/lib/Xft1/xftcore.c247
-rw-r--r--nx-X11/lib/Xft1/xftdbg.c43
-rw-r--r--nx-X11/lib/Xft1/xftdir.c42
-rw-r--r--nx-X11/lib/Xft1/xftdpy.c436
-rw-r--r--nx-X11/lib/Xft1/xftdraw.c482
-rw-r--r--nx-X11/lib/Xft1/xftextent.c190
-rw-r--r--nx-X11/lib/Xft1/xftfont.c327
-rw-r--r--nx-X11/lib/Xft1/xftfreetype.c678
-rw-r--r--nx-X11/lib/Xft1/xftfs.c44
-rw-r--r--nx-X11/lib/Xft1/xftglyphs.c491
-rw-r--r--nx-X11/lib/Xft1/xftgram.y452
-rw-r--r--nx-X11/lib/Xft1/xftinit.c42
-rw-r--r--nx-X11/lib/Xft1/xftint.h508
-rw-r--r--nx-X11/lib/Xft1/xftlex.l275
-rw-r--r--nx-X11/lib/Xft1/xftlist.c166
-rw-r--r--nx-X11/lib/Xft1/xftmatch.c37
-rw-r--r--nx-X11/lib/Xft1/xftmatrix.c104
-rw-r--r--nx-X11/lib/Xft1/xftname.c59
-rw-r--r--nx-X11/lib/Xft1/xftpat.c243
-rw-r--r--nx-X11/lib/Xft1/xftrender.c527
-rw-r--r--nx-X11/lib/Xft1/xftstr.c259
-rw-r--r--nx-X11/lib/Xft1/xftxlfd.c334
31 files changed, 7911 insertions, 0 deletions
diff --git a/nx-X11/lib/Xft1/Imakefile b/nx-X11/lib/Xft1/Imakefile
new file mode 100644
index 000000000..dbb48cf45
--- /dev/null
+++ b/nx-X11/lib/Xft1/Imakefile
@@ -0,0 +1,150 @@
+XCOMM $XFree86: xc/lib/Xft1/Imakefile,v 1.13tsi Exp $
+
+XCOMM Allow for builds against old installed bits
+#ifdef UseInstalled
+
+#ifndef SharedLibXft1
+#define SharedLibXft1 YES
+#endif
+
+#ifndef NormalLibXft1
+#define NormalLibXft1 (!SharedLibXft1 | ForceNormalLib)
+#endif
+
+#ifndef DebugLibXft1
+#define DebugLibXft1 NO
+#endif
+
+#ifndef ProfileLibXft1
+#define ProfileLibXft1 NO
+#endif
+
+#ifndef FontconfigClientDepLibs
+#define FontconfigClientDepLibs $(DEPFONTCONFIGLIB)
+#endif
+#ifndef FontconfigClientLibs
+#define FontconfigClientLibs $(FONTCONFIGLIB)
+#endif
+
+#if SharedLibFontconfig
+#define SharedFontconfigRev 1.0
+
+SharedLibReferences(FONTCONFIG,fontconfig,$(FONTCONFIGSRC),SOXLIBREV,SharedFontconfigRev)
+#else
+
+ProjectUnsharedLibReferences(FONTCONFIG,fontconfig,$(FONTCONFIGSRC),BuildLibDir)
+#endif
+
+#if SharedLibXft1
+#define SharedXft1Rev 1.2
+SharedLibReferences(XFT1,Xft,$(XFT1SRC),SOXFT1REV,SharedXft1Rev)
+#else
+ProjectUnsharedLibReferences(XFT1,Xft,$(XFT1SRC),BuildLibDir)
+#endif
+
+#undef LinkBuildLibrary
+#define LinkBuildLibrary(lib) MakeDir($(BUILDLIBDIR)) @@\
+ RemoveFile($(BUILDLIBDIR)/lib) @@\
+ cd $(BUILDLIBDIR) && $(LN) $(BUILDLIBTOP)/$(CURRENT_DIR)/lib .
+#undef _LinkBuildLibrary
+#define _LinkBuildLibrary(lib) LinkBuildLibrary(lib)
+
+#undef LinkBuildLibraryMaybe
+#define LinkBuildLibraryMaybe(lib,doit) MakeDir($(BUILDLIBDIR)) @@\
+ @if doit; then (set -x; \ @@\
+ RemoveFile($(BUILDLIBDIR)/lib); \ @@\
+ cd $(BUILDLIBDIR) && $(LN) $(BUILDLIBTOP)/$(CURRENT_DIR)/lib .); fi
+
+#ifdef LdPreLibs
+# undef LdPreLibs
+#endif
+#define LdPreLibs -L$(BUILDLIBDIR) LdPreLib XLdPreLibs
+
+LDPRELIBS=LdPreLibs
+#endif
+
+
+#define DoNormalLib NO
+#define DoSharedLib SharedLibXft1
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#define HasSharedData YES
+#define LibName Xft
+#define SoRev SOXFT1REV
+#define LibHeaders NO
+#define NoSoSymlink
+
+#include <Threads.tmpl>
+
+YFLAGS = -d
+
+#ifndef XftLibDir
+#define XftLibDir $(LIBDIR)
+#endif
+
+XFTLIBDIR=XftLibDir
+
+INCLUDES=$(FONTCONFIGINCLUDES) $(FREETYPE2INCLUDES) -I$(XBUILDINCDIR)
+DEFINES=$(FREETYPE2DEFINES) $(RENDERDEFINES) -DXFREE86_FT2
+
+#if UseFreetype2
+FREETYPE2REQLIB = $(FREETYPE2LIB)
+#endif
+
+REQUIREDLIBS=$(LDPRELIBS) $(XRENDERLIB) $(XLIB) $(FONTCONFIGLIB) $(EXPATLIB) $(FREETYPE2REQLIB)
+
+#if UseFreetype2
+FT_OLD = xftcache.c
+FT_HEADERS = XftFreetype.h
+ FT_SRCS = xftfreetype.c xftglyphs.c xftrender.c xftdir.c
+ FT_OBJS = xftfreetype.o xftglyphs.o xftrender.o xftdir.o
+#endif
+
+HEADERS = Xft.h $(FT_HEADERS)
+
+OLD = xftgram.c xftlex.c
+
+ SRCS = xftcfg.c xftcolor.c xftcore.c xftdbg.c xftdpy.c \
+ xftdraw.c xftextent.c xftfont.c xftfs.c\
+ xftinit.c xftlist.c xftmatch.c xftmatrix.c \
+ xftname.c xftpat.c xftstr.c xftxlfd.c $(FT_SRCS)
+
+ OBJS = xftcfg.o xftcolor.o xftcore.o xftdbg.o xftdpy.o \
+ xftdraw.o xftextent.o xftfont.o xftfs.o \
+ xftinit.o xftlist.o xftmatch.o xftmatrix.o \
+ xftname.o xftpat.o xftstr.o xftxlfd.o $(FT_OBJS)
+
+#include <Library.tmpl>
+
+#if DoSharedLib && SharedDataSeparation
+SpecialCObjectRule(sharedlib,NullParameter,$(SHLIBDEF))
+#endif
+
+/*
+ * InstallNamedTargetRelated - like InstallNamedTarget, but only
+ * installs if a related file already exists. Useful for
+ * annotating older systems with information on the relationship
+ * with the new system.
+ */
+
+#ifndef InstallNamedTargetRelated
+#define InstallNamedTargetRelated(step,srcname,flags,dest,dstname,dstrel)@@\
+step:: srcname @@\
+ MakeDir($(DESTDIR)dest) @@\
+ @if [ -f $(DESTDIR)dest/dstrel ]; then \ @@\
+ set -x; \ @@\
+ $(INSTALL) $(INSTALLFLAGS) flags srcname $(DESTDIR)dest/dstname; fi
+#endif
+
+#ifndef InstallNonExecFileRelated
+#define InstallNonExecFileRelated(file,dest,rel) @@\
+InstallNamedTargetRelated(install,file,$(INSTDATFLAGS),dest,file,rel)
+#endif /* InstallNonExecFileBackup */
+
+InstallNonExecFileRelated(XftConfig-OBSOLETE,$(XFTLIBDIR),XftConfig)
+InstallNonExecFileRelated(XftConfig-OBSOLETE,$(CONFDIR),XftConfig)
+
+MANSUFFIX = $(LIBMANSUFFIX)
+InstallManPage(Xft,$(LIBMANDIR))
+DependTarget()
diff --git a/nx-X11/lib/Xft1/Xft-def.cpp b/nx-X11/lib/Xft1/Xft-def.cpp
new file mode 100644
index 000000000..410b8202b
--- /dev/null
+++ b/nx-X11/lib/Xft1/Xft-def.cpp
@@ -0,0 +1,171 @@
+LIBRARY Xft
+VERSION LIBRARY_VERSION
+EXPORTS
+
+#ifndef __UNIXOS2__
+XftConfigAddDir
+XftConfigAddEdit
+XftConfigGetCache
+XftConfigSetCache
+XftConfigSubstitute
+_XftConfigCompareValue
+#endif
+XftColorAllocName
+XftColorAllocValue
+XftColorFree
+#ifndef __UNIXOS2__
+XftCoreConvert16
+XftCoreConvert32
+XftCoreConvertUtf8
+XftCoreExtents16
+XftCoreExtents32
+XftCoreExtents8
+XftCoreExtentsUtf8
+XftCoreGlyphExists
+XftEditPrint
+XftExprPrint
+XftFontSetPrint
+XftOpPrint
+XftPatternPrint
+XftSubstPrint
+XftTestPrint
+XftValueListPrint
+XftValuePrint
+#endif
+XftDefaultGetBool
+XftDefaultGetDouble
+XftDefaultGetInteger
+XftDefaultHasRender
+XftDefaultParseBool
+XftDefaultSet
+XftDefaultSubstitute
+#ifndef __UNIXOS2__
+XftDisplayGetFontSet
+#endif
+XftDrawChange
+#ifndef __UNIXOS2__
+XftDrawCorePrepare
+#endif
+XftDrawCreate
+XftDrawCreateBitmap
+XftDrawDestroy
+XftDrawRect
+#ifndef __UNIXOS2__
+XftDrawRenderPrepare
+#endif
+XftDrawSetClip
+XftDrawString16
+XftDrawString32
+XftDrawString8
+XftDrawStringUtf8
+XftTextExtents16
+XftTextExtents32
+XftTextExtents8
+XftTextExtentsUtf8
+XftFontClose
+XftFontMatch
+XftFontOpen
+XftFontOpenName
+XftFontOpenPattern
+XftFontOpenXlfd
+#ifndef __UNIXOS2__
+XftGlyphExists
+_XftFontDebug
+XftFontSetAdd
+XftFontSetCreate
+XftFontSetDestroy
+XftConfigSaveField
+XftConfigerror
+XftConfigparse
+XftConfigwrap
+XftEditCreate
+XftEditDestroy
+XftExprCreateBool
+XftExprCreateDouble
+XftExprCreateField
+XftExprCreateInteger
+XftExprCreateNil
+XftExprCreateOp
+XftExprCreateString
+XftExprDestroy
+XftTestCreate
+#endif
+XftInit
+#ifndef __UNIXOS2__
+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
+#endif
+XftListFonts
+XftListFontsPatternObjects
+#ifndef __UNIXOS2__
+XftListMatch
+XftListValueCompare
+XftListValueListCompare
+XftObjectSetAdd
+XftObjectSetBuild
+XftObjectSetCreate
+XftObjectSetDestroy
+XftObjectSetVaBuild
+XftFontSetMatch
+XftNameConstant
+#endif
+XftNameParse
+XftNameUnparse
+#ifndef __UNIXOS2__
+XftPatternAdd
+XftPatternAddBool
+XftPatternAddDouble
+XftPatternAddInteger
+XftPatternAddString
+XftPatternBuild
+XftPatternCreate
+XftPatternDel
+XftPatternDestroy
+XftPatternDuplicate
+XftPatternFind
+XftPatternGet
+XftPatternGetBool
+XftPatternGetDouble
+XftPatternGetInteger
+XftPatternGetString
+XftPatternVaBuild
+XftValueDestroy
+XftValueListDestroy
+XftUtf8Len
+XftUtf8ToUcs4
+_XftDownStr
+_XftGetInt
+#endif
+_XftMatchSymbolic
+#ifndef __UNIXOS2__
+_XftSaveString
+_XftSplitField
+_XftSplitStr
+_XftSplitValue
+_XftStrCmpIgnoreCase
+XftCoreAddFonts
+XftCoreClose
+XftCoreOpen
+#endif
+XftXlfdParse
+XftInitFtLibrary
+#ifndef __UNIXOS2__
+XftConfigDirs
+XftDirScan
+XftDirSave
+#endif
+
+/* $XFree86: xc/lib/Xft/Xft-def.cpp,v 1.4 2002/09/18 01:25:00 dawes Exp $ */
diff --git a/nx-X11/lib/Xft1/Xft.h b/nx-X11/lib/Xft1/Xft.h
new file mode 100644
index 000000000..71ef9b80c
--- /dev/null
+++ b/nx-X11/lib/Xft1/Xft.h
@@ -0,0 +1,486 @@
+/*
+ * $XFree86: xc/lib/Xft/Xft.h,v 1.19 2001/04/29 03:21:17 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_
+
+#include <X11/extensions/Xrender.h>
+#include <fontconfig/fontconfig.h>
+#include <stdarg.h>
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+
+typedef unsigned char XftChar8;
+typedef unsigned short XftChar16;
+typedef unsigned int XftChar32;
+
+#define XFT_FAMILY "family" /* String */
+#define XFT_STYLE "style" /* String */
+#define XFT_SLANT "slant" /* Int */
+#define XFT_WEIGHT "weight" /* Int */
+#define XFT_SIZE "size" /* Double */
+#define XFT_PIXEL_SIZE "pixelsize" /* Double */
+#define XFT_ENCODING "encoding" /* String */
+#define XFT_SPACING "spacing" /* Int */
+#define XFT_FOUNDRY "foundry" /* String */
+#define XFT_CORE "core" /* Bool */
+#define XFT_ANTIALIAS "antialias" /* Bool */
+#define XFT_XLFD "xlfd" /* String */
+#define XFT_FILE "file" /* String */
+#define XFT_INDEX "index" /* Int */
+#define XFT_RASTERIZER "rasterizer"/* String */
+#define XFT_OUTLINE "outline" /* Bool */
+#define XFT_SCALABLE "scalable" /* Bool */
+#define XFT_RGBA "rgba" /* Int */
+
+/* defaults from resources */
+#define XFT_SCALE "scale" /* double */
+#define XFT_RENDER "render" /* Bool */
+#define XFT_MINSPACE "minspace" /* Bool use minimum line spacing */
+#define XFT_DPI "dpi" /* double */
+
+/* specific to FreeType rasterizer */
+#define XFT_CHAR_WIDTH "charwidth" /* Int */
+#define XFT_CHAR_HEIGHT "charheight"/* Int */
+#define XFT_MATRIX "matrix" /* XftMatrix */
+
+#define XFT_WEIGHT_LIGHT 0
+#define XFT_WEIGHT_MEDIUM 100
+#define XFT_WEIGHT_DEMIBOLD 180
+#define XFT_WEIGHT_BOLD 200
+#define XFT_WEIGHT_BLACK 210
+
+#define XFT_SLANT_ROMAN 0
+#define XFT_SLANT_ITALIC 100
+#define XFT_SLANT_OBLIQUE 110
+
+#define XFT_PROPORTIONAL 0
+#define XFT_MONO 100
+#define XFT_CHARCELL 110
+
+#define XFT_RGBA_NONE 0
+#define XFT_RGBA_RGB 1
+#define XFT_RGBA_BGR 2
+#define XFT_RGBA_VRGB 3
+#define XFT_RGBA_VBGR 4
+
+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
+
+#define XftTypeVoid FcTypeVoid
+#define XftTypeInteger FcTypeInteger
+#define XftTypeDouble FcTypeDouble
+#define XftTypeString FcTypeString
+#define XftTypeBool FcTypeBool
+#define XftTypeMatrix FcTypeMatrix
+
+typedef FcValue XftValue;
+
+
+typedef FcPattern XftPattern;
+
+typedef FcFontSet XftFontSet;
+
+typedef struct _XftFontStruct XftFontStruct;
+
+typedef struct _XftFont {
+ int ascent;
+ int descent;
+ int height;
+ int max_advance_width;
+ Bool core;
+ XftPattern *pattern;
+ union {
+ struct {
+ XFontStruct *font;
+ } core;
+ struct {
+ XftFontStruct *font;
+ } ft;
+ } u;
+} XftFont;
+
+typedef struct _XftDraw XftDraw;
+
+typedef struct _XftColor {
+ unsigned long pixel;
+ XRenderColor color;
+} XftColor;
+
+typedef FcObjectSet XftObjectSet;
+
+_XFUNCPROTOBEGIN
+
+/* xftcfg.c */
+Bool
+XftConfigSubstitute (XftPattern *p);
+
+/* 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 */
+/* xftdbg.c */
+void
+XftValuePrint (XftValue v);
+
+void
+XftPatternPrint (XftPattern *p);
+
+void
+XftFontSetPrint (XftFontSet *s);
+
+/* xftdir.c */
+/* xftdpy.c */
+Bool
+XftDefaultHasRender (Display *dpy);
+
+Bool
+XftDefaultSet (Display *dpy, XftPattern *defaults);
+
+void
+XftDefaultSubstitute (Display *dpy, int screen, XftPattern *pattern);
+
+/* xftdraw.c */
+
+XftDraw *
+XftDrawCreate (Display *dpy,
+ Drawable drawable,
+ Visual *visual,
+ Colormap colormap);
+
+XftDraw *
+XftDrawCreateBitmap (Display *dpy,
+ Pixmap bitmap);
+
+void
+XftDrawChange (XftDraw *draw,
+ Drawable drawable);
+
+void
+XftDrawDestroy (XftDraw *draw);
+
+void
+XftDrawString8 (XftDraw *d,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar8 *string,
+ int len);
+
+void
+XftDrawString16 (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar16 *string,
+ int len);
+
+void
+XftDrawString32 (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar32 *string,
+ int len);
+
+void
+XftDrawStringUtf8 (XftDraw *d,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar8 *string,
+ 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
+XftTextExtents8 (Display *dpy,
+ XftFont *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftTextExtents16 (Display *dpy,
+ XftFont *font,
+ XftChar16 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftTextExtents32 (Display *dpy,
+ XftFont *font,
+ XftChar32 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftTextExtentsUtf8 (Display *dpy,
+ XftFont *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+/* xftfont.c */
+XftPattern *
+XftFontMatch (Display *dpy, int screen, XftPattern *pattern, XftResult *result);
+
+XftFont *
+XftFontOpenPattern (Display *dpy, XftPattern *pattern);
+
+XftFont *
+XftFontOpen (Display *dpy, int screen, ...);
+
+XftFont *
+XftFontOpenName (Display *dpy, int screen, const char *name);
+
+XftFont *
+XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd);
+
+void
+XftFontClose (Display *dpy, XftFont *font);
+
+Bool
+XftGlyphExists (Display *dpy, XftFont *font, XftChar32 glyph);
+
+/* xftfreetype.c */
+/* xftfs.c */
+
+XftFontSet *
+XftFontSetCreate (void);
+
+void
+XftFontSetDestroy (XftFontSet *s);
+
+Bool
+XftFontSetAdd (XftFontSet *s, XftPattern *font);
+
+/* xftglyphs.c */
+/* see XftFreetype.h */
+
+/* xftgram.y */
+
+/* xftinit.c */
+Bool
+XftInit (char *config);
+
+/* xftlex.l */
+
+/* xftlist.c */
+XftObjectSet *
+XftObjectSetCreate (void);
+
+Bool
+XftObjectSetAdd (XftObjectSet *os, const char *object);
+
+void
+XftObjectSetDestroy (XftObjectSet *os);
+
+XftObjectSet *
+XftObjectSetVaBuild (const char *first, va_list va);
+
+XftObjectSet *
+XftObjectSetBuild (const char *first, ...);
+
+XftFontSet *
+XftListFontSets (XftFontSet **sets,
+ int nsets,
+ XftPattern *p,
+ XftObjectSet *os);
+
+XftFontSet *
+XftListFontsPatternObjects (Display *dpy,
+ int screen,
+ XftPattern *pattern,
+ XftObjectSet *os);
+
+XftFontSet *
+XftListFonts (Display *dpy,
+ int screen,
+ ...);
+
+/* xftmatch.c */
+XftPattern *
+XftFontSetMatch (XftFontSet **sets,
+ int nsets,
+ XftPattern *p,
+ XftResult *result);
+
+/* xftmatrix.c */
+int
+XftMatrixEqual (const XftMatrix *mat1, const XftMatrix *mat2);
+
+void
+XftMatrixMultiply (XftMatrix *result, XftMatrix *a, XftMatrix *b);
+
+void
+XftMatrixRotate (XftMatrix *m, double c, double s);
+
+void
+XftMatrixScale (XftMatrix *m, double sx, double sy);
+
+void
+XftMatrixShear (XftMatrix *m, double sh, double sv);
+
+/* xftname.c */
+XftPattern *
+XftNameParse (const char *name);
+
+Bool
+XftNameUnparse (XftPattern *pat, char *dest, int len);
+
+/* xftpat.c */
+XftPattern *
+XftPatternCreate (void);
+
+XftPattern *
+XftPatternDuplicate (XftPattern *p);
+
+void
+XftValueDestroy (XftValue v);
+
+void
+XftPatternDestroy (XftPattern *p);
+
+Bool
+XftPatternAdd (XftPattern *p, const char *object, XftValue value, Bool append);
+
+XftResult
+XftPatternGet (XftPattern *p, const char *object, int id, XftValue *v);
+
+Bool
+XftPatternDel (XftPattern *p, const char *object);
+
+Bool
+XftPatternAddInteger (XftPattern *p, const char *object, int i);
+
+Bool
+XftPatternAddDouble (XftPattern *p, const char *object, double d);
+
+Bool
+XftPatternAddString (XftPattern *p, const char *object, const char *s);
+
+Bool
+XftPatternAddMatrix (XftPattern *p, const char *object, const XftMatrix *s);
+
+Bool
+XftPatternAddBool (XftPattern *p, const char *object, Bool b);
+
+XftResult
+XftPatternGetInteger (XftPattern *p, const char *object, int n, int *i);
+
+XftResult
+XftPatternGetDouble (XftPattern *p, const char *object, int n, double *d);
+
+XftResult
+XftPatternGetString (XftPattern *p, const char *object, int n, char **s);
+
+XftResult
+XftPatternGetMatrix (XftPattern *p, const char *object, int n, XftMatrix **s);
+
+XftResult
+XftPatternGetBool (XftPattern *p, const char *object, int n, Bool *b);
+
+XftPattern *
+XftPatternVaBuild (XftPattern *orig, va_list va);
+
+XftPattern *
+XftPatternBuild (XftPattern *orig, ...);
+
+/* xftrender.c */
+/* see XftFreetype.h */
+
+/* xftstr.c */
+
+int
+XftUtf8ToUcs4 (XftChar8 *src_orig,
+ XftChar32 *dst,
+ int len);
+
+Bool
+XftUtf8Len (XftChar8 *string,
+ int len,
+ int *nchar,
+ int *wchar);
+
+/* xftxlfd.c */
+XftPattern *
+XftXlfdParse (const char *xlfd_orig, Bool ignore_scalable, Bool complete);
+
+XFontStruct *
+XftCoreOpen (Display *dpy, XftPattern *pattern);
+
+void
+XftCoreClose (Display *dpy, XFontStruct *font);
+
+_XFUNCPROTOEND
+
+#endif /* _XFT_H_ */
diff --git a/nx-X11/lib/Xft1/Xft.man b/nx-X11/lib/Xft1/Xft.man
new file mode 100644
index 000000000..7d62818a2
--- /dev/null
+++ b/nx-X11/lib/Xft1/Xft.man
@@ -0,0 +1,180 @@
+.\"
+.\" $XFree86: xc/lib/Xft/Xft.man,v 1.2 2000/11/30 06:59:45 keithp Exp $
+.\"
+.\" Copyright © 2000 Keith Packard.
+.\" Permission to use, copy, modify, distribute, and sell this software and its
+.\" documentation for any purpose is hereby granted without fee, provided that
+.\" the above copyright notice appear in all copies and that both that
+.\" copyright notice and this permission notice appear in supporting
+.\" documentation, and that the name of Keith Packard not be used in
+.\" advertising or publicity pertaining to distribution of the software without
+.\" specific, written prior permission. Keith Packard makes no
+.\" representations about the suitability of this software for any purpose. It
+.\" is provided "as is" without express or implied warranty.
+.\"
+.\" KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+.\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+.\" EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+.\" CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+.\" DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+.\" PERFORMANCE OF THIS SOFTWARE.
+.\"
+.de TQ
+.br
+.ns
+.TP \\$1
+..
+.TH XFT __libmansuffix__ __vendorversion__
+
+.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
diff --git a/nx-X11/lib/Xft1/XftConfig-OBSOLETE b/nx-X11/lib/Xft1/XftConfig-OBSOLETE
new file mode 100644
index 000000000..ec90d1bfe
--- /dev/null
+++ b/nx-X11/lib/Xft1/XftConfig-OBSOLETE
@@ -0,0 +1,2 @@
+The XftConfig file is no longer used by Xft. Please see
+/etc/fonts/fonts.conf to configure client-side fonts.
diff --git a/nx-X11/lib/Xft1/XftFreetype.h b/nx-X11/lib/Xft1/XftFreetype.h
new file mode 100644
index 000000000..07fed47e4
--- /dev/null
+++ b/nx-X11/lib/Xft1/XftFreetype.h
@@ -0,0 +1,167 @@
+/*
+ * $XFree86: xc/lib/Xft1/XftFreetype.h,v 1.3 2002/03/02 22:09:04 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 _XFTFREETYPE_H_
+#define _XFTFREETYPE_H_
+
+#include "Xft.h"
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+
+extern FT_Library _XftFTlibrary;
+
+struct _XftFontStruct {
+ FT_Face face; /* handle to face object */
+ GlyphSet glyphset;
+ int min_char;
+ int max_char;
+ FT_F26Dot6 size;
+ int ascent;
+ int descent;
+ int height;
+ int max_advance_width;
+ int spacing;
+ int rgba;
+ Bool antialias;
+ int charmap; /* -1 for unencoded */
+ XRenderPictFormat *format;
+ XGlyphInfo **realized;
+ int nrealized;
+ Bool transform;
+ FT_Matrix matrix;
+};
+
+#define XftUntestedGlyph ((XGlyphInfo *) 1)
+
+_XFUNCPROTOBEGIN
+
+/* xftdir.c */
+Bool
+XftDirScan (XftFontSet *set, const char *dir, Bool force);
+
+Bool
+XftDirSave (XftFontSet *set, const char *dir);
+
+/* xftfreetype.c */
+XftPattern *
+XftFreeTypeQuery (const char *file, int id, int *count);
+
+Bool
+XftFreeTypeSetFace (FT_Face face, FT_F26Dot6 size, int charmap, FT_Matrix *matrix);
+
+XftFontStruct *
+XftFreeTypeOpen (Display *dpy, XftPattern *pattern);
+
+void
+XftFreeTypeClose (Display *dpy, XftFontStruct *font);
+
+XftFontStruct *
+XftFreeTypeGet (XftFont *font);
+
+Bool
+XftInitFtLibrary(void);
+
+/* xftglyphs.c */
+void
+XftGlyphLoad (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 *glyphs,
+ int nglyph);
+
+void
+XftGlyphCheck (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 glyph,
+ XftChar32 *missing,
+ int *nmissing);
+
+Bool
+XftFreeTypeGlyphExists (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 glyph);
+
+/* xftrender.c */
+
+void
+XftRenderString8 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar8 *string, int len);
+
+void
+XftRenderString16 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar16 *string, int len);
+
+void
+XftRenderString32 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar32 *string, int len);
+
+void
+XftRenderStringUtf8 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar8 *string, int len);
+
+void
+XftRenderExtents8 (Display *dpy,
+ XftFontStruct *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftRenderExtents16 (Display *dpy,
+ XftFontStruct *font,
+ XftChar16 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftRenderExtents32 (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftRenderExtentsUtf8 (Display *dpy,
+ XftFontStruct *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+_XFUNCPROTOEND
+
+#endif /* _XFTFREETYPE_H_ */
diff --git a/nx-X11/lib/Xft1/xftcache.c b/nx-X11/lib/Xft1/xftcache.c
new file mode 100644
index 000000000..13e20a92b
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftcache.c
@@ -0,0 +1,608 @@
+/*
+ * $XFree86: xc/lib/Xft/xftcache.c,v 1.2 2001/06/11 22:53:30 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 <unistd.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "xftint.h"
+
+typedef struct _XftFileCacheEnt {
+ struct _XftFileCacheEnt *next;
+ unsigned int hash;
+ char *file;
+ int id;
+ time_t time;
+ char *name;
+ Bool referenced;
+} XftFileCacheEnt;
+
+#define HASH_SIZE 509
+
+typedef struct _XftFileCache {
+ XftFileCacheEnt *ents[HASH_SIZE];
+ Bool updated;
+ int entries;
+ int referenced;
+} XftFileCache;
+
+static XftFileCache _XftFileCache;
+
+static unsigned int
+_XftFileCacheHash (char *string)
+{
+ unsigned int h = 0;
+ char c;
+
+ while ((c = *string++))
+ h = (h << 1) ^ c;
+ return h;
+}
+
+char *
+XftFileCacheFind (char *file, int id, int *count)
+{
+ XftFileCache *cache;
+ unsigned int hash;
+ char *match;
+ XftFileCacheEnt *c, *name;
+ int maxid;
+ struct stat statb;
+
+ cache = &_XftFileCache;
+ match = file;
+
+ hash = _XftFileCacheHash (match);
+ name = 0;
+ maxid = -1;
+ for (c = cache->ents[hash % HASH_SIZE]; c; c = c->next)
+ {
+ if (c->hash == hash && !strcmp (match, c->file))
+ {
+ if (c->id > maxid)
+ maxid = c->id;
+ if (c->id == id)
+ {
+ if (stat (file, &statb) < 0)
+ {
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ printf (" file missing\n");
+ return 0;
+ }
+ if (statb.st_mtime != c->time)
+ {
+ if (_XftFontDebug () & XFT_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 = True;
+ }
+ 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 Bool
+_XftFileCacheReadString (FILE *f, char *dest, int len)
+{
+ int c;
+ Bool escape;
+
+ while ((c = getc (f)) != EOF)
+ if (c == '"')
+ break;
+ if (c == EOF)
+ return False;
+ if (len == 0)
+ return False;
+
+ escape = False;
+ while ((c = getc (f)) != EOF)
+ {
+ if (!escape)
+ {
+ switch (c) {
+ case '"':
+ *dest++ = '\0';
+ return True;
+ case '\\':
+ escape = True;
+ continue;
+ }
+ }
+ if (--len <= 1)
+ return False;
+ *dest++ = c;
+ escape = False;
+ }
+ return False;
+}
+
+static Bool
+_XftFileCacheReadUlong (FILE *f, unsigned long *dest)
+{
+ unsigned long t;
+ int c;
+
+ while ((c = getc (f)) != EOF)
+ {
+ if (!isspace (c))
+ break;
+ }
+ if (c == EOF)
+ return False;
+ t = 0;
+ for (;;)
+ {
+ if (c == EOF || isspace (c))
+ break;
+ if (!isdigit (c))
+ return False;
+ t = t * 10 + (c - '0');
+ c = getc (f);
+ }
+ *dest = t;
+ return True;
+}
+
+static Bool
+_XftFileCacheReadInt (FILE *f, int *dest)
+{
+ unsigned long t;
+ Bool ret;
+
+ ret = _XftFileCacheReadUlong (f, &t);
+ if (ret)
+ *dest = (int) t;
+ return ret;
+}
+
+static Bool
+_XftFileCacheReadTime (FILE *f, time_t *dest)
+{
+ unsigned long t;
+ Bool ret;
+
+ ret = _XftFileCacheReadUlong (f, &t);
+ if (ret)
+ *dest = (time_t) t;
+ return ret;
+}
+
+static Bool
+_XftFileCacheAdd (XftFileCache *cache,
+ char *file,
+ int id,
+ time_t time,
+ char *name,
+ Bool replace)
+{
+ XftFileCacheEnt *c;
+ XftFileCacheEnt **prev, *old;
+ unsigned int hash;
+
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ {
+ printf ("%s face %s/%d as %s\n", replace ? "Replace" : "Add",
+ file, id, name);
+ }
+ hash = _XftFileCacheHash (file);
+ for (prev = &cache->ents[hash % HASH_SIZE];
+ (old = *prev);
+ prev = &(*prev)->next)
+ {
+ if (old->hash == hash && old->id == id && !strcmp (old->file, file))
+ break;
+ }
+ if (*prev)
+ {
+ if (!replace)
+ return False;
+
+ old = *prev;
+ if (old->referenced)
+ cache->referenced--;
+ *prev = old->next;
+ free (old);
+ cache->entries--;
+ }
+
+ c = malloc (sizeof (XftFileCacheEnt) +
+ strlen (file) + 1 +
+ strlen (name) + 1);
+ if (!c)
+ return False;
+ c->next = *prev;
+ *prev = c;
+ c->hash = hash;
+ c->file = (char *) (c + 1);
+ c->id = id;
+ c->name = c->file + strlen (file) + 1;
+ strcpy (c->file, file);
+ c->time = time;
+ c->referenced = replace;
+ strcpy (c->name, name);
+ cache->entries++;
+ return True;
+}
+
+void
+XftFileCacheDispose (void)
+{
+ XftFileCache *cache;
+ XftFileCacheEnt *c, *next;
+ int h;
+
+ cache = &_XftFileCache;
+
+ for (h = 0; h < HASH_SIZE; h++)
+ {
+ for (c = cache->ents[h]; c; c = next)
+ {
+ next = c->next;
+ free (c);
+ }
+ cache->ents[h] = 0;
+ }
+ cache->entries = 0;
+ cache->referenced = 0;
+ cache->updated = False;
+}
+
+void
+XftFileCacheLoad (char *cache_file)
+{
+ XftFileCache *cache;
+ FILE *f;
+ char file[8192];
+ int id;
+ time_t time;
+ char name[8192];
+
+ f = fopen (cache_file, "r");
+ if (!f)
+ return;
+
+ cache = &_XftFileCache;
+
+ cache->updated = False;
+ while (_XftFileCacheReadString (f, file, sizeof (file)) &&
+ _XftFileCacheReadInt (f, &id) &&
+ _XftFileCacheReadTime (f, &time) &&
+ _XftFileCacheReadString (f, name, sizeof (name)))
+ {
+ (void) _XftFileCacheAdd (cache, file, id, time, name, False);
+ }
+ fclose (f);
+}
+
+Bool
+XftFileCacheUpdate (char *file, int id, char *name)
+{
+ XftFileCache *cache;
+ char *match;
+ struct stat statb;
+ Bool ret;
+
+ cache = &_XftFileCache;
+ match = file;
+
+ if (stat (file, &statb) < 0)
+ return False;
+ ret = _XftFileCacheAdd (cache, match, id,
+ statb.st_mtime, name, True);
+ if (ret)
+ cache->updated = True;
+ return ret;
+}
+
+static Bool
+_XftFileCacheWriteString (FILE *f, char *string)
+{
+ char c;
+
+ if (putc ('"', f) == EOF)
+ return False;
+ while ((c = *string++))
+ {
+ switch (c) {
+ case '"':
+ case '\\':
+ if (putc ('\\', f) == EOF)
+ return False;
+ /* fall through */
+ default:
+ if (putc (c, f) == EOF)
+ return False;
+ }
+ }
+ if (putc ('"', f) == EOF)
+ return False;
+ return True;
+}
+
+static Bool
+_XftFileCacheWriteUlong (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 False;
+ temp = temp - pow * digit;
+ pow = pow / 10;
+ }
+ return True;
+}
+
+static Bool
+_XftFileCacheWriteInt (FILE *f, int i)
+{
+ return _XftFileCacheWriteUlong (f, (unsigned long) i);
+}
+
+static Bool
+_XftFileCacheWriteTime (FILE *f, time_t t)
+{
+ return _XftFileCacheWriteUlong (f, (unsigned long) t);
+}
+
+Bool
+XftFileCacheSave (char *cache_file)
+{
+ XftFileCache *cache;
+ char *lck;
+ char *tmp;
+ FILE *f;
+ int h;
+ XftFileCacheEnt *c;
+
+ cache = &_XftFileCache;
+
+ if (!cache->updated && cache->referenced == cache->entries)
+ return True;
+
+ lck = malloc (strlen (cache_file)*2 + 4);
+ if (!lck)
+ goto bail0;
+ tmp = lck + strlen (cache_file) + 2;
+ strcpy (lck, cache_file);
+ strcat (lck, "L");
+ strcpy (tmp, cache_file);
+ strcat (tmp, "T");
+ if (link (lck, cache_file) < 0 && errno != ENOENT)
+ goto bail1;
+ if (access (tmp, F_OK) == 0)
+ goto bail2;
+ f = fopen (tmp, "w");
+ if (!f)
+ goto bail2;
+
+ for (h = 0; h < HASH_SIZE; h++)
+ {
+ for (c = cache->ents[h]; c; c = c->next)
+ {
+ if (!c->referenced)
+ continue;
+ if (!_XftFileCacheWriteString (f, c->file))
+ goto bail4;
+ if (putc (' ', f) == EOF)
+ goto bail4;
+ if (!_XftFileCacheWriteInt (f, c->id))
+ goto bail4;
+ if (putc (' ', f) == EOF)
+ goto bail4;
+ if (!_XftFileCacheWriteTime (f, c->time))
+ goto bail4;
+ if (putc (' ', f) == EOF)
+ goto bail4;
+ if (!_XftFileCacheWriteString (f, c->name))
+ goto bail4;
+ if (putc ('\n', f) == EOF)
+ goto bail4;
+ }
+ }
+
+ if (fclose (f) == EOF)
+ goto bail3;
+
+ if (rename (tmp, cache_file) < 0)
+ goto bail3;
+
+ unlink (lck);
+ cache->updated = False;
+ return True;
+
+bail4:
+ fclose (f);
+bail3:
+ unlink (tmp);
+bail2:
+ unlink (lck);
+bail1:
+ free (lck);
+bail0:
+ return False;
+}
+
+Bool
+XftFileCacheReadDir (XftFontSet *set, const char *cache_file)
+{
+ XftPattern *font;
+ FILE *f;
+ char *path;
+ char *base;
+ char file[8192];
+ int id;
+ char name[8192];
+ Bool ret = False;
+
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ {
+ printf ("XftFileCacheReadDir cache_file \"%s\"\n", cache_file);
+ }
+
+ f = fopen (cache_file, "r");
+ if (!f)
+ {
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ {
+ printf (" no cache file\n");
+ }
+ goto bail0;
+ }
+
+ base = strrchr (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);
+
+ while (_XftFileCacheReadString (f, file, sizeof (file)) &&
+ _XftFileCacheReadInt (f, &id) &&
+ _XftFileCacheReadString (f, name, sizeof (name)))
+ {
+ font = XftNameParse (name);
+ if (font)
+ {
+ strcpy (base, file);
+ if (_XftFontDebug () & XFT_DBG_CACHEV)
+ {
+ printf (" dir cache file \"%s\"\n", file);
+ }
+ XftPatternAddString (font, XFT_FILE, path);
+ if (!XftFontSetAdd (set, font))
+ goto bail2;
+ }
+ }
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ {
+ printf (" cache loaded\n");
+ }
+
+ ret = True;
+bail2:
+ free (path);
+bail1:
+ fclose (f);
+bail0:
+ return ret;
+}
+
+Bool
+XftFileCacheWriteDir (XftFontSet *set, const char *cache_file)
+{
+ XftPattern *font;
+ FILE *f;
+ char name[8192];
+ char *file, *base;
+ int n;
+ int id;
+
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ printf ("XftFileCacheWriteDir cache_file \"%s\"\n", cache_file);
+
+ f = fopen (cache_file, "w");
+ if (!f)
+ {
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ printf (" can't create \"%s\"\n", cache_file);
+ goto bail0;
+ }
+ for (n = 0; n < set->nfont; n++)
+ {
+ font = set->fonts[n];
+ if (XftPatternGetString (font, XFT_FILE, 0, &file) != XftResultMatch)
+ goto bail1;
+ base = strrchr (file, '/');
+ if (base)
+ base = base + 1;
+ else
+ base = file;
+ if (XftPatternGetInteger (font, XFT_INDEX, 0, &id) != XftResultMatch)
+ goto bail1;
+ if (!XftNameUnparse (font, name, sizeof (name)))
+ goto bail1;
+ if (_XftFontDebug () & XFT_DBG_CACHEV)
+ printf (" write file \"%s\"\n", base);
+ if (!_XftFileCacheWriteString (f, base))
+ goto bail1;
+ if (putc (' ', f) == EOF)
+ goto bail1;
+ if (!_XftFileCacheWriteInt (f, id))
+ goto bail1;
+ if (putc (' ', f) == EOF)
+ goto bail1;
+ if (!_XftFileCacheWriteString (f, name))
+ goto bail1;
+ if (putc ('\n', f) == EOF)
+ goto bail1;
+ }
+ if (fclose (f) == EOF)
+ goto bail0;
+
+ if (_XftFontDebug () & XFT_DBG_CACHE)
+ printf (" cache written\n");
+ return True;
+
+bail1:
+ fclose (f);
+bail0:
+ unlink (cache_file);
+ return False;
+}
diff --git a/nx-X11/lib/Xft1/xftcfg.c b/nx-X11/lib/Xft1/xftcfg.c
new file mode 100644
index 000000000..b6e9d3a7c
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftcfg.c
@@ -0,0 +1,36 @@
+/*
+ * $XFree86: xc/lib/Xft/xftcfg.c,v 1.8 2001/01/02 02:46:51 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"
+
+Bool
+XftConfigSubstitute (XftPattern *p)
+{
+ FcConfigSubstitute (0, p, FcMatchPattern);
+ FcConfigSubstitute (0, p, FcMatchFont);
+ return True;
+}
diff --git a/nx-X11/lib/Xft1/xftcolor.c b/nx-X11/lib/Xft1/xftcolor.c
new file mode 100644
index 000000000..9c81f50ca
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftcolor.c
@@ -0,0 +1,125 @@
+/*
+ * $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);
+}
diff --git a/nx-X11/lib/Xft1/xftcore.c b/nx-X11/lib/Xft1/xftcore.c
new file mode 100644
index 000000000..331cbd7e3
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftcore.c
@@ -0,0 +1,247 @@
+/*
+ * $XFree86: xc/lib/Xft/xftcore.c,v 1.5 2000/12/20 00:28: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 "xftint.h"
+
+XChar2b *
+XftCoreConvert16 (XftChar16 *string,
+ int len,
+ XChar2b xcloc[XFT_CORE_N16LOCAL])
+{
+ XChar2b *xc;
+ int i;
+
+ if (len < XFT_CORE_N16LOCAL)
+ xc = xcloc;
+ else
+ xc = (XChar2b *) malloc (len * sizeof (XChar2b));
+ for (i = 0; i < len; i++)
+ {
+ xc[i].byte1 = string[i] & 0xff;
+ xc[i].byte2 = (string[i] >> 8) & 0xff;
+ }
+ return xc;
+}
+
+XChar2b *
+XftCoreConvert32 (XftChar32 *string,
+ int len,
+ XChar2b xcloc[XFT_CORE_N16LOCAL])
+{
+ XChar2b *xc;
+ int i;
+
+ if (len < XFT_CORE_N16LOCAL)
+ xc = xcloc;
+ else
+ xc = (XChar2b *) malloc (len * sizeof (XChar2b));
+ for (i = 0; i < len; i++)
+ {
+ xc[i].byte1 = string[i] & 0xff;
+ xc[i].byte2 = (string[i] >> 8) & 0xff;
+ }
+ return xc;
+}
+
+XChar2b *
+XftCoreConvertUtf8 (XftChar8 *string,
+ int len,
+ XChar2b xcloc[XFT_CORE_N16LOCAL],
+ int *nchar)
+{
+ XChar2b *xc;
+ XftChar32 c;
+ int i;
+ int n, width;
+ int clen;
+
+ if (!XftUtf8Len (string, len, &n, &width))
+ return 0;
+
+ if (n < XFT_CORE_N16LOCAL)
+ xc = xcloc;
+ else
+ xc = (XChar2b *) malloc (n * sizeof (XChar2b));
+ for (i = 0; i < n; i++)
+ {
+ clen = XftUtf8ToUcs4 (string, &c, len);
+ xc[i].byte1 = c & 0xff;
+ xc[i].byte2 = (c >> 8) & 0xff;
+ string += clen;
+ len -= clen;
+ }
+ *nchar = n;
+ return xc;
+}
+
+void
+XftCoreExtents8 (Display *dpy,
+ XFontStruct *fs,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ int direction;
+ int ascent, descent;
+ XCharStruct overall;
+
+ XTextExtents (fs, (char *) string, len, &direction,
+ &ascent, &descent, &overall);
+ if (overall.lbearing < overall.rbearing)
+ {
+ extents->x = overall.lbearing;
+ extents->width = overall.rbearing - overall.lbearing;
+ }
+ else
+ {
+ extents->x = overall.rbearing;
+ extents->width = overall.lbearing - overall.rbearing;
+ }
+ extents->y = -overall.ascent;
+ extents->height = overall.ascent + overall.descent;
+ extents->xOff = overall.width;
+ extents->yOff = 0;
+}
+
+void
+XftCoreExtents16 (Display *dpy,
+ XFontStruct *fs,
+ XftChar16 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ int direction;
+ int ascent, descent;
+ XCharStruct overall;
+ XChar2b *xc, xcloc[XFT_CORE_N16LOCAL];
+
+ xc = XftCoreConvert16 (string, len, xcloc);
+ XTextExtents16 (fs, xc, len, &direction,
+ &ascent, &descent, &overall);
+ if (xc != xcloc)
+ free (xc);
+ if (overall.lbearing < overall.rbearing)
+ {
+ extents->x = overall.lbearing;
+ extents->width = overall.rbearing - overall.lbearing;
+ }
+ else
+ {
+ extents->x = overall.rbearing;
+ extents->width = overall.lbearing - overall.rbearing;
+ }
+ extents->y = -overall.ascent;
+ extents->height = overall.ascent + overall.descent;
+ extents->xOff = overall.width;
+ extents->yOff = 0;
+}
+
+void
+XftCoreExtents32 (Display *dpy,
+ XFontStruct *fs,
+ XftChar32 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ int direction;
+ int ascent, descent;
+ XCharStruct overall;
+ XChar2b *xc, xcloc[XFT_CORE_N16LOCAL];
+
+ xc = XftCoreConvert32 (string, len, xcloc);
+ XTextExtents16 (fs, xc, len, &direction,
+ &ascent, &descent, &overall);
+ if (xc != xcloc)
+ free (xc);
+ if (overall.lbearing < overall.rbearing)
+ {
+ extents->x = overall.lbearing;
+ extents->width = overall.rbearing - overall.lbearing;
+ }
+ else
+ {
+ extents->x = overall.rbearing;
+ extents->width = overall.lbearing - overall.rbearing;
+ }
+ extents->y = -overall.ascent;
+ extents->height = overall.ascent + overall.descent;
+ extents->xOff = overall.width;
+ extents->yOff = 0;
+}
+
+void
+XftCoreExtentsUtf8 (Display *dpy,
+ XFontStruct *fs,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ int direction;
+ int ascent, descent;
+ XCharStruct overall;
+ XChar2b *xc, xcloc[XFT_CORE_N16LOCAL];
+ int n;
+
+ xc = XftCoreConvertUtf8 (string, len, xcloc, &n);
+ XTextExtents16 (fs, xc, n, &direction,
+ &ascent, &descent, &overall);
+ if (xc != xcloc)
+ free (xc);
+ if (overall.lbearing < overall.rbearing)
+ {
+ extents->x = overall.lbearing;
+ extents->width = overall.rbearing - overall.lbearing;
+ }
+ else
+ {
+ extents->x = overall.rbearing;
+ extents->width = overall.lbearing - overall.rbearing;
+ }
+ extents->y = -overall.ascent;
+ extents->height = overall.ascent + overall.descent;
+ extents->xOff = overall.width;
+ extents->yOff = 0;
+}
+
+Bool
+XftCoreGlyphExists (Display *dpy,
+ XFontStruct *fs,
+ XftChar32 glyph)
+{
+ int direction;
+ int ascent, descent;
+ XCharStruct overall;
+ XChar2b xc;
+
+ XftCoreConvert32 (&glyph, 1, &xc);
+ XTextExtents16 (fs, &xc, 1, &direction,
+ &ascent, &descent, &overall);
+ return (overall.lbearing != 0 ||
+ overall.rbearing != 0 ||
+ overall.width != 0 ||
+ overall.ascent != 0 ||
+ overall.descent != 0);
+}
+
diff --git a/nx-X11/lib/Xft1/xftdbg.c b/nx-X11/lib/Xft1/xftdbg.c
new file mode 100644
index 000000000..098fef74b
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftdbg.c
@@ -0,0 +1,43 @@
+/*
+ * $XFree86: xc/lib/Xft/xftdbg.c,v 1.3 2001/03/31 01:57:20 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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"
+
+void
+XftFontSetPrint (XftFontSet *s)
+{
+ FcFontSetPrint (s);
+}
+
+void
+XftPatternPrint (XftPattern *p)
+{
+ FcPatternPrint (p);
+}
+
+void
+XftValuePrint (XftValue v)
+{
+ FcValuePrint (v);
+}
diff --git a/nx-X11/lib/Xft1/xftdir.c b/nx-X11/lib/Xft1/xftdir.c
new file mode 100644
index 000000000..88d89c902
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftdir.c
@@ -0,0 +1,42 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftdir.c,v 1.2 2002/03/01 01:00:53 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 "xftint.h"
+
+Bool
+XftDirScan (XftFontSet *set, const char *dir, Bool force)
+{
+ return FcFalse;
+}
+
+Bool
+XftDirSave (XftFontSet *set, const char *dir)
+{
+ return FcFalse;
+}
+
diff --git a/nx-X11/lib/Xft1/xftdpy.c b/nx-X11/lib/Xft1/xftdpy.c
new file mode 100644
index 000000000..d28c5c88a
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftdpy.c
@@ -0,0 +1,436 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftdpy.c,v 1.2tsi 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)
+ XftPatternDestroy (info->defaults);
+ if (info->coreFonts)
+ XftFontSetDestroy (info->coreFonts);
+ free (info);
+ return 0;
+}
+
+XftDisplayInfo *
+_XftDisplayInfoGet (Display *dpy)
+{
+ XftDisplayInfo *info, **prev;
+
+ 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->coreFonts = 0;
+ info->hasRender = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, DefaultScreen (dpy))) != 0;
+ info->glyphSets = 0;
+ if (_XftFontDebug () & 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");
+ }
+
+ info->next = _XftDisplayInfo;
+ _XftDisplayInfo = info;
+ return info;
+
+bail1:
+ free (info);
+bail0:
+ if (_XftFontDebug () & XFT_DBG_RENDER)
+ {
+ printf ("XftDisplayInfoGet failed to initialize, Xft unhappy\n");
+ }
+ return 0;
+}
+
+Bool
+XftDefaultHasRender (Display *dpy)
+{
+#ifdef FREETYPE2
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
+
+ if (!info)
+ return False;
+ return info->hasRender;
+#else
+ return False;
+#endif
+}
+
+Bool
+XftDefaultSet (Display *dpy, XftPattern *defaults)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
+
+ if (!info)
+ return False;
+ if (info->defaults)
+ XftPatternDestroy (info->defaults);
+ info->defaults = defaults;
+ return True;
+}
+
+int
+XftDefaultParseBool (char *v)
+{
+ char c0, c1;
+
+ c0 = *v;
+ if (isupper (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 (c1))
+ c1 = tolower (c1);
+ if (c1 == 'n')
+ return 1;
+ if (c1 == 'f')
+ return 0;
+ }
+ return -1;
+}
+
+static Bool
+_XftDefaultInitBool (Display *dpy, XftPattern *pat, char *option)
+{
+ char *v;
+ int i;
+
+ v = XGetDefault (dpy, "Xft", option);
+ if (v && (i = XftDefaultParseBool (v)) >= 0)
+ return XftPatternAddBool (pat, option, i != 0);
+ return True;
+}
+
+static Bool
+_XftDefaultInitDouble (Display *dpy, XftPattern *pat, char *option)
+{
+ char *v, *e;
+ double d;
+
+ v = XGetDefault (dpy, "Xft", option);
+ if (v)
+ {
+ d = strtod (v, &e);
+ if (e != v)
+ return XftPatternAddDouble (pat, option, d);
+ }
+ return True;
+}
+
+static Bool
+_XftDefaultInitInteger (Display *dpy, XftPattern *pat, char *option)
+{
+ char *v, *e;
+ int i;
+
+ v = XGetDefault (dpy, "Xft", option);
+ if (v)
+ {
+ if (XftNameConstant (v, &i))
+ return XftPatternAddInteger (pat, option, i);
+ i = strtol (v, &e, 0);
+ if (e != v)
+ return XftPatternAddInteger (pat, option, i);
+ }
+ return True;
+}
+
+static XftPattern *
+_XftDefaultInit (Display *dpy)
+{
+ XftPattern *pat;
+
+ pat = XftPatternCreate ();
+ if (!pat)
+ goto bail0;
+
+ if (!_XftDefaultInitBool (dpy, pat, XFT_CORE))
+ goto bail1;
+ if (!_XftDefaultInitDouble (dpy, pat, XFT_SCALE))
+ goto bail1;
+ if (!_XftDefaultInitDouble (dpy, pat, XFT_DPI))
+ goto bail1;
+ if (!_XftDefaultInitBool (dpy, pat, XFT_RENDER))
+ goto bail1;
+ if (!_XftDefaultInitInteger (dpy, pat, XFT_RGBA))
+ goto bail1;
+ if (!_XftDefaultInitBool (dpy, pat, XFT_ANTIALIAS))
+ goto bail1;
+ if (!_XftDefaultInitBool (dpy, pat, XFT_MINSPACE))
+ goto bail1;
+
+ return pat;
+
+bail1:
+ XftPatternDestroy (pat);
+bail0:
+ return 0;
+}
+
+static XftResult
+_XftDefaultGet (Display *dpy, const char *object, int screen, XftValue *v)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
+ XftResult r;
+
+ if (!info)
+ return XftResultNoMatch;
+
+ if (!info->defaults)
+ {
+ info->defaults = _XftDefaultInit (dpy);
+ if (!info->defaults)
+ return XftResultNoMatch;
+ }
+ r = XftPatternGet (info->defaults, object, screen, v);
+ if (r == XftResultNoId && screen > 0)
+ r = XftPatternGet (info->defaults, object, 0, v);
+ return r;
+}
+
+Bool
+XftDefaultGetBool (Display *dpy, const char *object, int screen, Bool def)
+{
+ XftResult r;
+ XftValue v;
+
+ r = _XftDefaultGet (dpy, object, screen, &v);
+ if (r != XftResultMatch || v.type != XftTypeBool)
+ return def;
+ return v.u.b;
+}
+
+int
+XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def)
+{
+ XftResult r;
+ XftValue v;
+
+ r = _XftDefaultGet (dpy, object, screen, &v);
+ if (r != XftResultMatch || v.type != XftTypeInteger)
+ return def;
+ return v.u.i;
+}
+
+double
+XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def)
+{
+ XftResult r;
+ XftValue v;
+
+ r = _XftDefaultGet (dpy, object, screen, &v);
+ if (r != XftResultMatch || v.type != XftTypeDouble)
+ return def;
+ return v.u.d;
+}
+
+XftFontSet *
+XftDisplayGetFontSet (Display *dpy)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
+
+ if (!info)
+ return 0;
+ if (!info->coreFonts)
+ {
+ info->coreFonts = XftFontSetCreate ();
+ if (info->coreFonts)
+ {
+ if (!XftCoreAddFonts (info->coreFonts, dpy,
+ XftDefaultGetBool (dpy, XFT_SCALABLE,
+ DefaultScreen (dpy),
+ False)))
+ {
+ XftFontSetDestroy (info->coreFonts);
+ info->coreFonts = 0;
+ }
+ }
+ }
+ return info->coreFonts;
+}
+
+void
+XftDefaultSubstitute (Display *dpy, int screen, XftPattern *pattern)
+{
+ XftValue v;
+ double size;
+ double scale;
+
+ if (XftPatternGet (pattern, XFT_STYLE, 0, &v) == XftResultNoMatch)
+ {
+ if (XftPatternGet (pattern, XFT_WEIGHT, 0, &v) == XftResultNoMatch )
+ {
+ XftPatternAddInteger (pattern, XFT_WEIGHT, XFT_WEIGHT_MEDIUM);
+ }
+ if (XftPatternGet (pattern, XFT_SLANT, 0, &v) == XftResultNoMatch)
+ {
+ XftPatternAddInteger (pattern, XFT_SLANT, XFT_SLANT_ROMAN);
+ }
+ }
+ if (XftPatternGet (pattern, XFT_ENCODING, 0, &v) == XftResultNoMatch)
+ XftPatternAddString (pattern, XFT_ENCODING, "iso8859-1");
+ if (XftPatternGet (pattern, XFT_RENDER, 0, &v) == XftResultNoMatch)
+ {
+ XftPatternAddBool (pattern, XFT_RENDER,
+ XftDefaultGetBool (dpy, XFT_RENDER, screen,
+ XftDefaultHasRender (dpy)));
+ }
+ if (XftPatternGet (pattern, XFT_CORE, 0, &v) == XftResultNoMatch)
+ {
+ XftPatternAddBool (pattern, XFT_CORE,
+ XftDefaultGetBool (dpy, XFT_CORE, screen,
+ !XftDefaultHasRender (dpy)));
+ }
+ if (XftPatternGet (pattern, XFT_ANTIALIAS, 0, &v) == XftResultNoMatch)
+ {
+ XftPatternAddBool (pattern, XFT_ANTIALIAS,
+ XftDefaultGetBool (dpy, XFT_ANTIALIAS, screen,
+ True));
+ }
+ if (XftPatternGet (pattern, XFT_RGBA, 0, &v) == XftResultNoMatch)
+ {
+ int subpixel = XFT_RGBA_NONE;
+#if RENDER_MAJOR > 0 || RENDER_MINOR >= 6
+ int render_order = XRenderQuerySubpixelOrder (dpy, screen);
+ switch (render_order) {
+ default:
+ case SubPixelUnknown: subpixel = XFT_RGBA_NONE; break;
+ case SubPixelHorizontalRGB: subpixel = XFT_RGBA_RGB; break;
+ case SubPixelHorizontalBGR: subpixel = XFT_RGBA_BGR; break;
+ case SubPixelVerticalRGB: subpixel = XFT_RGBA_VRGB; break;
+ case SubPixelVerticalBGR: subpixel = XFT_RGBA_VBGR; break;
+ case SubPixelNone: subpixel = XFT_RGBA_NONE; break;
+ }
+#endif
+ XftPatternAddInteger (pattern, XFT_RGBA,
+ XftDefaultGetInteger (dpy, XFT_RGBA, screen,
+ subpixel));
+ }
+ if (XftPatternGet (pattern, XFT_MINSPACE, 0, &v) == XftResultNoMatch)
+ {
+ XftPatternAddBool (pattern, XFT_MINSPACE,
+ XftDefaultGetBool (dpy, XFT_MINSPACE, screen,
+ False));
+ }
+ if (XftPatternGet (pattern, XFT_PIXEL_SIZE, 0, &v) == XftResultNoMatch)
+ {
+ double pixels, mm, dpi;
+
+ if (XftPatternGet (pattern, XFT_SIZE, 0, &v) != XftResultMatch)
+ {
+ size = 12.0;
+ XftPatternAddDouble (pattern, XFT_SIZE, size);
+ }
+ else
+ {
+ switch (v.type) {
+ case XftTypeInteger:
+ size = (double) v.u.i;
+ break;
+ case XftTypeDouble:
+ size = v.u.d;
+ break;
+ default:
+ size = 12.0;
+ break;
+ }
+ }
+ scale = XftDefaultGetDouble (dpy, XFT_SCALE, screen, 1.0);
+ size *= scale;
+ pixels = DisplayHeight (dpy, screen);
+ mm = DisplayHeightMM (dpy, screen);
+ dpi = (pixels * 25.4) / mm;
+ dpi = XftDefaultGetDouble (dpy, XFT_DPI, screen, dpi);
+ size = size * dpi / 72.0;
+ XftPatternAddDouble (pattern, XFT_PIXEL_SIZE, size);
+ }
+}
diff --git a/nx-X11/lib/Xft1/xftdraw.c b/nx-X11/lib/Xft1/xftdraw.c
new file mode 100644
index 000000000..f9c3b8b79
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftdraw.c
@@ -0,0 +1,482 @@
+/*
+ * $XFree86: xc/lib/Xft/xftdraw.c,v 1.15 2001/05/16 19:20: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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "xftint.h"
+#include <X11/Xutil.h>
+
+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->visual = visual;
+ draw->colormap = colormap;
+ draw->core_set = False;
+ draw->render_set = False;
+ draw->render_able = False;
+ draw->clip = 0;
+ 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->visual = 0;
+ draw->colormap = 0;
+ draw->core_set = False;
+ draw->render_set = False;
+ draw->render_able = False;
+ draw->clip = 0;
+ return draw;
+}
+
+static XRenderPictFormat *
+_XftDrawFormat (XftDraw *draw)
+{
+ if (draw->visual == 0)
+ {
+ XRenderPictFormat pf;
+
+ pf.type = PictTypeDirect;
+ pf.depth = 1;
+ pf.direct.alpha = 0;
+ pf.direct.alphaMask = 1;
+ return XRenderFindFormat (draw->dpy,
+ (PictFormatType|
+ PictFormatDepth|
+ PictFormatAlpha|
+ PictFormatAlphaMask),
+ &pf,
+ 0);
+ }
+ else
+ return XRenderFindVisualFormat (draw->dpy, draw->visual);
+}
+
+static XRenderPictFormat *
+_XftDrawFgFormat (XftDraw *draw)
+{
+ XRenderPictFormat pf;
+
+ if (draw->visual == 0)
+ {
+ pf.type = PictTypeDirect;
+ pf.depth = 1;
+ pf.direct.alpha = 0;
+ pf.direct.alphaMask = 1;
+ return XRenderFindFormat (draw->dpy,
+ (PictFormatType|
+ PictFormatDepth|
+ PictFormatAlpha|
+ PictFormatAlphaMask),
+ &pf,
+ 0);
+ }
+ else
+ {
+ pf.type = PictTypeDirect;
+ pf.depth = 32;
+ pf.direct.redMask = 0xff;
+ pf.direct.greenMask = 0xff;
+ pf.direct.blueMask = 0xff;
+ pf.direct.alphaMask = 0xff;
+ return XRenderFindFormat (draw->dpy,
+ (PictFormatType|
+ PictFormatDepth|
+ PictFormatRedMask|
+ PictFormatGreenMask|
+ PictFormatBlueMask|
+ PictFormatAlphaMask),
+ &pf,
+ 0);
+ }
+}
+
+void
+XftDrawChange (XftDraw *draw,
+ Drawable drawable)
+{
+ draw->drawable = drawable;
+ if (draw->render_able)
+ {
+ XRenderPictFormat *format;
+
+ XRenderFreePicture (draw->dpy, draw->render.pict);
+ format = XRenderFindVisualFormat (draw->dpy, draw->visual);
+ draw->render.pict = XRenderCreatePicture (draw->dpy, draw->drawable,
+ format, 0, 0);
+ }
+}
+
+void
+XftDrawDestroy (XftDraw *draw)
+{
+ int n;
+
+ if (draw->render_able)
+ {
+ XRenderFreePicture (draw->dpy, draw->render.pict);
+ for (n = 0; n < XFT_DRAW_N_SRC; n++)
+ XRenderFreePicture (draw->dpy, draw->render.src[n].pict);
+ }
+ if (draw->core_set)
+ XFreeGC (draw->dpy, draw->core.draw_gc);
+ if (draw->clip)
+ XDestroyRegion (draw->clip);
+ free (draw);
+}
+
+Bool
+XftDrawRenderPrepare (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int src)
+{
+ if (!draw->render_set)
+ {
+ XRenderPictFormat *format;
+ XRenderPictFormat *pix_format;
+ XRenderPictureAttributes pa;
+ int n;
+ Pixmap pix;
+
+ draw->render_set = True;
+ draw->render_able = False;
+ format = _XftDrawFormat (draw);
+ pix_format = _XftDrawFgFormat (draw);
+ if (format && pix_format)
+ {
+ draw->render_able = True;
+
+ draw->render.pict = XRenderCreatePicture (draw->dpy, draw->drawable,
+ format, 0, 0);
+ for (n = 0; n < XFT_DRAW_N_SRC; n++)
+ {
+ pix = XCreatePixmap (draw->dpy, draw->drawable,
+ 1, 1, pix_format->depth);
+ pa.repeat = True;
+ draw->render.src[n].pict = XRenderCreatePicture (draw->dpy,
+ pix,
+ pix_format,
+ CPRepeat, &pa);
+ XFreePixmap (draw->dpy, pix);
+
+ draw->render.src[n].color = color->color;
+ XRenderFillRectangle (draw->dpy, PictOpSrc,
+ draw->render.src[n].pict,
+ &color->color, 0, 0, 1, 1);
+ }
+ if (draw->clip)
+ XRenderSetPictureClipRegion (draw->dpy, draw->render.pict,
+ draw->clip);
+ }
+ }
+ if (!draw->render_able)
+ return False;
+ if (memcmp (&color->color, &draw->render.src[src].color,
+ sizeof (XRenderColor)))
+ {
+ if (_XftFontDebug () & XFT_DBG_DRAW)
+ {
+ printf ("Switching to color %04x,%04x,%04x,%04x\n",
+ color->color.alpha,
+ color->color.red,
+ color->color.green,
+ color->color.blue);
+ }
+ XRenderFillRectangle (draw->dpy, PictOpSrc,
+ draw->render.src[src].pict,
+ &color->color, 0, 0, 1, 1);
+ draw->render.src[src].color = color->color;
+ }
+ return True;
+}
+
+Bool
+XftDrawCorePrepare (XftDraw *draw,
+ XftColor *color,
+ XftFont *font)
+{
+
+ if (!draw->core_set)
+ {
+ XGCValues gcv;
+ unsigned long mask;
+ draw->core_set = True;
+
+ draw->core.fg = color->pixel;
+ gcv.foreground = draw->core.fg;
+ mask = GCForeground;
+ if (font)
+ {
+ draw->core.font = font->u.core.font->fid;
+ gcv.font = draw->core.font;
+ mask |= GCFont;
+ }
+ draw->core.draw_gc = XCreateGC (draw->dpy, draw->drawable,
+ mask, &gcv);
+ if (draw->clip)
+ XSetRegion (draw->dpy, draw->core.draw_gc, draw->clip);
+ }
+ if (draw->core.fg != color->pixel)
+ {
+ draw->core.fg = color->pixel;
+ XSetForeground (draw->dpy, draw->core.draw_gc, draw->core.fg);
+ }
+ if (font && draw->core.font != font->u.core.font->fid)
+ {
+ draw->core.font = font->u.core.font->fid;
+ XSetFont (draw->dpy, draw->core.draw_gc, draw->core.font);
+ }
+ return True;
+}
+
+void
+XftDrawString8 (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar8 *string,
+ int len)
+{
+ if (_XftFontDebug () & XFT_DBG_DRAW)
+ {
+ printf ("DrawString \"%*.*s\"\n", len, len, string);
+ }
+ if (font->core)
+ {
+ XftDrawCorePrepare (draw, color, font);
+ XDrawString (draw->dpy, draw->drawable, draw->core.draw_gc, x, y,
+ (char *) string, len);
+ }
+#ifdef FREETYPE2
+ else if (XftDrawRenderPrepare (draw, color, font, XFT_DRAW_SRC_TEXT))
+ {
+ XftRenderString8 (draw->dpy,
+ draw->render.src[XFT_DRAW_SRC_TEXT].pict,
+ font->u.ft.font,
+ draw->render.pict, 0, 0, x, y, string, len);
+ }
+#endif
+}
+
+#define N16LOCAL 256
+
+void
+XftDrawString16 (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar16 *string,
+ int len)
+{
+ if (font->core)
+ {
+ XChar2b *xc;
+ XChar2b xcloc[XFT_CORE_N16LOCAL];
+
+ XftDrawCorePrepare (draw, color, font);
+ xc = XftCoreConvert16 (string, len, xcloc);
+ XDrawString16 (draw->dpy, draw->drawable, draw->core.draw_gc, x, y,
+ xc, len);
+ if (xc != xcloc)
+ free (xc);
+ }
+#ifdef FREETYPE2
+ else if (XftDrawRenderPrepare (draw, color, font, XFT_DRAW_SRC_TEXT))
+ {
+ XftRenderString16 (draw->dpy,
+ draw->render.src[XFT_DRAW_SRC_TEXT].pict,
+ font->u.ft.font,
+ draw->render.pict, 0, 0, x, y, string, len);
+ }
+#endif
+}
+
+void
+XftDrawString32 (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar32 *string,
+ int len)
+{
+ if (font->core)
+ {
+ XChar2b *xc;
+ XChar2b xcloc[XFT_CORE_N16LOCAL];
+
+ XftDrawCorePrepare (draw, color, font);
+ xc = XftCoreConvert32 (string, len, xcloc);
+ XDrawString16 (draw->dpy, draw->drawable, draw->core.draw_gc, x, y,
+ xc, len);
+ if (xc != xcloc)
+ free (xc);
+ }
+#ifdef FREETYPE2
+ else if (XftDrawRenderPrepare (draw, color, font, XFT_DRAW_SRC_TEXT))
+ {
+ XftRenderString32 (draw->dpy,
+ draw->render.src[XFT_DRAW_SRC_TEXT].pict,
+ font->u.ft.font,
+ draw->render.pict, 0, 0, x, y, string, len);
+ }
+#endif
+}
+
+void
+XftDrawStringUtf8 (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int x,
+ int y,
+ XftChar8 *string,
+ int len)
+{
+ if (font->core)
+ {
+ XChar2b *xc;
+ XChar2b xcloc[XFT_CORE_N16LOCAL];
+ int n;
+
+ XftDrawCorePrepare (draw, color, font);
+ xc = XftCoreConvertUtf8 (string, len, xcloc, &n);
+ if (xc)
+ {
+ XDrawString16 (draw->dpy, draw->drawable, draw->core.draw_gc, x, y,
+ xc, n);
+ }
+ if (xc != xcloc)
+ free (xc);
+ }
+#ifdef FREETYPE2
+ else if (XftDrawRenderPrepare (draw, color, font, XFT_DRAW_SRC_TEXT))
+ {
+ XftRenderStringUtf8 (draw->dpy,
+ draw->render.src[XFT_DRAW_SRC_TEXT].pict,
+ font->u.ft.font,
+ draw->render.pict, 0, 0, x, y, string, len);
+ }
+#endif
+}
+
+
+void
+XftDrawRect (XftDraw *draw,
+ XftColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height)
+{
+ if (XftDrawRenderPrepare (draw, color, 0, XFT_DRAW_SRC_RECT))
+ {
+ XRenderFillRectangle (draw->dpy, PictOpOver, draw->render.pict,
+ &color->color, x, y, width, height);
+ }
+ else
+ {
+ XftDrawCorePrepare (draw, color, 0);
+ XFillRectangle (draw->dpy, draw->drawable, draw->core.draw_gc,
+ x, y, width, height);
+ }
+}
+
+Bool
+XftDrawSetClip (XftDraw *draw,
+ Region r)
+{
+ Region n = 0;
+
+ if (!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_able)
+ {
+ XRenderPictureAttributes pa;
+ if (n)
+ {
+ XRenderSetPictureClipRegion (draw->dpy, draw->render.pict, n);
+ }
+ else
+ {
+ pa.clip_mask = None;
+ XRenderChangePicture (draw->dpy, draw->render.pict,
+ CPClipMask, &pa);
+ }
+ }
+ if (draw->core_set)
+ {
+ XGCValues gv;
+
+ if (n)
+ XSetRegion (draw->dpy, draw->core.draw_gc, n);
+ else
+ {
+ gv.clip_mask = None;
+ XChangeGC (draw->dpy, draw->core.draw_gc,
+ GCClipMask, &gv);
+ }
+ }
+ return True;
+}
diff --git a/nx-X11/lib/Xft1/xftextent.c b/nx-X11/lib/Xft1/xftextent.c
new file mode 100644
index 000000000..8a6cf620a
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftextent.c
@@ -0,0 +1,190 @@
+/*
+ * $XFree86: xc/lib/Xft/xftextent.c,v 1.6 2001/04/01 14:00:01 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 <string.h>
+#include "xftint.h"
+
+void
+XftTextExtents8 (Display *dpy,
+ XftFont *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ if (font->core)
+ {
+ XftCoreExtents8 (dpy, font->u.core.font, string, len, extents);
+ }
+#ifdef FREETYPE2
+ else
+ {
+ XftRenderExtents8 (dpy, font->u.ft.font, string, len, extents);
+ }
+#endif
+}
+
+void
+XftTextExtents16 (Display *dpy,
+ XftFont *font,
+ XftChar16 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ if (font->core)
+ {
+ XftCoreExtents16 (dpy, font->u.core.font, string, len, extents);
+ }
+#ifdef FREETYPE2
+ else
+ {
+ XftRenderExtents16 (dpy, font->u.ft.font, string, len, extents);
+ }
+#endif
+}
+
+void
+XftTextExtents32 (Display *dpy,
+ XftFont *font,
+ XftChar32 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ if (font->core)
+ {
+ XftCoreExtents32 (dpy, font->u.core.font, string, len, extents);
+ }
+#ifdef FREETYPE2
+ else
+ {
+ XftRenderExtents32 (dpy, font->u.ft.font, string, len, extents);
+ }
+#endif
+}
+
+void
+XftTextExtentsUtf8 (Display *dpy,
+ XftFont *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ XftChar8 *src;
+ XftChar32 c;
+ XftChar32 lbuf[4096];
+ XftChar32 *dst;
+ XftChar8 *dst8;
+ XftChar16 *dst16;
+ XftChar32 *dst32;
+ int rlen, clen;
+ int width = 1;
+ int n;
+
+ /* compute needed width */
+ src = string;
+ rlen = len;
+ n = 0;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (src, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ {
+ memset (extents, 0, sizeof (XGlyphInfo));
+ return;
+ }
+ if (c >= 0x10000)
+ width = 4;
+ else if (c >= 0x100)
+ {
+ if (width == 1)
+ width = 2;
+ }
+ src += clen;
+ rlen -= clen;
+ n++;
+ }
+ dst = lbuf;
+ if (n * width > sizeof (lbuf))
+ {
+ dst = (XftChar32 *) malloc (n * width);
+ if (!dst)
+ {
+ memset (extents, 0, sizeof (XGlyphInfo));
+ return;
+ }
+ }
+
+ switch (width) {
+ case 4:
+ src = string;
+ rlen = len;
+ dst32 = dst;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (src, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ return;
+ *dst32++ = c;
+ src += clen;
+ rlen -= clen;
+ }
+ dst32 = dst;
+ XftTextExtents32 (dpy, font, dst32, n, extents);
+ break;
+ case 2:
+ src = string;
+ rlen = len;
+ dst16 = (XftChar16 *) dst;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (src, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ return;
+ *dst16++ = c;
+ src += clen;
+ rlen -= clen;
+ }
+ dst16 = (XftChar16 *) dst;
+ XftTextExtents16 (dpy, font, dst16, n, extents);
+ break;
+ case 1:
+ src = string;
+ rlen = len;
+ dst8 = (XftChar8 *) dst;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (src, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ return;
+ *dst8++ = c;
+ src += clen;
+ rlen -= clen;
+ }
+ dst8 = (XftChar8 *) dst;
+ XftTextExtents8 (dpy, font, dst8, n, extents);
+ break;
+ }
+ if (dst != lbuf)
+ free (dst);
+}
diff --git a/nx-X11/lib/Xft1/xftfont.c b/nx-X11/lib/Xft1/xftfont.c
new file mode 100644
index 000000000..ab393af81
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftfont.c
@@ -0,0 +1,327 @@
+/*
+ * $XFree86: xc/lib/Xft/xftfont.c,v 1.8 2000/12/20 00:20: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 <stdio.h>
+#include <stdlib.h>
+#include "xftint.h"
+
+XftPattern *
+XftFontMatch (Display *dpy, int screen, XftPattern *pattern, XftResult *result)
+{
+ XftPattern *new;
+ XftPattern *match;
+ XftFontSet *sets[2];
+ int nsets;
+#ifdef FREETYPE2
+ Bool render, core;
+#endif
+
+ if (!XftInit (0))
+ return 0;
+
+ new = XftPatternDuplicate (pattern);
+ if (!new)
+ return 0;
+
+ if (_XftFontDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch pattern ");
+ XftPatternPrint (new);
+ }
+ XftConfigSubstitute (new);
+ if (_XftFontDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch after XftConfig substitutions ");
+ XftPatternPrint (new);
+ }
+ XftDefaultSubstitute (dpy, screen, new);
+ if (_XftFontDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch after X resource substitutions ");
+ XftPatternPrint (new);
+ }
+ nsets = 0;
+
+#ifdef FREETYPE2
+ render = False;
+ core = True;
+ (void) XftPatternGetBool (new, XFT_RENDER, 0, &render);
+ (void) XftPatternGetBool (new, XFT_CORE, 0, &core);
+ if (_XftFontDebug () & XFT_DBG_OPENV)
+ {
+ printf ("XftFontMatch: use core fonts \"%s\", use render fonts \"%s\"\n",
+ core ? "True" : "False", render ? "True" : "False");
+ }
+
+ if (render)
+ {
+ if (XftInitFtLibrary())
+ {
+ sets[nsets] = _XftFontSet;
+ if (sets[nsets])
+ nsets++;
+ }
+ }
+ if (core)
+#endif
+ {
+ sets[nsets] = XftDisplayGetFontSet (dpy);
+ if (sets[nsets])
+ nsets++;
+ }
+
+ match = XftFontSetMatch (sets, nsets, new, result);
+ XftPatternDestroy (new);
+ return match;
+}
+
+XftFont *
+XftFontOpenPattern (Display *dpy, XftPattern *pattern)
+{
+ Bool core = True;
+ XFontStruct *xfs = 0;
+ XftFont *font;
+#ifdef FREETYPE2
+ XftFontStruct *fs = 0;
+
+ if (XftPatternGetBool (pattern, XFT_CORE, 0, &core) != XftResultMatch)
+ return 0;
+ if (core)
+#endif
+ {
+ xfs = XftCoreOpen (dpy, pattern);
+ if (!xfs) return 0;
+ }
+#ifdef FREETYPE2
+ else
+ {
+ fs = XftFreeTypeOpen (dpy, pattern);
+ if (!fs) return 0;
+ }
+#endif
+ font = (XftFont *) malloc (sizeof (XftFont));
+ font->core = core;
+ font->pattern = pattern;
+#ifdef FREETYPE2
+ if (core)
+#endif
+ {
+ font->u.core.font = xfs;
+ font->ascent = xfs->ascent;
+ font->descent = xfs->descent;
+ font->height = xfs->ascent + xfs->descent;
+ font->max_advance_width = xfs->max_bounds.width;
+ }
+#ifdef FREETYPE2
+ else
+ {
+ font->u.ft.font = fs;
+ font->ascent = fs->ascent;
+ font->descent = fs->descent;
+ font->height = fs->height;
+ font->max_advance_width = fs->max_advance_width;
+ }
+#endif
+ return font;
+}
+
+int
+_XftFontDebug (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;
+}
+
+XftFont *
+XftFontOpen (Display *dpy, int screen, ...)
+{
+ va_list va;
+ XftPattern *pat;
+ XftPattern *match;
+ XftResult result;
+ XftFont *font;
+
+ va_start (va, screen);
+ pat = XftPatternVaBuild (0, va);
+ va_end (va);
+ if (!pat)
+ {
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ printf ("XftFontOpen: Invalid pattern argument\n");
+ return 0;
+ }
+ match = XftFontMatch (dpy, screen, pat, &result);
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ {
+ printf ("Pattern ");
+ XftPatternPrint (pat);
+ if (match)
+ {
+ printf ("Match ");
+ XftPatternPrint (match);
+ }
+ else
+ printf ("No Match\n");
+ }
+ XftPatternDestroy (pat);
+ if (!match)
+ return 0;
+
+ font = XftFontOpenPattern (dpy, match);
+ if (!font)
+ {
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ printf ("No Font\n");
+ XftPatternDestroy (match);
+ }
+
+ return font;
+}
+
+XftFont *
+XftFontOpenName (Display *dpy, int screen, const char *name)
+{
+ XftPattern *pat;
+ XftPattern *match;
+ XftResult result;
+ XftFont *font;
+
+ pat = XftNameParse (name);
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ {
+ printf ("XftFontOpenName \"%s\": ", name);
+ if (pat)
+ XftPatternPrint (pat);
+ else
+ printf ("Invalid name\n");
+ }
+
+ if (!pat)
+ return 0;
+ match = XftFontMatch (dpy, screen, pat, &result);
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ {
+ if (match)
+ {
+ printf ("Match ");
+ XftPatternPrint (match);
+ }
+ else
+ printf ("No Match\n");
+ }
+ XftPatternDestroy (pat);
+ if (!match)
+ return 0;
+
+ font = XftFontOpenPattern (dpy, match);
+ if (!font)
+ XftPatternDestroy (match);
+
+ return font;
+}
+
+XftFont *
+XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd)
+{
+ XftPattern *pat;
+ XftPattern *match;
+ XftResult result;
+ XftFont *font;
+
+ pat = XftXlfdParse (xlfd, False, False);
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ {
+ printf ("XftFontOpenXlfd \"%s\": ", xlfd);
+ if (pat)
+ printf ("Invalid xlfd\n");
+ else
+ XftPatternPrint (pat);
+ }
+
+ if (!pat)
+ return 0;
+ match = XftFontMatch (dpy, screen, pat, &result);
+ if (_XftFontDebug () & XFT_DBG_OPEN)
+ {
+ if (match)
+ {
+ printf ("Match ");
+ XftPatternPrint (match);
+ }
+ else
+ printf ("No Match\n");
+ }
+ XftPatternDestroy (pat);
+ if (!match)
+ return 0;
+
+ font = XftFontOpenPattern (dpy, match);
+ if (!font)
+ XftPatternDestroy (match);
+
+ return font;
+}
+
+void
+XftFontClose (Display *dpy, XftFont *font)
+{
+ if (font->core)
+ XftCoreClose (dpy, font->u.core.font);
+#ifdef FREETYPE2
+ else
+ XftFreeTypeClose (dpy, font->u.ft.font);
+#endif
+ if (font->pattern)
+ XftPatternDestroy (font->pattern);
+ free (font);
+}
+
+Bool
+XftGlyphExists (Display *dpy, XftFont *font, XftChar32 glyph)
+{
+ if (font->core)
+ return XftCoreGlyphExists (dpy, font->u.core.font, glyph);
+ else
+#ifdef FREETYPE2
+ return XftFreeTypeGlyphExists (dpy, font->u.ft.font, glyph);
+#else
+ return False;
+#endif
+}
diff --git a/nx-X11/lib/Xft1/xftfreetype.c b/nx-X11/lib/Xft1/xftfreetype.c
new file mode 100644
index 000000000..1021c95bf
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftfreetype.c
@@ -0,0 +1,678 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftfreetype.c,v 1.5 2002/08/12 22:17:49 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 <string.h>
+#include "xftint.h"
+
+FT_Library _XftFTlibrary;
+
+typedef struct _XftFtEncoding {
+ const char *name;
+ FT_Encoding encoding;
+} XftFtEncoding;
+
+static XftFtEncoding xftFtEncoding[] = {
+ { "iso10646-1", ft_encoding_unicode, },
+ { "iso8859-1", ft_encoding_unicode, },
+ { "apple-roman", ft_encoding_apple_roman },
+ { "adobe-fontspecific", ft_encoding_symbol, },
+ { "glyphs-fontspecific",ft_encoding_none, },
+};
+
+#define NUM_FT_ENCODINGS (sizeof xftFtEncoding / sizeof xftFtEncoding[0])
+
+#define FT_Matrix_Equal(a,b) ((a)->xx == (b)->xx && \
+ (a)->yy == (b)->yy && \
+ (a)->xy == (b)->xy && \
+ (a)->yx == (b)->yx)
+
+XftPattern *
+XftFreeTypeQuery (const char *file, int id, int *count)
+{
+ FT_Face face;
+ XftPattern *pat;
+ int slant;
+ int weight;
+ int i, j;
+
+ if (FT_New_Face (_XftFTlibrary, file, id, &face))
+ return 0;
+
+ *count = face->num_faces;
+
+ pat = XftPatternCreate ();
+ if (!pat)
+ goto bail0;
+
+
+ if (!XftPatternAddBool (pat, XFT_CORE, False))
+ goto bail1;
+
+ if (!XftPatternAddBool (pat, XFT_OUTLINE,
+ (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
+ goto bail1;
+
+ if (!XftPatternAddBool (pat, XFT_SCALABLE,
+ (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
+ goto bail1;
+
+
+ slant = XFT_SLANT_ROMAN;
+ if (face->style_flags & FT_STYLE_FLAG_ITALIC)
+ slant = XFT_SLANT_ITALIC;
+
+ if (!XftPatternAddInteger (pat, XFT_SLANT, slant))
+ goto bail1;
+
+ weight = XFT_WEIGHT_MEDIUM;
+ if (face->style_flags & FT_STYLE_FLAG_BOLD)
+ weight = XFT_WEIGHT_BOLD;
+
+ if (!XftPatternAddInteger (pat, XFT_WEIGHT, weight))
+ goto bail1;
+
+ if (!XftPatternAddString (pat, XFT_FAMILY, face->family_name))
+ goto bail1;
+
+ if (!XftPatternAddString (pat, XFT_STYLE, face->style_name))
+ goto bail1;
+
+ if (!XftPatternAddString (pat, XFT_FILE, file))
+ goto bail1;
+
+ if (!XftPatternAddInteger (pat, XFT_INDEX, id))
+ goto bail1;
+
+#if 0
+ if ((face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) != 0)
+ if (!XftPatternAddInteger (pat, XFT_SPACING, XFT_MONO))
+ goto bail1;
+#endif
+
+ if (!(face->face_flags & FT_FACE_FLAG_SCALABLE))
+ {
+ for (i = 0; i < face->num_fixed_sizes; i++)
+ if (!XftPatternAddDouble (pat, XFT_PIXEL_SIZE,
+ (double) face->available_sizes[i].height))
+ goto bail1;
+ }
+
+ for (i = 0; i < face->num_charmaps; i++)
+ {
+#if 0
+ printf ("face %s encoding %d %c%c%c%c\n",
+ face->family_name, i,
+ face->charmaps[i]->encoding >> 24,
+ face->charmaps[i]->encoding >> 16,
+ face->charmaps[i]->encoding >> 8,
+ face->charmaps[i]->encoding >> 0);
+#endif
+ for (j = 0; j < NUM_FT_ENCODINGS; j++)
+ {
+ if (face->charmaps[i]->encoding == xftFtEncoding[j].encoding)
+ {
+ if (!XftPatternAddString (pat, XFT_ENCODING,
+ xftFtEncoding[j].name))
+ goto bail1;
+ }
+ }
+ }
+
+ if (!XftPatternAddString (pat, XFT_ENCODING,
+ "glyphs-fontspecific"))
+ goto bail1;
+
+
+ FT_Done_Face (face);
+ return pat;
+
+bail1:
+ XftPatternDestroy (pat);
+bail0:
+ FT_Done_Face (face);
+ return 0;
+}
+
+/*
+ * List of all open files (each face in a file is managed separately)
+ */
+typedef struct _XftFtFile {
+ struct _XftFtFile *next;
+ int ref;
+
+ char *file;
+ int id;
+
+ FT_Face face;
+ FT_F26Dot6 size;
+ FT_Matrix matrix;
+ int charmap;
+} XftFtFile;
+
+static XftFtFile *_XftFtFiles;
+
+static XftFtFile *
+_XftFreeTypeOpenFile (char *file, int id)
+{
+ XftFtFile *f;
+ FT_Face face;
+
+ for (f = _XftFtFiles; f; f = f->next)
+ {
+ if (!strcmp (f->file, file) && f->id == id)
+ {
+ ++f->ref;
+ if (_XftFontDebug () & XFT_DBG_REF)
+ printf ("FontFile %s/%d matches existing (%d)\n",
+ file, id, f->ref);
+ return f;
+ }
+ }
+ if (FT_New_Face (_XftFTlibrary, file, id, &face))
+ return 0;
+
+ f = malloc (sizeof (XftFtFile) + strlen (file) + 1);
+ if (!f)
+ return 0;
+
+ if (_XftFontDebug () & 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, file);
+ f->id = id;
+
+ f->face = face;
+ f->size = 0;
+ f->charmap = -1;
+ f->matrix.xx = 0x10000;
+ f->matrix.xy = 0x0;
+ f->matrix.yy = 0x10000;
+ f->matrix.yx = 0x0;
+ return f;
+}
+
+Bool
+XftFreeTypeSetFace (FT_Face face, FT_F26Dot6 size, int charmap, FT_Matrix *matrix)
+{
+ XftFtFile *f, **prev;
+
+ for (prev = &_XftFtFiles; (f = *prev); prev = &f->next)
+ {
+ if (f->face == face)
+ {
+ /* LRU */
+ if (prev != &_XftFtFiles)
+ {
+ *prev = f->next;
+ f->next = _XftFtFiles;
+ _XftFtFiles = f;
+ }
+ if (f->size != size)
+ {
+ if (_XftFontDebug() & 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 (f->charmap != charmap && charmap != -1)
+ {
+ if (_XftFontDebug() & XFT_DBG_GLYPH)
+ printf ("Set face charmap to %d\n", charmap);
+ if (FT_Set_Charmap (face, face->charmaps[charmap]))
+ return False;
+ f->charmap = charmap;
+ }
+ if (!FT_Matrix_Equal (&f->matrix, matrix))
+ {
+ if (_XftFontDebug() & 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;
+ }
+ break;
+ }
+ }
+ return True;
+}
+
+static void
+_XftFreeTypeCloseFile (XftFtFile *f)
+{
+ XftFtFile **prev;
+
+ if (--f->ref != 0)
+ return;
+ for (prev = &_XftFtFiles; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == f)
+ {
+ *prev = f->next;
+ break;
+ }
+ }
+ FT_Done_Face (f->face);
+ free (f);
+}
+
+/*
+ * Cache of all glyphsets
+ */
+typedef struct _XftFtGlyphSet {
+ struct _XftFtGlyphSet *next;
+ int ref;
+
+ XftFtFile *file;
+ Bool minspace;
+ int char_width;
+
+ XftFontStruct font;
+} XftFtGlyphSet;
+
+XftFontStruct *
+XftFreeTypeOpen (Display *dpy, XftPattern *pattern)
+{
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
+ XftFtFile *file;
+ FT_Face face;
+ XftFtGlyphSet *gs;
+ char *filename;
+ int id;
+ double dsize;
+ FT_F26Dot6 size;
+ int rgba;
+ int spacing;
+ int char_width;
+ Bool antialias;
+ Bool minspace;
+ char *encoding_name;
+ XftFontStruct *font;
+ int j;
+ FT_Encoding encoding;
+ int charmap;
+ FT_Matrix matrix;
+ XftMatrix *font_matrix;
+
+#if 0
+ int extra;
+#endif
+ int height, ascent, descent;
+ XRenderPictFormat pf, *format;
+
+ /*
+ * Open the file
+ */
+ if (XftPatternGetString (pattern, XFT_FILE, 0, &filename) != XftResultMatch)
+ goto bail0;
+
+ if (XftPatternGetInteger (pattern, XFT_INDEX, 0, &id) != XftResultMatch)
+ goto bail0;
+
+ file = _XftFreeTypeOpenFile (filename, id);
+ if (!file)
+ goto bail0;
+
+ face = file->face;
+
+ /*
+ * Extract the glyphset information from the pattern
+ */
+ if (XftPatternGetString (pattern, XFT_ENCODING, 0, &encoding_name) != XftResultMatch)
+ goto bail0;
+
+ if (XftPatternGetDouble (pattern, XFT_PIXEL_SIZE, 0, &dsize) != XftResultMatch)
+ goto bail0;
+
+ switch (XftPatternGetInteger (pattern, XFT_RGBA, 0, &rgba)) {
+ case XftResultNoMatch:
+ rgba = XFT_RGBA_NONE;
+ break;
+ case XftResultMatch:
+ break;
+ default:
+ goto bail0;
+ }
+
+ switch (XftPatternGetBool (pattern, XFT_ANTIALIAS, 0, &antialias)) {
+ case XftResultNoMatch:
+ antialias = True;
+ break;
+ case XftResultMatch:
+ break;
+ default:
+ goto bail0;
+ }
+
+ switch (XftPatternGetBool (pattern, XFT_MINSPACE, 0, &minspace)) {
+ case XftResultNoMatch:
+ minspace = False;
+ break;
+ case XftResultMatch:
+ break;
+ default:
+ goto bail0;
+ }
+
+ switch (XftPatternGetInteger (pattern, XFT_SPACING, 0, &spacing)) {
+ case XftResultNoMatch:
+ spacing = XFT_PROPORTIONAL;
+ break;
+ case XftResultMatch:
+ break;
+ default:
+ goto bail1;
+ }
+
+ if (XftPatternGetInteger (pattern, XFT_CHAR_WIDTH,
+ 0, &char_width) != XftResultMatch)
+ {
+ char_width = 0;
+ }
+ else if (char_width)
+ spacing = XFT_MONO;
+
+ matrix.xx = matrix.yy = 0x10000;
+ matrix.xy = matrix.yx = 0;
+
+ switch (XftPatternGetMatrix (pattern, XFT_MATRIX, 0, &font_matrix)) {
+ case XftResultNoMatch:
+ break;
+ case XftResultMatch:
+ 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 bail1;
+ }
+
+
+
+ if (XftPatternGetInteger (pattern, XFT_CHAR_WIDTH,
+ 0, &char_width) != XftResultMatch)
+ {
+ char_width = 0;
+ }
+ else if (char_width)
+ spacing = XFT_MONO;
+
+ encoding = face->charmaps[0]->encoding;
+
+ for (j = 0; j < NUM_FT_ENCODINGS; j++)
+ if (!strcmp (encoding_name, xftFtEncoding[j].name))
+ {
+ encoding = xftFtEncoding[j].encoding;
+ break;
+ }
+
+ size = (FT_F26Dot6) (dsize * 64.0);
+
+ if (encoding == ft_encoding_none)
+ charmap = -1;
+ else
+ {
+ for (charmap = 0; charmap < face->num_charmaps; charmap++)
+ if (face->charmaps[charmap]->encoding == encoding)
+ break;
+
+ if (charmap == face->num_charmaps)
+ goto bail1;
+ }
+
+
+ /*
+ * Match an existing glyphset
+ */
+ for (gs = info->glyphSets; gs; gs = gs->next)
+ {
+ if (gs->file == file &&
+ gs->minspace == minspace &&
+ gs->char_width == char_width &&
+ gs->font.size == size &&
+ gs->font.spacing == spacing &&
+ gs->font.charmap == charmap &&
+ gs->font.rgba == rgba &&
+ gs->font.antialias == antialias &&
+ FT_Matrix_Equal (&gs->font.matrix, &matrix))
+ {
+ ++gs->ref;
+ if (_XftFontDebug () & XFT_DBG_REF)
+ {
+ printf ("Face size %g matches existing (%d)\n",
+ dsize, gs->ref);
+ }
+ return &gs->font;
+ }
+ }
+
+ if (_XftFontDebug () & XFT_DBG_REF)
+ {
+ printf ("Face size %g matches new\n",
+ dsize);
+ }
+ /*
+ * No existing glyphset, create another
+ */
+ gs = malloc (sizeof (XftFtGlyphSet));
+ if (!gs)
+ goto bail1;
+
+ gs->ref = 1;
+
+ gs->file = file;
+ gs->minspace = minspace;
+ gs->char_width = char_width;
+
+ font = &gs->font;
+
+ if (antialias)
+ {
+ switch (rgba) {
+ case FC_RGBA_RGB:
+ case FC_RGBA_BGR:
+ case FC_RGBA_VRGB:
+ case FC_RGBA_VBGR:
+ pf.depth = 32;
+ pf.type = PictTypeDirect;
+ pf.direct.alpha = 24;
+ pf.direct.alphaMask = 0xff;
+ pf.direct.red = 16;
+ pf.direct.redMask = 0xff;
+ pf.direct.green = 8;
+ pf.direct.greenMask = 0xff;
+ pf.direct.blue = 0;
+ pf.direct.blueMask = 0xff;
+ format = XRenderFindFormat(dpy,
+ PictFormatType|
+ PictFormatDepth|
+ PictFormatAlpha|
+ PictFormatAlphaMask|
+ PictFormatRed|
+ PictFormatRedMask|
+ PictFormatGreen|
+ PictFormatGreenMask|
+ PictFormatBlue|
+ PictFormatBlueMask,
+ &pf, 0);
+ break;
+ default:
+ pf.depth = 8;
+ pf.type = PictTypeDirect;
+ pf.direct.alpha = 0;
+ pf.direct.alphaMask = 0xff;
+ format = XRenderFindFormat(dpy,
+ PictFormatType|
+ PictFormatDepth|
+ PictFormatAlpha|
+ PictFormatAlphaMask,
+ &pf, 0);
+ break;
+ }
+ }
+ else
+ {
+ pf.depth = 1;
+ pf.type = PictTypeDirect;
+ pf.direct.alpha = 0;
+ pf.direct.alphaMask = 0x1;
+ format = XRenderFindFormat(dpy,
+ PictFormatType|
+ PictFormatDepth|
+ PictFormatAlpha|
+ PictFormatAlphaMask,
+ &pf, 0);
+ }
+
+ if (!format)
+ goto bail2;
+
+ if (!XftFreeTypeSetFace (face, size, charmap, &matrix))
+ goto bail2;
+
+ descent = -(face->size->metrics.descender >> 6);
+ ascent = face->size->metrics.ascender >> 6;
+ if (minspace)
+ {
+ height = ascent + descent;
+ }
+ else
+ {
+ height = face->size->metrics.height >> 6;
+#if 0
+ extra = (height - (ascent + descent));
+ if (extra > 0)
+ {
+ ascent = ascent + extra / 2;
+ descent = height - ascent;
+ }
+ else if (extra < 0)
+ height = ascent + descent;
+#endif
+ }
+ font->ascent = ascent;
+ font->descent = descent;
+ font->height = height;
+
+ if (char_width)
+ font->max_advance_width = char_width;
+ else
+ font->max_advance_width = face->size->metrics.max_advance >> 6;
+
+ gs->next = info->glyphSets;
+ info->glyphSets = gs;
+
+ font->glyphset = XRenderCreateGlyphSet (dpy, format);
+
+ font->size = size;
+ font->spacing = spacing;
+ font->format = format;
+ font->realized =0;
+ font->nrealized = 0;
+ font->rgba = rgba;
+ font->antialias = antialias;
+ font->charmap = charmap;
+ font->transform = (matrix.xx != 0x10000 || matrix.xy != 0 ||
+ matrix.yx != 0 || matrix.yy != 0x10000);
+ font->matrix = matrix;
+ font->face = face;
+
+ return font;
+
+bail2:
+ free (gs);
+bail1:
+ _XftFreeTypeCloseFile (file);
+bail0:
+ return 0;
+}
+
+void
+XftFreeTypeClose (Display *dpy, XftFontStruct *font)
+{
+ XftFtGlyphSet *gs, **prev;
+ XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
+ int i;
+ XGlyphInfo *gi;
+
+ for (prev = &info->glyphSets; (gs = *prev); prev = &gs->next)
+ {
+ if (&gs->font == font)
+ {
+ if (--gs->ref == 0)
+ {
+ XRenderFreeGlyphSet (dpy, font->glyphset);
+ for (i = 0; i < font->nrealized; i++)
+ {
+ gi = font->realized[i];
+ if (gi && gi != XftUntestedGlyph)
+ free (gi);
+ }
+ if (font->realized)
+ free (font->realized);
+
+ _XftFreeTypeCloseFile (gs->file);
+
+ *prev = gs->next;
+ free (gs);
+ }
+ break;
+ }
+ }
+}
+
+XftFontStruct *
+XftFreeTypeGet (XftFont *font)
+{
+ if (font->core)
+ return 0;
+ return font->u.ft.font;
+}
+
+/* #define XFT_DEBUG_FONTSET */
+
+Bool
+XftInitFtLibrary (void)
+{
+ if (_XftFTlibrary)
+ return True;
+ if (FT_Init_FreeType (&_XftFTlibrary))
+ return False;
+ _XftFontSet = FcConfigGetFonts (0, FcSetSystem);
+ if (!_XftFontSet)
+ return False;
+ return True;
+}
diff --git a/nx-X11/lib/Xft1/xftfs.c b/nx-X11/lib/Xft1/xftfs.c
new file mode 100644
index 000000000..a246b2056
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftfs.c
@@ -0,0 +1,44 @@
+/*
+ * $XFree86$
+ *
+ * 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"
+
+XftFontSet *
+XftFontSetCreate (void)
+{
+ return FcFontSetCreate ();
+}
+
+void
+XftFontSetDestroy (XftFontSet *s)
+{
+ FcFontSetDestroy (s);
+}
+
+Bool
+XftFontSetAdd (XftFontSet *s, XftPattern *font)
+{
+ return FcFontSetAdd (s, font);
+}
diff --git a/nx-X11/lib/Xft1/xftglyphs.c b/nx-X11/lib/Xft1/xftglyphs.c
new file mode 100644
index 000000000..1e23d0a0b
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftglyphs.c
@@ -0,0 +1,491 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftglyphs.c,v 1.3 2003/05/27 22:26:41 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 <string.h>
+#include "xftint.h"
+#include <ft2build.h>
+#include FT_OUTLINE_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
+XftGlyphLoad (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 *glyphs,
+ int nglyph)
+{
+ FT_Error error;
+ FT_ULong charcode;
+ FT_UInt glyphindex;
+ FT_GlyphSlot glyph;
+ XGlyphInfo *gi;
+ Glyph g;
+ 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;
+
+ if (!XftFreeTypeSetFace (font->face, font->size, font->charmap, &font->matrix))
+ return ;
+
+ matrix.xx = matrix.yy = 0x10000L;
+ matrix.xy = matrix.yx = 0;
+
+ if (font->antialias)
+ {
+ switch (font->rgba) {
+ case XFT_RGBA_RGB:
+ case XFT_RGBA_BGR:
+ matrix.xx *= 3;
+ subpixel = True;
+ hmul = 3;
+ break;
+ case XFT_RGBA_VRGB:
+ case XFT_RGBA_VBGR:
+ matrix.yy *= 3;
+ vmul = 3;
+ subpixel = True;
+ break;
+ }
+ }
+
+ while (nglyph--)
+ {
+ charcode = (FT_ULong) *glyphs++;
+ gi = font->realized[charcode];
+ if (!gi)
+ continue;
+
+ if (font->charmap != -1)
+ {
+ glyphindex = FT_Get_Char_Index (font->face, charcode);
+#if 0
+ if (!glyphindex)
+ {
+ if (_XftFontDebug() & XFT_DBG_GLYPH)
+ printf ("glyph (%c) %d missing\n",
+ (int) charcode, (int) charcode);
+ continue;
+ }
+#endif
+ }
+ else
+ glyphindex = (FT_UInt) charcode;
+ error = FT_Load_Glyph (font->face, glyphindex, 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)
+
+ glyph = font->face->glyph;
+
+ if(font->transform)
+ {
+ /*
+ * 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 = glyph->metrics.horiBearingX + xc * glyph->metrics.width;
+ vector.y = glyph->metrics.horiBearingY - yc * glyph->metrics.height;
+ FT_Vector_Transform(&vector, &font->matrix);
+ if (_XftFontDebug() & 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( glyph->metrics.horiBearingX );
+ right = CEIL( glyph->metrics.horiBearingX + glyph->metrics.width );
+
+ top = CEIL( glyph->metrics.horiBearingY );
+ bottom = FLOOR( glyph->metrics.horiBearingY - glyph->metrics.height );
+ }
+
+ width = TRUNC(right - left);
+ height = TRUNC( top - bottom );
+
+
+ /*
+ * Try to keep monospace fonts ink-inside
+ * XXX transformed?
+ */
+ if (font->spacing != XFT_PROPORTIONAL && !font->transform)
+ {
+ if (TRUNC(right) > font->max_advance_width)
+ {
+ int adjust;
+
+ adjust = right - (font->max_advance_width << 6);
+ if (adjust > left)
+ adjust = left;
+ left -= adjust;
+ right -= adjust;
+ width = font->max_advance_width;
+ }
+ }
+
+ if ( glyph->format == ft_glyph_format_outline )
+ {
+ if (font->antialias)
+ pitch = (width * hmul + 3) & ~3;
+ else
+ pitch = ((width + 31) & ~31) >> 3;
+
+ size = pitch * height * vmul;
+
+ if (size > bufSize)
+ {
+ if (bufBitmap != bufLocal)
+ free (bufBitmap);
+ bufBitmap = (unsigned char *) malloc (size);
+ if (!bufBitmap)
+ continue;
+ bufSize = size;
+ }
+ memset (bufBitmap, 0, size);
+
+ 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 (&glyph->outline, &matrix);
+
+ FT_Outline_Translate ( &glyph->outline, -left*hmul, -bottom*vmul );
+
+ FT_Outline_Get_Bitmap( _XftFTlibrary, &glyph->outline, &ftbit );
+
+ /*
+ * swap bit order around
+ */
+ 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 (_XftFontDebug() & XFT_DBG_GLYPH)
+ {
+ printf ("char 0x%x (%c):\n", (int) charcode, (char) charcode);
+ printf (" xywh (%d %d %d %d), trans (%d %d %d %d) wh (%d %d)\n",
+ (int) glyph->metrics.horiBearingX,
+ (int) glyph->metrics.horiBearingY,
+ (int) glyph->metrics.width,
+ (int) glyph->metrics.height,
+ left, right, top, bottom,
+ width, height);
+ if (_XftFontDebug() & 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");
+ }
+ }
+ }
+ else
+ {
+ if (_XftFontDebug() & XFT_DBG_GLYPH)
+ printf ("glyph (%c) %d no outline\n",
+ (int) charcode, (int) charcode);
+ continue;
+ }
+
+ gi->width = width;
+ gi->height = height;
+ gi->x = -TRUNC(left);
+ gi->y = TRUNC(top);
+ if (font->spacing != XFT_PROPORTIONAL)
+ {
+ if (font->transform)
+ {
+ vector.x = font->max_advance_width;
+ vector.y = 0;
+ FT_Vector_Transform (&vector, &font->matrix);
+ gi->xOff = vector.x;
+ gi->yOff = -vector.y;
+ }
+ else
+ {
+ gi->xOff = font->max_advance_width;
+ gi->yOff = 0;
+ }
+ }
+ else
+ {
+ gi->xOff = TRUNC(ROUND(glyph->advance.x));
+ gi->yOff = -TRUNC(ROUND(glyph->advance.y));
+ }
+ g = charcode;
+
+ 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;
+
+ widthrgba = width;
+ pitchrgba = (widthrgba * 4 + 3) & ~3;
+ sizergba = pitchrgba * height;
+
+ os = 1;
+ switch (font->rgba) {
+ case XFT_RGBA_VRGB:
+ os = pitch;
+ case XFT_RGBA_RGB:
+ default:
+ rf = 0;
+ gf = 1;
+ bf = 2;
+ break;
+ case XFT_RGBA_VBGR:
+ os = pitch;
+ case XFT_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;
+ }
+ }
+
+ XRenderAddGlyphs (dpy, font->glyphset, &g, gi, 1,
+ (char *) bufBitmapRgba, sizergba);
+ }
+ else
+ {
+ XRenderAddGlyphs (dpy, font->glyphset, &g, gi, 1,
+ (char *) bufBitmap, size);
+ }
+ }
+ if (bufBitmap != bufLocal)
+ free (bufBitmap);
+ if (bufBitmapRgba != bufLocalRgba)
+ free (bufBitmapRgba);
+}
+
+#define STEP 256
+
+/*
+ * Return whether the given glyph generates any image on the screen,
+ * this means it exists or a default glyph exists
+ */
+static Bool
+XftGlyphDrawable (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 glyph)
+{
+ if (font->charmap != -1)
+ {
+ FT_Set_Charmap (font->face, font->face->charmaps[font->charmap]);
+ glyph = (XftChar32) FT_Get_Char_Index (font->face, (FT_ULong) glyph);
+ }
+ return glyph <= font->face->num_glyphs;
+}
+
+void
+XftGlyphCheck (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 glyph,
+ XftChar32 *missing,
+ int *nmissing)
+{
+ XGlyphInfo **realized;
+ int nrealized;
+ int n;
+
+ if (glyph >= font->nrealized)
+ {
+ nrealized = glyph + STEP;
+
+ if (font->realized)
+ realized = (XGlyphInfo **) realloc ((void *) font->realized,
+ nrealized * sizeof (XGlyphInfo *));
+ else
+ realized = (XGlyphInfo **) malloc (nrealized * sizeof (XGlyphInfo *));
+ if (!realized)
+ return;
+ for (n = font->nrealized; n < nrealized; n++)
+ realized[n] = XftUntestedGlyph;
+
+ font->realized = realized;
+ font->nrealized = nrealized;
+ }
+ if (font->realized[glyph] == XftUntestedGlyph)
+ {
+ if (XftGlyphDrawable (dpy, font, glyph))
+ {
+ font->realized[glyph] = (XGlyphInfo *) malloc (sizeof (XGlyphInfo));
+ n = *nmissing;
+ missing[n++] = glyph;
+ if (n == XFT_NMISSING)
+ {
+ XftGlyphLoad (dpy, font, missing, n);
+ n = 0;
+ }
+ *nmissing = n;
+ }
+ else
+ font->realized[glyph] = 0;
+ }
+}
+
+Bool
+XftFreeTypeGlyphExists (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 glyph)
+{
+ if (font->charmap != -1)
+ {
+ FT_Set_Charmap (font->face, font->face->charmaps[font->charmap]);
+ glyph = (XftChar32) FT_Get_Char_Index (font->face, (FT_ULong) glyph);
+ }
+ return glyph && glyph <= font->face->num_glyphs;
+}
diff --git a/nx-X11/lib/Xft1/xftgram.y b/nx-X11/lib/Xft1/xftgram.y
new file mode 100644
index 000000000..04e231e7c
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftgram.y
@@ -0,0 +1,452 @@
+/*
+ * $XFree86: xc/lib/Xft/xftgram.y,v 1.5 2001/05/16 10:32:54 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"
+
+static XftMatrix matrix;
+
+%}
+
+%union {
+ int ival;
+ double dval;
+ char *sval;
+ XftExpr *eval;
+ XftPattern *pval;
+ XftValue vval;
+ XftEdit *Eval;
+ XftOp oval;
+ XftQual qval;
+ XftTest *tval;
+}
+
+%token <ival> INTEGER
+%token <dval> DOUBLE
+%token <sval> STRING NAME
+%token <ival> ANY ALL
+%token <ival> DIR CACHE INCLUDE INCLUDEIF MATCH EDIT
+%token <ival> TOK_TRUE TOK_FALSE TOK_NIL
+%token <ival> EQUAL SEMI OS CS
+
+%type <eval> expr
+%type <vval> value
+%type <sval> field
+%type <Eval> edit
+%type <Eval> edits
+%type <oval> eqop
+%type <qval> qual
+%type <oval> compare
+%type <tval> tests test
+%type <dval> number
+
+%right <ival> QUEST COLON
+%left <ival> OROR
+%left <ival> ANDAND
+%left <ival> EQEQ NOTEQ
+%left <ival> LESS LESSEQ MORE MOREEQ
+%left <ival> PLUS MINUS
+%left <ival> TIMES DIVIDE
+%right <ival> NOT
+
+%%
+configs : configs config
+ |
+ ;
+config : DIR STRING
+ { XftConfigAddDir ($2); }
+ | CACHE STRING
+ { XftConfigSetCache ($2); }
+ | INCLUDE STRING
+ { XftConfigPushInput ($2, True); }
+ | INCLUDEIF STRING
+ { XftConfigPushInput ($2, False); }
+ | MATCH tests EDIT edits
+ { XftConfigAddEdit ($2, $4); }
+ ;
+tests : test tests
+ { $1->next = $2; $$ = $1; }
+ |
+ { $$ = 0; }
+ ;
+test : qual field compare value
+ { $$ = XftTestCreate ($1, $2, $3, $4); }
+ ;
+qual : ANY
+ { $$ = XftQualAny; }
+ | ALL
+ { $$ = XftQualAll; }
+ |
+ { $$ = XftQualAny; }
+ ;
+field : NAME
+ {
+ $$ = XftConfigSaveField ($1);
+ }
+ ;
+compare : EQUAL
+ { $$ = XftOpEqual; }
+ | EQEQ
+ { $$ = XftOpEqual; }
+ | NOTEQ
+ { $$ = XftOpNotEqual; }
+ | LESS
+ { $$ = XftOpLess; }
+ | LESSEQ
+ { $$ = XftOpLessEqual; }
+ | MORE
+ { $$ = XftOpMore; }
+ | MOREEQ
+ { $$ = XftOpMoreEqual; }
+ ;
+value : INTEGER
+ {
+ $$.type = XftTypeInteger;
+ $$.u.i = $1;
+ }
+ | DOUBLE
+ {
+ $$.type = XftTypeDouble;
+ $$.u.d = $1;
+ }
+ | STRING
+ {
+ $$.type = XftTypeString;
+ $$.u.s = $1;
+ }
+ | TOK_TRUE
+ {
+ $$.type = XftTypeBool;
+ $$.u.b = True;
+ }
+ | TOK_FALSE
+ {
+ $$.type = XftTypeBool;
+ $$.u.b = False;
+ }
+ | TOK_NIL
+ {
+ $$.type = XftTypeVoid;
+ }
+ | matrix
+ {
+ $$.type = XftTypeMatrix;
+ $$.u.m = &matrix;
+ }
+ ;
+matrix : OS number number number number CS
+ {
+ matrix.xx = $2;
+ matrix.xy = $3;
+ matrix.yx = $4;
+ matrix.__REALLY_YY__ = $5;
+ }
+number : INTEGER
+ { $$ = (double) $1; }
+ | DOUBLE
+ ;
+edits : edit edits
+ { $1->next = $2; $$ = $1; }
+ |
+ { $$ = 0; }
+ ;
+edit : field eqop expr SEMI
+ { $$ = XftEditCreate ($1, $2, $3); }
+ ;
+eqop : EQUAL
+ { $$ = XftOpAssign; }
+ | PLUS EQUAL
+ { $$ = XftOpPrepend; }
+ | EQUAL PLUS
+ { $$ = XftOpAppend; }
+ ;
+expr : INTEGER
+ { $$ = XftExprCreateInteger ($1); }
+ | DOUBLE
+ { $$ = XftExprCreateDouble ($1); }
+ | STRING
+ { $$ = XftExprCreateString ($1); }
+ | TOK_TRUE
+ { $$ = XftExprCreateBool (True); }
+ | TOK_FALSE
+ { $$ = XftExprCreateBool (False); }
+ | TOK_NIL
+ { $$ = XftExprCreateNil (); }
+ | matrix
+ { $$ = XftExprCreateMatrix (&matrix); }
+ | NAME
+ { $$ = XftExprCreateField ($1); }
+ | expr OROR expr
+ { $$ = XftExprCreateOp ($1, XftOpOr, $3); }
+ | expr ANDAND expr
+ { $$ = XftExprCreateOp ($1, XftOpAnd, $3); }
+ | expr EQEQ expr
+ { $$ = XftExprCreateOp ($1, XftOpEqual, $3); }
+ | expr NOTEQ expr
+ { $$ = XftExprCreateOp ($1, XftOpNotEqual, $3); }
+ | expr LESS expr
+ { $$ = XftExprCreateOp ($1, XftOpLess, $3); }
+ | expr LESSEQ expr
+ { $$ = XftExprCreateOp ($1, XftOpLessEqual, $3); }
+ | expr MORE expr
+ { $$ = XftExprCreateOp ($1, XftOpMore, $3); }
+ | expr MOREEQ expr
+ { $$ = XftExprCreateOp ($1, XftOpMoreEqual, $3); }
+ | expr PLUS expr
+ { $$ = XftExprCreateOp ($1, XftOpPlus, $3); }
+ | expr MINUS expr
+ { $$ = XftExprCreateOp ($1, XftOpMinus, $3); }
+ | expr TIMES expr
+ { $$ = XftExprCreateOp ($1, XftOpTimes, $3); }
+ | expr DIVIDE expr
+ { $$ = XftExprCreateOp ($1, XftOpDivide, $3); }
+ | NOT expr
+ { $$ = XftExprCreateOp ($2, XftOpNot, (XftExpr *) 0); }
+ | expr QUEST expr COLON expr
+ { $$ = XftExprCreateOp ($1, XftOpQuest, XftExprCreateOp ($3, XftOpQuest, $5)); }
+ ;
+%%
+
+int
+XftConfigwrap (void)
+{
+ return 1;
+}
+
+void
+XftConfigerror (char *fmt, ...)
+{
+ va_list args;
+
+ fprintf (stderr, "\"%s\": line %d, ", XftConfigFile, XftConfigLineno);
+ va_start (args, fmt);
+ vfprintf (stderr, fmt, args);
+ va_end (args);
+ fprintf (stderr, "\n");
+}
+
+XftTest *
+XftTestCreate (XftQual qual, const char *field, XftOp compare, XftValue value)
+{
+ XftTest *test = (XftTest *) malloc (sizeof (XftTest));;
+
+ if (test)
+ {
+ test->next = 0;
+ test->qual = qual;
+ test->field = field; /* already saved in grammar */
+ test->op = compare;
+ if (value.type == XftTypeString)
+ value.u.s = _XftSaveString (value.u.s);
+ else if (value.type == XftTypeMatrix)
+ value.u.m = _XftSaveMatrix (value.u.m);
+ test->value = value;
+ }
+ return test;
+}
+
+XftExpr *
+XftExprCreateInteger (int i)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpInteger;
+ e->u.ival = i;
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateDouble (double d)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpDouble;
+ e->u.dval = d;
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateString (const char *s)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpString;
+ e->u.sval = _XftSaveString (s);
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateMatrix (const XftMatrix *m)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpMatrix;
+ e->u.mval = _XftSaveMatrix (m);
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateBool (Bool b)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpBool;
+ e->u.bval = b;
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateNil (void)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpNil;
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateField (const char *field)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = XftOpField;
+ e->u.field = _XftSaveString (field);
+ }
+ return e;
+}
+
+XftExpr *
+XftExprCreateOp (XftExpr *left, XftOp op, XftExpr *right)
+{
+ XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+ if (e)
+ {
+ e->op = op;
+ e->u.tree.left = left;
+ e->u.tree.right = right;
+ }
+ return e;
+}
+
+void
+XftExprDestroy (XftExpr *e)
+{
+ switch (e->op) {
+ case XftOpInteger:
+ break;
+ case XftOpDouble:
+ break;
+ case XftOpString:
+ free (e->u.sval);
+ break;
+ case XftOpMatrix:
+ free (e->u.mval);
+ break;
+ case XftOpBool:
+ break;
+ case XftOpField:
+ free (e->u.field);
+ break;
+ case XftOpAssign:
+ case XftOpPrepend:
+ case XftOpAppend:
+ break;
+ case XftOpOr:
+ case XftOpAnd:
+ case XftOpEqual:
+ case XftOpNotEqual:
+ case XftOpLess:
+ case XftOpLessEqual:
+ case XftOpMore:
+ case XftOpMoreEqual:
+ case XftOpPlus:
+ case XftOpMinus:
+ case XftOpTimes:
+ case XftOpDivide:
+ case XftOpQuest:
+ XftExprDestroy (e->u.tree.right);
+ /* fall through */
+ case XftOpNot:
+ XftExprDestroy (e->u.tree.left);
+ break;
+ case XftOpNil:
+ break;
+ }
+ free (e);
+}
+
+XftEdit *
+XftEditCreate (const char *field, XftOp op, XftExpr *expr)
+{
+ XftEdit *e = (XftEdit *) malloc (sizeof (XftEdit));
+
+ if (e)
+ {
+ e->next = 0;
+ e->field = field; /* already saved in grammar */
+ e->op = op;
+ e->expr = expr;
+ }
+ return e;
+}
+
+void
+XftEditDestroy (XftEdit *e)
+{
+ if (e->next)
+ XftEditDestroy (e->next);
+ free ((void *) e->field);
+ if (e->expr)
+ XftExprDestroy (e->expr);
+}
+
+char *
+XftConfigSaveField (const char *field)
+{
+ return _XftSaveString (field);
+}
diff --git a/nx-X11/lib/Xft1/xftinit.c b/nx-X11/lib/Xft1/xftinit.c
new file mode 100644
index 000000000..79e589160
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftinit.c
@@ -0,0 +1,42 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftinit.c,v 1.3 2002/03/01 20:33:33 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"
+
+XftFontSet *_XftFontSet;
+Bool _XftConfigInitialized;
+static char *nodirs[] = { 0 };
+char **XftConfigDirs = nodirs;
+
+Bool
+XftInit (char *config)
+{
+ if (_XftConfigInitialized)
+ return True;
+ if (!FcInit ())
+ return False;
+ _XftConfigInitialized = True;
+ return True;
+}
diff --git a/nx-X11/lib/Xft1/xftint.h b/nx-X11/lib/Xft1/xftint.h
new file mode 100644
index 000000000..c73fb1723
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftint.h
@@ -0,0 +1,508 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftint.h,v 1.2 2002/03/01 01:00:53 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 _XFTINT_H_
+#define _XFTINT_H_
+
+#include <X11/Xlib.h>
+#include <fontconfig/fontconfig.h>
+#ifdef FREETYPE2
+#include "XftFreetype.h"
+#else
+#include "Xft.h"
+#endif
+
+typedef struct _XftMatcher {
+ char *object;
+ double (*compare) (char *object, XftValue value1, XftValue value2);
+} XftMatcher;
+
+typedef struct _XftSymbolic {
+ const char *name;
+ int value;
+} XftSymbolic;
+
+#define XFT_DRAW_N_SRC 2
+
+#define XFT_DRAW_SRC_TEXT 0
+#define XFT_DRAW_SRC_RECT 1
+
+struct _XftDraw {
+ Display *dpy;
+ Drawable drawable;
+ Visual *visual; /* NULL for bitmaps */
+ Colormap colormap;
+ Region clip;
+ Bool core_set;
+ Bool render_set;
+ Bool render_able;
+ struct {
+ Picture pict;
+ struct {
+ Picture pict;
+ XRenderColor color;
+ } src[XFT_DRAW_N_SRC];
+ } render;
+ struct {
+ GC draw_gc;
+ unsigned long fg;
+ Font font;
+ } core;
+};
+
+typedef struct _XftDisplayInfo {
+ struct _XftDisplayInfo *next;
+ Display *display;
+ XExtCodes *codes;
+ XftPattern *defaults;
+ XftFontSet *coreFonts;
+ Bool hasRender;
+ struct _XftFtGlyphSet *glyphSets;
+} XftDisplayInfo;
+
+extern XftFontSet *_XftGlobalFontSet;
+extern XftDisplayInfo *_XftDisplayInfo;
+extern char **XftConfigDirs;
+extern XftFontSet *_XftFontSet;
+
+typedef struct _FcPatternElt FcPatternElt;
+
+/*
+ * Yes, these are stolen from fcint.h
+ */
+FcPatternElt *
+FcPatternFindElt (const FcPattern *p, const char *object);
+
+FcPatternElt *
+FcPatternInsertElt (FcPattern *p, const char *object);
+
+typedef FcPatternElt XftPatternElt;
+
+#define XFT_NMISSING 256
+
+#ifndef XFT_DEFAULT_PATH
+#define XFT_DEFAULT_PATH "/usr/X11R6/lib/X11/XftConfig"
+#endif
+
+#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_MATCH 512
+#define XFT_DBG_MATCHV 1024
+#define XFT_DBG_EDIT 2048
+
+typedef enum _XftOp {
+ XftOpInteger, XftOpDouble, XftOpString, XftOpMatrix, XftOpBool, XftOpNil,
+ XftOpField,
+ XftOpAssign, XftOpPrepend, XftOpAppend,
+ XftOpQuest,
+ XftOpOr, XftOpAnd, XftOpEqual, XftOpNotEqual,
+ XftOpLess, XftOpLessEqual, XftOpMore, XftOpMoreEqual,
+ XftOpPlus, XftOpMinus, XftOpTimes, XftOpDivide,
+ XftOpNot
+} XftOp;
+
+typedef struct _XftExpr {
+ XftOp op;
+ union {
+ int ival;
+ double dval;
+ char *sval;
+ XftMatrix *mval;
+ Bool bval;
+ char *field;
+ struct {
+ struct _XftExpr *left, *right;
+ } tree;
+ } u;
+} XftExpr;
+
+typedef enum _XftQual {
+ XftQualAny, XftQualAll
+} XftQual;
+
+typedef struct _XftTest {
+ struct _XftTest *next;
+ XftQual qual;
+ const char *field;
+ XftOp op;
+ XftValue value;
+} XftTest;
+
+typedef struct _XftEdit {
+ struct _XftEdit *next;
+ const char *field;
+ XftOp op;
+ XftExpr *expr;
+} XftEdit;
+
+typedef struct _XftSubst {
+ struct _XftSubst *next;
+ XftTest *test;
+ XftEdit *edit;
+} XftSubst;
+
+/*
+ * I tried this with functions that took va_list* arguments
+ * but portability concerns made me change these functions
+ * into macros (sigh).
+ */
+
+#define _XftPatternVapBuild(result, orig, va) \
+{ \
+ XftPattern *__p__ = (orig); \
+ const char *__o__; \
+ XftValue __v__; \
+ \
+ if (!__p__) \
+ { \
+ __p__ = XftPatternCreate (); \
+ if (!__p__) \
+ goto _XftPatternVapBuild_bail0; \
+ } \
+ for (;;) \
+ { \
+ __o__ = va_arg (va, const char *); \
+ if (!__o__) \
+ break; \
+ __v__.type = va_arg (va, XftType); \
+ switch (__v__.type) { \
+ case XftTypeVoid: \
+ goto _XftPatternVapBuild_bail1; \
+ case XftTypeInteger: \
+ __v__.u.i = va_arg (va, int); \
+ break; \
+ case XftTypeDouble: \
+ __v__.u.d = va_arg (va, double); \
+ break; \
+ case XftTypeString: \
+ __v__.u.s = va_arg (va, char *); \
+ break; \
+ case XftTypeBool: \
+ __v__.u.b = va_arg (va, Bool); \
+ break; \
+ case XftTypeMatrix: \
+ __v__.u.m = va_arg (va, XftMatrix *); \
+ break; \
+ } \
+ if (!XftPatternAdd (__p__, __o__, __v__, True)) \
+ goto _XftPatternVapBuild_bail1; \
+ } \
+ result = __p__; \
+ goto _XftPatternVapBuild_return; \
+ \
+_XftPatternVapBuild_bail1: \
+ if (!orig) \
+ XftPatternDestroy (__p__); \
+_XftPatternVapBuild_bail0: \
+ result = 0; \
+ \
+_XftPatternVapBuild_return: \
+ ; \
+}
+
+
+/* xftcache.c */
+
+char *
+XftFileCacheFind (char *file, int id, int *count);
+
+void
+XftFileCacheDispose (void);
+
+void
+XftFileCacheLoad (char *cache);
+
+Bool
+XftFileCacheUpdate (char *file, int id, char *name);
+
+Bool
+XftFileCacheSave (char *cache);
+
+Bool
+XftFileCacheReadDir (XftFontSet *set, const char *cache_file);
+
+Bool
+XftFileCacheWriteDir (XftFontSet *set, const char *cache_file);
+
+/* xftcfg.c */
+Bool
+XftConfigAddDir (char *d);
+
+Bool
+XftConfigSetCache (char *c);
+
+char *
+XftConfigGetCache (void);
+
+Bool
+XftConfigAddEdit (XftTest *test, XftEdit *edit);
+
+Bool
+_XftConfigCompareValue (XftValue m,
+ XftOp op,
+ XftValue v);
+
+/* xftcore.c */
+
+#define XFT_CORE_N16LOCAL 256
+
+XChar2b *
+XftCoreConvert16 (XftChar16 *string,
+ int len,
+ XChar2b xcloc[XFT_CORE_N16LOCAL]);
+
+XChar2b *
+XftCoreConvert32 (XftChar32 *string,
+ int len,
+ XChar2b xcloc[XFT_CORE_N16LOCAL]);
+
+XChar2b *
+XftCoreConvertUtf8 (XftChar8 *string,
+ int len,
+ XChar2b xcloc[XFT_CORE_N16LOCAL],
+ int *nchar);
+
+void
+XftCoreExtents8 (Display *dpy,
+ XFontStruct *fs,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftCoreExtents16 (Display *dpy,
+ XFontStruct *fs,
+ XftChar16 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftCoreExtents32 (Display *dpy,
+ XFontStruct *fs,
+ XftChar32 *string,
+ int len,
+ XGlyphInfo *extents);
+
+void
+XftCoreExtentsUtf8 (Display *dpy,
+ XFontStruct *fs,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents);
+
+Bool
+XftCoreGlyphExists (Display *dpy,
+ XFontStruct *fs,
+ XftChar32 glyph);
+
+/* xftdbg.c */
+void
+XftOpPrint (XftOp op);
+
+void
+XftTestPrint (XftTest *test);
+
+void
+XftExprPrint (XftExpr *expr);
+
+void
+XftEditPrint (XftEdit *edit);
+
+void
+XftSubstPrint (XftSubst *subst);
+
+/* xftdpy.c */
+XftDisplayInfo *
+_XftDisplayInfoGet (Display *dpy);
+
+int
+XftDefaultParseBool (char *v);
+
+Bool
+XftDefaultGetBool (Display *dpy, const char *object, int screen, Bool def);
+
+int
+XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def);
+
+double
+XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def);
+
+XftFontSet *
+XftDisplayGetFontSet (Display *dpy);
+
+/* xftdraw.c */
+Bool
+XftDrawRenderPrepare (XftDraw *draw,
+ XftColor *color,
+ XftFont *font,
+ int src);
+
+Bool
+XftDrawCorePrepare (XftDraw *draw,
+ XftColor *color,
+ XftFont *font);
+
+/* xftextent.c */
+/* xftfont.c */
+int
+_XftFontDebug (void);
+
+/* xftfs.c */
+/* xftgram.y */
+int
+XftConfigparse (void);
+
+int
+XftConfigwrap (void);
+
+void
+XftConfigerror (char *fmt, ...);
+
+char *
+XftConfigSaveField (const char *field);
+
+XftTest *
+XftTestCreate (XftQual qual, const char *field, XftOp compare, XftValue value);
+
+XftExpr *
+XftExprCreateInteger (int i);
+
+XftExpr *
+XftExprCreateDouble (double d);
+
+XftExpr *
+XftExprCreateString (const char *s);
+
+XftExpr *
+XftExprCreateMatrix (const XftMatrix *m);
+
+XftExpr *
+XftExprCreateBool (Bool b);
+
+XftExpr *
+XftExprCreateNil (void);
+
+XftExpr *
+XftExprCreateField (const char *field);
+
+XftExpr *
+XftExprCreateOp (XftExpr *left, XftOp op, XftExpr *right);
+
+void
+XftExprDestroy (XftExpr *e);
+
+XftEdit *
+XftEditCreate (const char *field, XftOp op, XftExpr *expr);
+
+void
+XftEditDestroy (XftEdit *e);
+
+/* xftinit.c */
+
+/* xftlex.l */
+extern int XftConfigLineno;
+extern char *XftConfigFile;
+
+int
+XftConfiglex (void);
+
+Bool
+XftConfigLexFile(char *s);
+
+Bool
+XftConfigPushInput (char *s, Bool complain);
+
+/* xftlist.c */
+Bool
+XftListValueCompare (XftValue v1,
+ XftValue v2);
+
+Bool
+XftListMatch (XftPattern *p,
+ XftPattern *font,
+ XftQual qual);
+
+Bool
+XftListAppend (XftFontSet *s,
+ XftPattern *font,
+ XftObjectSet *os);
+
+
+/* xftmatch.c */
+
+/* xftname.c */
+Bool
+XftNameConstant (char *string, int *result);
+
+/* xftpat.c */
+
+extern FcPatternElt *
+FcPatternFind (FcPattern *p, const char *object, FcBool insert);
+
+XftPatternElt *
+XftPatternFind (XftPattern *p, const char *object, FcBool insert);
+
+/* xftrender.c */
+
+/* xftmatrix.c */
+XftMatrix *
+_XftSaveMatrix (const XftMatrix *mat);
+
+/* xftstr.c */
+char *
+_XftSaveString (const char *s);
+
+const char *
+_XftGetInt(const char *ptr, int *val);
+
+char *
+_XftSplitStr (const char *field, char *save);
+
+char *
+_XftDownStr (const char *field, char *save);
+
+const char *
+_XftSplitField (const char *field, char *save);
+
+const char *
+_XftSplitValue (const char *field, char *save);
+
+int
+_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def);
+
+int
+_XftStrCmpIgnoreCase (const char *s1, const char *s2);
+
+/* xftxlfd.c */
+Bool
+XftCoreAddFonts (XftFontSet *set, Display *dpy, Bool ignore_scalable);
+
+#endif /* _XFT_INT_H_ */
diff --git a/nx-X11/lib/Xft1/xftlex.l b/nx-X11/lib/Xft1/xftlex.l
new file mode 100644
index 000000000..3eff3f429
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftlex.l
@@ -0,0 +1,275 @@
+%{
+/*
+ * $XFree86: xc/lib/Xft/xftlex.l,v 1.7 2001/05/18 16:03:06 tsi Exp $
+ *
+ * Copyright (c) 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 "xftint.h"
+
+#include "xftgram.h"
+
+int XftConfigLineno;
+
+static void _XftConfigSkipComment (void);
+
+static void _XftConfigSkipLine (void);
+
+static int _XftConfigPopInput (void);
+
+
+#define XFT_CONFIG_IN_DEEP 20
+FILE *XftConfigInStack[XFT_CONFIG_IN_DEEP];
+FILE **XftConfigInpt = XftConfigInStack + XFT_CONFIG_IN_DEEP;
+FILE *XftConfigInput;
+int XftConfigLinenos[XFT_CONFIG_IN_DEEP];
+int *XftConfigLinenopt = XftConfigLinenos + XFT_CONFIG_IN_DEEP;
+char *XftConfigFile = "";
+char *XftConfigFileNames[XFT_CONFIG_IN_DEEP];
+char **XftConfigFileNamePt = XftConfigFileNames + XFT_CONFIG_IN_DEEP;
+int XftConfigFiledeep = 0;
+
+#undef YY_INPUT
+
+#define YY_INPUT(buf,result,max_size) \
+{ \
+ int c; \
+ result = 0; \
+ while (result < max_size) { \
+ c = getc (XftConfigInput); \
+ if (c < 0) { \
+ c = _XftConfigPopInput (); \
+ if (c < 0) \
+ break; \
+ } \
+ buf[result++] = c; \
+ if (c == '\n') \
+ { \
+ XftConfigLineno++; \
+ break; \
+ } \
+ } \
+}
+
+#ifndef FLEX_SCANNER
+#undef input
+#undef unput
+static int input (void)
+{
+ char buf[1];
+ static int r = EOF;
+
+ if (r == 0)
+ return 0;
+ YY_INPUT(buf, r, 1);
+ if (r == 0)
+ return EOF;
+ return buf[0];
+}
+
+static void unput (char c)
+{
+ if (!c || c == EOF)
+ return;
+ if (c == '\n')
+ XftConfigLineno--;
+ ungetc (c, XftConfigInput);
+}
+#endif
+
+%}
+%%
+"/\052" _XftConfigSkipComment();
+^# _XftConfigSkipLine();
+dir return DIR;
+cache return CACHE;
+include return INCLUDE;
+includeif return INCLUDEIF;
+match return MATCH;
+edit return EDIT;
+true return TOK_TRUE;
+false return TOK_FALSE;
+nil return TOK_NIL;
+any return ANY;
+all return ALL;
+"=" return EQUAL;
+":" return COLON;
+";" return SEMI;
+"+" return PLUS;
+"-" return MINUS;
+"*" return TIMES;
+"/" return DIVIDE;
+"!" return NOT;
+"&&" return ANDAND;
+"||" return OROR;
+"<" return LESS;
+"<=" return LESSEQ;
+"==" return EQEQ;
+">=" return MOREEQ;
+">" return MORE;
+"!=" return NOTEQ;
+"?" return QUEST;
+"[" return OS;
+"]" return CS;
+\"([^\n\"]|\\\")*\" {
+ yytext[yyleng - 1] = '\0';
+ yylval.sval = yytext+1;
+ return STRING;
+ }
+[0-9]+ {
+ yylval.ival = strtol (yytext, 0, 10);
+ return INTEGER;
+ }
+(([0-9]+((\.[0-9]*(\{[0-9]+\})?)?))|(\.[0-9]+)|(\.[0-9]*\{[0-9]+\}))(([Ee][-+]?[0-9]+)?) {
+ yylval.dval = strtod (yytext, 0);
+ return DOUBLE;
+ }
+[a-zA-Z][0-9a-zA-Z_]* {
+ if (XftNameConstant (yytext, &yylval.ival))
+ return INTEGER;
+ yylval.sval = yytext;
+ return NAME;
+ }
+. ;
+"\n" ;
+%%
+static void
+_XftConfigSkipComment (void)
+{
+ int c;
+
+ c = input();
+ for (;;) {
+ while (c != EOF && c != '*')
+ c = input();
+ if (c == EOF)
+ return;
+ c = input();
+ if (c == EOF || c == '/')
+ return;
+ }
+}
+
+static void
+_XftConfigSkipLine (void)
+{
+ int c;
+
+ do {
+ c = input();
+ } while (c != EOF && c != '\n');
+ if (c == '\n') unput('\n');
+}
+
+Bool
+XftConfigLexFile(char *s)
+{
+ FILE *f;
+
+ f = fopen (s, "r");
+ if (f == 0)
+ {
+ fprintf (stderr, "cannot open file \"%s\"\n", s);
+ return False;
+ }
+ ++XftConfigFiledeep;
+ XftConfigInput = f;
+ XftConfigFile = s;
+ return True;
+}
+
+Bool
+XftConfigPushInput (char *s, Bool complain)
+{
+ FILE *f;
+ char *t;
+ char *h;
+
+ if (XftConfigInpt == XftConfigInStack)
+ {
+ (void) fprintf (stderr, "files nested too deeply\n");
+ return False;
+ }
+ t = s;
+ if (*s == '~')
+ {
+ h = getenv ("HOME");
+ if (h)
+ {
+ t = (char *) malloc (strlen (h) + strlen (s));
+ if (t)
+ {
+ strcpy (t, h);
+ strcat (t, s+1);
+ }
+ else
+ t = s;
+ }
+ }
+ f = fopen (t, "r");
+ if (t != s)
+ free (t);
+ if (f == 0)
+ {
+ if (complain)
+ (void) fprintf (stderr, "cannot open file %s\n", s);
+ return False;
+ }
+ ++XftConfigFiledeep;
+ *--XftConfigInpt = XftConfigInput;
+ *--XftConfigLinenopt = XftConfigLineno;
+ *--XftConfigFileNamePt = XftConfigFile;
+ XftConfigInput = f;
+ XftConfigLineno = 1;
+ XftConfigFile = _XftSaveString (s);
+ return True;
+}
+
+static int
+_XftConfigPopInput (void)
+{
+ int c;
+
+ for (;;)
+ {
+ c = getc (XftConfigInput);
+ if (c >= 0)
+ return c;
+ fclose (XftConfigInput);
+ XftConfigInput = 0;
+ if (XftConfigInpt == XftConfigInStack + XFT_CONFIG_IN_DEEP)
+ return EOF;
+ XftConfigInput = *XftConfigInpt++;
+ XftConfigLineno = *XftConfigLinenopt++;
+ free (XftConfigFile);
+ XftConfigFile = *XftConfigFileNamePt++;
+ --XftConfigFiledeep;
+ }
+}
+
+void
+XftConfigLexDone (void)
+{
+#ifdef FLEX_SCANNER
+ XftConfig_delete_buffer (XftConfig_current_buffer);
+#endif
+}
diff --git a/nx-X11/lib/Xft1/xftlist.c b/nx-X11/lib/Xft1/xftlist.c
new file mode 100644
index 000000000..dca5c42d1
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftlist.c
@@ -0,0 +1,166 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftlist.c,v 1.3 2002/06/21 06:15:14 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"
+#include <fontconfig/fcprivate.h>
+
+XftObjectSet *
+XftObjectSetCreate (void)
+{
+ return FcObjectSetCreate ();
+}
+
+Bool
+XftObjectSetAdd (XftObjectSet *os, const char *object)
+{
+ return FcObjectSetAdd (os, object);
+}
+
+void
+XftObjectSetDestroy (XftObjectSet *os)
+{
+ FcObjectSetDestroy (os);
+}
+
+
+XftObjectSet *
+XftObjectSetVaBuild (const char *first, va_list va)
+{
+ XftObjectSet *ret;
+
+ FcObjectSetVapBuild (ret, first, va);
+ return ret;
+}
+
+XftObjectSet *
+XftObjectSetBuild (const char *first, ...)
+{
+ va_list va;
+ XftObjectSet *os;
+
+ va_start (va, first);
+ FcObjectSetVapBuild (os, first, va);
+ va_end (va);
+ return os;
+}
+
+XftFontSet *
+XftListFontSets (XftFontSet **sets,
+ int nsets,
+ XftPattern *p,
+ XftObjectSet *os)
+{
+ return FcFontSetList (0, sets, nsets, p, os);
+}
+
+XftFontSet *
+XftListFontsPatternObjects (Display *dpy,
+ int screen,
+ XftPattern *pattern,
+ XftObjectSet *os)
+{
+ XftFontSet *sets[2];
+ int nsets = 0;
+#ifdef FREETYPE2
+ Bool core, render;
+ XftResult result;
+#endif
+ XftPattern *pattern_trim;
+ XftFontSet *ret;
+
+ if (!XftInit (0))
+ return 0;
+
+ pattern_trim = XftPatternDuplicate (pattern);
+ if (!pattern_trim)
+ return 0;
+
+ XftPatternDel (pattern_trim, XFT_CORE);
+ XftPatternDel (pattern_trim, XFT_RENDER);
+#ifdef FREETYPE2
+ render = core = False;
+ result = XftPatternGetBool (pattern, XFT_CORE, 0, &core);
+ if (result != XftResultMatch)
+ core = XftDefaultGetBool (dpy, XFT_CORE, screen,
+ !XftDefaultHasRender (dpy));
+
+ result = XftPatternGetBool (pattern, XFT_RENDER, 0, &render);
+ if (result != XftResultMatch)
+ render = XftDefaultGetBool (dpy, XFT_RENDER, screen,
+ XftDefaultHasRender (dpy));
+ if (render)
+ {
+ /*
+ * fontconfig fonts never include encoding values.
+ * deleting it is something of a kludge as it eliminates the
+ * ability to list core fonts and render fonts of a specific
+ * encoding. Fortunately, Xft1 apps generally don't want core
+ * fonts in any case.
+ */
+ XftPatternDel (pattern_trim, XFT_ENCODING);
+ if (XftInitFtLibrary())
+ {
+ sets[nsets] = _XftFontSet;
+ if (sets[nsets])
+ nsets++;
+ }
+ }
+ if (core)
+#endif
+ {
+ sets[nsets] = XftDisplayGetFontSet (dpy);
+ if (sets[nsets])
+ nsets++;
+ }
+ ret = XftListFontSets (sets, nsets, pattern_trim, os);
+ XftPatternDestroy (pattern_trim);
+ return ret;
+}
+
+XftFontSet *
+XftListFonts (Display *dpy,
+ int screen,
+ ...)
+{
+ va_list va;
+ XftFontSet *fs;
+ XftObjectSet *os;
+ XftPattern *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);
+ XftPatternDestroy (pattern);
+ XftObjectSetDestroy (os);
+ return fs;
+}
diff --git a/nx-X11/lib/Xft1/xftmatch.c b/nx-X11/lib/Xft1/xftmatch.c
new file mode 100644
index 000000000..f764abb9a
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftmatch.c
@@ -0,0 +1,37 @@
+/*
+ * $XFree86: xc/lib/Xft/xftmatch.c,v 1.6 2001/09/21 19:54:53 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 "xftint.h"
+#include <stdio.h>
+
+XftPattern *
+XftFontSetMatch (XftFontSet **sets,
+ int nsets,
+ XftPattern *p,
+ XftResult *result)
+{
+ return FcFontSetMatch (0, sets, nsets, p, result);
+}
diff --git a/nx-X11/lib/Xft1/xftmatrix.c b/nx-X11/lib/Xft1/xftmatrix.c
new file mode 100644
index 000000000..7feeccc94
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftmatrix.c
@@ -0,0 +1,104 @@
+/*
+ * $XFree86: xc/lib/Xft/xftmatrix.c,v 1.1 2001/03/30 18:50:18 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 "xftint.h"
+
+XftMatrix *
+_XftSaveMatrix (const XftMatrix *mat)
+{
+ XftMatrix *r;
+ if(!mat)
+ return 0;
+ r = (XftMatrix *) malloc (sizeof (*r) );
+ if (!r)
+ return 0;
+ *r = *mat;
+ return r;
+}
+
+int
+XftMatrixEqual (const XftMatrix *mat1, const XftMatrix *mat2)
+{
+ if(mat1 == mat2) return True;
+ if(mat1 == 0 || mat2 == 0) return False;
+ return mat1->xx == mat2->xx &&
+ mat1->xy == mat2->xy &&
+ mat1->yx == mat2->yx &&
+ mat1->yy == mat2->yy;
+}
+
+void
+XftMatrixMultiply (XftMatrix *result, XftMatrix *a, XftMatrix *b)
+{
+ XftMatrix 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
+XftMatrixRotate (XftMatrix *m, double c, double s)
+{
+ XftMatrix r;
+
+ /*
+ * X Coordinate system is upside down, swap to make
+ * rotations counterclockwise
+ */
+ r.xx = c;
+ r.xy = -s;
+ r.yx = s;
+ r.yy = c;
+ XftMatrixMultiply (m, &r, m);
+}
+
+void
+XftMatrixScale (XftMatrix *m, double sx, double sy)
+{
+ XftMatrix r;
+
+ r.xx = sx;
+ r.xy = 0;
+ r.yx = 0;
+ r.yy = sy;
+ XftMatrixMultiply (m, &r, m);
+}
+
+void
+XftMatrixShear (XftMatrix *m, double sh, double sv)
+{
+ XftMatrix r;
+
+ r.xx = 1;
+ r.xy = sh;
+ r.yx = sv;
+ r.yy = 1;
+ XftMatrixMultiply (m, &r, m);
+}
diff --git a/nx-X11/lib/Xft1/xftname.c b/nx-X11/lib/Xft1/xftname.c
new file mode 100644
index 000000000..a28e32cd9
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftname.c
@@ -0,0 +1,59 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftname.c,v 1.3tsi 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"
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+XftPattern *
+XftNameParse (const char *name)
+{
+ return FcNameParse ((const FcChar8 *) name);
+}
+
+
+Bool
+XftNameUnparse (XftPattern *pat, char *dest, int len)
+{
+ FcChar8 *name = FcNameUnparse (pat);
+ if (!name)
+ return FcFalse;
+ if (strlen ((char *) name) > len - 1)
+ {
+ free (name);
+ return FcFalse;
+ }
+ strcpy (dest, (char *) name);
+ free (name);
+ return FcTrue;
+}
+
+Bool
+XftNameConstant (char *string, int *result)
+{
+ return FcNameConstant ((FcChar8 *) string, result);
+}
+
diff --git a/nx-X11/lib/Xft1/xftpat.c b/nx-X11/lib/Xft1/xftpat.c
new file mode 100644
index 000000000..611144c2d
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftpat.c
@@ -0,0 +1,243 @@
+/*
+ * $XFree86: xc/lib/Xft/xftpat.c,v 1.6 2001/03/30 18:50:18 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"
+#include <fontconfig/fcprivate.h>
+
+XftPattern *
+XftPatternCreate (void)
+{
+ return FcPatternCreate ();
+}
+
+void
+XftValueDestroy (XftValue v)
+{
+ FcValueDestroy (v);
+}
+
+void
+XftPatternDestroy (XftPattern *p)
+{
+ FcPatternDestroy (p);
+}
+
+
+Bool
+XftPatternAdd (XftPattern *p, const char *object, XftValue value, Bool append)
+{
+ return FcPatternAdd (p, object, value, append);
+}
+
+Bool
+XftPatternDel (XftPattern *p, const char *object)
+{
+ return FcPatternDel (p, object);
+}
+
+Bool
+XftPatternAddInteger (XftPattern *p, const char *object, int i)
+{
+ XftValue v;
+
+ v.type = XftTypeInteger;
+ v.u.i = i;
+ return XftPatternAdd (p, object, v, True);
+}
+
+Bool
+XftPatternAddDouble (XftPattern *p, const char *object, double d)
+{
+ XftValue v;
+
+ v.type = XftTypeDouble;
+ v.u.d = d;
+ return XftPatternAdd (p, object, v, True);
+}
+
+
+Bool
+XftPatternAddString (XftPattern *p, const char *object, const char *s)
+{
+ XftValue v;
+
+ v.type = XftTypeString;
+ v.u.s = (FcChar8 *) s;
+ return XftPatternAdd (p, object, v, True);
+}
+
+Bool
+XftPatternAddMatrix (XftPattern *p, const char *object, const XftMatrix *s)
+{
+ XftValue v;
+
+ v.type = XftTypeMatrix;
+ v.u.m = (XftMatrix *) s;
+ return XftPatternAdd (p, object, v, True);
+}
+
+
+Bool
+XftPatternAddBool (XftPattern *p, const char *object, Bool b)
+{
+ XftValue v;
+
+ v.type = XftTypeBool;
+ v.u.b = b;
+ return XftPatternAdd (p, object, v, True);
+}
+
+XftResult
+XftPatternGet (XftPattern *p, const char *object, int id, XftValue *v)
+{
+ return FcPatternGet (p, object, id, v);
+}
+
+XftResult
+XftPatternGetInteger (XftPattern *p, const char *object, int id, int *i)
+{
+ XftValue v;
+ XftResult r;
+
+ r = XftPatternGet (p, object, id, &v);
+ if (r != XftResultMatch)
+ return r;
+ switch (v.type) {
+ case XftTypeDouble:
+ *i = (int) v.u.d;
+ break;
+ case XftTypeInteger:
+ *i = v.u.i;
+ break;
+ default:
+ return XftResultTypeMismatch;
+ }
+ return XftResultMatch;
+}
+
+XftResult
+XftPatternGetDouble (XftPattern *p, const char *object, int id, double *d)
+{
+ XftValue v;
+ XftResult r;
+
+ r = XftPatternGet (p, object, id, &v);
+ if (r != XftResultMatch)
+ return r;
+ switch (v.type) {
+ case XftTypeDouble:
+ *d = v.u.d;
+ break;
+ case XftTypeInteger:
+ *d = (double) v.u.i;
+ break;
+ default:
+ return XftResultTypeMismatch;
+ }
+ return XftResultMatch;
+}
+
+XftResult
+XftPatternGetString (XftPattern *p, const char *object, int id, char **s)
+{
+ XftValue v;
+ XftResult r;
+
+ r = XftPatternGet (p, object, id, &v);
+ if (r != XftResultMatch)
+ return r;
+ if (v.type != XftTypeString)
+ return XftResultTypeMismatch;
+ *s = (char *) v.u.s;
+ return XftResultMatch;
+}
+
+XftResult
+XftPatternGetMatrix (XftPattern *p, const char *object, int id, XftMatrix **m)
+{
+ XftValue v;
+ XftResult r;
+
+ r = XftPatternGet (p, object, id, &v);
+ if (r != XftResultMatch)
+ return r;
+ if (v.type != XftTypeMatrix)
+ return XftResultTypeMismatch;
+ *m = (XftMatrix *) v.u.m;
+ return XftResultMatch;
+}
+
+
+XftResult
+XftPatternGetBool (XftPattern *p, const char *object, int id, Bool *b)
+{
+ XftValue v;
+ XftResult r;
+
+ r = XftPatternGet (p, object, id, &v);
+ if (r != XftResultMatch)
+ return r;
+ if (v.type != XftTypeBool)
+ return XftResultTypeMismatch;
+ *b = v.u.b;
+ return XftResultMatch;
+}
+
+XftPatternElt *
+XftPatternFind (XftPattern *p, const char *object, FcBool insert)
+{
+ if (insert)
+ return FcPatternInsertElt (p, object);
+ else
+ return FcPatternFindElt (p, object);
+}
+
+
+XftPattern *
+XftPatternDuplicate (XftPattern *orig)
+{
+ return FcPatternDuplicate (orig);
+}
+
+XftPattern *
+XftPatternVaBuild (XftPattern *orig, va_list va)
+{
+ XftPattern *ret;
+
+ FcPatternVapBuild (ret, orig, va);
+ return ret;
+}
+
+XftPattern *
+XftPatternBuild (XftPattern *orig, ...)
+{
+ va_list va;
+
+ va_start (va, orig);
+ FcPatternVapBuild (orig, orig, va);
+ va_end (va);
+ return orig;
+}
diff --git a/nx-X11/lib/Xft1/xftrender.c b/nx-X11/lib/Xft1/xftrender.c
new file mode 100644
index 000000000..419ae9f8a
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftrender.c
@@ -0,0 +1,527 @@
+/*
+ * $XFree86: xc/lib/Xft/xftrender.c,v 1.8 2001/07/13 18:16: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 "xftint.h"
+
+void
+XftRenderString8 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar8 *string, int len)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar8 *s;
+ int l;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l--)
+ XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+ XRenderCompositeString8 (dpy, PictOpOver, src, dst,
+ font->format, font->glyphset,
+ srcx, srcy, x, y, (char *) string, len);
+}
+
+void
+XftRenderString16 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar16 *string, int len)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar16 *s;
+ int l;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l--)
+ XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+ XRenderCompositeString16 (dpy, PictOpOver, src, dst,
+ font->format, font->glyphset,
+ srcx, srcy, x, y, string, len);
+}
+
+void
+XftRenderString32 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar32 *string, int len)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar32 *s;
+ int l;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l--)
+ XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+ XRenderCompositeString32 (dpy, PictOpOver, src, dst,
+ font->format, font->glyphset,
+ srcx, srcy, x, y, string, len);
+}
+
+void
+XftRenderStringUtf8 (Display *dpy, Picture src,
+ XftFontStruct *font, Picture dst,
+ int srcx, int srcy,
+ int x, int y,
+ XftChar8 *string, int len)
+{
+ XftChar8 *s;
+ XftChar32 c;
+ XftChar32 lbuf[4096];
+ XftChar32 *d;
+ XftChar8 *dst8;
+ XftChar16 *dst16;
+ XftChar32 *dst32;
+ int rlen, clen;
+ int width = 1;
+ int n;
+
+ /* compute needed width */
+ if (!XftUtf8Len (string, len, &n, &width))
+ return;
+
+ d = lbuf;
+ if (n * width > sizeof (lbuf))
+ {
+ d = (XftChar32 *) malloc (n * width);
+ if (!d)
+ return;
+ }
+
+ switch (width) {
+ case 4:
+ s = string;
+ rlen = len;
+ dst32 = d;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (s, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ return;
+ *dst32++ = c;
+ s += clen;
+ rlen -= clen;
+ }
+ dst32 = d;
+ XftRenderString32 (dpy, src, font, dst, srcx, srcy, x, y,
+ dst32, n);
+ break;
+ case 2:
+ s = string;
+ rlen = len;
+ dst16 = (XftChar16 *) d;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (s, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ return;
+ *dst16++ = c;
+ s += clen;
+ rlen -= clen;
+ }
+ dst16 = (XftChar16 *) d;
+ XftRenderString16 (dpy, src, font, dst, srcx, srcy, x, y,
+ dst16, n);
+ break;
+ case 1:
+ s = string;
+ rlen = len;
+ dst8 = (XftChar8 *) d;
+ while (rlen)
+ {
+ clen = XftUtf8ToUcs4 (s, &c, rlen);
+ if (clen <= 0) /* malformed UTF8 string */
+ return;
+ *dst8++ = c;
+ s += clen;
+ rlen -= clen;
+ }
+ dst8 = (XftChar8 *) d;
+ XftRenderString8 (dpy, src, font, dst, srcx, srcy, x, y,
+ dst8, n);
+ break;
+ }
+ if (d != lbuf)
+ free (d);
+}
+
+void
+XftRenderExtents8 (Display *dpy,
+ XftFontStruct *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar8 *s, c;
+ int l;
+ XGlyphInfo *gi;
+ int x, y;
+ int left, right, top, bottom;
+ int overall_left, overall_right;
+ int overall_top, overall_bottom;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l--)
+ XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+
+ gi = 0;
+ while (len)
+ {
+ c = *string++;
+ len--;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (gi)
+ break;
+ }
+ if (len == 0 && !gi)
+ {
+ extents->width = 0;
+ extents->height = 0;
+ extents->x = 0;
+ extents->y = 0;
+ extents->yOff = 0;
+ extents->xOff = 0;
+ return;
+ }
+ x = 0;
+ y = 0;
+ overall_left = x - gi->x;
+ overall_top = y - gi->y;
+ overall_right = overall_left + (int) gi->width;
+ overall_bottom = overall_top + (int) gi->height;
+ x += gi->xOff;
+ y += gi->yOff;
+ while (len--)
+ {
+ c = *string++;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (!gi)
+ continue;
+ left = x - gi->x;
+ top = y - gi->y;
+ right = left + (int) gi->width;
+ bottom = top + (int) gi->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 += gi->xOff;
+ y += gi->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;
+}
+
+void
+XftRenderExtents16 (Display *dpy,
+ XftFontStruct *font,
+ XftChar16 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar16 *s, c;
+ int l;
+ XGlyphInfo *gi;
+ int x, y;
+ int left, right, top, bottom;
+ int overall_left, overall_right;
+ int overall_top, overall_bottom;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l--)
+ XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+
+ gi = 0;
+ while (len)
+ {
+ c = *string++;
+ len--;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (gi)
+ break;
+ }
+ if (len == 0 && !gi)
+ {
+ extents->width = 0;
+ extents->height = 0;
+ extents->x = 0;
+ extents->y = 0;
+ extents->yOff = 0;
+ extents->xOff = 0;
+ return;
+ }
+ x = 0;
+ y = 0;
+ overall_left = x - gi->x;
+ overall_top = y - gi->y;
+ overall_right = overall_left + (int) gi->width;
+ overall_bottom = overall_top + (int) gi->height;
+ x += gi->xOff;
+ y += gi->yOff;
+ while (len--)
+ {
+ c = *string++;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (!gi)
+ continue;
+ left = x - gi->x;
+ top = y - gi->y;
+ right = left + (int) gi->width;
+ bottom = top + (int) gi->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 += gi->xOff;
+ y += gi->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;
+}
+
+void
+XftRenderExtents32 (Display *dpy,
+ XftFontStruct *font,
+ XftChar32 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar32 *s, c;
+ int l;
+ XGlyphInfo *gi;
+ int x, y;
+ int left, right, top, bottom;
+ int overall_left, overall_right;
+ int overall_top, overall_bottom;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l--)
+ XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+
+ gi = 0;
+ while (len)
+ {
+ c = *string++;
+ len--;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (gi)
+ break;
+ }
+ if (len == 0 && !gi)
+ {
+ extents->width = 0;
+ extents->height = 0;
+ extents->x = 0;
+ extents->y = 0;
+ extents->yOff = 0;
+ extents->xOff = 0;
+ return;
+ }
+ x = 0;
+ y = 0;
+ overall_left = x - gi->x;
+ overall_top = y - gi->y;
+ overall_right = overall_left + (int) gi->width;
+ overall_bottom = overall_top + (int) gi->height;
+ x += gi->xOff;
+ y += gi->yOff;
+ while (len--)
+ {
+ c = *string++;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (!gi)
+ continue;
+ left = x - gi->x;
+ top = y - gi->y;
+ right = left + (int) gi->width;
+ bottom = top + (int) gi->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 += gi->xOff;
+ y += gi->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;
+}
+
+void
+XftRenderExtentsUtf8 (Display *dpy,
+ XftFontStruct *font,
+ XftChar8 *string,
+ int len,
+ XGlyphInfo *extents)
+{
+ XftChar32 missing[XFT_NMISSING];
+ int nmissing;
+ XftChar8 *s;
+ XftChar32 c;
+ int l, clen;
+ XGlyphInfo *gi;
+ int x, y;
+ int left, right, top, bottom;
+ int overall_left, overall_right;
+ int overall_top, overall_bottom;
+
+ s = string;
+ l = len;
+ nmissing = 0;
+ while (l)
+ {
+ clen = XftUtf8ToUcs4 (s, &c, l);
+ if (clen < 0)
+ break;
+ XftGlyphCheck (dpy, font, (XftChar32) c, missing, &nmissing);
+ s += clen;
+ l -= clen;
+ }
+ if (nmissing)
+ XftGlyphLoad (dpy, font, missing, nmissing);
+
+ gi = 0;
+ while (len)
+ {
+ clen = XftUtf8ToUcs4 (string, &c, len);
+ if (clen < 0)
+ {
+ len = 0;
+ break;
+ }
+ len -= clen;
+ string += clen;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (gi)
+ break;
+ }
+ if (len == 0 && !gi)
+ {
+ extents->width = 0;
+ extents->height = 0;
+ extents->x = 0;
+ extents->y = 0;
+ extents->yOff = 0;
+ extents->xOff = 0;
+ return;
+ }
+ x = 0;
+ y = 0;
+ overall_left = x - gi->x;
+ overall_top = y - gi->y;
+ overall_right = overall_left + (int) gi->width;
+ overall_bottom = overall_top + (int) gi->height;
+ x += gi->xOff;
+ y += gi->yOff;
+ while (len)
+ {
+ clen = XftUtf8ToUcs4 (string, &c, len);
+ if (clen < 0)
+ break;
+ len -= clen;
+ string += clen;
+ gi = c < font->nrealized ? font->realized[c] : 0;
+ if (!gi)
+ continue;
+ left = x - gi->x;
+ top = y - gi->y;
+ right = left + (int) gi->width;
+ bottom = top + (int) gi->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 += gi->xOff;
+ y += gi->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;
+}
diff --git a/nx-X11/lib/Xft1/xftstr.c b/nx-X11/lib/Xft1/xftstr.c
new file mode 100644
index 000000000..af6013764
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftstr.c
@@ -0,0 +1,259 @@
+/*
+ * $XFree86: xc/lib/Xft/xftstr.c,v 1.6 2001/04/01 14:00:01 tsi Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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"
+
+char *
+_XftSaveString (const char *s)
+{
+ char *r;
+
+ if (!s)
+ return 0;
+ r = (char *) malloc (strlen (s) + 1);
+ if (!r)
+ return 0;
+ strcpy (r, s);
+ return r;
+}
+
+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;
+}
+
+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;
+}
+
+char *
+_XftDownStr (const char *field, char *save)
+{
+ char *s = save;
+ char c;
+
+ while (*field)
+ {
+ c = *field++;
+ *save++ = c;
+ }
+ *save = 0;
+ return s;
+}
+
+const char *
+_XftSplitField (const char *field, char *save)
+{
+ char c;
+
+ while (*field)
+ {
+ if (*field == '-' || *field == '=')
+ break;
+ c = *field++;
+ *save++ = c;
+ }
+ *save = 0;
+ return field;
+}
+
+const char *
+_XftSplitValue (const char *field, char *save)
+{
+ char c;
+
+ while (*field)
+ {
+ if (*field == '-' || *field == ',')
+ break;
+ c = *field++;
+ *save++ = c;
+ }
+ *save = 0;
+ if (*field)
+ field++;
+ return field;
+}
+
+int
+_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def)
+{
+ while (n--)
+ {
+ if (!_XftStrCmpIgnoreCase (s->name, name))
+ return s->value;
+ s++;
+ }
+ return def;
+}
+
+int
+_XftStrCmpIgnoreCase (const char *s1, const char *s2)
+{
+ char c1, c2;
+
+ for (;;)
+ {
+ c1 = *s1++;
+ c2 = *s2++;
+ if (!c1 || !c2)
+ break;
+ if (isupper (c1))
+ c1 = tolower (c1);
+ if (isupper (c2))
+ c2 = tolower (c2);
+ if (c1 != c2)
+ break;
+ }
+ return (int) c2 - (int) c1;
+}
+
+int
+XftUtf8ToUcs4 (XftChar8 *src_orig,
+ XftChar32 *dst,
+ int len)
+{
+ XftChar8 *src = src_orig;
+ XftChar8 s;
+ int extra;
+ XftChar32 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;
+}
+
+Bool
+XftUtf8Len (XftChar8 *string,
+ int len,
+ int *nchar,
+ int *wchar)
+{
+ int n;
+ int clen;
+ int width = 1;
+ XftChar32 c;
+
+ n = 0;
+ while (len)
+ {
+ clen = XftUtf8ToUcs4 (string, &c, len);
+ if (clen <= 0) /* malformed UTF8 string */
+ return False;
+ if (c >= 0x10000)
+ width = 4;
+ else if (c >= 0x100)
+ {
+ if (width == 1)
+ width = 2;
+ }
+ string += clen;
+ len -= clen;
+ n++;
+ }
+ *nchar = n;
+ *wchar = width;
+ return True;
+}
diff --git a/nx-X11/lib/Xft1/xftxlfd.c b/nx-X11/lib/Xft1/xftxlfd.c
new file mode 100644
index 000000000..8de596b47
--- /dev/null
+++ b/nx-X11/lib/Xft1/xftxlfd.c
@@ -0,0 +1,334 @@
+/*
+ * $XFree86: xc/lib/Xft1/xftxlfd.c,v 1.1.1.1tsi 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", XFT_WEIGHT_LIGHT },
+ { "medium", XFT_WEIGHT_MEDIUM },
+ { "regular", XFT_WEIGHT_MEDIUM },
+ { "demibold", XFT_WEIGHT_DEMIBOLD },
+ { "bold", XFT_WEIGHT_BOLD },
+ { "black", XFT_WEIGHT_BLACK },
+};
+
+#define NUM_XLFD_WEIGHTS (sizeof XftXlfdWeights/sizeof XftXlfdWeights[0])
+
+static XftSymbolic XftXlfdSlants[] = {
+ { "r", XFT_SLANT_ROMAN },
+ { "i", XFT_SLANT_ITALIC },
+ { "o", XFT_SLANT_OBLIQUE },
+};
+
+#define NUM_XLFD_SLANTS (sizeof XftXlfdSlants/sizeof XftXlfdSlants[0])
+
+XftPattern *
+XftXlfdParse (const char *xlfd_orig, Bool ignore_scalable, Bool complete)
+{
+ XftPattern *pat;
+ const char *xlfd = xlfd_orig;
+ const char *foundry;
+ const char *family;
+ const char *weight_name;
+ const char *slant;
+ const char *registry;
+ char *save;
+ char style[128];
+ 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 (ignore_scalable && !pixel)
+ return 0;
+
+ pat = XftPatternCreate ();
+ if (!pat)
+ return 0;
+
+ save = (char *) malloc (strlen (foundry) + 1);
+
+ if (!save)
+ return 0;
+
+ if (!XftPatternAddString (pat, XFT_XLFD, xlfd_orig)) goto bail;
+
+ _XftSplitStr (foundry, save);
+ if (save[0] && strcmp (save, "*") != 0)
+ if (!XftPatternAddString (pat, XFT_FOUNDRY, save)) goto bail;
+
+ _XftSplitStr (family, save);
+ if (save[0] && strcmp (save, "*") != 0)
+ if (!XftPatternAddString (pat, XFT_FAMILY, save)) goto bail;
+
+ weight_value = _XftMatchSymbolic (XftXlfdWeights, NUM_XLFD_WEIGHTS,
+ _XftSplitStr (weight_name, save),
+ XFT_WEIGHT_MEDIUM);
+ if (!XftPatternAddInteger (pat, XFT_WEIGHT, weight_value))
+ goto bail;
+
+ slant_value = _XftMatchSymbolic (XftXlfdSlants, NUM_XLFD_SLANTS,
+ _XftSplitStr (slant, save),
+ XFT_SLANT_ROMAN);
+ if (!XftPatternAddInteger (pat, XFT_SLANT, slant_value))
+ goto bail;
+
+ dpixel = (double) pixel;
+
+ if (complete)
+ {
+ /*
+ * Build a style name
+ */
+ style[0] = '\0';
+ switch (weight_value) {
+ case XFT_WEIGHT_LIGHT: strcat (style, "light"); break;
+ case XFT_WEIGHT_DEMIBOLD: strcat (style, "demibold"); break;
+ case XFT_WEIGHT_BOLD: strcat (style, "bold"); break;
+ case XFT_WEIGHT_BLACK: strcat (style, "black"); break;
+ }
+ if (slant_value != XFT_SLANT_ROMAN) {
+ if (style[0])
+ strcat (style, " ");
+ switch (slant_value) {
+ case XFT_SLANT_ITALIC: strcat (style, "italic"); break;
+ case XFT_SLANT_OBLIQUE: strcat (style, "oblique"); break;
+ }
+ }
+ if (!style[0])
+ strcat (style, "Regular");
+
+ if (!XftPatternAddString (pat, XFT_STYLE, style))
+ goto bail;
+ if (!XftPatternAddBool (pat, XFT_SCALABLE, pixel == 0)) goto bail;
+ if (!XftPatternAddBool (pat, XFT_CORE, True)) goto bail;
+ if (!XftPatternAddBool (pat, XFT_ANTIALIAS, False)) goto bail;
+ }
+ else
+ {
+ if (point > 0)
+ {
+ if (!XftPatternAddDouble (pat, XFT_SIZE, ((double) point) / 10.0)) goto bail;
+ if (pixel <= 0 && resy > 0)
+ {
+ dpixel = (double) point * (double) resy / 720.0;
+ }
+ }
+ }
+
+ if (dpixel > 0)
+ if (!XftPatternAddDouble (pat, XFT_PIXEL_SIZE, dpixel)) goto bail;
+
+ _XftDownStr (registry, save);
+ if (registry[0] && !strchr (registry, '*'))
+ if (!XftPatternAddString (pat, XFT_ENCODING, save)) goto bail;
+
+ free (save);
+ return pat;
+
+bail:
+ free (save);
+ XftPatternDestroy (pat);
+ return 0;
+}
+
+Bool
+XftCoreAddFonts (XftFontSet *set, Display *dpy, Bool ignore_scalable)
+{
+ char **xlfds;
+ int num;
+ int i;
+ XftPattern *font;
+ Bool ret;
+
+ xlfds = XListFonts (dpy,
+ "-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
+ 10000, &num);
+ if (!xlfds)
+ return False;
+ ret = True;
+ for (i = 0; ret && i < num; i++)
+ {
+ font = XftXlfdParse (xlfds[i], ignore_scalable, True);
+ if (font)
+ {
+ if (!XftFontSetAdd (set, font))
+ {
+ XftPatternDestroy (font);
+ ret = False;
+ }
+ }
+ }
+ XFreeFontNames (xlfds);
+ return ret;
+}
+
+typedef struct _XftCoreFont {
+ struct _XftCoreFont *next;
+ int ref;
+
+ XFontStruct *font;
+ Display *display;
+ char *xlfd;
+} XftCoreFont;
+
+static XftCoreFont *_XftCoreFonts;
+
+XFontStruct*
+XftCoreOpen (Display *dpy, XftPattern *pattern)
+{
+ XftCoreFont *cf;
+ char *xlfd;
+ char *xlfd_pixel = 0;
+ char *i, *o;
+ int d;
+ Bool scalable;
+ double pixel_size;
+ int pixel_int;
+ XFontStruct *ret;
+
+#if 0
+ printf ("Core ");
+ XftPatternPrint (pattern);
+#endif
+ if (XftPatternGetString (pattern, XFT_XLFD, 0, &xlfd) != XftResultMatch)
+ return 0;
+ if (XftPatternGetBool (pattern, XFT_SCALABLE, 0, &scalable) != XftResultMatch)
+ return 0;
+ if (scalable)
+ {
+ if (XftPatternGetDouble (pattern, XFT_PIXEL_SIZE, 0, &pixel_size) != XftResultMatch)
+ return 0;
+ pixel_int = (int) (pixel_size + 0.5);
+ if (pixel_int)
+ {
+ xlfd_pixel = (char *) malloc (strlen (xlfd) + 32);
+ i = xlfd;
+ o = xlfd_pixel;
+ d = 0;
+ while (d != 7 && *i)
+ {
+ if ((*o++ = *i++) == '-')
+ d++;
+ }
+ if (*i)
+ {
+ sprintf (o, "%d", pixel_int);
+ o += strlen (o);
+ while (*i != '-')
+ ++i;
+ }
+ while ((*o++ = *i++));
+#if 0
+ printf ("original %s sized %s\n", xlfd, xlfd_pixel);
+#endif
+ xlfd = xlfd_pixel;
+ }
+ }
+ for (cf = _XftCoreFonts; cf; cf = cf->next)
+ {
+ if (cf->display == dpy &&
+ !_XftStrCmpIgnoreCase (cf->xlfd, xlfd))
+ {
+ cf->ref++;
+ if (_XftFontDebug () & XFT_DBG_REF)
+ {
+ printf ("Xlfd \"%s\" matches existing font (%d)\n",
+ xlfd, cf->ref);
+ }
+ break;
+ }
+ }
+ if (!cf)
+ {
+ ret = XLoadQueryFont (dpy, xlfd);
+ if (!ret)
+ return 0;
+
+ cf = (XftCoreFont *) malloc (sizeof (XftCoreFont) +
+ strlen (xlfd) + 1);
+ if (!cf)
+ {
+ XFreeFont (dpy, ret);
+ return 0;
+ }
+
+ if (_XftFontDebug () & XFT_DBG_REF)
+ printf ("Xlfd \"%s\" matches new font\n", xlfd);
+
+ cf->next = _XftCoreFonts;
+ _XftCoreFonts = cf;
+ cf->ref = 1;
+
+ cf->font = ret;
+ cf->xlfd = (char *) (cf + 1);
+ strcpy (cf->xlfd, xlfd);
+ }
+ if (xlfd_pixel)
+ free (xlfd_pixel);
+ return cf->font;
+}
+
+void
+XftCoreClose (Display *dpy, XFontStruct *font)
+{
+ XftCoreFont *cf, **prev;
+
+ for (prev = &_XftCoreFonts; (cf = *prev); prev = &cf->next)
+ {
+ if (cf->display == dpy && cf->font == font)
+ {
+ if (--cf->ref == 0)
+ {
+ XFreeFont (dpy, cf->font);
+ *prev = cf->next;
+ free (cf);
+ }
+ break;
+ }
+ }
+}