aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/font/fontfile
diff options
context:
space:
mode:
authorMihai Moldovan <ionic@ionic.de>2015-04-22 08:38:21 +0200
committerMihai Moldovan <ionic@ionic.de>2015-04-22 08:38:21 +0200
commitb964406ba6e7e2d65b88010856ce881ee928898a (patch)
tree2c37d81d17f33bf288c3a44adc11bc328ee8e697 /nx-X11/lib/font/fontfile
parenta77ca871c6c1b0d6d866f95e4eb6e013f92e9627 (diff)
parent70b77a0fc329e2e205a596a738c7307d354e7b1c (diff)
downloadnx-libs-b964406ba6e7e2d65b88010856ce881ee928898a.tar.gz
nx-libs-b964406ba6e7e2d65b88010856ce881ee928898a.tar.bz2
nx-libs-b964406ba6e7e2d65b88010856ce881ee928898a.zip
Merge branch 'sunweaver-pr/libxfont-cleanup' into arctica-3.6.x
Attributes GH PR #14: https://github.com/ArcticaProject/nx-libs/pull/14
Diffstat (limited to 'nx-X11/lib/font/fontfile')
-rw-r--r--nx-X11/lib/font/fontfile/Imakefile81
-rw-r--r--nx-X11/lib/font/fontfile/bitsource.c174
-rw-r--r--nx-X11/lib/font/fontfile/bufio.c212
-rw-r--r--nx-X11/lib/font/fontfile/decompress.c415
-rw-r--r--nx-X11/lib/font/fontfile/defaults.c77
-rw-r--r--nx-X11/lib/font/fontfile/dirfile.c495
-rw-r--r--nx-X11/lib/font/fontfile/encparse.c966
-rw-r--r--nx-X11/lib/font/fontfile/ffcheck.c171
-rw-r--r--nx-X11/lib/font/fontfile/fileio.c90
-rw-r--r--nx-X11/lib/font/fontfile/filewr.c65
-rw-r--r--nx-X11/lib/font/fontfile/fontdir.c832
-rw-r--r--nx-X11/lib/font/fontfile/fontenc.c952
-rw-r--r--nx-X11/lib/font/fontfile/fontencI.h46
-rw-r--r--nx-X11/lib/font/fontfile/fontencc.c77
-rw-r--r--nx-X11/lib/font/fontfile/fontfile.c1147
-rw-r--r--nx-X11/lib/font/fontfile/fontscale.c447
-rw-r--r--nx-X11/lib/font/fontfile/gunzip.c227
-rw-r--r--nx-X11/lib/font/fontfile/module/Imakefile21
-rw-r--r--nx-X11/lib/font/fontfile/printerfont.c178
-rw-r--r--nx-X11/lib/font/fontfile/register.c107
-rw-r--r--nx-X11/lib/font/fontfile/renderers.c117
21 files changed, 0 insertions, 6897 deletions
diff --git a/nx-X11/lib/font/fontfile/Imakefile b/nx-X11/lib/font/fontfile/Imakefile
deleted file mode 100644
index fa075a951..000000000
--- a/nx-X11/lib/font/fontfile/Imakefile
+++ /dev/null
@@ -1,81 +0,0 @@
-XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:46:36 cpqbld Exp $
-
-
-
-
-XCOMM $XFree86: xc/lib/font/fontfile/Imakefile,v 3.20 2001/11/03 23:03:00 dawes Exp $
-
-#include <Server.tmpl>
-
-#if BuildServer && DoLoadableServer
-#define IHaveSubdirs
-#define NoLibSubdirs
-SUBDIRS = module
-#endif
-
- INCLUDES = -I$(FONTINCSRC) -I../include -I$(SERVERSRC)/include \
- -I$(INCLUDESRC)
- HEADERS =
-#ifdef FontFormatDefines
-FORMAT_DEFS = FontFormatDefines
-#endif
-
-#if BuildSpeedo
-SPEEDO_DEFINES = -DBUILD_SPEEDO
-#endif
-#if BuildType1
-TYPE1_DEFINES = -DBUILD_TYPE1
-#endif
-#if BuildCID
-CID_DEFINES = -DBUILD_CID
-#endif
-#if BuildFreeType
-FREETYPE_DEFINES = -DBUILD_FREETYPE
-#endif
-
-#if FontencCompatibility
- COMPAT_SRC = fontencc.c
- COMPAT_OBJ = fontencc.o
-#endif
-
-#if GzipFontCompression
- GUNZIP_SRC = gunzip.c
- GUNZIP_OBJ = gunzip.o
- GZIP_DEFS = -DX_GZIP_FONT_COMPRESSION
-#endif
-
-FONTENCDEFS = -DFONT_ENCODINGS_DIRECTORY=\"$(ENCODINGSDIR)/encodings.dir\"
-
- DEFINES = StrcasecmpDefines \
- $(SPEEDO_DEFINES) $(TYPE1_DEFINES) $(CID_DEFINES) \
- $(FREETYPE_DEFINES) $(FONTENCDEFS) \
- $(GZIP_DEFS)
-
- SRCS = dirfile.c fontdir.c fontfile.c fileio.c fontscale.c \
- defaults.c bitsource.c register.c renderers.c bufio.c \
- decompress.c filewr.c printerfont.c ffcheck.c \
- fontenc.c encparse.c $(COMPAT_SRC) $(GUNZIP_SRC)
- OBJS = dirfile.o fontdir.o fontfile.o fileio.o fontscale.o \
- defaults.o bitsource.o register.o renderers.o bufio.o \
- decompress.o filewr.o printerfont.o ffcheck.o \
- fontenc.o encparse.o $(COMPAT_OBJ) $(GUNZIP_OBJ)
-
-#define DoNormalLib NormalLibFont
-#define DoSharedLib SharedLibFont
-#define DoDebugLib DebugLibFont
-#define DoProfileLib ProfileLibFont
-#include <Library.tmpl>
-LibraryObjectRule()
-
-SpecialCLibObjectRule(fileio,$(ICONFIGFILES),$(GZIP_DEFS))
-
-SubdirLibraryRule($(OBJS))
-NormalLintTarget($(SRCS))
-
-#if BuildServer && DoLoadableServer
-MakeSubdirs($(SUBDIRS))
-DependSubdirs($(SUBDIRS))
-#endif
-
-DependTarget()
-
diff --git a/nx-X11/lib/font/fontfile/bitsource.c b/nx-X11/lib/font/fontfile/bitsource.c
deleted file mode 100644
index ae27de8fe..000000000
--- a/nx-X11/lib/font/fontfile/bitsource.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/* $Xorg: bitsource.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1991, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/bitsource.c,v 1.3 2001/01/17 19:43:29 dawes Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fntfilst.h>
-
-BitmapSourcesRec FontFileBitmapSources;
-
-Bool
-FontFileRegisterBitmapSource (FontPathElementPtr fpe)
-{
- FontPathElementPtr *new;
- int i;
- int newsize;
-
- for (i = 0; i < FontFileBitmapSources.count; i++)
- if (FontFileBitmapSources.fpe[i] == fpe)
- return TRUE;
- if (FontFileBitmapSources.count == FontFileBitmapSources.size)
- {
- newsize = FontFileBitmapSources.size + 4;
- new = (FontPathElementPtr *) xrealloc (FontFileBitmapSources.fpe, newsize * sizeof *new);
- if (!new)
- return FALSE;
- FontFileBitmapSources.size = newsize;
- FontFileBitmapSources.fpe = new;
- }
- FontFileBitmapSources.fpe[FontFileBitmapSources.count++] = fpe;
- return TRUE;
-}
-
-void
-FontFileUnregisterBitmapSource (FontPathElementPtr fpe)
-{
- int i;
-
- for (i = 0; i < FontFileBitmapSources.count; i++)
- if (FontFileBitmapSources.fpe[i] == fpe)
- {
- FontFileBitmapSources.count--;
- if (FontFileBitmapSources.count == 0)
- {
- FontFileBitmapSources.size = 0;
- xfree (FontFileBitmapSources.fpe);
- FontFileBitmapSources.fpe = 0;
- }
- else
- {
- for (; i < FontFileBitmapSources.count; i++)
- FontFileBitmapSources.fpe[i] = FontFileBitmapSources.fpe[i+1];
- }
- break;
- }
-}
-
-/*
- * Our set_path_hook: unregister all bitmap sources.
- * This is necessary because already open fonts will keep their FPEs
- * allocated, but they may not be on the new font path.
- * The bitmap sources in the new path will be registered by the init_func.
- */
-void
-FontFileEmptyBitmapSource(void)
-{
- if (FontFileBitmapSources.count == 0)
- return;
-
- FontFileBitmapSources.count = 0;
- FontFileBitmapSources.size = 0;
- xfree (FontFileBitmapSources.fpe);
- FontFileBitmapSources.fpe = 0;
-}
-
-int
-FontFileMatchBitmapSource (FontPathElementPtr fpe,
- FontPtr *pFont,
- int flags,
- FontEntryPtr entry,
- FontNamePtr zeroPat,
- FontScalablePtr vals,
- fsBitmapFormat format,
- fsBitmapFormatMask fmask,
- Bool noSpecificSize)
-{
- int source;
- FontEntryPtr zero;
- FontBitmapEntryPtr bitmap;
- int ret;
- FontDirectoryPtr dir;
- FontScaledPtr scaled;
-
- /*
- * Look through all the registered bitmap sources for
- * the same zero name as ours; entries along that one
- * can be scaled as desired.
- */
- ret = BadFontName;
- for (source = 0; source < FontFileBitmapSources.count; source++)
- {
- if (FontFileBitmapSources.fpe[source] == fpe)
- continue;
- dir = (FontDirectoryPtr) FontFileBitmapSources.fpe[source]->private;
- zero = FontFileFindNameInDir (&dir->scalable, zeroPat);
- if (!zero)
- continue;
- scaled = FontFileFindScaledInstance (zero, vals, noSpecificSize);
- if (scaled)
- {
- if (scaled->pFont)
- {
- *pFont = scaled->pFont;
- (*pFont)->fpe = FontFileBitmapSources.fpe[source];
- ret = Successful;
- }
- else if (scaled->bitmap)
- {
- entry = scaled->bitmap;
- bitmap = &entry->u.bitmap;
- if (bitmap->pFont)
- {
- *pFont = bitmap->pFont;
- (*pFont)->fpe = FontFileBitmapSources.fpe[source];
- ret = Successful;
- }
- else
- {
- ret = FontFileOpenBitmap (
- FontFileBitmapSources.fpe[source],
- pFont, flags, entry, format, fmask);
- if (ret == Successful && *pFont)
- (*pFont)->fpe = FontFileBitmapSources.fpe[source];
- }
- }
- else /* "cannot" happen */
- {
- ret = BadFontName;
- }
- break;
- }
- }
- return ret;
-}
diff --git a/nx-X11/lib/font/fontfile/bufio.c b/nx-X11/lib/font/fontfile/bufio.c
deleted file mode 100644
index 43c6a13a7..000000000
--- a/nx-X11/lib/font/fontfile/bufio.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/* $Xorg: bufio.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1991, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/bufio.c,v 3.9 2001/12/14 19:56:50 dawes Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/Xos.h>
-#include <X11/fonts/fontmisc.h>
-#include <X11/fonts/bufio.h>
-#include <errno.h>
-
-BufFilePtr
-BufFileCreate (char *private,
- int (*input)(BufFilePtr),
- int (*output)(int, BufFilePtr),
- int (*skip)(BufFilePtr, int),
- int (*close)(BufFilePtr, int))
-{
- BufFilePtr f;
-
- f = (BufFilePtr) xalloc (sizeof *f);
- if (!f)
- return 0;
- f->private = private;
- f->bufp = f->buffer;
- f->left = 0;
- f->input = input;
- f->output = output;
- f->skip = skip;
- f->eof = 0;
- f->close = close;
- return f;
-}
-
-#define FileDes(f) ((int)(long) (f)->private)
-
-static int
-BufFileRawFill (BufFilePtr f)
-{
- int left;
-
- left = read (FileDes(f), (char *)f->buffer, BUFFILESIZE);
- if (left <= 0) {
- f->left = 0;
- return BUFFILEEOF;
- }
- f->left = left - 1;
- f->bufp = f->buffer + 1;
- return f->buffer[0];
-}
-
-static int
-BufFileRawSkip (BufFilePtr f, int count)
-{
- int curoff;
- int fileoff;
- int todo;
-
- curoff = f->bufp - f->buffer;
- fileoff = curoff + f->left;
- if (curoff + count <= fileoff) {
- f->bufp += count;
- f->left -= count;
- } else {
- todo = count - (fileoff - curoff);
- if (lseek (FileDes(f), todo, 1) == -1) {
- if (errno != ESPIPE)
- return BUFFILEEOF;
- while (todo) {
- curoff = BUFFILESIZE;
- if (curoff > todo)
- curoff = todo;
- fileoff = read (FileDes(f), (char *)f->buffer, curoff);
- if (fileoff <= 0)
- return BUFFILEEOF;
- todo -= fileoff;
- }
- }
- f->left = 0;
- }
- return count;
-}
-
-static int
-BufFileRawClose (BufFilePtr f, int doClose)
-{
- if (doClose)
- close (FileDes (f));
- return 1;
-}
-
-BufFilePtr
-BufFileOpenRead (int fd)
-{
-#if defined(__UNIXOS2__) || defined (WIN32)
- /* hv: I'd bet WIN32 has the same effect here */
- setmode(fd,O_BINARY);
-#endif
- return BufFileCreate ((char *)(long) fd, BufFileRawFill, 0, BufFileRawSkip, BufFileRawClose);
-}
-
-static int
-BufFileRawFlush (int c, BufFilePtr f)
-{
- int cnt;
-
- if (c != BUFFILEEOF)
- *f->bufp++ = c;
- cnt = f->bufp - f->buffer;
- f->bufp = f->buffer;
- f->left = BUFFILESIZE;
- if (write (FileDes(f), (char *)f->buffer, cnt) != cnt)
- return BUFFILEEOF;
- return c;
-}
-
-BufFilePtr
-BufFileOpenWrite (int fd)
-{
- BufFilePtr f;
-
-#if defined(__UNIXOS2__) || defined(WIN32)
- /* hv: I'd bet WIN32 has the same effect here */
- setmode(fd,O_BINARY);
-#endif
- f = BufFileCreate ((char *)(long) fd, 0, BufFileRawFlush, 0, BufFileFlush);
- f->bufp = f->buffer;
- f->left = BUFFILESIZE;
- return f;
-}
-
-int
-BufFileRead (BufFilePtr f, char *b, int n)
-{
- int c, cnt;
- cnt = n;
- while (cnt--) {
- c = BufFileGet (f);
- if (c == BUFFILEEOF)
- break;
- *b++ = c;
- }
- return n - cnt - 1;
-}
-
-int
-BufFileWrite (BufFilePtr f, char *b, int n)
-{
- int cnt;
- cnt = n;
- while (cnt--) {
- if (BufFilePut (*b++, f) == BUFFILEEOF)
- return BUFFILEEOF;
- }
- return n;
-}
-
-int
-BufFileFlush (BufFilePtr f, int doClose)
-{
- if (f->bufp != f->buffer)
- return (*f->output) (BUFFILEEOF, f);
- return 0;
-}
-
-int
-BufFileClose (BufFilePtr f, int doClose)
-{
- int ret;
- ret = (*f->close) (f, doClose);
- xfree (f);
- return ret;
-}
-
-void
-BufFileFree (BufFilePtr f)
-{
- xfree (f);
-}
diff --git a/nx-X11/lib/font/fontfile/decompress.c b/nx-X11/lib/font/fontfile/decompress.c
deleted file mode 100644
index c7e649f91..000000000
--- a/nx-X11/lib/font/fontfile/decompress.c
+++ /dev/null
@@ -1,415 +0,0 @@
-/* $Xorg: decompress.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-/*
- * Copyright 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
-
-Copyright 1993, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/decompress.c,v 1.4 2001/01/17 19:43:29 dawes Exp $ */
-/*
- * decompress - cat a compressed file
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fontmisc.h>
-#include <X11/fonts/bufio.h>
-
-#define BITS 16
-
-/*
- * a code_int must be able to hold 2**BITS values of type int, and also -1
- */
-#if BITS > 15
-typedef long int code_int;
-#else
-typedef int code_int;
-#endif
-
-typedef long int count_int;
-
-#ifdef NO_UCHAR
- typedef char char_type;
-#else
- typedef unsigned char char_type;
-#endif /* UCHAR */
-
-static char_type magic_header[] = { "\037\235" }; /* 1F 9D */
-
-/* Defines for third byte of header */
-#define BIT_MASK 0x1f
-#define BLOCK_MASK 0x80
-/* Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is
- a fourth header byte (for expansion).
-*/
-
-#define INIT_BITS 9 /* initial number of bits/code */
-
-#ifdef COMPATIBLE /* But wrong! */
-# define MAXCODE(n_bits) (1 << (n_bits) - 1)
-#else
-# define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
-#endif /* COMPATIBLE */
-
-/*
- * the next two codes should not be changed lightly, as they must not
- * lie within the contiguous general code space.
- */
-#define FIRST 257 /* first free entry */
-#define CLEAR 256 /* table clear output code */
-
-#define STACK_SIZE 65300
-
-typedef struct _compressedFILE {
- BufFilePtr file;
-
- char_type *stackp;
- code_int oldcode;
- char_type finchar;
-
- int block_compress;
- int maxbits;
- code_int maxcode, maxmaxcode;
-
- code_int free_ent;
- int clear_flg;
- int n_bits;
-
- /* bit buffer */
- int offset, size;
- char_type buf[BITS];
-
- char_type de_stack[STACK_SIZE];
- char_type *tab_suffix;
- unsigned short *tab_prefix;
-} CompressedFile;
-
-
-static int hsize_table[] = {
- 5003, /* 12 bits - 80% occupancy */
- 9001, /* 13 bits - 91% occupancy */
- 18013, /* 14 bits - 91% occupancy */
- 35023, /* 15 bits - 94% occupancy */
- 69001 /* 16 bits - 95% occupancy */
-};
-
-static int BufCompressedClose ( BufFilePtr f, int doClose );
-static int BufCompressedFill ( BufFilePtr f );
-static code_int getcode ( CompressedFile *file );
-static int BufCompressedSkip ( BufFilePtr f, int bytes );
-
-BufFilePtr
-BufFilePushCompressed (BufFilePtr f)
-{
- int code;
- int maxbits;
- int hsize;
- CompressedFile *file;
- int extra;
-
- if ((BufFileGet(f) != (magic_header[0] & 0xFF)) ||
- (BufFileGet(f) != (magic_header[1] & 0xFF)))
- {
- return 0;
- }
- code = BufFileGet (f);
- if (code == BUFFILEEOF) return 0;
-
- maxbits = code & BIT_MASK;
- if (maxbits > BITS || maxbits < 12)
- return 0;
- hsize = hsize_table[maxbits - 12];
- extra = (1 << maxbits) * sizeof (char_type) +
- hsize * sizeof (unsigned short);
- file = (CompressedFile *) xalloc (sizeof (CompressedFile) + extra);
- if (!file)
- return 0;
- file->file = f;
- file->maxbits = maxbits;
- file->block_compress = code & BLOCK_MASK;
- file->maxmaxcode = 1 << file->maxbits;
- file->tab_suffix = (char_type *) &file[1];
- file->tab_prefix = (unsigned short *) (file->tab_suffix + file->maxmaxcode);
- /*
- * As above, initialize the first 256 entries in the table.
- */
- file->maxcode = MAXCODE(file->n_bits = INIT_BITS);
- for ( code = 255; code >= 0; code-- ) {
- file->tab_prefix[code] = 0;
- file->tab_suffix[code] = (char_type) code;
- }
- file->free_ent = ((file->block_compress) ? FIRST : 256 );
- file->oldcode = -1;
- file->clear_flg = 0;
- file->offset = 0;
- file->size = 0;
- file->stackp = file->de_stack;
- bzero(file->buf, BITS);
- return BufFileCreate ((char *) file,
- BufCompressedFill,
- 0,
- BufCompressedSkip,
- BufCompressedClose);
-}
-
-static int
-BufCompressedClose (BufFilePtr f, int doClose)
-{
- CompressedFile *file;
- BufFilePtr raw;
-
- file = (CompressedFile *) f->private;
- raw = file->file;
- xfree (file);
- BufFileClose (raw, doClose);
- return 1;
-}
-
-static int
-BufCompressedFill (BufFilePtr f)
-{
- CompressedFile *file;
- register char_type *stackp, *de_stack;
- register char_type finchar;
- register code_int code, oldcode, incode;
- BufChar *buf, *bufend;
-
- file = (CompressedFile *) f->private;
-
- buf = f->buffer;
- bufend = buf + BUFFILESIZE;
- stackp = file->stackp;
- de_stack = file->de_stack;
- finchar = file->finchar;
- oldcode = file->oldcode;
- while (buf < bufend) {
- while (stackp > de_stack && buf < bufend)
- *buf++ = *--stackp;
-
- if (buf == bufend)
- break;
-
- code = getcode (file);
- if (code == -1)
- break;
-
- if ( (code == CLEAR) && file->block_compress ) {
- for ( code = 255; code >= 0; code-- )
- file->tab_prefix[code] = 0;
- file->clear_flg = 1;
- file->free_ent = FIRST;
- oldcode = -1;
- continue;
- }
- incode = code;
- /*
- * Special case for KwKwK string.
- */
- if ( code >= file->free_ent ) {
- if ( code > file->free_ent || oldcode == -1 ) {
- /* Bad stream. */
- return BUFFILEEOF;
- }
- *stackp++ = finchar;
- code = oldcode;
- }
- /*
- * The above condition ensures that code < free_ent.
- * The construction of tab_prefixof in turn guarantees that
- * each iteration decreases code and therefore stack usage is
- * bound by 1 << BITS - 256.
- */
-
- /*
- * Generate output characters in reverse order
- */
- while ( code >= 256 )
- {
- *stackp++ = file->tab_suffix[code];
- code = file->tab_prefix[code];
- }
- finchar = file->tab_suffix[code];
- *stackp++ = finchar;
-
- /*
- * Generate the new entry.
- */
- if ( (code=file->free_ent) < file->maxmaxcode && oldcode != -1) {
- file->tab_prefix[code] = (unsigned short)oldcode;
- file->tab_suffix[code] = finchar;
- file->free_ent = code+1;
- }
- /*
- * Remember previous code.
- */
- oldcode = incode;
- }
- file->oldcode = oldcode;
- file->stackp = stackp;
- file->finchar = finchar;
- if (buf == f->buffer) {
- f->left = 0;
- return BUFFILEEOF;
- }
- f->bufp = f->buffer + 1;
- f->left = (buf - f->buffer) - 1;
- return f->buffer[0];
-}
-
-/*****************************************************************
- * TAG( getcode )
- *
- * Read one code from the standard input. If BUFFILEEOF, return -1.
- * Inputs:
- * stdin
- * Outputs:
- * code or -1 is returned.
- */
-
-static char_type rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
-
-static code_int
-getcode(CompressedFile *file)
-{
- register code_int code;
- register int r_off, bits;
- register char_type *bp = file->buf;
- register BufFilePtr raw;
-
- if ( file->clear_flg > 0 || file->offset >= file->size ||
- file->free_ent > file->maxcode )
- {
- /*
- * If the next entry will be too big for the current code
- * size, then we must increase the size. This implies reading
- * a new buffer full, too.
- */
- if ( file->free_ent > file->maxcode ) {
- file->n_bits++;
- if ( file->n_bits == file->maxbits )
- file->maxcode = file->maxmaxcode; /* won't get any bigger now */
- else
- file->maxcode = MAXCODE(file->n_bits);
- }
- if ( file->clear_flg > 0) {
- file->maxcode = MAXCODE (file->n_bits = INIT_BITS);
- file->clear_flg = 0;
- }
- bits = file->n_bits;
- raw = file->file;
- while (bits > 0 && (code = BufFileGet (raw)) != BUFFILEEOF)
- {
- *bp++ = code;
- --bits;
- }
- bp = file->buf;
- if (bits == file->n_bits)
- return -1; /* end of file */
- file->size = file->n_bits - bits;
- file->offset = 0;
- /* Round size down to integral number of codes */
- file->size = (file->size << 3) - (file->n_bits - 1);
- }
- r_off = file->offset;
- bits = file->n_bits;
- /*
- * Get to the first byte.
- */
- bp += (r_off >> 3);
- r_off &= 7;
- /* Get first part (low order bits) */
-#ifdef NO_UCHAR
- code = ((*bp++ >> r_off) & rmask[8 - r_off]) & 0xff;
-#else
- code = (*bp++ >> r_off);
-#endif /* NO_UCHAR */
- bits -= (8 - r_off);
- r_off = 8 - r_off; /* now, offset into code word */
- /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
- if ( bits >= 8 ) {
-#ifdef NO_UCHAR
- code |= (*bp++ & 0xff) << r_off;
-#else
- code |= *bp++ << r_off;
-#endif /* NO_UCHAR */
- r_off += 8;
- bits -= 8;
- }
- /* high order bits. */
- code |= (*bp & rmask[bits]) << r_off;
- file->offset += file->n_bits;
-
- return code;
-}
-
-static int
-BufCompressedSkip (BufFilePtr f, int bytes)
-{
- int c;
- while (bytes--)
- {
- c = BufFileGet(f);
- if (c == BUFFILEEOF)
- return BUFFILEEOF;
- }
- return 0;
-}
-
-#ifdef TEST
-int
-main (int argc, char *argv[])
-{
- BufFilePtr inputraw, input, output;
- int c;
-
- inputraw = BufFileOpenRead (0);
- input = BufFilePushCompressed (inputraw);
- output = BufFileOpenWrite (1);
- while ((c = BufFileGet (input)) != BUFFILEEOF)
- BufFilePut (c, output);
- BufFileClose (input, FALSE);
- BufFileClose (output, FALSE);
- return 0;
-}
-#endif
diff --git a/nx-X11/lib/font/fontfile/defaults.c b/nx-X11/lib/font/fontfile/defaults.c
deleted file mode 100644
index 7f20cab67..000000000
--- a/nx-X11/lib/font/fontfile/defaults.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* $Xorg: defaults.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1990, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/defaults.c,v 1.7 2001/01/17 19:43:29 dawes Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/X.h>
-#include <X11/Xproto.h>
-
-#ifndef DEFAULT_BIT_ORDER
-#ifdef BITMAP_BIT_ORDER
-#define DEFAULT_BIT_ORDER BITMAP_BIT_ORDER
-#else
-#define DEFAULT_BIT_ORDER MSBFirst
-#endif
-#endif
-
-#ifndef DEFAULT_BYTE_ORDER
-#ifdef IMAGE_BYTE_ORDER
-#define DEFAULT_BYTE_ORDER IMAGE_BYTE_ORDER
-#else
-#define DEFAULT_BYTE_ORDER MSBFirst
-#endif
-#endif
-
-#ifndef DEFAULT_GLYPH_PAD
-#ifdef GLYPHPADBYTES
-#define DEFAULT_GLYPH_PAD GLYPHPADBYTES
-#else
-#define DEFAULT_GLYPH_PAD 4
-#endif
-#endif
-
-#ifndef DEFAULT_SCAN_UNIT
-#define DEFAULT_SCAN_UNIT 1
-#endif
-
-#include <X11/fonts/fntfilst.h>
-
-void
-FontDefaultFormat (int *bit, int *byte, int *glyph, int *scan)
-{
- *bit = DEFAULT_BIT_ORDER;
- *byte = DEFAULT_BYTE_ORDER;
- *glyph = DEFAULT_GLYPH_PAD;
- *scan = DEFAULT_SCAN_UNIT;
-}
diff --git a/nx-X11/lib/font/fontfile/dirfile.c b/nx-X11/lib/font/fontfile/dirfile.c
deleted file mode 100644
index 3a2fead81..000000000
--- a/nx-X11/lib/font/fontfile/dirfile.c
+++ /dev/null
@@ -1,495 +0,0 @@
-/* $Xorg: dirfile.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1991, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/dirfile.c,v 3.17 2004/02/08 01:52:27 dawes Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-
-/*
- * dirfile.c
- *
- * Read fonts.dir and fonts.alias files
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fntfilst.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <limits.h>
-
-static Bool AddFileNameAliases ( FontDirectoryPtr dir );
-static int ReadFontAlias ( char *directory, Bool isFile,
- FontDirectoryPtr *pdir );
-static int lexAlias ( FILE *file, char **lexToken );
-static int lexc ( FILE *file );
-
-int
-FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
-{
- char file_name[MAXFONTFILENAMELEN];
- char font_name[MAXFONTNAMELEN];
- char dir_file[MAXFONTFILENAMELEN];
- char dir_path[MAXFONTFILENAMELEN];
- char *ptr;
- FILE *file;
- int count,
- i,
- status;
- struct stat statb;
- static char format[24] = "";
-
- FontDirectoryPtr dir = NullFontDirectory;
-
- if (strlen(directory) + 1 + sizeof(FontDirFile) > sizeof(dir_file))
- return BadFontPath;
-
- /* Check for font directory attributes */
-#if !defined(__UNIXOS2__) && !defined(WIN32)
- if ((ptr = strchr(directory, ':'))) {
-#else
- /* OS/2 and WIN32 path might start with a drive letter, don't clip this */
- if ((ptr = strchr(directory+2, ':'))) {
-#endif
- strncpy(dir_path, directory, ptr - directory);
- dir_path[ptr - directory] = '\0';
- } else {
- strcpy(dir_path, directory);
- }
- strcpy(dir_file, dir_path);
- if (dir_file[strlen(dir_file) - 1] != '/')
- strcat(dir_file, "/");
- strcat(dir_file, FontDirFile);
- file = fopen(dir_file, "rt");
- if (file) {
- Bool found_font = FALSE;
-
-#ifndef WIN32
- if (fstat (fileno(file), &statb) == -1)
-#else
- if (stat (dir_file, &statb) == -1)
-#endif
- {
- fclose(file);
- return BadFontPath;
- }
- count = fscanf(file, "%d\n", &i);
- if ((count == EOF) || (count != 1)) {
- fclose(file);
- return BadFontPath;
- }
- dir = FontFileMakeDir(directory, i);
- if (dir == NULL) {
- fclose(file);
- return BadFontPath;
- }
- dir->dir_mtime = statb.st_mtime;
- if (format[0] == '\0')
- sprintf(format, "%%%ds %%%d[^\n]\n",
- MAXFONTFILENAMELEN-1, MAXFONTNAMELEN-1);
-
- while ((count = fscanf(file, format, file_name, font_name)) != EOF) {
-#if defined(__UNIXOS2__) || defined(WIN32)
- /* strip any existing trailing CR */
- for (i=0; i<strlen(font_name); i++) {
- if (font_name[i]=='\r') font_name[i] = '\0';
- }
-#endif
- if (count != 2) {
- FontFileFreeDir (dir);
- fclose(file);
- return BadFontPath;
- }
- if (FontFileAddFontFile (dir, font_name, file_name))
- found_font = TRUE;
- }
- if (!found_font) {
- FontFileFreeDir (dir);
- fclose(file);
- return BadFontPath;
- }
- fclose(file);
-
- } else if (errno != ENOENT) {
- return BadFontPath;
- }
- status = ReadFontAlias(dir_path, FALSE, &dir);
- if (status != Successful) {
- if (dir)
- FontFileFreeDir (dir);
- return status;
- }
- if (!dir)
- return BadFontPath;
-
- FontFileSortDir(dir);
-
- *pdir = dir;
- return Successful;
-}
-
-Bool
-FontFileDirectoryChanged(FontDirectoryPtr dir)
-{
- char dir_file[MAXFONTFILENAMELEN];
- struct stat statb;
-
- if (strlen(dir->directory) + sizeof(FontDirFile) > sizeof(dir_file))
- return FALSE;
-
- strcpy (dir_file, dir->directory);
- strcat (dir_file, FontDirFile);
- if (stat (dir_file, &statb) == -1)
- {
- if (errno != ENOENT || dir->dir_mtime != 0)
- return TRUE;
- return FALSE; /* doesn't exist and never did: no change */
- }
- if (dir->dir_mtime != statb.st_mtime)
- return TRUE;
- strcpy (dir_file, dir->directory);
- strcat (dir_file, FontAliasFile);
- if (stat (dir_file, &statb) == -1)
- {
- if (errno != ENOENT || dir->alias_mtime != 0)
- return TRUE;
- return FALSE; /* doesn't exist and never did: no change */
- }
- if (dir->alias_mtime != statb.st_mtime)
- return TRUE;
- return FALSE;
-}
-
-/*
- * Make each of the file names an automatic alias for each of the files.
- */
-
-static Bool
-AddFileNameAliases(FontDirectoryPtr dir)
-{
- int i;
- char copy[MAXFONTFILENAMELEN];
- char *fileName;
- FontTablePtr table;
- FontRendererPtr renderer;
- int len;
- FontNameRec name;
-
- table = &dir->nonScalable;
- for (i = 0; i < table->used; i++) {
- if (table->entries[i].type != FONT_ENTRY_BITMAP)
- continue;
- fileName = table->entries[i].u.bitmap.fileName;
- renderer = FontFileMatchRenderer (fileName);
- if (!renderer)
- continue;
-
- len = strlen (fileName) - renderer->fileSuffixLen;
- if (len >= sizeof(copy))
- continue;
- CopyISOLatin1Lowered (copy, fileName, len);
- copy[len] = '\0';
- name.name = copy;
- name.length = len;
- name.ndashes = FontFileCountDashes (copy, len);
-
- if (!FontFileFindNameInDir(table, &name)) {
- if (!FontFileAddFontAlias (dir, copy, table->entries[i].name.name))
- return FALSE;
- }
- }
- return TRUE;
-}
-
-/*
- * parse the font.alias file. Format is:
- *
- * alias font-name
- *
- * To imbed white-space in an alias name, enclose it like "font name"
- * in double quotes. \ escapes and character, so
- * "font name \"With Double Quotes\" \\ and \\ back-slashes"
- * works just fine.
- *
- * A line beginning with a ! denotes a newline-terminated comment.
- */
-
-/*
- * token types
- */
-
-#define NAME 0
-#define NEWLINE 1
-#define DONE 2
-#define EALLOC 3
-
-static int
-ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir)
-{
- char alias[MAXFONTNAMELEN];
- char font_name[MAXFONTNAMELEN];
- char alias_file[MAXFONTFILENAMELEN];
- FILE *file;
- FontDirectoryPtr dir;
- int token;
- char *lexToken;
- int status = Successful;
- struct stat statb;
-
- if (strlen(directory) >= sizeof(alias_file))
- return BadFontPath;
- dir = *pdir;
- strcpy(alias_file, directory);
- if (!isFile) {
- if (strlen(directory) + 1 + sizeof(FontAliasFile) > sizeof(alias_file))
- return BadFontPath;
- if (directory[strlen(directory) - 1] != '/')
- strcat(alias_file, "/");
- strcat(alias_file, FontAliasFile);
- }
- file = fopen(alias_file, "rt");
- if (!file)
- return ((errno == ENOENT) ? Successful : BadFontPath);
- if (!dir)
- *pdir = dir = FontFileMakeDir(directory, 10);
- if (!dir)
- {
- fclose (file);
- return AllocError;
- }
-#ifndef WIN32
- if (fstat (fileno (file), &statb) == -1)
-#else
- if (stat (alias_file, &statb) == -1)
-#endif
- {
- fclose (file);
- return BadFontPath;
- }
- dir->alias_mtime = statb.st_mtime;
- while (status == Successful) {
- token = lexAlias(file, &lexToken);
- switch (token) {
- case NEWLINE:
- break;
- case DONE:
- fclose(file);
- return Successful;
- case EALLOC:
- status = AllocError;
- break;
- case NAME:
- if (strlen(lexToken) >= sizeof(alias)) {
- status = BadFontPath;
- break;
- }
- strcpy(alias, lexToken);
- token = lexAlias(file, &lexToken);
- switch (token) {
- case NEWLINE:
- if (strcmp(alias, "FILE_NAMES_ALIASES"))
- status = BadFontPath;
- else if (!AddFileNameAliases(dir))
- status = AllocError;
- break;
- case DONE:
- status = BadFontPath;
- break;
- case EALLOC:
- status = AllocError;
- break;
- case NAME:
- if (strlen(lexToken) >= sizeof(font_name)) {
- status = BadFontPath;
- break;
- }
- CopyISOLatin1Lowered(alias, alias, strlen(alias));
- CopyISOLatin1Lowered(font_name, lexToken, strlen(lexToken));
- if (!FontFileAddFontAlias (dir, alias, font_name))
- status = AllocError;
- break;
- }
- }
- }
- fclose(file);
- return status;
-}
-
-#define QUOTE 0
-#define WHITE 1
-#define NORMAL 2
-#define END 3
-#define NL 4
-#define BANG 5
-
-static int charClass;
-
-static int
-lexAlias(FILE *file, char **lexToken)
-{
- int c;
- char *t;
- enum state {
- Begin, Normal, Quoted, Comment
- } state;
- int count;
-
- static char *tokenBuf = (char *) NULL;
- static int tokenSize = 0;
-
- t = tokenBuf;
- count = 0;
- state = Begin;
- for (;;) {
- if (count == tokenSize) {
- int nsize;
- char *nbuf;
-
- if (tokenSize >= (INT_MAX >> 2))
- /* Stop before we overflow */
- return EALLOC;
- nsize = tokenSize ? (tokenSize << 1) : 64;
- nbuf = (char *) xrealloc(tokenBuf, nsize);
- if (!nbuf)
- return EALLOC;
- tokenBuf = nbuf;
- tokenSize = nsize;
- t = tokenBuf + count;
- }
- c = lexc(file);
- switch (charClass) {
- case QUOTE:
- switch (state) {
- case Begin:
- case Normal:
- state = Quoted;
- break;
- case Quoted:
- state = Normal;
- break;
- case Comment:
- break;
- }
- break;
- case WHITE:
- switch (state) {
- case Begin:
- case Comment:
- continue;
- case Normal:
- *t = '\0';
- *lexToken = tokenBuf;
- return NAME;
- case Quoted:
- break;
- }
- /* fall through */
- case NORMAL:
- switch (state) {
- case Begin:
- state = Normal;
- break;
- case Comment:
- continue;
- default:
- break;
- }
- *t++ = c;
- ++count;
- break;
- case END:
- case NL:
- switch (state) {
- case Begin:
- case Comment:
- *lexToken = (char *) NULL;
- return charClass == END ? DONE : NEWLINE;
- default:
- *t = '\0';
- *lexToken = tokenBuf;
- ungetc(c, file);
- return NAME;
- }
- break;
- case BANG:
- switch (state) {
- case Begin:
- state = Comment;
- break;
- case Comment:
- break;
- default:
- *t++ = c;
- ++count;
- }
- break;
- }
- }
-}
-
-static int
-lexc(FILE *file)
-{
- int c;
-
- c = getc(file);
- switch (c) {
- case EOF:
- charClass = END;
- break;
- case '\\':
- c = getc(file);
- if (c == EOF)
- charClass = END;
- else
- charClass = NORMAL;
- break;
- case '"':
- charClass = QUOTE;
- break;
- case ' ':
- case '\t':
- charClass = WHITE;
- break;
- case '\r':
- case '\n':
- charClass = NL;
- break;
- case '!':
- charClass = BANG;
- break;
- default:
- charClass = NORMAL;
- break;
- }
- return c;
-}
diff --git a/nx-X11/lib/font/fontfile/encparse.c b/nx-X11/lib/font/fontfile/encparse.c
deleted file mode 100644
index 6262aff07..000000000
--- a/nx-X11/lib/font/fontfile/encparse.c
+++ /dev/null
@@ -1,966 +0,0 @@
-/*
-Copyright (c) 1998-2001 by Juliusz Chroboczek
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-/* $XFree86: xc/lib/font/fontfile/encparse.c,v 1.20tsi Exp $ */
-
-/* Parser for encoding files */
-
-/* This code assumes that we are using ASCII. We don't use the ctype
- functions, as they depend on the current locale. On the other
- hand, we do use strcasecmp, but only on strings that we've checked
- to be pure ASCII. Bloody ``Code Set Independence''. */
-
-#include <string.h>
-#include <stdio.h>
-
-#if defined(__SCO__) || defined(__UNIXWARE__)
-#include <strings.h>
-#endif
-
-#ifndef FONTENC_NO_LIBFONT
-
-#include <X11/fonts/fntfilio.h>
-#include <X11/fonts/fntfilst.h>
-
-#else
-
-#include <stdlib.h>
-#define xalloc(n) malloc(n)
-#define xrealloc(p, n) realloc(p, n)
-#define xfree(p) free(p)
-
-#include "zlib.h"
-typedef gzFile FontFilePtr;
-#define FontFileGetc(f) gzgetc(f)
-#define FontFileOpen(filename) gzopen(filename, "rb")
-#define FontFileClose(f) gzclose(f)
-
-#define MAXFONTFILENAMELEN 1024
-#define MAXFONTNAMELEN 1024
-
-#endif
-
-#include <X11/fonts/fontenc.h>
-#include "fontencI.h"
-
-#define MAXALIASES 20
-
-#define EOF_TOKEN -1
-#define ERROR_TOKEN -2
-#define EOL_TOKEN 0
-#define NUMBER_TOKEN 1
-#define KEYWORD_TOKEN 2
-
-#define EOF_LINE -1
-#define ERROR_LINE -2
-#define STARTENCODING_LINE 1
-#define STARTMAPPING_LINE 2
-#define ENDMAPPING_LINE 3
-#define CODE_LINE 4
-#define CODE_RANGE_LINE 5
-#define CODE_UNDEFINE_LINE 6
-#define NAME_LINE 7
-#define SIZE_LINE 8
-#define ALIAS_LINE 9
-#define FIRSTINDEX_LINE 10
-
-/* Return from lexer */
-#define MAXKEYWORDLEN 100
-
-static long number_value;
-static char keyword_value[MAXKEYWORDLEN+1];
-
-static long value1, value2, value3;
-
-/* Lexer code */
-
-/* Skip to the beginning of new line */
-static void
-skipEndOfLine(FontFilePtr f, int c)
-{
- if(c == 0)
- c = FontFileGetc(f);
-
- for(;;)
- if(c <= 0 || c == '\n')
- return;
- else
- c = FontFileGetc(f);
-}
-
-/* Get a number; we're at the first digit. */
-static unsigned
-getnum(FontFilePtr f, int c, int *cp)
-{
- unsigned n = 0;
- int base = 10;
-
- /* look for `0' or `0x' prefix */
- if(c == '0') {
- c = FontFileGetc(f);
- base = 8;
- if(c == 'x' || c == 'X') {
- base = 16;
- c = FontFileGetc(f);
- }
- }
-
- /* accumulate digits */
- for(;;) {
- if ('0' <= c && c <= '9') {
- n *= base; n += c - '0';
- } else if('a' <= c && c <= 'f') {
- n *= base; n += c - 'a' + 10;
- } else if('A' <=c && c <= 'F') {
- n *= base; n += c - 'A' + 10;
- } else
- break;
- c = FontFileGetc(f);
- }
-
- *cp = c; return n;
-}
-
-/* Skip to beginning of new line; return 1 if only whitespace was found. */
-static int
-endOfLine(FontFilePtr f, int c)
-{
- if(c == 0)
- c = FontFileGetc(f);
-
- for(;;) {
- if(c <= 0 || c == '\n')
- return 1;
- else if(c == '#') {
- skipEndOfLine(f,c);
- return 1;
- }
- else if(c == ' ' || c == '\t') {
- skipEndOfLine(f,c);
- return 0;
- }
- c = FontFileGetc(f);
- }
-}
-
-/* Get a token; we're at first char */
-static int
-gettoken(FontFilePtr f, int c, int *cp)
-{
- char *p;
-
- if(c <= 0)
- c = FontFileGetc(f);
-
- if(c <= 0) {
- return EOF_TOKEN;
- }
-
- while(c == ' ' || c == '\t')
- c = FontFileGetc(f);
-
- if(c=='\n') {
- return EOL_TOKEN;
- } else if(c == '#') {
- skipEndOfLine(f,c);
- return EOL_TOKEN;
- } else if(c >= '0' && c <= '9') {
- number_value = getnum(f,c,cp);
- return NUMBER_TOKEN;
- } else if((c >= 'A' && c <= 'Z') ||
- (c >= 'a' && c <= 'z') ||
- c == '/' || c == '_' || c == '-' || c == '.') {
- p = keyword_value;
- *p++ = c;
- while(p-keyword_value < MAXKEYWORDLEN) {
- c = FontFileGetc(f);
- if(c <= ' ' || c > '~' || c == '#')
- break;
- *p++ = c;
- }
- *cp = c;
- *p = '\0';
- return KEYWORD_TOKEN;
- } else {
- *cp = c;
- return ERROR_TOKEN;
- }
-}
-
-/* Parse a line.
- * Always skips to the beginning of a new line, even if an error occurs */
-static int
-getnextline(FontFilePtr f)
-{
- int c, token;
- c = FontFileGetc(f);
- if(c <= 0)
- return EOF_LINE;
-
- again:
- token=gettoken(f,c,&c);
-
- switch(token) {
- case EOF_TOKEN:
- return EOF_LINE;
- case EOL_TOKEN:
- /* empty line */
- c = FontFileGetc(f);
- goto again;
- case NUMBER_TOKEN:
- value1 = number_value;
- token = gettoken(f,c,&c);
- switch(token) {
- case NUMBER_TOKEN:
- value2 = number_value;
- token = gettoken(f,c,&c);
- switch(token) {
- case NUMBER_TOKEN:
- value3 = number_value;
- return CODE_RANGE_LINE;
- case EOL_TOKEN:
- return CODE_LINE;
- default:
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- case KEYWORD_TOKEN:
- if(!endOfLine(f,c))
- return ERROR_LINE;
- else
- return NAME_LINE;
- default:
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- case KEYWORD_TOKEN:
- if(!strcasecmp(keyword_value, "STARTENCODING")) {
- token = gettoken(f,c,&c);
- if(token == KEYWORD_TOKEN) {
- if(endOfLine(f,c))
- return STARTENCODING_LINE;
- else
- return ERROR_LINE;
- } else {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else if(!strcasecmp(keyword_value, "ALIAS")) {
- token = gettoken(f,c,&c);
- if(token == KEYWORD_TOKEN) {
- if(endOfLine(f,c))
- return ALIAS_LINE;
- else
- return ERROR_LINE;
- } else {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else if(!strcasecmp(keyword_value, "SIZE")) {
- token = gettoken(f,c,&c);
- if(token == NUMBER_TOKEN) {
- value1 = number_value;
- token = gettoken(f,c,&c);
- switch(token) {
- case NUMBER_TOKEN:
- value2 = number_value;
- return SIZE_LINE;
- case EOL_TOKEN:
- value2=0;
- return SIZE_LINE;
- default:
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else if(!strcasecmp(keyword_value, "FIRSTINDEX")) {
- token = gettoken(f,c,&c);
- if(token == NUMBER_TOKEN) {
- value1 = number_value;
- token = gettoken(f,c,&c);
- switch(token) {
- case NUMBER_TOKEN:
- value2 = number_value;
- return FIRSTINDEX_LINE;
- case EOL_TOKEN:
- value2 = 0;
- return FIRSTINDEX_LINE;
- default:
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else if(!strcasecmp(keyword_value, "STARTMAPPING")) {
- keyword_value[0] = 0;
- value1 = 0; value1 = 0;
- /* first a keyword */
- token = gettoken(f,c,&c);
- if(token != KEYWORD_TOKEN) {
- skipEndOfLine(f, c);
- return ERROR_LINE;
- }
-
- /* optional first integer */
- token = gettoken(f,c,&c);
- if(token == NUMBER_TOKEN) {
- value1 = number_value;
- } else if(token == EOL_TOKEN) {
- return STARTMAPPING_LINE;
- } else {
- skipEndOfLine(f, c);
- return ERROR_LINE;
- }
-
- /* optional second integer */
- token = gettoken(f,c,&c);
- if(token == NUMBER_TOKEN) {
- value2 = number_value;
- } else if(token == EOL_TOKEN) {
- return STARTMAPPING_LINE;
- } else {
- skipEndOfLine(f, c);
- return ERROR_LINE;
- }
-
- if(!endOfLine(f,c))
- return ERROR_LINE;
- else {
- return STARTMAPPING_LINE;
- }
- } else if(!strcasecmp(keyword_value, "UNDEFINE")) {
- /* first integer */
- token = gettoken(f,c,&c);
- if(token != NUMBER_TOKEN) {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- value1 = number_value;
- /* optional second integer */
- token = gettoken(f,c,&c);
- if(token == EOL_TOKEN) {
- value2 = value1;
- return CODE_UNDEFINE_LINE;
- } else if(token == NUMBER_TOKEN) {
- value2 = number_value;
- if(endOfLine(f,c)) {
- return CODE_UNDEFINE_LINE;
- } else
- return ERROR_LINE;
- } else {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else if(!strcasecmp(keyword_value, "ENDENCODING")) {
- if(endOfLine(f,c))
- return EOF_LINE;
- else
- return ERROR_LINE;
- } else if(!strcasecmp(keyword_value, "ENDMAPPING")) {
- if(endOfLine(f,c))
- return ENDMAPPING_LINE;
- else
- return ERROR_LINE;
- } else {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- default:
- return ERROR_LINE;
- }
-}
-
-static void
-install_mapping(FontEncPtr encoding, FontMapPtr mapping)
-{
- FontMapPtr m;
-
- if(encoding->mappings == NULL)
- encoding->mappings = mapping;
- else {
- m = encoding->mappings;
- while(m->next != NULL)
- m = m->next;
- m->next = mapping;
- }
- mapping->next = NULL;
- mapping->encoding = encoding;
-}
-
-static int
-setCode(unsigned from, unsigned to, unsigned row_size,
- unsigned *first, unsigned *last,
- unsigned *encsize, unsigned short **enc)
-{
- unsigned index, i;
- unsigned short *newenc;
-
- if(from>0xFFFF)
- return 0; /* success */
-
- if(row_size==0)
- index=from;
- else {
- if((value1 & 0xFF) >= row_size)
- return 0; /* ignore out of range mappings */
- index = (from>>8) * row_size + (from&0xFF);
- }
-
- /* Optimize away useless identity mappings. This is only expected
- to be useful with linear encodings. */
- if(index == to && (index < *first || index > *last))
- return 0;
- if(*encsize == 0) {
- *encsize = (index < 256) ? 256 : 0x10000;
- *enc = (unsigned short*)xalloc((*encsize) * sizeof(unsigned short));
- if(*enc == NULL) {
- *encsize = 0;
- return 1;
- }
- } else if(*encsize <= index) {
- *encsize = 0x10000;
- if((newenc = (unsigned short*)xrealloc(enc, *encsize))==NULL)
- return 1;
- *enc = newenc;
- }
- if(*first > *last) {
- *first = *last = index;
- }
- if(index < *first) {
- for(i = index; i < *first; i++)
- (*enc)[i] = i;
- *first = index;
- }
- if(index > *last) {
- for(i = *last + 1; i <= index; i++)
- (*enc)[i] = i;
- *last = index;
- }
- (*enc)[index] = to;
- return 0;
-}
-
-/* Parser. If headerOnly is true, we're only interested in the
- data contained in the encoding file's header. */
-
-/* As font encodings are currently never freed, the allocations done
- by this function are mostly its private business. Note, however,
- that FontEncIdentify needs to free the header fields -- so if you
- change this function, you may need to change FontEncIdentify. */
-
-/* I want a garbage collector. */
-
-static FontEncPtr
-parseEncodingFile(FontFilePtr f, int headerOnly)
-{
- int line;
-
- unsigned short *enc=NULL;
- char **nam = NULL, **newnam;
- unsigned i, first = 0xFFFF, last=0, encsize=0, namsize=0;
- FontEncPtr encoding = NULL;
- FontMapPtr mapping = NULL;
- FontEncSimpleMapPtr sm;
- FontEncSimpleNamePtr sn;
- char *aliases[MAXALIASES];
- int numaliases=0;
-
-#if 0
- /* GCC complains about unused labels. Please fix GCC rather than
- obfuscating my code. */
- no_encoding:
-#endif
- line = getnextline(f);
- switch(line) {
- case EOF_LINE:
- goto error;
- case STARTENCODING_LINE:
- encoding = (FontEncPtr)xalloc(sizeof(FontEncRec));
- if(encoding == NULL)
- goto error;
- encoding->name = (char*)xalloc(strlen(keyword_value)+1);
- if(encoding->name == NULL)
- goto error;
- strcpy(encoding->name, keyword_value);
- encoding->size = 256;
- encoding->row_size = 0;
- encoding->mappings = NULL;
- encoding->next = NULL;
- encoding->first = encoding->first_col=0;
- goto no_mapping;
- default:
- goto error;
- }
-
- no_mapping:
- line = getnextline(f);
- switch(line) {
- case EOF_LINE: goto done;
- case ALIAS_LINE:
- if(numaliases < MAXALIASES) {
- aliases[numaliases] = (char*)xalloc(strlen(keyword_value)+1);
- if(aliases[numaliases] == NULL)
- goto error;
- strcpy(aliases[numaliases], keyword_value);
- numaliases++;
- }
- goto no_mapping;
- case SIZE_LINE:
- encoding->size = value1;
- encoding->row_size = value2;
- goto no_mapping;
- case FIRSTINDEX_LINE:
- encoding->first = value1;
- encoding->first_col = value2;
- goto no_mapping;
- case STARTMAPPING_LINE:
- if(headerOnly)
- goto done;
- if(!strcasecmp(keyword_value, "unicode")) {
- mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
- if(mapping == NULL)
- goto error;
- mapping->type = FONT_ENCODING_UNICODE;
- mapping->pid = 0;
- mapping->eid = 0;
- mapping->recode = 0;
- mapping->name = 0;
- mapping->client_data = 0;
- mapping->next = 0;
- goto mapping;
- } else if(!strcasecmp(keyword_value, "cmap")) {
- mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
- if(mapping == NULL)
- goto error;
- mapping->type = FONT_ENCODING_TRUETYPE;
- mapping->pid = value1;
- mapping->eid = value2;
- mapping->recode = 0;
- mapping->name = 0;
- mapping->client_data = 0;
- mapping->next = 0;
- goto mapping;
- } else if(!strcasecmp(keyword_value, "postscript")) {
- mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
- if(mapping == NULL)
- goto error;
- mapping->type = FONT_ENCODING_POSTSCRIPT;
- mapping->pid = 0;
- mapping->eid = 0;
- mapping->recode = 0;
- mapping->name = 0;
- mapping->client_data = 0;
- mapping->next = 0;
- goto string_mapping;
- } else { /* unknown mapping type -- ignore */
- goto skipmapping;
- }
- /* NOTREACHED */
- goto error;
- default: goto no_mapping; /* ignore unknown lines */
- }
-
- skipmapping:
- line = getnextline(f);
- switch(line) {
- case ENDMAPPING_LINE:
- goto no_mapping;
- case EOF_LINE:
- goto error;
- default:
- goto skipmapping;
- }
-
- mapping:
- line = getnextline(f);
- switch(line) {
- case EOF_LINE: goto error;
- case ENDMAPPING_LINE:
- mapping->recode = FontEncSimpleRecode;
- mapping->name = FontEncUndefinedName;
- mapping->client_data = sm =
- (FontEncSimpleMapPtr)xalloc(sizeof(FontEncSimpleMapRec));
- if(sm == NULL)
- goto error;
- sm->row_size = encoding->row_size;
- if(first <= last) {
- sm->first = first;
- sm->len=last-first+1;
- sm->map =
- (unsigned short*)xalloc(sm->len * sizeof(unsigned short));
- if(sm->map == NULL) {
- xfree(sm);
- mapping->client_data = sm = NULL;
- goto error;
- }
- } else {
- sm->first = 0;
- sm->len = 0;
- sm->map = 0;
- }
- for(i=0; i < sm->len; i++)
- sm -> map[i] = enc[first+i];
- install_mapping(encoding, mapping);
- mapping = 0;
- first = 0xFFFF; last=0;
- goto no_mapping;
-
- case CODE_LINE:
- if(setCode(value1, value2, encoding->row_size,
- &first, &last, &encsize, &enc))
- goto error;
- goto mapping;
-
- case CODE_RANGE_LINE:
- if(value1 > 0x10000)
- value1 = 0x10000;
- if(value2 > 0x10000)
- value2 = 0x10000;
- if(value2 < value1)
- goto mapping;
- /* Do the last value first to avoid having to realloc() */
- if(setCode(value2, value3+(value2-value1), encoding->row_size,
- &first, &last, &encsize, &enc))
- goto error;
- for(i=value1; i<value2; i++) {
- if(setCode(i, value3+(i-value1), encoding->row_size,
- &first, &last, &encsize, &enc))
- goto error;
- }
- goto mapping;
-
- case CODE_UNDEFINE_LINE:
- if(value1 > 0x10000)
- value1 = 0x10000;
- if(value2 > 0x10000)
- value2 = 0x10000;
- if(value2 < value1)
- goto mapping;
- /* Do the last value first to avoid having to realloc() */
- if(setCode(value2, 0, encoding->row_size,
- &first, &last, &encsize, &enc))
- goto error;
- for(i = value1; i < value2; i++) {
- if(setCode(i, 0, encoding->row_size,
- &first, &last, &encsize, &enc))
- goto error;
- }
- goto mapping;
-
- default: goto mapping; /* ignore unknown lines */
- }
-
- string_mapping:
- line = getnextline(f);
- switch(line) {
- case EOF_LINE: goto error;
- case ENDMAPPING_LINE:
- mapping->recode = FontEncUndefinedRecode;
- mapping->name = FontEncSimpleName;
- mapping->client_data = sn =
- (FontEncSimpleNamePtr)xalloc(sizeof(FontEncSimpleNameRec));
- if(sn == NULL)
- goto error;
- if(first > last) {
- xfree(sn);
- mapping->client_data = sn = NULL;
- goto error;
- }
- sn->first = first;
- sn->len = last - first + 1;
- sn->map = (char**)xalloc(sn->len*sizeof(char*));
- if(sn->map == NULL) {
- xfree(sn);
- mapping->client_data = sn = NULL;
- goto error;
- }
- for(i = 0; i < sn->len; i++)
- sn->map[i] = nam[first+i];
- install_mapping(encoding,mapping);
- mapping = 0;
- first = 0xFFFF; last=0;
- goto no_mapping;
- case NAME_LINE:
- if(value1 >= 0x10000) goto string_mapping;
- if(namsize == 0) {
- namsize = (value1) < 256 ? 256 : 0x10000;
- nam = (char**)xalloc(namsize * sizeof(char*));
- if(nam == NULL) {
- namsize=0;
- goto error;
- }
- } else if(namsize <= value1) {
- namsize = 0x10000;
- if((newnam = (char**)xrealloc(nam, namsize)) == NULL)
- goto error;
- nam = newnam;
- }
- if(first > last) {
- first = last = value1;
- }
- if(value1 < first) {
- for(i = value1; i < first; i++)
- nam[i] = NULL;
- first = value1;
- }
- if(value1 > last) {
- for(i=last+1; i <= value1; i++)
- nam[i]=NULL;
- last = value1;
- }
- nam[value1] = (char*)xalloc(strlen(keyword_value)+1);
- if(nam[value1] == NULL) {
- goto error;
- }
- strcpy(nam[value1], keyword_value);
- goto string_mapping;
-
- default: goto string_mapping; /* ignore unknown lines */
- }
-
- done:
- if(encsize) xfree(enc); encsize=0; enc = NULL;
- if(namsize) xfree(nam); namsize=0; nam = NULL; /* don't free entries! */
-
- encoding->aliases=NULL;
- if(numaliases) {
- encoding->aliases = (char**)xalloc((numaliases+1)*sizeof(char*));
- if(encoding->aliases == NULL)
- goto error;
- for(i=0; i<numaliases; i++)
- encoding->aliases[i] = aliases[i];
- encoding->aliases[numaliases]=NULL;
- }
-
- return encoding;
-
-error:
- if(encsize) xfree(enc); encsize=0;
- if(namsize) {
- for(i = first; i <= last; i++)
- if(nam[i])
- xfree(nam[i]);
- xfree(nam);
- namsize = 0;
- }
- if(mapping) {
- if(mapping->client_data) xfree(mapping->client_data);
- xfree(mapping);
- }
- if(encoding) {
- if(encoding->name) xfree(encoding->name);
- for(mapping = encoding->mappings; mapping; mapping = mapping->next) {
- if(mapping->client_data) xfree(mapping->client_data);
- xfree(mapping);
- }
- xfree(encoding);
- }
- for(i = 0; i < numaliases; i++)
- xfree(aliases[i]);
- /* We don't need to free sn and sm as they handled locally in the body.*/
- return 0;
-}
-
-char*
-FontEncDirectory()
-{
- static char* dir = NULL;
-
- if(dir == NULL) {
- char *c = getenv("FONT_ENCODINGS_DIRECTORY");
- if(c) {
- dir = malloc(strlen(c) + 1);
- if(!dir)
- return NULL;
- strcpy(dir, c);
- } else {
- dir = FONT_ENCODINGS_DIRECTORY;
- }
- }
- return dir;
-}
-
-static void
-parseFontFileName(const char *fontFileName, char *buf, char *dir)
-{
- const char *p;
- char *q, *lastslash;
-
- for(p = fontFileName, q = dir, lastslash = NULL; *p; p++, q++) {
- *q = *p;
- if(*p == '/')
- lastslash = q+1;
- }
-
- if(!lastslash)
- lastslash = dir;
-
- *lastslash = '\0';
-
- if(buf && strlen(dir) + 14 < MAXFONTFILENAMELEN) {
- strcpy(buf, dir);
- strcat(buf, "encodings.dir");
- }
-}
-
-static FontEncPtr
-FontEncReallyReallyLoad(const char *charset,
- const char *dirname, const char *dir)
-{
- FontFilePtr f;
- FILE *file;
- FontEncPtr encoding;
- char file_name[MAXFONTFILENAMELEN], encoding_name[MAXFONTNAMELEN],
- buf[MAXFONTFILENAMELEN];
- int count, n;
- static char format[24] = "";
-
- /* As we don't really expect to open encodings that often, we don't
- take the trouble of caching encodings directories. */
-
- if((file = fopen(dirname, "r")) == NULL) {
- return NULL;
- }
-
- count = fscanf(file, "%d\n", &n);
- if(count == EOF || count != 1) {
- fclose(file);
- return NULL;
- }
-
- encoding = NULL;
- if (!format[0]) {
- sprintf(format, "%%%ds %%%d[^\n]\n", (int)sizeof(encoding_name) - 1,
- (int)sizeof(file_name) - 1);
- }
- for(;;) {
- count = fscanf(file, format, encoding_name, file_name);
- if(count == EOF)
- break;
- if(count != 2)
- break;
-
- if(!strcasecmp(encoding_name, charset)) {
- /* Found it */
- if(file_name[0] != '/') {
- if(strlen(dir) + strlen(file_name) >= MAXFONTFILENAMELEN) {
- fclose(file);
- return NULL;
- }
- strcpy(buf, dir);
- strcat(buf, file_name);
- } else {
- strcpy(buf , file_name);
- }
-
- f = FontFileOpen(buf);
- if(f == NULL) {
- fclose(file);
- return NULL;
- }
- encoding = parseEncodingFile(f, 0);
- FontFileClose(f);
- break;
- }
- }
-
- fclose(file);
-
- return encoding;
-}
-
-/* Parser ntrypoint -- used by FontEncLoad */
-FontEncPtr
-FontEncReallyLoad(const char *charset, const char *fontFileName)
-{
- FontEncPtr encoding;
- char dir[MAXFONTFILENAMELEN], dirname[MAXFONTFILENAMELEN];
- char *d;
-
- if(fontFileName) {
- parseFontFileName(fontFileName, dirname, dir);
- encoding = FontEncReallyReallyLoad(charset, dirname, dir);
- if(encoding)
- return(encoding);
- }
-
- d = FontEncDirectory();
- if(d) {
- parseFontFileName(d, NULL, dir);
- encoding = FontEncReallyReallyLoad(charset, d, dir);
- return encoding;
- }
-
- return NULL;
-}
-
-/* Return a NULL-terminated array of encoding names. Note that this
- * function has incestuous knowledge of the allocations done by
- * parseEncodingFile. */
-
-char **
-FontEncIdentify(const char *fileName)
-{
- FontFilePtr f;
- FontEncPtr encoding;
- char **names, **name, **alias;
- int numaliases;
-
- if((f = FontFileOpen(fileName))==NULL) {
- return NULL;
- }
- encoding = parseEncodingFile(f, 1);
- FontFileClose(f);
-
- if(!encoding)
- return NULL;
-
- numaliases = 0;
- if(encoding->aliases)
- for(alias = encoding->aliases; *alias; alias++)
- numaliases++;
-
- names = (char**)xalloc((numaliases+2)*sizeof(char*));
- if(names == NULL) {
- if(encoding->aliases)
- xfree(encoding->aliases);
- xfree(encoding);
- return NULL;
- }
-
- name = names;
- *(name++) = encoding->name;
- if(numaliases > 0)
- for(alias = encoding->aliases; *alias; alias++, name++)
- *name = *alias;
-
- *name = 0;
- xfree(encoding->aliases);
- xfree(encoding);
-
- return names;
-}
diff --git a/nx-X11/lib/font/fontfile/ffcheck.c b/nx-X11/lib/font/fontfile/ffcheck.c
deleted file mode 100644
index d3d121700..000000000
--- a/nx-X11/lib/font/fontfile/ffcheck.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/* $Xorg: ffcheck.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1991, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/ffcheck.c,v 1.15tsi Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fntfilst.h>
-#include <X11/fonts/bitmap.h>
-#ifdef LOADABLEFONTS
-#include <X11/fonts/fontmod.h>
-#endif
-
-/*
- * Map FPE functions to renderer functions
- */
-
-
-/* Here we must check the client to see if it has a context attached to
- * it that allows us to access the printer fonts
- */
-
-static int
-FontFileCheckOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
- char *name, int namelen,
- fsBitmapFormat format, fsBitmapFormatMask fmask,
- XID id, FontPtr *pFont, char **aliasName,
- FontPtr non_cachable_font)
-{
- if (XpClientIsBitmapClient(client))
- return (FontFileOpenFont (client, fpe, flags, name, namelen, format,
- fmask, id, pFont, aliasName, non_cachable_font));
- return BadFontName;
-}
-
-static int
-FontFileCheckListFonts (pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max, FontNamesPtr names)
-{
- if (XpClientIsBitmapClient(client))
- return FontFileListFonts (client, fpe, pat, len, max, names);
- return BadFontName;
-}
-
-static int
-FontFileCheckStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
- pointer *privatep)
-{
- if (XpClientIsBitmapClient(client))
- return FontFileStartListFontsWithInfo(client, fpe, pat, len,
- max, privatep);
- return BadFontName;
-}
-
-static int
-FontFileCheckListNextFontWithInfo(pointer client, FontPathElementPtr fpe,
- char **namep, int *namelenp,
- FontInfoPtr *pFontInfo,
- int *numFonts, pointer private)
-{
- if (XpClientIsBitmapClient(client))
- return FontFileListNextFontWithInfo(client, fpe, namep, namelenp,
- pFontInfo, numFonts, private);
- return BadFontName;
-}
-
-static int
-FontFileCheckStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
- pointer *privatep)
-{
- if (XpClientIsBitmapClient(client))
- return FontFileStartListFontsAndAliases(client, fpe, pat, len,
- max, privatep);
- return BadFontName;
-}
-
-static int
-FontFileCheckListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
- char **namep, int *namelenp,
- char **resolvedp, int *resolvedlenp,
- pointer private)
-{
- if (XpClientIsBitmapClient(client))
- return FontFileListNextFontOrAlias(client, fpe, namep, namelenp,
- resolvedp, resolvedlenp, private);
- return BadFontName;
-}
-
-void
-FontFileCheckRegisterFpeFunctions (void)
-{
-#ifndef LOADABLEFONTS
- BitmapRegisterFontFileFunctions ();
-
-
-#ifdef BUILD_SPEEDO
- SpeedoRegisterFontFileFunctions ();
-#endif
-#ifdef BUILD_TYPE1
- Type1RegisterFontFileFunctions();
-#endif
-#ifdef BUILD_CID
- CIDRegisterFontFileFunctions();
-#endif
-#ifdef BUILD_FREETYPE
- FreeTypeRegisterFontFileFunctions();
-#endif
-
-
-#else
-
- {
- int i;
-
- if (FontModuleList) {
- for (i = 0; FontModuleList[i].name; i++) {
- if (FontModuleList[i].initFunc)
- FontModuleList[i].initFunc();
- }
- }
- }
-#endif
-
- RegisterFPEFunctions(FontFileNameCheck,
- FontFileInitFPE,
- FontFileFreeFPE,
- FontFileResetFPE,
- FontFileCheckOpenFont,
- FontFileCloseFont,
- FontFileCheckListFonts,
- FontFileCheckStartListFontsWithInfo,
- FontFileCheckListNextFontWithInfo,
- NULL,
- NULL,
- NULL,
- FontFileCheckStartListFontsAndAliases,
- FontFileCheckListNextFontOrAlias,
- FontFileEmptyBitmapSource);
-}
diff --git a/nx-X11/lib/font/fontfile/fileio.c b/nx-X11/lib/font/fontfile/fileio.c
deleted file mode 100644
index a3f94640b..000000000
--- a/nx-X11/lib/font/fontfile/fileio.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* $Xorg: fileio.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1991, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/fileio.c,v 3.9 2001/12/14 19:56:51 dawes Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fntfilio.h>
-#include <X11/Xos.h>
-#ifndef O_BINARY
-#define O_BINARY O_RDONLY
-#endif
-
-FontFilePtr
-FontFileOpen (const char *name)
-{
- int fd;
- int len;
- BufFilePtr raw, cooked;
-
- fd = open (name, O_BINARY);
- if (fd < 0)
- return 0;
- raw = BufFileOpenRead (fd);
- if (!raw)
- {
- close (fd);
- return 0;
- }
- len = strlen (name);
-#ifndef __UNIXOS2__
- if (len > 2 && !strcmp (name + len - 2, ".Z")) {
-#else
- if (len > 2 && (!strcmp (name + len - 4, ".pcz") ||
- !strcmp (name + len - 2, ".Z"))) {
-#endif
- cooked = BufFilePushCompressed (raw);
- if (!cooked) {
- BufFileClose (raw, TRUE);
- return 0;
- }
- raw = cooked;
-#ifdef X_GZIP_FONT_COMPRESSION
- } else if (len > 3 && !strcmp (name + len - 3, ".gz")) {
- cooked = BufFilePushZIP (raw);
- if (!cooked) {
- BufFileClose (raw, TRUE);
- return 0;
- }
- raw = cooked;
-#endif
- }
- return (FontFilePtr) raw;
-}
-
-int
-FontFileClose (FontFilePtr f)
-{
- return BufFileClose ((BufFilePtr) f, TRUE);
-}
-
diff --git a/nx-X11/lib/font/fontfile/filewr.c b/nx-X11/lib/font/fontfile/filewr.c
deleted file mode 100644
index d076f166a..000000000
--- a/nx-X11/lib/font/fontfile/filewr.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/* $Xorg: filewr.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1991, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/filewr.c,v 3.6 2001/12/14 19:56:51 dawes Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fntfilio.h>
-#include <X11/Xos.h>
-
-FontFilePtr
-FontFileOpenWrite (const char *name)
-{
- int fd;
-
-#if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)
- fd = open (name, O_CREAT|O_TRUNC|O_RDWR|O_BINARY, 0666);
-#else
- fd = creat (name, 0666);
-#endif
- if (fd < 0)
- return 0;
- return (FontFilePtr) BufFileOpenWrite (fd);
-}
-
-FontFilePtr
-FontFileOpenWriteFd (int fd)
-{
- return (FontFilePtr) BufFileOpenWrite (fd);
-}
-
-FontFilePtr
-FontFileOpenFd (int fd)
-{
- return (FontFilePtr) BufFileOpenRead (fd);
-}
diff --git a/nx-X11/lib/font/fontfile/fontdir.c b/nx-X11/lib/font/fontfile/fontdir.c
deleted file mode 100644
index 899ff05ef..000000000
--- a/nx-X11/lib/font/fontfile/fontdir.c
+++ /dev/null
@@ -1,832 +0,0 @@
-/* $XdotOrg: xc/lib/font/fontfile/fontdir.c,v 1.6 2005/11/14 20:40:42 ajax Exp $ */
-/* $Xorg: fontdir.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1991, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/fontdir.c,v 3.22 2003/07/07 16:40:11 eich Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fntfilst.h>
-#include <X11/keysym.h>
-
-#if HAVE_STDINT_H
-#include <stdint.h>
-#elif !defined(INT32_MAX)
-#define INT32_MAX 0x7fffffff
-#endif
-
-Bool
-FontFileInitTable (FontTablePtr table, int size)
-{
- if (size < 0 || (size > INT32_MAX/sizeof(FontEntryRec)))
- return FALSE;
- if (size)
- {
- table->entries = (FontEntryPtr) xalloc(sizeof(FontEntryRec) * size);
- if (!table->entries)
- return FALSE;
- }
- else
- table->entries = 0;
- table->used = 0;
- table->size = size;
- table->sorted = FALSE;
- return TRUE;
-}
-
-void
-FontFileFreeEntry (FontEntryPtr entry)
-{
- FontScalableExtraPtr extra;
- int i;
-
- if (entry->name.name)
- xfree(entry->name.name);
- entry->name.name = NULL;
-
- switch (entry->type)
- {
- case FONT_ENTRY_SCALABLE:
- xfree (entry->u.scalable.fileName);
- extra = entry->u.scalable.extra;
- for (i = 0; i < extra->numScaled; i++)
- if (extra->scaled[i].vals.ranges)
- xfree (extra->scaled[i].vals.ranges);
- xfree (extra->scaled);
- xfree (extra);
- break;
- case FONT_ENTRY_BITMAP:
- xfree (entry->u.bitmap.fileName);
- entry->u.bitmap.fileName = NULL;
- break;
- case FONT_ENTRY_ALIAS:
- xfree (entry->u.alias.resolved);
- entry->u.alias.resolved = NULL;
- break;
-#ifdef NOTYET
- case FONT_ENTRY_BC:
- break;
-#endif
- }
-}
-
-void
-FontFileFreeTable (FontTablePtr table)
-{
- int i;
-
- for (i = 0; i < table->used; i++)
- FontFileFreeEntry (&table->entries[i]);
- xfree (table->entries);
-}
-
-FontDirectoryPtr
-FontFileMakeDir(char *dirName, int size)
-{
- FontDirectoryPtr dir;
- int dirlen;
- int needslash = 0;
- char *attrib;
- int attriblen;
-
-#if !defined(__UNIXOS2__) && !defined(WIN32)
- attrib = strchr(dirName, ':');
-#else
- /* OS/2 uses the colon in the drive letter descriptor, skip this */
- attrib = strchr(dirName+2, ':');
-#endif
- if (attrib) {
- dirlen = attrib - dirName;
- attriblen = strlen(attrib);
- } else {
- dirlen = strlen(dirName);
- attriblen = 0;
- }
- if (dirName[dirlen - 1] != '/')
-#ifdef NCD
- if (dirlen) /* leave out slash for builtins */
-#endif
- needslash = 1;
- dir = (FontDirectoryPtr) xalloc(sizeof *dir + dirlen + needslash + 1 +
- (attriblen ? attriblen + 1 : 0));
- if (!dir)
- return (FontDirectoryPtr)0;
- if (!FontFileInitTable (&dir->scalable, 0))
- {
- xfree (dir);
- return (FontDirectoryPtr)0;
- }
- if (!FontFileInitTable (&dir->nonScalable, size))
- {
- FontFileFreeTable (&dir->scalable);
- xfree (dir);
- return (FontDirectoryPtr)0;
- }
- dir->directory = (char *) (dir + 1);
- dir->dir_mtime = 0;
- dir->alias_mtime = 0;
- if (attriblen)
- dir->attributes = dir->directory + dirlen + needslash + 1;
- else
- dir->attributes = NULL;
- strncpy(dir->directory, dirName, dirlen);
- dir->directory[dirlen] = '\0';
- if (dir->attributes)
- strcpy(dir->attributes, attrib);
- if (needslash)
- strcat(dir->directory, "/");
- return dir;
-}
-
-void
-FontFileFreeDir (FontDirectoryPtr dir)
-{
- FontFileFreeTable (&dir->scalable);
- FontFileFreeTable (&dir->nonScalable);
- xfree(dir);
-}
-
-FontEntryPtr
-FontFileAddEntry(FontTablePtr table, FontEntryPtr prototype)
-{
- FontEntryPtr entry;
- int newsize;
-
- /* can't add entries to a sorted table, pointers get broken! */
- if (table->sorted)
- return (FontEntryPtr) 0; /* "cannot" happen */
- if (table->used == table->size) {
- if (table->size >= ((INT32_MAX / sizeof(FontEntryRec)) - 100))
- /* If we've read so many entries we're going to ask for 2gb
- or more of memory, something is so wrong with this font
- directory that we should just give up before we overflow. */
- return NULL;
- newsize = table->size + 100;
- entry = (FontEntryPtr) xrealloc(table->entries,
- newsize * sizeof(FontEntryRec));
- if (!entry)
- return (FontEntryPtr)0;
- table->size = newsize;
- table->entries = entry;
- }
- entry = &table->entries[table->used];
- *entry = *prototype;
- entry->name.name = (char *) xalloc(prototype->name.length + 1);
- if (!entry->name.name)
- return (FontEntryPtr)0;
- memcpy (entry->name.name, prototype->name.name, prototype->name.length);
- entry->name.name[entry->name.length] = '\0';
- table->used++;
- return entry;
-}
-
-/*
- * Compare two strings just like strcmp, but preserve decimal integer
- * sorting order, i.e. "2" < "10" or "iso8859-2" < "iso8859-10" <
- * "iso10646-1". Strings are sorted as if sequences of digits were
- * prefixed by a length indicator (i.e., does not ignore leading zeroes).
- *
- * Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
- */
-#define Xisdigit(c) ('\060' <= (c) && (c) <= '\071')
-
-static int strcmpn(const char *s1, const char *s2)
-{
- int digits, predigits = 0;
- const char *ss1, *ss2;
-
- while (1) {
- if (*s1 == 0 && *s2 == 0)
- return 0;
- digits = Xisdigit(*s1) && Xisdigit(*s2);
- if (digits && !predigits) {
- ss1 = s1;
- ss2 = s2;
- while (Xisdigit(*ss1) && Xisdigit(*ss2))
- ss1++, ss2++;
- if (!Xisdigit(*ss1) && Xisdigit(*ss2))
- return -1;
- if (Xisdigit(*ss1) && !Xisdigit(*ss2))
- return 1;
- }
- if ((unsigned char)*s1 < (unsigned char)*s2)
- return -1;
- if ((unsigned char)*s1 > (unsigned char)*s2)
- return 1;
- predigits = digits;
- s1++, s2++;
- }
-}
-
-
-static int
-FontFileNameCompare(const void* a, const void* b)
-{
- FontEntryPtr a_name = (FontEntryPtr) a,
- b_name = (FontEntryPtr) b;
-
- return strcmpn(a_name->name.name, b_name->name.name);
-}
-
-void
-FontFileSortTable (FontTablePtr table)
-{
- if (!table->sorted) {
- qsort((char *) table->entries, table->used, sizeof(FontEntryRec),
- FontFileNameCompare);
- table->sorted = TRUE;
- }
-}
-
-void
-FontFileSortDir(FontDirectoryPtr dir)
-{
- FontFileSortTable (&dir->scalable);
- FontFileSortTable (&dir->nonScalable);
- /* now that the table is fixed in size, swizzle the pointers */
- FontFileSwitchStringsToBitmapPointers (dir);
-}
-
-/*
- Given a Font Table, SetupWildMatch() sets up various pointers and state
- information so the table can be searched for name(s) that match a given
- fontname pattern -- which may contain wildcards. Under certain
- circumstances, SetupWildMatch() will find the one table entry that
- matches the pattern. If those circumstances do not pertain,
- SetupWildMatch() returns a range within the the table that should be
- searched for matching name(s). With the information established by
- SetupWildMatch(), including state information in "private", the
- PatternMatch() procedure is then used to test names in the range for a
- match.
-*/
-
-#define isWild(c) ((c) == XK_asterisk || (c) == XK_question)
-#define isDigit(c) (XK_0 <= (c) && (c) <= XK_9)
-
-static int
-SetupWildMatch(FontTablePtr table, FontNamePtr pat,
- int *leftp, int *rightp, int *privatep)
-{
- int nDashes;
- char c;
- char *t;
- char *firstWild;
- char *firstDigit;
- int first;
- int center,
- left,
- right;
- int result;
- char *name;
-
- name = pat->name;
- nDashes = pat->ndashes;
- firstWild = 0;
- firstDigit = 0;
- t = name;
- while ((c = *t++)) {
- if (isWild(c)) {
- if (!firstWild)
- firstWild = t - 1;
- }
- if (isDigit(c)) {
- if (!firstDigit)
- firstDigit = t - 1;
- }
- }
- left = 0;
- right = table->used;
- if (firstWild)
- *privatep = nDashes;
- else
- *privatep = -1;
- if (!table->sorted) {
- *leftp = left;
- *rightp = right;
- return -1;
- } else if (firstWild) {
- if (firstDigit && firstDigit < firstWild)
- first = firstDigit - name;
- else
- first = firstWild - name;
- while (left < right) {
- center = (left + right) / 2;
- result = strncmp(name, table->entries[center].name.name, first);
- if (result == 0)
- break;
- if (result < 0)
- right = center;
- else
- left = center + 1;
- }
- *leftp = left;
- *rightp = right;
- return -1;
- } else {
- while (left < right) {
- center = (left + right) / 2;
- result = strcmpn(name, table->entries[center].name.name);
- if (result == 0)
- return center;
- if (result < 0)
- right = center;
- else
- left = center + 1;
- }
- *leftp = 1;
- *rightp = 0;
- return -1;
- }
-}
-
-static int
-PatternMatch(char *pat, int patdashes, char *string, int stringdashes)
-{
- char c,
- t;
-
- if (stringdashes < patdashes)
- return 0;
- for (;;) {
- switch (c = *pat++) {
- case '*':
- if (!(c = *pat++))
- return 1;
- if (c == XK_minus) {
- patdashes--;
- for (;;) {
- while ((t = *string++) != XK_minus)
- if (!t)
- return 0;
- stringdashes--;
- if (PatternMatch(pat, patdashes, string, stringdashes))
- return 1;
- if (stringdashes == patdashes)
- return 0;
- }
- } else {
- for (;;) {
- while ((t = *string++) != c) {
- if (!t)
- return 0;
- if (t == XK_minus) {
- if (stringdashes-- < patdashes)
- return 0;
- }
- }
- if (PatternMatch(pat, patdashes, string, stringdashes))
- return 1;
- }
- }
- case '?':
- if (*string++ == XK_minus)
- stringdashes--;
- break;
- case '\0':
- return (*string == '\0');
- case XK_minus:
- if (*string++ == XK_minus) {
- patdashes--;
- stringdashes--;
- break;
- }
- return 0;
- default:
- if (c == *string++)
- break;
- return 0;
- }
- }
-}
-
-int
-FontFileCountDashes (char *name, int namelen)
-{
- int ndashes = 0;
-
- while (namelen--)
- if (*name++ == '\055') /* avoid non ascii systems */
- ++ndashes;
- return ndashes;
-}
-
-char *
-FontFileSaveString (char *s)
-{
- char *n;
-
- n = (char *) xalloc (strlen (s) + 1);
- if (!n)
- return 0;
- strcpy (n, s);
- return n;
-}
-
-FontEntryPtr
-FontFileFindNameInScalableDir(FontTablePtr table, FontNamePtr pat,
- FontScalablePtr vals)
-{
- int i,
- start,
- stop,
- res,
- private;
- FontNamePtr name;
-
- if ((i = SetupWildMatch(table, pat, &start, &stop, &private)) >= 0)
- return &table->entries[i];
- for (i = start; i < stop; i++) {
- name = &table->entries[i].name;
- res = PatternMatch(pat->name, private, name->name, name->ndashes);
- if (res > 0)
- {
- /* Check to see if enhancements requested are available */
- if (vals)
- {
- int vs = vals->values_supplied;
- int cap;
-
- if (table->entries[i].type == FONT_ENTRY_SCALABLE)
- cap = table->entries[i].u.scalable.renderer->capabilities;
- else if (table->entries[i].type == FONT_ENTRY_ALIAS)
- cap = ~0; /* Calling code will have to see if true */
- else
- cap = 0;
- if ((((vs & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
- (vs & POINTSIZE_MASK) == POINTSIZE_ARRAY) &&
- !(cap & CAP_MATRIX)) ||
- ((vs & CHARSUBSET_SPECIFIED) &&
- !(cap & CAP_CHARSUBSETTING)))
- continue;
- }
- return &table->entries[i];
- }
- if (res < 0)
- break;
- }
- return (FontEntryPtr)0;
-}
-
-FontEntryPtr
-FontFileFindNameInDir(FontTablePtr table, FontNamePtr pat)
-{
- return FontFileFindNameInScalableDir(table, pat, (FontScalablePtr)0);
-}
-
-int
-FontFileFindNamesInScalableDir(FontTablePtr table, FontNamePtr pat, int max,
- FontNamesPtr names, FontScalablePtr vals,
- int alias_behavior, int *newmax)
-{
- int i,
- start,
- stop,
- res,
- private;
- int ret = Successful;
- FontEntryPtr fname;
- FontNamePtr name;
-
- if (max <= 0)
- return Successful;
- if ((i = SetupWildMatch(table, pat, &start, &stop, &private)) >= 0) {
- if (alias_behavior == NORMAL_ALIAS_BEHAVIOR ||
- table->entries[i].type != FONT_ENTRY_ALIAS)
- {
- name = &table->entries[i].name;
- if (newmax) *newmax = max - 1;
- return AddFontNamesName(names, name->name, name->length);
- }
- start = i;
- stop = i + 1;
- }
- for (i = start, fname = &table->entries[start]; i < stop; i++, fname++) {
- res = PatternMatch(pat->name, private, fname->name.name, fname->name.ndashes);
- if (res > 0) {
- if (vals)
- {
- int vs = vals->values_supplied;
- int cap;
-
- if (fname->type == FONT_ENTRY_SCALABLE)
- cap = fname->u.scalable.renderer->capabilities;
- else if (fname->type == FONT_ENTRY_ALIAS)
- cap = ~0; /* Calling code will have to see if true */
- else
- cap = 0;
- if ((((vs & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
- (vs & POINTSIZE_MASK) == POINTSIZE_ARRAY) &&
- !(cap & CAP_MATRIX)) ||
- ((vs & CHARSUBSET_SPECIFIED) &&
- !(cap & CAP_CHARSUBSETTING)))
- continue;
- }
-
- if ((alias_behavior & IGNORE_SCALABLE_ALIASES) &&
- fname->type == FONT_ENTRY_ALIAS)
- {
- FontScalableRec tmpvals;
- if (FontParseXLFDName (fname->name.name, &tmpvals,
- FONT_XLFD_REPLACE_NONE) &&
- !(tmpvals.values_supplied & SIZE_SPECIFY_MASK))
- continue;
- }
-
- ret = AddFontNamesName(names, fname->name.name, fname->name.length);
- if (ret != Successful)
- goto bail;
-
- /* If alias_behavior is LIST_ALIASES_AND_TARGET_NAMES, mark
- this entry as an alias by negating its length and follow
- it by the resolved name */
- if ((alias_behavior & LIST_ALIASES_AND_TARGET_NAMES) &&
- fname->type == FONT_ENTRY_ALIAS)
- {
- names->length[names->nnames - 1] =
- -names->length[names->nnames - 1];
- ret = AddFontNamesName(names, fname->u.alias.resolved,
- strlen(fname->u.alias.resolved));
- if (ret != Successful)
- goto bail;
- }
-
- if (--max <= 0)
- break;
- } else if (res < 0)
- break;
- }
- bail: ;
- if (newmax) *newmax = max;
- return ret;
-}
-
-int
-FontFileFindNamesInDir(FontTablePtr table, FontNamePtr pat,
- int max, FontNamesPtr names)
-{
- return FontFileFindNamesInScalableDir(table, pat, max, names,
- (FontScalablePtr)0,
- NORMAL_ALIAS_BEHAVIOR, (int *)0);
-}
-
-Bool
-FontFileMatchName(char *name, int length, FontNamePtr pat)
-{
- /* Perform a fontfile-type name match on a single name */
- FontTableRec table;
- FontEntryRec entries[1];
-
- /* Dummy up a table */
- table.used = 1;
- table.size = 1;
- table.sorted = TRUE;
- table.entries = entries;
- entries[0].name.name = name;
- entries[0].name.length = length;
- entries[0].name.ndashes = FontFileCountDashes(name, length);
-
- return FontFileFindNameInDir(&table, pat) != (FontEntryPtr)0;
-}
-
-/*
- * Add a font file to a directory. This handles bitmap and
- * scalable names both
- */
-
-Bool
-FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
-{
- FontEntryRec entry;
- FontScalableRec vals, zeroVals;
- FontRendererPtr renderer;
- FontEntryPtr existing;
- FontScalableExtraPtr extra;
- FontEntryPtr bitmap = 0, scalable;
- Bool isscale;
- Bool scalable_xlfd;
-
- renderer = FontFileMatchRenderer (fileName);
- if (!renderer)
- return FALSE;
- entry.name.length = strlen (fontName);
- if (entry.name.length > MAXFONTNAMELEN)
- entry.name.length = MAXFONTNAMELEN;
- entry.name.name = fontName;
- CopyISOLatin1Lowered (entry.name.name, fontName, entry.name.length);
- entry.name.ndashes = FontFileCountDashes (entry.name.name, entry.name.length);
- entry.name.name[entry.name.length] = '\0';
- /*
- * Add a bitmap name if the incoming name isn't an XLFD name, or
- * if it isn't a scalable name (i.e. non-zero scalable fields)
- *
- * If name of bitmapped font contains XLFD enhancements, do not add
- * a scalable version of the name... this can lead to confusion and
- * ambiguity between the font name and the field enhancements.
- */
- isscale = entry.name.ndashes == 14 &&
- FontParseXLFDName(entry.name.name,
- &vals, FONT_XLFD_REPLACE_NONE) &&
- (vals.values_supplied & PIXELSIZE_MASK) != PIXELSIZE_ARRAY &&
- (vals.values_supplied & POINTSIZE_MASK) != POINTSIZE_ARRAY &&
- !(vals.values_supplied & ENHANCEMENT_SPECIFY_MASK);
-#define UNSCALED_ATTRIB "unscaled"
- scalable_xlfd = (isscale &&
- (((vals.values_supplied & PIXELSIZE_MASK) == 0) ||
- ((vals.values_supplied & POINTSIZE_MASK) == 0)));
- /*
- * For scalable fonts without a scalable XFLD, check if the "unscaled"
- * attribute is present.
- */
- if (isscale && !scalable_xlfd &&
- dir->attributes && dir->attributes[0] == ':') {
- char *ptr1 = dir->attributes + 1;
- char *ptr2;
- int length;
- int uslength = strlen(UNSCALED_ATTRIB);
-
- do {
- ptr2 = strchr(ptr1, ':');
- if (ptr2)
- length = ptr2 - ptr1;
- else
- length = dir->attributes + strlen(dir->attributes) - ptr1;
- if (length == uslength && !strncmp(ptr1, UNSCALED_ATTRIB, uslength))
- isscale = FALSE;
- if (ptr2)
- ptr1 = ptr2 + 1;
- } while (ptr2);
- }
- if (!isscale || (vals.values_supplied & SIZE_SPECIFY_MASK))
- {
- /*
- * If the renderer doesn't support OpenBitmap, FontFileOpenFont
- * will still do the right thing.
- */
- entry.type = FONT_ENTRY_BITMAP;
- entry.u.bitmap.renderer = renderer;
- entry.u.bitmap.pFont = NullFont;
- if (!(entry.u.bitmap.fileName = FontFileSaveString (fileName)))
- return FALSE;
- if (!(bitmap = FontFileAddEntry (&dir->nonScalable, &entry)))
- {
- xfree (entry.u.bitmap.fileName);
- return FALSE;
- }
- }
- /*
- * Parse out scalable fields from XLFD names - a scalable name
- * just gets inserted, a scaled name has more things to do.
- */
- if (isscale)
- {
- if (vals.values_supplied & SIZE_SPECIFY_MASK)
- {
- bzero((char *)&zeroVals, sizeof(zeroVals));
- zeroVals.x = vals.x;
- zeroVals.y = vals.y;
- zeroVals.values_supplied = PIXELSIZE_SCALAR | POINTSIZE_SCALAR;
- FontParseXLFDName (entry.name.name, &zeroVals,
- FONT_XLFD_REPLACE_VALUE);
- entry.name.length = strlen (entry.name.name);
- existing = FontFileFindNameInDir (&dir->scalable, &entry.name);
- if (existing)
- {
- if ((vals.values_supplied & POINTSIZE_MASK) ==
- POINTSIZE_SCALAR &&
- (int)(vals.point_matrix[3] * 10) == GetDefaultPointSize())
- {
- existing->u.scalable.extra->defaults = vals;
-
- xfree (existing->u.scalable.fileName);
- if (!(existing->u.scalable.fileName = FontFileSaveString (fileName)))
- return FALSE;
- }
- if(bitmap)
- {
- FontFileCompleteXLFD(&vals, &vals);
- FontFileAddScaledInstance (existing, &vals, NullFont,
- bitmap->name.name);
- return TRUE;
- }
- }
- }
- if (!(entry.u.scalable.fileName = FontFileSaveString (fileName)))
- return FALSE;
- extra = (FontScalableExtraPtr) xalloc (sizeof (FontScalableExtraRec));
- if (!extra)
- {
- xfree (entry.u.scalable.fileName);
- return FALSE;
- }
- bzero((char *)&extra->defaults, sizeof(extra->defaults));
- if ((vals.values_supplied & POINTSIZE_MASK) == POINTSIZE_SCALAR &&
- (int)(vals.point_matrix[3] * 10) == GetDefaultPointSize())
- extra->defaults = vals;
- else
- {
- FontResolutionPtr resolution;
- int num;
-
- extra->defaults.point_matrix[0] =
- extra->defaults.point_matrix[3] =
- (double)GetDefaultPointSize() / 10.0;
- extra->defaults.point_matrix[1] =
- extra->defaults.point_matrix[2] = 0.0;
- extra->defaults.values_supplied =
- POINTSIZE_SCALAR | PIXELSIZE_UNDEFINED;
- extra->defaults.width = -1;
- if (vals.x <= 0 || vals.y <= 0)
- {
- resolution = GetClientResolutions (&num);
- if (resolution && num > 0)
- {
- extra->defaults.x = resolution->x_resolution;
- extra->defaults.y = resolution->y_resolution;
- }
- else
- {
- extra->defaults.x = 75;
- extra->defaults.y = 75;
- }
- }
- else
- {
- extra->defaults.x = vals.x;
- extra->defaults.y = vals.y;
- }
- FontFileCompleteXLFD (&extra->defaults, &extra->defaults);
- }
- extra->numScaled = 0;
- extra->sizeScaled = 0;
- extra->scaled = 0;
- extra->private = 0;
- entry.type = FONT_ENTRY_SCALABLE;
- entry.u.scalable.renderer = renderer;
- entry.u.scalable.extra = extra;
- if (!(scalable = FontFileAddEntry (&dir->scalable, &entry)))
- {
- xfree (extra);
- xfree (entry.u.scalable.fileName);
- return FALSE;
- }
- if (vals.values_supplied & SIZE_SPECIFY_MASK)
- {
- if(bitmap)
- {
- FontFileCompleteXLFD(&vals, &vals);
- FontFileAddScaledInstance (scalable, &vals, NullFont,
- bitmap->name.name);
- }
- }
- }
- return TRUE;
-}
-
-Bool
-FontFileAddFontAlias (FontDirectoryPtr dir, char *aliasName, char *fontName)
-{
- FontEntryRec entry;
-
- entry.name.length = strlen (aliasName);
- CopyISOLatin1Lowered (aliasName, aliasName, entry.name.length);
- entry.name.name = aliasName;
- entry.name.ndashes = FontFileCountDashes (entry.name.name, entry.name.length);
- entry.type = FONT_ENTRY_ALIAS;
- if (!(entry.u.alias.resolved = FontFileSaveString (fontName)))
- return FALSE;
- if (!FontFileAddEntry (&dir->nonScalable, &entry))
- {
- xfree (entry.u.alias.resolved);
- return FALSE;
- }
- return TRUE;
-}
diff --git a/nx-X11/lib/font/fontfile/fontenc.c b/nx-X11/lib/font/fontfile/fontenc.c
deleted file mode 100644
index e96cdde26..000000000
--- a/nx-X11/lib/font/fontfile/fontenc.c
+++ /dev/null
@@ -1,952 +0,0 @@
-/*
-Copyright (c) 1998-2001 by Juliusz Chroboczek
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-/* $XdotOrg: xc/lib/font/fontfile/fontenc.c,v 1.5 2005/11/08 06:33:26 jkj Exp $ */
-/* $XFree86: xc/lib/font/fontfile/fontenc.c,v 1.15 2003/02/20 03:25:19 dawes Exp $ */
-
-/* Backend-independent encoding code */
-
-#include <string.h>
-
-#if defined(__SCO__) || defined(__UNIXWARE__)
-#include <strings.h>
-#endif
-
-#ifndef FONTENC_NO_LIBFONT
-
-#include <X11/fonts/fontmisc.h> /* defines xalloc and friends */
-#include <X11/fonts/fntfilst.h>
-
-#else
-
-#include <stdlib.h>
-#define xalloc(n) malloc(n)
-#define xrealloc(p, n) realloc(p, n)
-#define xfree(p) free(p)
-#define FALSE 0
-#define TRUE 1
-#define MAXFONTNAMELEN 1024
-#define MAXFONTFILENAMELEN 1024
-
-#endif /* FONTENC_NO_FONTFILE */
-
-#include <X11/fonts/fontenc.h>
-#include "fontencI.h"
-
-/* Functions local to this file */
-
-static FontEncPtr FontEncLoad(const char*, const char*);
-
-/* Early versions of this code only knew about hardwired encodings,
- hence the following data. Now that the code knows how to load an
- encoding from a file, most of these tables could go away. */
-
-/* At any rate, no new hardcoded encodings will be added. */
-
-static FontMapRec iso10646[]=
-{
- {FONT_ENCODING_UNICODE,0,0,0,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-/* Notice that the Apple encodings do not have all the characters in
- the corresponding ISO 8859, and therefore the table has some holes.
- There's not much more we can do with fonts without a Unicode cmap
- unless we are willing to combine cmaps (which we are not). */
-
-static unsigned short
-iso8859_1_apple_roman[]=
-{ 0xCA, 0xC1, 0xA2, 0xA3, 0xDB, 0xB4, 0x00, 0xA4,
- 0xAC, 0xA9, 0xBB, 0xC7, 0xC2, 0x00, 0xA8, 0xF8,
- 0xA1, 0xB1, 0x00, 0x00, 0xAB, 0xB5, 0xA6, 0xE1,
- 0xFC, 0x00, 0xBC, 0xC8, 0x00, 0x00, 0x00, 0xC0,
- 0xCB, 0xE7, 0xE5, 0xCC, 0x80, 0x81, 0xAE, 0x82,
- 0xE9, 0x83, 0xE6, 0xE8, 0xED, 0xEA, 0xEB, 0xEC,
- 0x00, 0x84, 0xF1, 0xEE, 0xEF, 0xCD, 0x85, 0x00,
- 0xAF, 0xF4, 0xF2, 0xF3, 0x86, 0x00, 0x00, 0xA7,
- 0x88, 0x87, 0x89, 0x8B, 0x8A, 0x8C, 0xBE, 0x8D,
- 0x8F, 0x8E, 0x90, 0x91, 0x93, 0x92, 0x94, 0x95,
- 0x00, 0x96, 0x98, 0x97, 0x99, 0x9B, 0x9A, 0xD6,
- 0xBF, 0x9D, 0x9C, 0x9E, 0x9F, 0x00, 0x00, 0xD8 };
-
-/* Cannot use simple_recode because need to eliminate 0x80<=code<0xA0 */
-static unsigned
-iso8859_1_to_apple_roman(unsigned isocode, void *client_data)
-{
- if(isocode<=0x80)
- return isocode;
- else if(isocode>=0xA0)
- return iso8859_1_apple_roman[isocode-0xA0];
- else
- return 0;
-}
-
-static FontMapRec iso8859_1[]=
-{
- {FONT_ENCODING_TRUETYPE,2,2,0,0,0,0}, /* ISO 8859-1 */
- {FONT_ENCODING_UNICODE,0,0,0,0,0,0}, /* ISO 8859-1 coincides with Unicode*/
- {FONT_ENCODING_TRUETYPE,1,0,iso8859_1_to_apple_roman,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-static unsigned short iso8859_2_tophalf[]=
-{ 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7,
- 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B,
- 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7,
- 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C,
- 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
- 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
- 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
- 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
- 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
- 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
- 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
- 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9 };
-
-static FontEncSimpleMapRec iso8859_2_to_unicode_map=
-{0x60, 0, 0xA0, iso8859_2_tophalf };
-
-static unsigned short iso8859_2_apple_centeuro[]=
-{ 0xCA, 0x84, 0x00, 0xFC, 0x00, 0xBB, 0xE5, 0xA4,
- 0xAC, 0xE1, 0x00, 0xE8, 0x8F, 0x00, 0xEB, 0xFB,
- 0xA1, 0x88, 0x00, 0xB8, 0x00, 0xBC, 0xE6, 0xFF,
- 0x00, 0xE4, 0x00, 0xE9, 0x90, 0x00, 0xEC, 0xFD,
- 0xD9, 0xE7, 0x00, 0x00, 0x80, 0xBD, 0x8C, 0x00,
- 0x89, 0x83, 0xA2, 0x00, 0x9D, 0xEA, 0x00, 0x91,
- 0x00, 0xC1, 0xC5, 0xEE, 0xEF, 0xCC, 0x85, 0x00,
- 0xDB, 0xF1, 0xF2, 0xF4, 0x86, 0xF8, 0x00, 0xA7,
- 0xDA, 0x87, 0x00, 0x00, 0x8A, 0xBE, 0x8D, 0x00,
- 0x8B, 0x8E, 0xAB, 0x00, 0x9E, 0x92, 0x00, 0x93,
- 0x00, 0xC4, 0xCB, 0x97, 0x99, 0xCE, 0x9A, 0xD6,
- 0xDE, 0xF3, 0x9C, 0xF5, 0x9F, 0xF9, 0x00, 0x00 };
-
-static unsigned
-iso8859_2_to_apple_centeuro(unsigned isocode, void *client_data)
-{
- if(isocode<=0x80)
- return isocode;
- else if(isocode>=0xA0)
- return iso8859_2_apple_centeuro[isocode-0xA0];
- else
- return 0;
-}
-
-
-static FontMapRec iso8859_2[]=
-{
- {FONT_ENCODING_UNICODE,0,0,
- FontEncSimpleRecode,0,&iso8859_2_to_unicode_map,0},
- {FONT_ENCODING_TRUETYPE,1,29,iso8859_2_to_apple_centeuro,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-static unsigned short iso8859_3_tophalf[]=
-{ 0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, 0x0000, 0x0124, 0x00A7,
- 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, 0x0000, 0x017B,
- 0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7,
- 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, 0x0000, 0x017C,
- 0x00C0, 0x00C1, 0x00C2, 0x0000, 0x00C4, 0x010A, 0x0108, 0x00C7,
- 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
- 0x0000, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7,
- 0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF,
- 0x00E0, 0x00E1, 0x00E2, 0x0000, 0x00E4, 0x010B, 0x0109, 0x00E7,
- 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
- 0x0000, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7,
- 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9};
-
-static FontEncSimpleMapRec iso8859_3_to_unicode_map=
-{ 0x60, 0, 0xA0, iso8859_3_tophalf };
-
-static FontMapRec iso8859_3[]=
-{
- {FONT_ENCODING_UNICODE,0,0,
- FontEncSimpleRecode,0,&iso8859_3_to_unicode_map,0},
- {0,0,0,0,0,0,0}
-};
-
-
-static unsigned short iso8859_4_tophalf[]=
-{ 0x00A0, 0x0104, 0x0138, 0x0156, 0x00A4, 0x0128, 0x013B, 0x00A7,
- 0x00A8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00AD, 0x017D, 0x00AF,
- 0x00B0, 0x0105, 0x02DB, 0x0157, 0x00B4, 0x0129, 0x013C, 0x02C7,
- 0x00B8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014A, 0x017E, 0x014B,
- 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E,
- 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x012A,
- 0x0110, 0x0145, 0x014C, 0x0136, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
- 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x0168, 0x016A, 0x00DF,
- 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F,
- 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x012B,
- 0x0111, 0x0146, 0x014D, 0x0137, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
- 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x02D9,
-};
-
-static FontEncSimpleMapRec iso8859_4_to_unicode_map=
-{ 0x60, 0, 0xA0, iso8859_4_tophalf };
-
-static FontMapRec iso8859_4[]=
-{
- {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,0,
- &iso8859_4_to_unicode_map,0},
- {0,0,0,0,0,0,0}
-};
-
-static unsigned short iso8859_5_tophalf[]=
-{ 0x00A0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
- 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00AD, 0x040E, 0x040F,
- 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
- 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
- 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
- 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
- 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
- 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
- 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
- 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
- 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
- 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F};
-
-static FontEncSimpleMapRec iso8859_5_to_unicode_map=
-{ 0x60, 0, 0xA0, iso8859_5_tophalf };
-
-static unsigned short
-iso8859_5_apple_cyrillic[]=
-{ 0xCA, 0xDD, 0xAB, 0xAE, 0xB8, 0xC1, 0xA7, 0xBA,
- 0xB7, 0xBC, 0xBE, 0xCB, 0xCD, 0x00, 0xD8, 0xDA,
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
- 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
- 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
- 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
- 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
- 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xDF,
- 0xDC, 0xDE, 0xAC, 0xAF, 0xB9, 0xCF, 0xB4, 0xBB,
- 0xC0, 0xBD, 0xBF, 0xCC, 0xCE, 0xA4, 0xD9, 0xDB };
-
-static unsigned
-iso8859_5_to_apple_cyrillic(unsigned isocode, void *client_data)
-{
- if(isocode<=0x80)
- return isocode;
- else if(isocode>=0xA0)
- return iso8859_5_apple_cyrillic[isocode-0x80];
- else return 0;
-}
-
-static FontMapRec iso8859_5[]=
-{
- {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,0,
- &iso8859_5_to_unicode_map,0},
- {FONT_ENCODING_TRUETYPE,1,7,iso8859_5_to_apple_cyrillic,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-/* ISO 8859-6 seems useless for serving fonts (not enough presentation
- * forms). What do Arabic-speakers use? */
-
-static unsigned
-iso8859_6_to_unicode(unsigned isocode, void *client_data)
-{
- if(isocode<=0xA0 || isocode==0xA4 || isocode==0xAD)
- return isocode;
- else if(isocode==0xAC || isocode==0xBB ||
- (isocode>=0xBF && isocode<=0xDA) ||
- (isocode>=0xE0 && isocode<=0xEF) ||
- (isocode>=0xF0 && isocode<=0xF2))
- return isocode-0xA0+0x0600;
- else
- return 0;
-}
-
-static FontMapRec iso8859_6[]=
-{
- {FONT_ENCODING_UNICODE,0,0,iso8859_6_to_unicode,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-static unsigned
-iso8859_7_to_unicode(unsigned isocode, void *client_data)
-{
- if(isocode<=0xA0 ||
- (isocode>=0xA3 && isocode<=0xAD) ||
- (isocode>=0xB0 && isocode<=0xB3) ||
- isocode==0xB7 || isocode==0xBB || isocode==0xBD)
- return isocode;
- else if(isocode==0xA1)
- return 0x02BD;
- else if(isocode==0xA2)
- return 0x02BC;
- else if(isocode==0xAF)
- return 0x2015;
- else if(isocode>=0xB4)
- return isocode-0xA0+0x0370;
- else
- return 0;
-}
-
-static FontMapRec iso8859_7[]=
-{
- {FONT_ENCODING_UNICODE,0,0,iso8859_7_to_unicode,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-static unsigned
-iso8859_8_to_unicode(unsigned isocode, void *client_data)
-{
- if(isocode==0xA1)
- return 0;
- else if(isocode<0xBF)
- return isocode;
- else if(isocode==0xDF)
- return 0x2017;
- else if(isocode>=0xE0 && isocode<=0xFA)
- return isocode+0x04F0;
- else
- return 0;
-}
-
-static FontMapRec iso8859_8[]=
-{
- {FONT_ENCODING_UNICODE,0,0,iso8859_8_to_unicode,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-static unsigned
-iso8859_9_to_unicode(unsigned isocode, void *client_data)
-{
- switch(isocode) {
- case 0xD0: return 0x011E;
- case 0xDD: return 0x0130;
- case 0xDE: return 0x015E;
- case 0xF0: return 0x011F;
- case 0xFD: return 0x0131;
- case 0xFE: return 0x015F;
- default: return isocode;
- }
-}
-
-static FontMapRec iso8859_9[]=
-{
- {FONT_ENCODING_UNICODE,0,0,iso8859_9_to_unicode,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-static unsigned short iso8859_10_tophalf[]=
-{ 0x00A0, 0x0104, 0x0112, 0x0122, 0x012A, 0x0128, 0x0136, 0x00A7,
- 0x013B, 0x0110, 0x0160, 0x0166, 0x017D, 0x00AD, 0x016A, 0x014A,
- 0x00B0, 0x0105, 0x0113, 0x0123, 0x012B, 0x0129, 0x0137, 0x00B7,
- 0x013C, 0x0111, 0x0161, 0x0167, 0x017E, 0x2014, 0x016B, 0x014B,
- 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E,
- 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x00CF,
- 0x00D0, 0x0145, 0x014C, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x0168,
- 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
- 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F,
- 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x00EF,
- 0x00F0, 0x0146, 0x014D, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x0169,
- 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x0138};
-
-static FontEncSimpleMapRec iso8859_10_to_unicode_map=
-{ 0x60, 0, 0xA0, iso8859_10_tophalf };
-
-static FontMapRec iso8859_10[]=
-{
- {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,0,
- &iso8859_10_to_unicode_map,0},
- {0,0,0,0,0,0,0}
-};
-
-static unsigned
-iso8859_15_to_unicode(unsigned isocode, void *client_data)
-{
- switch(isocode) {
- case 0xA4: return 0x20AC;
- case 0xA6: return 0x0160;
- case 0xA8: return 0x0161;
- case 0xB4: return 0x017D;
- case 0xB8: return 0x017E;
- case 0xBC: return 0x0152;
- case 0xBD: return 0x0153;
- case 0xBE: return 0x0178;
- default: return isocode;
- }
-}
-
-static FontMapRec iso8859_15[]=
-{
- {FONT_ENCODING_UNICODE,0,0,iso8859_15_to_unicode,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-static unsigned short koi8_r_tophalf[]=
-{ 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
- 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
- 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2022, 0x221A, 0x2248,
- 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7,
- 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556,
- 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E,
- 0x255F, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565,
- 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x00A9,
- 0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
- 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E,
- 0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
- 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A,
- 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
- 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E,
- 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
- 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A};
-
-static FontEncSimpleMapRec koi8_r_to_unicode_map=
-{ 0x80, 0, 0x80, koi8_r_tophalf };
-
-
-static FontMapRec koi8_r[]=
-{
- {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,0,
- &koi8_r_to_unicode_map,0},
- {0,0,0,0,0,0,0}
-};
-
-static unsigned
-koi8_ru_to_unicode(unsigned koicode, void *client_data)
-{
- switch(koicode) {
- case 0x93: return 0x201C;
- case 0x96: return 0x201D;
- case 0x97: return 0x2014;
- case 0x98: return 0x2116;
- case 0x99: return 0x2122;
- case 0x9B: return 0x00BB;
- case 0x9C: return 0x00AE;
- case 0x9D: return 0x00AB;
- case 0x9F: return 0x00A4;
- case 0xA4: return 0x0454;
- case 0xA6: return 0x0456;
- case 0xA7: return 0x0457;
- case 0xAD: return 0x0491;
- case 0xAE: return 0x045E;
- case 0xB4: return 0x0404;
- case 0xB6: return 0x0406;
- case 0xB7: return 0x0407;
- case 0xBD: return 0x0490;
- case 0xBE: return 0x040E;
- default: return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
- }
-}
-
-static FontMapRec koi8_ru[]=
-{
- {FONT_ENCODING_UNICODE,0,0,koi8_ru_to_unicode,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-/* koi8-e, ISO-IR-111 or ECMA-Cyrillic */
-
-static unsigned short koi8_e_A0_BF[]=
-{ 0x00A0, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
- 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00AD, 0x045E, 0x045F,
- 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
- 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00A4, 0x040E, 0x040F };
-
-static unsigned
-koi8_e_to_unicode(unsigned koicode, void *client_data)
-{
- if(koicode<0xA0)
- return koicode;
- else if(koicode<0xC0)
- return koi8_e_A0_BF[koicode-0xA0];
- else
- return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
-}
-
-static FontMapRec koi8_e[]=
-{
- {FONT_ENCODING_UNICODE,0,0,koi8_e_to_unicode,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-/* Koi8 unified */
-
-static unsigned short koi8_uni_80_BF[]=
-{ 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
- 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
- 0x2591, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
- 0x00A9, 0x2122, 0x00A0, 0x00BB, 0x00AE, 0x00AB, 0x00B7, 0x00A4,
- 0x00A0, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
- 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x0491, 0x045E, 0x045F,
- 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
- 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x0490, 0x040E, 0x040F };
-
-static unsigned
-koi8_uni_to_unicode(unsigned koicode, void *client_data)
-{
- if(koicode<0x80)
- return koicode;
- else if(koicode<0xC0)
- return koi8_uni_80_BF[koicode-0x80];
- else
- return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
-}
-
-static FontMapRec koi8_uni[]=
-{
- {FONT_ENCODING_UNICODE,0,0,koi8_uni_to_unicode,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-/* Ukrainian variant of Koi8-R; see RFC 2319 */
-
-static unsigned
-koi8_u_to_unicode(unsigned koicode, void *client_data)
-{
- switch(koicode) {
- case 0xA4: return 0x0454;
- case 0xA6: return 0x0456;
- case 0xA7: return 0x0457;
- case 0xAD: return 0x0491;
- case 0xB4: return 0x0404;
- case 0xB6: return 0x0406;
- case 0xB7: return 0x0407;
- case 0xBD: return 0x0490;
- default: return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
- }
-}
-
-static FontMapRec koi8_u[]=
-{
- {FONT_ENCODING_UNICODE,0,0,koi8_u_to_unicode,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-/* Microsoft Symbol, which is only meaningful for TrueType fonts, is
- treated specially in ftenc.c, where we add usFirstCharIndex-0x20 to
- the glyph index before applying the cmap. Lovely design. */
-
-static FontMapRec microsoft_symbol[]=
-{{FONT_ENCODING_TRUETYPE,3,0,0,0,0,0},
- /* You never know */
- {FONT_ENCODING_TRUETYPE,3,1,0,0,0,0},
- {0,0,0,0,0,0,0}};
-
-static FontMapRec apple_roman[]=
-{{FONT_ENCODING_TRUETYPE,1,0,0,0,0,0}, {0,0,0,0,0,0,0}};
-
-/* The data for recodings */
-
-/* For compatibility with X11R6.4. Losers. */
-static char *iso8859_15_aliases[2]={"fcd8859-15",0};
-
-static FontEncRec initial_encodings[]=
-{
- {"iso10646-1",0,256*256,0,iso10646,0,0,0}, /* Unicode */
- {"iso8859-1",0,256,0,iso8859_1,0,0,0}, /* Latin 1 (West European) */
- {"iso8859-2",0,256,0,iso8859_2,0,0,0}, /* Latin 2 (East European) */
- {"iso8859-3",0,256,0,iso8859_3,0,0,0}, /* Latin 3 (South European) */
- {"iso8859-4",0,256,0,iso8859_4,0,0,0}, /* Latin 4 (North European) */
- {"iso8859-5",0,256,0,iso8859_5,0,0,0}, /* Cyrillic */
- {"iso8859-6",0,256,0,iso8859_6,0,0,0}, /* Arabic */
- {"iso8859-7",0,256,0,iso8859_7,0,0,0}, /* Greek */
- {"iso8859-8",0,256,0,iso8859_8,0,0,0}, /* Hebrew */
- {"iso8859-9",0,256,0,iso8859_9,0,0,0}, /* Latin 5 (Turkish) */
- {"iso8859-10",0,256,0,iso8859_10,0,0,0}, /* Latin 6 (Nordic) */
- {"iso8859-15",iso8859_15_aliases,256,0,iso8859_15,0,0,0}, /* Latin 9 */
- {"koi8-r",0,256,0,koi8_r,0,0,0}, /* Russian */
- {"koi8-ru",0,256,0,koi8_ru,0,0,0}, /* Ukrainian */
- {"koi8-uni",0,256,0,koi8_uni,0,0,0}, /* Russian/Ukrainian/Bielorussian */
- {"koi8-e",0,256,0,koi8_e,0,0,0}, /* ``European'' */
- {"koi8-u",0,256,0,koi8_u,0,0,0}, /* Ukrainian too */
- {"microsoft-symbol",0,256,0,microsoft_symbol,0,0,0},
- {"apple-roman",0,256,0,apple_roman,0,0,0},
- {0,0,0,0,0,0,0}
-};
-
-static FontEncPtr font_encodings=NULL;
-
-static void
-define_initial_encoding_info(void)
-{
- FontEncPtr encoding;
- FontMapPtr mapping;
-
- font_encodings = initial_encodings;
- for(encoding = font_encodings; ; encoding++) {
- encoding->next = encoding + 1;
- for(mapping = encoding->mappings; ; mapping++) {
- mapping->next = mapping+1;
- mapping->encoding = encoding;
- if(mapping->next->type == 0) {
- mapping->next = NULL;
- break;
- }
- }
- if(!encoding->next->name) {
- encoding->next = NULL;
- break;
- }
- }
-}
-
-
-char*
-FontEncFromXLFD(const char *name, int length)
-{
- const char *p;
- char *q;
- static char charset[MAXFONTNAMELEN];
- int len;
-
- if(length > MAXFONTNAMELEN - 1)
- return 0;
-
- if(name == NULL)
- p = NULL;
- else {
- p = name + length - 1;
- while(p > name && *p != '-')
- p--;
- p--;
- while(p >= name && *p != '-')
- p--;
- if(p <= name)
- p = 0;
- }
-
- /* now p either is null or points at the '-' before the charset registry */
-
- if(p == 0)
- return 0;
-
- len = length - (p - name) - 1;
- memcpy(charset, p+1, len);
- charset[len] = 0;
-
- /* check for a subset specification */
- if((q = strchr(charset, (int)'[')))
- *q = 0;
-
- return charset;
-}
-
-unsigned
-FontEncRecode(unsigned code, FontMapPtr mapping)
-{
- FontEncPtr encoding = mapping->encoding;
- if(encoding && mapping->recode) {
- if(encoding->row_size == 0) {
- /* linear encoding */
- if(code < encoding->first || code>=encoding->size)
- return 0;
- } else {
- /* matrix encoding */
- int row = code/0x100, col = code&0xFF;
- if(row < encoding->first || row >= encoding->size ||
- col < encoding->first_col || col >= encoding->row_size)
- return 0;
- }
- return (*mapping->recode)(code, mapping->client_data);
- } else
- return code;
-}
-
-char*
-FontEncName(unsigned code, FontMapPtr mapping)
-{
- FontEncPtr encoding = mapping->encoding;
- if(encoding && mapping->name) {
- if((encoding->row_size == 0 && code >= encoding->size) ||
- (encoding->row_size != 0 &&
- (code/0x100 >= encoding->size ||
- (code&0xFF) >= encoding->row_size)))
- return 0;
- return (*mapping->name)(code, mapping->client_data);
- } else
- return 0;
-}
-
-FontEncPtr
-FontEncFind(const char *encoding_name, const char *filename)
-{
- FontEncPtr encoding;
- char **alias;
-
- if(font_encodings == NULL) define_initial_encoding_info();
-
- for(encoding = font_encodings; encoding; encoding = encoding->next) {
- if(!strcasecmp(encoding->name, encoding_name))
- return encoding;
- if(encoding->aliases)
- for(alias=encoding->aliases; *alias; alias++)
- if(!strcasecmp(*alias, encoding_name))
- return encoding;
- }
-
- /* Unknown charset, try to load a definition file */
- return FontEncLoad(encoding_name, filename);
-}
-
-FontMapPtr
-FontMapFind(FontEncPtr encoding, int type, int pid, int eid)
-{
- FontMapPtr mapping;
- if(encoding == NULL)
- return NULL;
-
- for(mapping = encoding->mappings; mapping; mapping = mapping->next) {
- if(mapping->type != type)
- continue;
- if(pid > 0 && mapping->pid != pid)
- continue;
- if(eid > 0 && mapping->eid != eid)
- continue;
- return mapping;
- }
- return NULL;
-}
-
-FontMapPtr
-FontEncMapFind(const char *encoding_name, int type, int pid, int eid,
- const char *filename)
-{
- FontEncPtr encoding;
- FontMapPtr mapping;
-
- encoding = FontEncFind(encoding_name, filename);
- if(encoding == NULL)
- return NULL;
- mapping = FontMapFind(encoding, type, pid, eid);
- return mapping;
-}
-
-static FontEncPtr
-FontEncLoad(const char *encoding_name, const char *filename)
-{
- FontEncPtr encoding;
-
- encoding = FontEncReallyLoad(encoding_name, filename);
- if (encoding == NULL) {
- return 0;
- } else {
- char **alias;
- int found = 0;
-
- /* Check whether the name is already known for this encoding */
- if(strcasecmp(encoding->name, encoding_name) == 0) {
- found = 1;
- } else {
- if(encoding->aliases) {
- for(alias=encoding->aliases; *alias; alias++)
- if(!strcasecmp(*alias, encoding_name)) {
- found = 1;
- break;
- }
- }
- }
-
- if(!found) {
- /* Add a new alias. This works because we know that this
- particular encoding has been allocated dynamically */
- char **new_aliases;
- char *new_name;
- int numaliases = 0;
-
- new_name = xalloc(strlen(encoding_name) + 1);
- if(new_name == NULL)
- return NULL;
- strcpy(new_name, encoding_name);
- if(encoding->aliases) {
- for(alias = encoding->aliases; *alias; alias++)
- numaliases++;
- }
- new_aliases = (char**)xalloc((numaliases+2)*sizeof(char*));
- if(new_aliases == NULL) {
- xfree(new_name);
- return NULL;
- }
- if(encoding->aliases) {
- memcpy(new_aliases, encoding->aliases, numaliases*sizeof(char*));
- xfree(encoding->aliases);
- }
- new_aliases[numaliases] = new_name;
- new_aliases[numaliases+1] = NULL;
- encoding->aliases = new_aliases;
- }
-
- /* register the new encoding */
- encoding->next=font_encodings;
- font_encodings=encoding;
-
- return encoding;
- }
-}
-
-unsigned
-FontEncSimpleRecode(unsigned code, void *client_data)
-{
- FontEncSimpleMapPtr map;
- unsigned index;
-
- map = client_data;
-
- if(code > 0xFFFF || (map->row_size && (code&0xFF) >= map->row_size))
- return 0;
-
- if(map->row_size)
- index = (code&0xFF)+(code>>8)*map->row_size;
- else
- index = code;
-
- if(map->map && index>=map->first && index<map->first+map->len)
- return map->map[index-map->first];
- else
- return code;
-}
-
-char *
-FontEncSimpleName(unsigned code, void *client_data)
-{
- FontEncSimpleNamePtr map;
-
- map = client_data;
- if(map && code >= map->first && code<map->first+map->len)
- return map->map[code-map->first];
- else
- return NULL;
-}
-
-unsigned
-FontEncUndefinedRecode(unsigned code, void *client_data)
-{
- return code;
-}
-
-char *
-FontEncUndefinedName(unsigned code, void *client_data)
-{
- return NULL;
-}
-
-#define FONTENC_SEGMENT_SIZE 256
-#define FONTENC_SEGMENTS 256
-#define FONTENC_INVERSE_CODES (FONTENC_SEGMENT_SIZE * FONTENC_SEGMENTS)
-
-static unsigned int
-reverse_reverse(unsigned i, void* data)
-{
- int s, j;
- unsigned **map = (unsigned**)data;
-
- if(i >= FONTENC_INVERSE_CODES)
- return 0;
-
- if(map == NULL)
- return 0;
-
- s = i / FONTENC_SEGMENT_SIZE;
- j = i % FONTENC_SEGMENT_SIZE;
-
- if(map[s] == NULL)
- return 0;
- else
- return map[s][j];
-}
-
-static int
-tree_set(unsigned int **map, unsigned int i, unsigned int j)
-{
- int s, c;
-
- if(i >= FONTENC_INVERSE_CODES)
- return FALSE;
-
- s = i / FONTENC_SEGMENT_SIZE;
- c = i % FONTENC_SEGMENT_SIZE;
-
- if(map[s] == NULL) {
- map[s] = calloc(FONTENC_SEGMENT_SIZE, sizeof(int));
- if(map[s] == NULL)
- return FALSE;
- }
-
- map[s][c] = j;
- return TRUE;
-}
-
-FontMapReversePtr
-FontMapReverse(FontMapPtr mapping)
-{
- FontEncPtr encoding = mapping->encoding;
- FontMapReversePtr reverse = NULL;
- unsigned int **map = NULL;
- int i, j, k;
-
- if(encoding == NULL) goto bail;
-
- map = calloc(FONTENC_SEGMENTS, sizeof(int*));
- if(map == NULL) goto bail;
-
- if(encoding->row_size == 0) {
- for(i = encoding->first; i < encoding->size; i++) {
- k = FontEncRecode(i, mapping);
- if(k != 0)
- if(!tree_set(map, k, i))
- goto bail;
- }
- } else {
- for(i = encoding->first; i < encoding->size; i++) {
- for(j = encoding->first_col; j < encoding->row_size; j++) {
- k = FontEncRecode(i*256 + j, mapping);
- if(k != 0)
- if(!tree_set(map, k, i*256+j))
- goto bail;
- }
- }
- }
-
- reverse = malloc(sizeof(FontMapReverseRec));
- if(!reverse) goto bail;
-
- reverse->reverse = reverse_reverse;
- reverse->data = map;
- return reverse;
-
- bail:
- if(map)
- xfree(map);
- if(reverse)
- xfree(reverse);
- return NULL;
-}
-
-void
-FontMapReverseFree(FontMapReversePtr delendum)
-{
- unsigned int **map = (unsigned int**)delendum;
- int i;
-
- if(map == NULL)
- return;
-
- for(i = 0; i < FONTENC_SEGMENTS; i++)
- if(map[i] != NULL)
- xfree(map[i]);
-
- xfree(map);
- return;
-}
diff --git a/nx-X11/lib/font/fontfile/fontencI.h b/nx-X11/lib/font/fontfile/fontencI.h
deleted file mode 100644
index bd35a1fbb..000000000
--- a/nx-X11/lib/font/fontfile/fontencI.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-Copyright (c) 1998-2001 by Juliusz Chroboczek
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-/* $XFree86: xc/lib/font/fontfile/fontencI.h,v 1.3 1999/04/25 10:01:43 dawes Exp $ */
-
-/* Private types and functions for the encoding code. */
-/* Used by the files `fontenc.h' and `encparse.h' */
-
-typedef struct _FontEncSimpleMap {
- unsigned len; /* might be 0x10000 */
- unsigned short row_size;
- unsigned short first;
- unsigned short *map;
-} FontEncSimpleMapRec, *FontEncSimpleMapPtr;
-
-typedef struct _FontEncSimpleName {
- unsigned len;
- unsigned short first;
- char **map;
-} FontEncSimpleNameRec, *FontEncSimpleNamePtr;
-
-unsigned FontEncSimpleRecode(unsigned, void*);
-unsigned FontEncUndefinedRecode(unsigned, void*);
-char *FontEncSimpleName(unsigned, void*);
-char *FontEncUndefinedName(unsigned, void*);
-
-FontEncPtr FontEncReallyLoad(const char*, const char*);
diff --git a/nx-X11/lib/font/fontfile/fontencc.c b/nx-X11/lib/font/fontfile/fontencc.c
deleted file mode 100644
index b54079acf..000000000
--- a/nx-X11/lib/font/fontfile/fontencc.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-Copyright (c) 1998-2001 by Juliusz Chroboczek
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-/* $XFree86: xc/lib/font/fontfile/fontencc.c,v 1.1 2001/08/13 21:46:47 dawes Exp $ */
-
-/* Binary compatibility code. */
-
-/* This file includes code to make modules compiled for earlier
- versions of the fontenc interfaces link with this one. It does
- *not* provide source compatibility, as many of the data structures
- now have different names. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fontenc.h>
-#include <X11/fonts/fontencc.h>
-
-extern void ErrorF(const char *f, ...);
-
-char *
-font_encoding_from_xlfd(const char * name, int length)
-{
- return FontEncFromXLFD(name, length);
-}
-
-FontEncPtr
-font_encoding_find(const char *encoding_name, const char *filename)
-{
- return FontEncFind(encoding_name, filename);
-}
-
-unsigned
-font_encoding_recode(unsigned code,
- FontEncPtr encoding, FontMapPtr mapping)
-{
- if(encoding != mapping->encoding) {
- ErrorF("Inconsistent mapping/encoding\n");
- return 0;
- }
- return FontEncRecode(code, mapping);
-}
-
-char *
-font_encoding_name(unsigned code,
- FontEncPtr encoding, FontMapPtr mapping)
-{
- if(encoding != mapping->encoding) {
- ErrorF("Inconsistent mapping/encoding\n");
- return 0;
- }
- return FontEncName(code, mapping);
-}
-
-char **
-identifyEncodingFile(const char *filename)
-{
- return FontEncIdentify(filename);
-}
diff --git a/nx-X11/lib/font/fontfile/fontfile.c b/nx-X11/lib/font/fontfile/fontfile.c
deleted file mode 100644
index 2356c0595..000000000
--- a/nx-X11/lib/font/fontfile/fontfile.c
+++ /dev/null
@@ -1,1147 +0,0 @@
-/* $XdotOrg: xc/lib/font/fontfile/fontfile.c,v 1.5 2005/07/09 06:36:13 keithp Exp $ */
-/* $Xorg: fontfile.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1991, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/fontfile.c,v 3.21 2003/12/02 19:50:40 dawes Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fntfilst.h>
-#ifdef WIN32
-#include <ctype.h>
-#endif
-
-/*
- * Map FPE functions to renderer functions
- */
-
-static int FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont,
- int flags, FontEntryPtr entry,
- fsBitmapFormat format,
- fsBitmapFormatMask fmask,
- FontPtr non_cachable_font);
-
-int
-FontFileNameCheck (char *name)
-{
-#ifndef NCD
-#if defined(__UNIXOS2__) || defined(WIN32)
- /* OS/2 uses D:/... as a path name for fonts, so accept this as a valid
- * path if it starts with a letter and a colon. Same applies for WIN32
- */
- if (isalpha(*name) && name[1]==':')
- return TRUE;
-#endif
- return *name == '/';
-#else
- return ((strcmp(name, "built-ins") == 0) || (*name == '/'));
-#endif
-}
-
-int
-FontFileInitFPE (FontPathElementPtr fpe)
-{
- int status;
- FontDirectoryPtr dir;
-
- status = FontFileReadDirectory (fpe->name, &dir);
- if (status == Successful)
- {
- if (dir->nonScalable.used > 0)
- if (!FontFileRegisterBitmapSource (fpe))
- {
- FontFileFreeFPE (fpe);
- return AllocError;
- }
- fpe->private = (pointer) dir;
- }
- return status;
-}
-
-/* ARGSUSED */
-int
-FontFileResetFPE (FontPathElementPtr fpe)
-{
- FontDirectoryPtr dir;
-
- dir = (FontDirectoryPtr) fpe->private;
- /*
- * The reset must fail for bitmap fonts because they get cleared when
- * the path is set.
- */
- if (FontFileDirectoryChanged (dir))
- {
- /* can't do it, so tell the caller to close and re-open */
- return FPEResetFailed;
- }
- else
- {
- if (dir->nonScalable.used > 0)
- if (!FontFileRegisterBitmapSource (fpe))
- {
- return FPEResetFailed;
- }
- return Successful;
- }
-}
-
-int
-FontFileFreeFPE (FontPathElementPtr fpe)
-{
- FontFileUnregisterBitmapSource (fpe);
- FontFileFreeDir ((FontDirectoryPtr) fpe->private);
- return Successful;
-}
-
-static int
-transfer_values_to_alias(char *entryname, int entrynamelength,
- char *resolvedname,
- char **aliasName, FontScalablePtr vals)
-{
- static char aliasname[MAXFONTNAMELEN];
- int nameok = 1, len;
- char lowerName[MAXFONTNAMELEN];
-
- *aliasName = resolvedname;
- if ((len = strlen(*aliasName)) <= MAXFONTNAMELEN &&
- (entrynamelength < MAXFONTNAMELEN) &&
- FontFileCountDashes (*aliasName, len) == 14)
- {
- FontScalableRec tmpVals;
- FontScalableRec tmpVals2;
-
- tmpVals2 = *vals;
-
- /* If we're aliasing a scalable name, transfer values
- from the name into the destination alias, multiplying
- by matrices that appear in the alias. */
-
- CopyISOLatin1Lowered (lowerName, entryname,
- entrynamelength);
- lowerName[entrynamelength] = '\0';
-
- if (FontParseXLFDName(lowerName, &tmpVals,
- FONT_XLFD_REPLACE_NONE) &&
- !tmpVals.values_supplied &&
- FontParseXLFDName(*aliasName, &tmpVals,
- FONT_XLFD_REPLACE_NONE))
- {
- double *matrix = 0, tempmatrix[4];
-
- /* Use a matrix iff exactly one is defined */
- if ((tmpVals.values_supplied & PIXELSIZE_MASK) ==
- PIXELSIZE_ARRAY &&
- !(tmpVals.values_supplied & POINTSIZE_MASK))
- matrix = tmpVals.pixel_matrix;
- else if ((tmpVals.values_supplied & POINTSIZE_MASK) ==
- POINTSIZE_ARRAY &&
- !(tmpVals.values_supplied & PIXELSIZE_MASK))
- matrix = tmpVals.point_matrix;
-
- /* If matrix given in the alias, compute new point
- and/or pixel matrices */
- if (matrix)
- {
- /* Complete the XLFD name to avoid potential
- gotchas */
- if (FontFileCompleteXLFD(&tmpVals2, &tmpVals2))
- {
- tempmatrix[0] =
- matrix[0] * tmpVals2.point_matrix[0] +
- matrix[1] * tmpVals2.point_matrix[2];
- tempmatrix[1] =
- matrix[0] * tmpVals2.point_matrix[1] +
- matrix[1] * tmpVals2.point_matrix[3];
- tempmatrix[2] =
- matrix[2] * tmpVals2.point_matrix[0] +
- matrix[3] * tmpVals2.point_matrix[2];
- tempmatrix[3] =
- matrix[2] * tmpVals2.point_matrix[1] +
- matrix[3] * tmpVals2.point_matrix[3];
- tmpVals2.point_matrix[0] = tempmatrix[0];
- tmpVals2.point_matrix[1] = tempmatrix[1];
- tmpVals2.point_matrix[2] = tempmatrix[2];
- tmpVals2.point_matrix[3] = tempmatrix[3];
-
- tempmatrix[0] =
- matrix[0] * tmpVals2.pixel_matrix[0] +
- matrix[1] * tmpVals2.pixel_matrix[2];
- tempmatrix[1] =
- matrix[0] * tmpVals2.pixel_matrix[1] +
- matrix[1] * tmpVals2.pixel_matrix[3];
- tempmatrix[2] =
- matrix[2] * tmpVals2.pixel_matrix[0] +
- matrix[3] * tmpVals2.pixel_matrix[2];
- tempmatrix[3] =
- matrix[2] * tmpVals2.pixel_matrix[1] +
- matrix[3] * tmpVals2.pixel_matrix[3];
- tmpVals2.pixel_matrix[0] = tempmatrix[0];
- tmpVals2.pixel_matrix[1] = tempmatrix[1];
- tmpVals2.pixel_matrix[2] = tempmatrix[2];
- tmpVals2.pixel_matrix[3] = tempmatrix[3];
-
- tmpVals2.values_supplied =
- (tmpVals2.values_supplied &
- ~(PIXELSIZE_MASK | POINTSIZE_MASK)) |
- PIXELSIZE_ARRAY | POINTSIZE_ARRAY;
- }
- else
- nameok = 0;
- }
-
- CopyISOLatin1Lowered (aliasname, *aliasName, len + 1);
- if (nameok && FontParseXLFDName(aliasname, &tmpVals2,
- FONT_XLFD_REPLACE_VALUE))
- /* Return a version of the aliasname that has
- had the vals stuffed into it. To avoid
- memory leak, this alias name lives in a
- static buffer. The caller needs to be done
- with this buffer before this procedure is
- called again to avoid reentrancy problems. */
- *aliasName = aliasname;
- }
- }
- return nameok;
-}
-
-/* ARGSUSED */
-int
-FontFileOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
- char *name, int namelen,
- fsBitmapFormat format, fsBitmapFormatMask fmask,
- XID id, FontPtr *pFont, char **aliasName,
- FontPtr non_cachable_font)
-{
- FontDirectoryPtr dir;
- char lowerName[MAXFONTNAMELEN];
- char fileName[MAXFONTFILENAMELEN*2 + 1];
- FontNameRec tmpName;
- FontEntryPtr entry;
- FontScalableRec vals;
- FontScalableEntryPtr scalable;
- FontScaledPtr scaled;
- FontBitmapEntryPtr bitmap;
- int ret;
- Bool noSpecificSize;
- int nranges;
- fsRange *ranges;
-
- if (namelen >= MAXFONTNAMELEN)
- return AllocError;
- dir = (FontDirectoryPtr) fpe->private;
-
- /* Match non-scalable pattern */
- CopyISOLatin1Lowered (lowerName, name, namelen);
- lowerName[namelen] = '\0';
- ranges = FontParseRanges(lowerName, &nranges);
- tmpName.name = lowerName;
- tmpName.length = namelen;
- tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
- if (!FontParseXLFDName(lowerName, &vals, FONT_XLFD_REPLACE_NONE))
- bzero(&vals, sizeof(vals));
- if (!(entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName)) &&
- tmpName.ndashes == 14 &&
- FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO))
- {
- tmpName.length = strlen(lowerName);
- entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName);
- }
-
- if (entry)
- {
- switch (entry->type) {
- case FONT_ENTRY_BITMAP:
- bitmap = &entry->u.bitmap;
- if (bitmap->pFont)
- {
- *pFont = bitmap->pFont;
- (*pFont)->fpe = fpe;
- ret = Successful;
- }
- else
- {
- ret = FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format,
- fmask, non_cachable_font);
- if (ret == Successful && *pFont)
- (*pFont)->fpe = fpe;
- }
- break;
- case FONT_ENTRY_ALIAS:
- vals.nranges = nranges;
- vals.ranges = ranges;
- transfer_values_to_alias(entry->name.name, entry->name.length,
- entry->u.alias.resolved, aliasName, &vals);
- ret = FontNameAlias;
- break;
-#ifdef NOTYET
- case FONT_ENTRY_BC:
- bc = &entry->u.bc;
- entry = bc->entry;
- ret = (*scalable->renderer->OpenScalable)
- (fpe, pFont, flags, entry, &bc->vals, format, fmask,
- non_cachable_font);
- if (ret == Successful && *pFont)
- (*pFont)->fpe = fpe;
- break;
-#endif
- default:
- ret = BadFontName;
- }
- }
- else
- {
- ret = BadFontName;
- }
-
- if (ret != BadFontName)
- {
- if (ranges) xfree(ranges);
- return ret;
- }
-
- /* Match XLFD patterns */
- CopyISOLatin1Lowered (lowerName, name, namelen);
- lowerName[namelen] = '\0';
- tmpName.name = lowerName;
- tmpName.length = namelen;
- tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
- if (!FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO) ||
- !(tmpName.length = strlen (lowerName),
- entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName,
- &vals))) {
- CopyISOLatin1Lowered (lowerName, name, namelen);
- lowerName[namelen] = '\0';
- tmpName.name = lowerName;
- tmpName.length = namelen;
- tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
- entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, &vals);
- if (entry)
- {
- strcpy(lowerName, entry->name.name);
- tmpName.name = lowerName;
- tmpName.length = entry->name.length;
- tmpName.ndashes = entry->name.ndashes;
- }
- }
- if (entry)
- {
- noSpecificSize = FALSE; /* TRUE breaks XLFD enhancements */
- if (entry->type == FONT_ENTRY_SCALABLE &&
- FontFileCompleteXLFD (&vals, &entry->u.scalable.extra->defaults))
- {
- scalable = &entry->u.scalable;
- if ((vals.values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
- (vals.values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY ||
- (vals.values_supplied &
- ~SIZE_SPECIFY_MASK & ~CHARSUBSET_SPECIFIED))
- scaled = 0;
- else
- scaled = FontFileFindScaledInstance (entry, &vals,
- noSpecificSize);
- /*
- * A scaled instance can occur one of two ways:
- *
- * Either the font has been scaled to this
- * size already, in which case scaled->pFont
- * will point at that font.
- *
- * Or a bitmap instance in this size exists,
- * which is handled as if we got a pattern
- * matching the bitmap font name.
- */
- if (scaled)
- {
- if (scaled->pFont)
- {
- *pFont = scaled->pFont;
- (*pFont)->fpe = fpe;
- ret = Successful;
- }
- else if (scaled->bitmap)
- {
- entry = scaled->bitmap;
- bitmap = &entry->u.bitmap;
- if (bitmap->pFont)
- {
- *pFont = bitmap->pFont;
- (*pFont)->fpe = fpe;
- ret = Successful;
- }
- else
- {
- ret = FontFileOpenBitmapNCF (fpe, pFont, flags, entry,
- format, fmask,
- non_cachable_font);
- if (ret == Successful && *pFont)
- (*pFont)->fpe = fpe;
- }
- }
- else /* "cannot" happen */
- {
- ret = BadFontName;
- }
- }
- else
- {
- ret = FontFileMatchBitmapSource (fpe, pFont, flags, entry, &tmpName, &vals, format, fmask, noSpecificSize);
- if (ret != Successful)
- {
- char origName[MAXFONTNAMELEN];
-
- CopyISOLatin1Lowered (origName, name, namelen);
- origName[namelen] = '\0';
-
- /* Pass the original XLFD name in the vals
- structure; the rasterizer is free to examine it
- for hidden meanings. This information will not
- be saved in the scaled-instances table. */
-
- vals.xlfdName = origName;
- vals.ranges = ranges;
- vals.nranges = nranges;
-
- if (strlen(dir->directory) + strlen(scalable->fileName) >=
- sizeof(fileName)) {
- ret = BadFontName;
- } else {
- strcpy (fileName, dir->directory);
- strcat (fileName, scalable->fileName);
- ret = (*scalable->renderer->OpenScalable) (fpe, pFont,
- flags, entry, fileName, &vals, format, fmask,
- non_cachable_font);
- }
-
- /* In case rasterizer does something bad because of
- charset subsetting... */
- if (ret == Successful &&
- ((*pFont)->info.firstCol > (*pFont)->info.lastCol ||
- (*pFont)->info.firstRow > (*pFont)->info.lastRow))
- {
- (*(*pFont)->unload_font)(*pFont);
- ret = BadFontName;
- }
- /* Save the instance */
- if (ret == Successful)
- {
- if (FontFileAddScaledInstance (entry, &vals,
- *pFont, (char *) 0))
- ranges = 0;
- else
- (*pFont)->fpePrivate = (pointer) 0;
- (*pFont)->fpe = fpe;
- }
- }
- }
- }
- }
- else
- ret = BadFontName;
-
- if (ranges)
- xfree(ranges);
- return ret;
-}
-
-/* ARGSUSED */
-void
-FontFileCloseFont (FontPathElementPtr fpe, FontPtr pFont)
-{
- FontEntryPtr entry;
-
- if ((entry = (FontEntryPtr) pFont->fpePrivate)) {
- switch (entry->type) {
- case FONT_ENTRY_SCALABLE:
- FontFileRemoveScaledInstance (entry, pFont);
- break;
- case FONT_ENTRY_BITMAP:
- entry->u.bitmap.pFont = 0;
- break;
- default:
- /* "cannot" happen */
- break;
- }
- pFont->fpePrivate = 0;
- }
- (*pFont->unload_font) (pFont);
-}
-
-static int
-FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont,
- int flags, FontEntryPtr entry,
- fsBitmapFormat format, fsBitmapFormatMask fmask,
- FontPtr non_cachable_font)
-{
- FontBitmapEntryPtr bitmap;
- char fileName[MAXFONTFILENAMELEN*2+1];
- int ret;
- FontDirectoryPtr dir;
-
- dir = (FontDirectoryPtr) fpe->private;
- bitmap = &entry->u.bitmap;
- if(!bitmap || !bitmap->renderer->OpenBitmap)
- return BadFontName;
- if (strlen(dir->directory) + strlen(bitmap->fileName) >= sizeof(fileName))
- return BadFontName;
- strcpy (fileName, dir->directory);
- strcat (fileName, bitmap->fileName);
- ret = (*bitmap->renderer->OpenBitmap)
- (fpe, pFont, flags, entry, fileName, format, fmask,
- non_cachable_font);
- if (ret == Successful)
- {
- bitmap->pFont = *pFont;
- (*pFont)->fpePrivate = (pointer) entry;
- }
- return ret;
-}
-
-int
-FontFileOpenBitmap (FontPathElementPtr fpe, FontPtr *pFont,
- int flags, FontEntryPtr entry,
- fsBitmapFormat format, fsBitmapFormatMask fmask)
-{
- return FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format, fmask,
- (FontPtr)0);
-}
-
-static int
-FontFileGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo,
- FontEntryPtr entry)
-{
- FontBitmapEntryPtr bitmap;
- char fileName[MAXFONTFILENAMELEN*2+1];
- int ret;
- FontDirectoryPtr dir;
-
- dir = (FontDirectoryPtr) fpe->private;
- bitmap = &entry->u.bitmap;
- if (!bitmap || !bitmap->renderer->GetInfoBitmap)
- return BadFontName;
- if (strlen(dir->directory) + strlen(bitmap->fileName) >= sizeof(fileName))
- return BadFontName;
- strcpy (fileName, dir->directory);
- strcat (fileName, bitmap->fileName);
- ret = (*bitmap->renderer->GetInfoBitmap) (fpe, pFontInfo, entry, fileName);
- return ret;
-}
-
-static void
-_FontFileAddScalableNames(FontNamesPtr names, FontNamesPtr scaleNames,
- FontNamePtr nameptr, char *zeroChars,
- FontScalablePtr vals, fsRange *ranges,
- int nranges, int *max)
-{
- int i;
- FontScalableRec zeroVals, tmpVals;
- for (i = 0; i < scaleNames->nnames; i++)
- {
- char nameChars[MAXFONTNAMELEN];
- if (!*max)
- return;
- FontParseXLFDName (scaleNames->names[i], &zeroVals,
- FONT_XLFD_REPLACE_NONE);
- tmpVals = *vals;
- if (FontFileCompleteXLFD (&tmpVals, &zeroVals))
- {
- --*max;
-
- strcpy (nameChars, scaleNames->names[i]);
- if ((vals->values_supplied & PIXELSIZE_MASK) ||
- !(vals->values_supplied & PIXELSIZE_WILDCARD) ||
- vals->y == 0)
- {
- tmpVals.values_supplied =
- (tmpVals.values_supplied & ~PIXELSIZE_MASK) |
- (vals->values_supplied & PIXELSIZE_MASK);
- tmpVals.pixel_matrix[0] = vals->pixel_matrix[0];
- tmpVals.pixel_matrix[1] = vals->pixel_matrix[1];
- tmpVals.pixel_matrix[2] = vals->pixel_matrix[2];
- tmpVals.pixel_matrix[3] = vals->pixel_matrix[3];
- }
- if ((vals->values_supplied & POINTSIZE_MASK) ||
- !(vals->values_supplied & POINTSIZE_WILDCARD) ||
- vals->y == 0)
- {
- tmpVals.values_supplied =
- (tmpVals.values_supplied & ~POINTSIZE_MASK) |
- (vals->values_supplied & POINTSIZE_MASK);
- tmpVals.point_matrix[0] = vals->point_matrix[0];
- tmpVals.point_matrix[1] = vals->point_matrix[1];
- tmpVals.point_matrix[2] = vals->point_matrix[2];
- tmpVals.point_matrix[3] = vals->point_matrix[3];
- }
- if (vals->width <= 0)
- tmpVals.width = 0;
- if (vals->x == 0)
- tmpVals.x = 0;
- if (vals->y == 0)
- tmpVals.y = 0;
- tmpVals.ranges = ranges;
- tmpVals.nranges = nranges;
- FontParseXLFDName (nameChars, &tmpVals,
- FONT_XLFD_REPLACE_VALUE);
- /* If we're marking aliases with negative lengths, we
- need to concoct a valid target name to follow it.
- Otherwise we're done. */
- if (scaleNames->length[i] >= 0)
- {
- (void) AddFontNamesName (names, nameChars,
- strlen (nameChars));
- /* If our original pattern matches the name from
- the table and that name doesn't duplicate what
- we just added, add the name from the table */
- if (strcmp(nameChars, scaleNames->names[i]) &&
- FontFileMatchName(scaleNames->names[i],
- scaleNames->length[i],
- nameptr) &&
- *max)
- {
- --*max;
- (void) AddFontNamesName (names, scaleNames->names[i],
- scaleNames->length[i]);
- }
- }
- else
- {
- char *aliasName;
- vals->ranges = ranges;
- vals->nranges = nranges;
- if (transfer_values_to_alias(zeroChars,
- strlen(zeroChars),
- scaleNames->names[++i],
- &aliasName, vals))
- {
- (void) AddFontNamesName (names, nameChars,
- strlen (nameChars));
- names->length[names->nnames - 1] =
- -names->length[names->nnames - 1];
- (void) AddFontNamesName (names, aliasName,
- strlen (aliasName));
- /* If our original pattern matches the name from
- the table and that name doesn't duplicate what
- we just added, add the name from the table */
- if (strcmp(nameChars, scaleNames->names[i - 1]) &&
- FontFileMatchName(scaleNames->names[i - 1],
- -scaleNames->length[i - 1],
- nameptr) &&
- *max)
- {
- --*max;
- (void) AddFontNamesName (names,
- scaleNames->names[i - 1],
- -scaleNames->length[i - 1]);
- names->length[names->nnames - 1] =
- -names->length[names->nnames - 1];
- (void) AddFontNamesName (names, aliasName,
- strlen (aliasName));
- }
- }
- }
- }
- }
-}
-
-/* ARGSUSED */
-static int
-_FontFileListFonts (pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max, FontNamesPtr names,
- int mark_aliases)
-{
- FontDirectoryPtr dir;
- char lowerChars[MAXFONTNAMELEN], zeroChars[MAXFONTNAMELEN];
- FontNameRec lowerName;
- FontNameRec zeroName;
- FontNamesPtr scaleNames;
- FontScalableRec vals;
- fsRange *ranges;
- int nranges;
- int result = BadFontName;
-
- if (len >= MAXFONTNAMELEN)
- return AllocError;
- dir = (FontDirectoryPtr) fpe->private;
- CopyISOLatin1Lowered (lowerChars, pat, len);
- lowerChars[len] = '\0';
- lowerName.name = lowerChars;
- lowerName.length = len;
- lowerName.ndashes = FontFileCountDashes (lowerChars, len);
-
- /* Match XLFD patterns */
-
- strcpy (zeroChars, lowerChars);
- if (lowerName.ndashes == 14 &&
- FontParseXLFDName (zeroChars, &vals, FONT_XLFD_REPLACE_ZERO))
- {
- ranges = FontParseRanges(lowerChars, &nranges);
- result = FontFileFindNamesInScalableDir (&dir->nonScalable,
- &lowerName, max, names,
- (FontScalablePtr)0,
- (mark_aliases ?
- LIST_ALIASES_AND_TARGET_NAMES :
- NORMAL_ALIAS_BEHAVIOR) |
- IGNORE_SCALABLE_ALIASES,
- &max);
- zeroName.name = zeroChars;
- zeroName.length = strlen (zeroChars);
- zeroName.ndashes = lowerName.ndashes;
-
- /* Look for scalable names and aliases, adding scaled instances of
- them to the output */
-
- /* Scalable names... */
- scaleNames = MakeFontNamesRecord (0);
- if (!scaleNames)
- {
- if (ranges) xfree(ranges);
- return AllocError;
- }
- FontFileFindNamesInScalableDir (&dir->scalable, &zeroName, max,
- scaleNames, &vals,
- mark_aliases ?
- LIST_ALIASES_AND_TARGET_NAMES :
- NORMAL_ALIAS_BEHAVIOR, (int *)0);
- _FontFileAddScalableNames(names, scaleNames, &lowerName,
- zeroChars, &vals, ranges, nranges,
- &max);
- FreeFontNames (scaleNames);
-
- /* Scalable aliases... */
- scaleNames = MakeFontNamesRecord (0);
- if (!scaleNames)
- {
- if (ranges) xfree(ranges);
- return AllocError;
- }
- FontFileFindNamesInScalableDir (&dir->nonScalable, &zeroName,
- max, scaleNames, &vals,
- mark_aliases ?
- LIST_ALIASES_AND_TARGET_NAMES :
- NORMAL_ALIAS_BEHAVIOR, (int *)0);
- _FontFileAddScalableNames(names, scaleNames, &lowerName,
- zeroChars, &vals, ranges, nranges,
- &max);
- FreeFontNames (scaleNames);
-
- if (ranges) xfree(ranges);
- }
- else
- {
- result = FontFileFindNamesInScalableDir (&dir->nonScalable,
- &lowerName, max, names,
- (FontScalablePtr)0,
- mark_aliases ?
- LIST_ALIASES_AND_TARGET_NAMES :
- NORMAL_ALIAS_BEHAVIOR,
- &max);
- if (result == Successful)
- result = FontFileFindNamesInScalableDir (&dir->scalable,
- &lowerName, max, names,
- (FontScalablePtr)0,
- mark_aliases ?
- LIST_ALIASES_AND_TARGET_NAMES :
- NORMAL_ALIAS_BEHAVIOR, (int *)0);
- }
- return result;
-}
-
-typedef struct _LFWIData {
- FontNamesPtr names;
- int current;
-} LFWIDataRec, *LFWIDataPtr;
-
-int
-FontFileListFonts (pointer client, FontPathElementPtr fpe, char *pat,
- int len, int max, FontNamesPtr names)
-{
- return _FontFileListFonts (client, fpe, pat, len, max, names, 0);
-}
-
-int
-FontFileStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
- pointer *privatep)
-{
- LFWIDataPtr data;
- int ret;
-
- data = (LFWIDataPtr) xalloc (sizeof *data);
- if (!data)
- return AllocError;
- data->names = MakeFontNamesRecord (0);
- if (!data->names)
- {
- xfree (data);
- return AllocError;
- }
- ret = FontFileListFonts (client, fpe, pat, len, max, data->names);
- if (ret != Successful)
- {
- FreeFontNames (data->names);
- xfree (data);
- return ret;
- }
- data->current = 0;
- *privatep = (pointer) data;
- return Successful;
-}
-
-/* ARGSUSED */
-static int
-FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe,
- char **namep, int *namelenp,
- FontInfoPtr *pFontInfo)
-{
- FontDirectoryPtr dir;
- char lowerName[MAXFONTNAMELEN];
- char fileName[MAXFONTFILENAMELEN*2 + 1];
- FontNameRec tmpName;
- FontEntryPtr entry;
- FontScalableRec vals;
- FontScalableEntryPtr scalable;
- FontScaledPtr scaled;
- FontBitmapEntryPtr bitmap;
- int ret;
- Bool noSpecificSize;
- int nranges;
- fsRange *ranges;
-
- char *name = *namep;
- int namelen = *namelenp;
-
- if (namelen >= MAXFONTNAMELEN)
- return AllocError;
- dir = (FontDirectoryPtr) fpe->private;
-
- /* Match non-scalable pattern */
- CopyISOLatin1Lowered (lowerName, name, namelen);
- lowerName[namelen] = '\0';
- ranges = FontParseRanges(lowerName, &nranges);
- tmpName.name = lowerName;
- tmpName.length = namelen;
- tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
- if (!FontParseXLFDName(lowerName, &vals, FONT_XLFD_REPLACE_NONE))
- bzero(&vals, sizeof(vals));
- if (!(entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName)) &&
- tmpName.ndashes == 14 &&
- FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO))
- {
- tmpName.length = strlen(lowerName);
- entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName);
- }
-
- if (entry)
- {
- switch (entry->type) {
- case FONT_ENTRY_BITMAP:
- bitmap = &entry->u.bitmap;
- if (bitmap->pFont)
- {
- *pFontInfo = &bitmap->pFont->info;
- ret = Successful;
- }
- else
- {
- ret = FontFileGetInfoBitmap (fpe, *pFontInfo, entry);
- }
- break;
- case FONT_ENTRY_ALIAS:
- vals.nranges = nranges;
- vals.ranges = ranges;
- transfer_values_to_alias(entry->name.name, entry->name.length,
- entry->u.alias.resolved, namep, &vals);
- *namelenp = strlen (*namep);
- ret = FontNameAlias;
- break;
-#ifdef NOTYET
- case FONT_ENTRY_BC:
- /* no LFWI for this yet */
- bc = &entry->u.bc;
- entry = bc->entry;
- /* Make a new scaled instance */
- if (strlen(dir->directory) + strlen(scalable->fileName) >=
- sizeof(fileName)) {
- ret = BadFontName;
- } else {
- strcpy (fileName, dir->directory);
- strcat (fileName, scalable->fileName);
- ret = (*scalable->renderer->GetInfoScalable)
- (fpe, *pFontInfo, entry, tmpName, fileName, &bc->vals);
- }
- break;
-#endif
- default:
- ret = BadFontName;
- }
- }
- else
- {
- ret = BadFontName;
- }
-
- if (ret != BadFontName)
- {
- if (ranges) xfree(ranges);
- return ret;
- }
-
- /* Match XLFD patterns */
- CopyISOLatin1Lowered (lowerName, name, namelen);
- lowerName[namelen] = '\0';
- tmpName.name = lowerName;
- tmpName.length = namelen;
- tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
- if (!FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO) ||
- !(tmpName.length = strlen (lowerName),
- entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName,
- &vals))) {
- CopyISOLatin1Lowered (lowerName, name, namelen);
- lowerName[namelen] = '\0';
- tmpName.name = lowerName;
- tmpName.length = namelen;
- tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
- entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, &vals);
- if (entry)
- {
- strcpy(lowerName, entry->name.name);
- tmpName.name = lowerName;
- tmpName.length = entry->name.length;
- tmpName.ndashes = entry->name.ndashes;
- }
- }
-
- if (entry)
- {
- noSpecificSize = FALSE; /* TRUE breaks XLFD enhancements */
- if (entry && entry->type == FONT_ENTRY_SCALABLE &&
- FontFileCompleteXLFD (&vals, &entry->u.scalable.extra->defaults))
- {
- scalable = &entry->u.scalable;
- scaled = FontFileFindScaledInstance (entry, &vals, noSpecificSize);
- /*
- * A scaled instance can occur one of two ways:
- *
- * Either the font has been scaled to this
- * size already, in which case scaled->pFont
- * will point at that font.
- *
- * Or a bitmap instance in this size exists,
- * which is handled as if we got a pattern
- * matching the bitmap font name.
- */
- if (scaled)
- {
- if (scaled->pFont)
- {
- *pFontInfo = &scaled->pFont->info;
- ret = Successful;
- }
- else if (scaled->bitmap)
- {
- entry = scaled->bitmap;
- bitmap = &entry->u.bitmap;
- if (bitmap->pFont)
- {
- *pFontInfo = &bitmap->pFont->info;
- ret = Successful;
- }
- else
- {
- ret = FontFileGetInfoBitmap (fpe, *pFontInfo, entry);
- }
- }
- else /* "cannot" happen */
- {
- ret = BadFontName;
- }
- }
- else
- {
-#ifdef NOTDEF
- /* no special case yet */
- ret = FontFileMatchBitmapSource (fpe, pFont, flags, entry, &vals, format, fmask, noSpecificSize);
- if (ret != Successful)
-#endif
- {
- char origName[MAXFONTNAMELEN];
-
- CopyISOLatin1Lowered (origName, name, namelen);
- origName[namelen] = '\0';
- vals.xlfdName = origName;
- vals.ranges = ranges;
- vals.nranges = nranges;
-
- /* Make a new scaled instance */
- if (strlen(dir->directory) + strlen(scalable->fileName) >=
- sizeof(fileName)) {
- ret = BadFontName;
- } else {
- strcpy (fileName, dir->directory);
- strcat (fileName, scalable->fileName);
- ret = (*scalable->renderer->GetInfoScalable)
- (fpe, *pFontInfo, entry, &tmpName, fileName, &vals);
- }
- if (ranges) xfree(ranges);
- }
- }
- if (ret == Successful) return ret;
- }
- CopyISOLatin1Lowered (lowerName, name, namelen);
- tmpName.length = namelen;
- }
- else
- ret = BadFontName;
-
- if (ranges)
- xfree(ranges);
- return ret;
-}
-
-int
-FontFileListNextFontWithInfo(pointer client, FontPathElementPtr fpe,
- char **namep, int *namelenp,
- FontInfoPtr *pFontInfo,
- int *numFonts, pointer private)
-{
- LFWIDataPtr data = (LFWIDataPtr) private;
- int ret;
- char *name;
- int namelen;
-
- if (data->current == data->names->nnames)
- {
- FreeFontNames (data->names);
- xfree (data);
- return BadFontName;
- }
- name = data->names->names[data->current];
- namelen = data->names->length[data->current];
- ret = FontFileListOneFontWithInfo (client, fpe, &name, &namelen, pFontInfo);
- if (ret == BadFontName)
- ret = AllocError;
- *namep = name;
- *namelenp = namelen;
- ++data->current;
- *numFonts = data->names->nnames - data->current;
- return ret;
-}
-
-int
-FontFileStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
- pointer *privatep)
-{
- LFWIDataPtr data;
- int ret;
-
- data = (LFWIDataPtr) xalloc (sizeof *data);
- if (!data)
- return AllocError;
- data->names = MakeFontNamesRecord (0);
- if (!data->names)
- {
- xfree (data);
- return AllocError;
- }
- ret = _FontFileListFonts (client, fpe, pat, len, max, data->names, 1);
- if (ret != Successful)
- {
- FreeFontNames (data->names);
- xfree (data);
- return ret;
- }
- data->current = 0;
- *privatep = (pointer) data;
- return Successful;
-}
-
-int
-FontFileListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
- char **namep, int *namelenp, char **resolvedp,
- int *resolvedlenp, pointer private)
-{
- LFWIDataPtr data = (LFWIDataPtr) private;
- int ret;
- char *name;
- int namelen;
-
- if (data->current == data->names->nnames)
- {
- FreeFontNames (data->names);
- xfree (data);
- return BadFontName;
- }
- name = data->names->names[data->current];
- namelen = data->names->length[data->current];
-
- /* If this is a real font name... */
- if (namelen >= 0)
- {
- *namep = name;
- *namelenp = namelen;
- ret = Successful;
- }
- /* Else if an alias */
- else
- {
- /* Tell the caller that this is an alias... let him resolve it to
- see if it's valid */
- *namep = name;
- *namelenp = -namelen;
- *resolvedp = data->names->names[++data->current];
- *resolvedlenp = data->names->length[data->current];
- ret = FontNameAlias;
- }
-
- ++data->current;
- return ret;
-}
-
-void
-FontFileRegisterLocalFpeFunctions (void)
-{
- RegisterFPEFunctions(FontFileNameCheck,
- FontFileInitFPE,
- FontFileFreeFPE,
- FontFileResetFPE,
- FontFileOpenFont,
- FontFileCloseFont,
- FontFileListFonts,
- FontFileStartListFontsWithInfo,
- FontFileListNextFontWithInfo,
- NULL,
- NULL,
- NULL,
- FontFileStartListFontsAndAliases,
- FontFileListNextFontOrAlias,
- FontFileEmptyBitmapSource);
-}
diff --git a/nx-X11/lib/font/fontfile/fontscale.c b/nx-X11/lib/font/fontfile/fontscale.c
deleted file mode 100644
index 8e9de513d..000000000
--- a/nx-X11/lib/font/fontfile/fontscale.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/* $Xorg: fontscale.c,v 1.5 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1991, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/fontscale.c,v 3.9 2001/08/27 19:49:54 dawes Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fntfilst.h>
-#ifdef _XOPEN_SOURCE
-#include <math.h>
-#else
-#define _XOPEN_SOURCE /* to get prototype for hypot on some systems */
-#include <math.h>
-#undef _XOPEN_SOURCE
-#endif
-
-Bool
-FontFileAddScaledInstance (FontEntryPtr entry, FontScalablePtr vals,
- FontPtr pFont, char *bitmapName)
-{
- FontScalableEntryPtr scalable;
- FontScalableExtraPtr extra;
- FontScaledPtr new;
- int newsize;
-
- scalable = &entry->u.scalable;
- extra = scalable->extra;
- if (extra->numScaled == extra->sizeScaled)
- {
- newsize = extra->sizeScaled + 4;
- new = (FontScaledPtr) xrealloc (extra->scaled,
- newsize * sizeof (FontScaledRec));
- if (!new)
- return FALSE;
- extra->sizeScaled = newsize;
- extra->scaled = new;
- }
- new = &extra->scaled[extra->numScaled++];
- new->vals = *vals;
- new->pFont = pFont;
- new->bitmap = (FontEntryPtr) bitmapName;
- if (pFont)
- pFont->fpePrivate = (pointer) entry;
- return TRUE;
-}
-
-/* Must call this after the directory is sorted */
-
-void
-FontFileSwitchStringsToBitmapPointers (FontDirectoryPtr dir)
-{
- int s;
- int b;
- int i;
- FontEntryPtr scalable;
- FontEntryPtr nonScalable;
- FontScaledPtr scaled;
- FontScalableExtraPtr extra;
-
- scalable = dir->scalable.entries;
- nonScalable = dir->nonScalable.entries;
- for (s = 0; s < dir->scalable.used; s++)
- {
- extra = scalable[s].u.scalable.extra;
- scaled = extra->scaled;
- for (i = 0; i < extra->numScaled; i++)
- for (b = 0; b < dir->nonScalable.used; b++)
- if (nonScalable[b].name.name == (char *) scaled[i].bitmap)
- scaled[i].bitmap = &nonScalable[b];
- }
-}
-
-void
-FontFileRemoveScaledInstance (FontEntryPtr entry, FontPtr pFont)
-{
- FontScalableEntryPtr scalable;
- FontScalableExtraPtr extra;
- int i;
-
- scalable = &entry->u.scalable;
- extra = scalable->extra;
- for (i = 0; i < extra->numScaled; i++)
- {
- if (extra->scaled[i].pFont == pFont)
- {
- if (extra->scaled[i].vals.ranges)
- xfree (extra->scaled[i].vals.ranges);
- extra->numScaled--;
- for (; i < extra->numScaled; i++)
- extra->scaled[i] = extra->scaled[i+1];
- }
- }
-}
-
-Bool
-FontFileCompleteXLFD (FontScalablePtr vals, FontScalablePtr def)
-{
- FontResolutionPtr res;
- int num_res;
- double sx, sy, temp_matrix[4];
- double pixel_setsize_adjustment = 1.0;
- /*
- * If two of the three vertical scale values are specified, compute the
- * third. If all three are specified, make sure they are consistent
- * (within a pixel)
- *
- * One purpose of this procedure is to complete XLFD names in a
- * repeatable manner. That is, if the user partially specifies
- * a name (say, pixelsize but not pointsize), the results generated
- * here result in a fully specified name that will result in the
- * same font.
- */
-
- res = GetClientResolutions(&num_res);
-
- if (!(vals->values_supplied & PIXELSIZE_MASK) ||
- !(vals->values_supplied & POINTSIZE_MASK))
- {
- /* If resolution(s) unspecified and cannot be computed from
- pixelsize and pointsize, get appropriate defaults. */
-
- if (num_res)
- {
- if (vals->x <= 0)
- vals->x = res->x_resolution;
- if (vals->y <= 0)
- vals->y = res->y_resolution;
- }
-
- if (vals->x <= 0)
- vals->x = def->x;
- if (vals->y <= 0)
- vals->y = def->y;
- }
- else
- {
- /* If needed, compute resolution values from the pixel and
- pointsize information we were given. This problem is
- overdetermined (four equations, two unknowns), but we don't
- check for inconsistencies here. If they exist, they will
- show up in later tests for the point and pixel sizes. */
-
- if (vals->y <= 0)
- {
- double x = hypot(vals->pixel_matrix[1], vals->pixel_matrix[3]);
- double y = hypot(vals->point_matrix[1], vals->point_matrix[3]);
- if (y < EPS) return FALSE;
- vals->y = (int)(x * 72.27 / y + .5);
- }
- if (vals->x <= 0)
- {
- /* If the pixelsize was given as an array, or as a scalar that
- has been normalized for the pixel shape, we have enough
- information to compute a separate horizontal resolution */
-
- if ((vals->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
- (vals->values_supplied & PIXELSIZE_MASK) ==
- PIXELSIZE_SCALAR_NORMALIZED)
- {
- double x = hypot(vals->pixel_matrix[0], vals->pixel_matrix[2]);
- double y = hypot(vals->point_matrix[0], vals->point_matrix[2]);
- if (y < EPS) return FALSE;
- vals->x = (int)(x * 72.27 / y + .5);
- }
- else
- {
- /* Not enough information in the pixelsize array. Just
- assume the pixels are square. */
- vals->x = vals->y;
- }
- }
- }
-
- if (vals->x <= 0 || vals->y <= 0) return FALSE;
-
- /* If neither pixelsize nor pointsize is defined, take the pointsize
- from the defaults structure we've been passed. */
- if (!(vals->values_supplied & PIXELSIZE_MASK) &&
- !(vals->values_supplied & POINTSIZE_MASK))
- {
- if (num_res)
- {
- vals->point_matrix[0] =
- vals->point_matrix[3] = (double)res->point_size / 10.0;
- vals->point_matrix[1] =
- vals->point_matrix[2] = 0;
- vals->values_supplied = (vals->values_supplied & ~POINTSIZE_MASK) |
- POINTSIZE_SCALAR;
- }
- else if (def->values_supplied & POINTSIZE_MASK)
- {
- vals->point_matrix[0] = def->point_matrix[0];
- vals->point_matrix[1] = def->point_matrix[1];
- vals->point_matrix[2] = def->point_matrix[2];
- vals->point_matrix[3] = def->point_matrix[3];
- vals->values_supplied = (vals->values_supplied & ~POINTSIZE_MASK) |
- (def->values_supplied & POINTSIZE_MASK);
- }
- else return FALSE;
- }
-
- /* At this point, at least two of the three vertical scale values
- should be specified. Our job now is to compute the missing ones
- and check for agreement between overspecified values */
-
- /* If pixelsize was specified by a scalar, we need to fix the matrix
- now that we know the resolutions. */
- if ((vals->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_SCALAR)
- {
- /* pixel_setsize_adjustment used below to modify permissible
- error in pixel/pointsize matching, since multiplying a
- number rounded to integer changes the amount of the error
- caused by the rounding */
-
- pixel_setsize_adjustment = (double)vals->x / (double)vals->y;
- vals->pixel_matrix[0] *= pixel_setsize_adjustment;
- vals->values_supplied = (vals->values_supplied & ~PIXELSIZE_MASK) |
- PIXELSIZE_SCALAR_NORMALIZED;
- }
-
- sx = (double)vals->x / 72.27;
- sy = (double)vals->y / 72.27;
-
- /* If a pointsize was specified, make sure pixelsize is consistent
- to within 1 pixel, then replace pixelsize with a consistent
- floating-point value. */
-
- if (vals->values_supplied & POINTSIZE_MASK)
- {
- recompute_pixelsize: ;
- temp_matrix[0] = vals->point_matrix[0] * sx;
- temp_matrix[1] = vals->point_matrix[1] * sy;
- temp_matrix[2] = vals->point_matrix[2] * sx;
- temp_matrix[3] = vals->point_matrix[3] * sy;
- if (vals->values_supplied & PIXELSIZE_MASK)
- {
- if (fabs(vals->pixel_matrix[0] - temp_matrix[0]) >
- pixel_setsize_adjustment ||
- fabs(vals->pixel_matrix[1] - temp_matrix[1]) > 1 ||
- fabs(vals->pixel_matrix[2] - temp_matrix[2]) > 1 ||
- fabs(vals->pixel_matrix[3] - temp_matrix[3]) > 1)
- return FALSE;
- }
- if ((vals->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY &&
- (vals->values_supplied & POINTSIZE_MASK) == POINTSIZE_SCALAR)
- {
- /* In the special case that pixelsize came as an array and
- pointsize as a scalar, recompute the pointsize matrix
- from the pixelsize matrix. */
- goto recompute_pointsize;
- }
-
- /* Refresh pixel matrix with precise values computed from
- pointsize and resolution. */
- vals->pixel_matrix[0] = temp_matrix[0];
- vals->pixel_matrix[1] = temp_matrix[1];
- vals->pixel_matrix[2] = temp_matrix[2];
- vals->pixel_matrix[3] = temp_matrix[3];
-
- /* Set values_supplied for pixel to match that for point */
- vals->values_supplied =
- (vals->values_supplied & ~PIXELSIZE_MASK) |
- (((vals->values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY) ?
- PIXELSIZE_ARRAY : PIXELSIZE_SCALAR_NORMALIZED);
- }
- else
- {
- /* Pointsize unspecified... compute from pixel size and
- resolutions */
- recompute_pointsize: ;
- if (fabs(sx) < EPS || fabs(sy) < EPS) return FALSE;
- vals->point_matrix[0] = vals->pixel_matrix[0] / sx;
- vals->point_matrix[1] = vals->pixel_matrix[1] / sy;
- vals->point_matrix[2] = vals->pixel_matrix[2] / sx;
- vals->point_matrix[3] = vals->pixel_matrix[3] / sy;
-
- /* Set values_supplied for pixel to match that for point */
- vals->values_supplied =
- (vals->values_supplied & ~POINTSIZE_MASK) |
- (((vals->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY) ?
- POINTSIZE_ARRAY : POINTSIZE_SCALAR);
-
- /* If we computed scalar pointsize from scalar pixelsize, round
- pointsize to decipoints and recompute pixelsize so we end up
- with a repeatable name */
- if ((vals->values_supplied & POINTSIZE_MASK) == POINTSIZE_SCALAR)
- {
- /* Off-diagonal elements should be zero since no matrix was
- specified. */
- vals->point_matrix[0] =
- (double)(int)(vals->point_matrix[0] * 10.0 + .5) / 10.0;
- vals->point_matrix[3] =
- (double)(int)(vals->point_matrix[3] * 10.0 + .5) / 10.0;
- goto recompute_pixelsize;
- }
- }
-
- /* We've succeeded. Round everything to a few decimal places
- for repeatability. */
-
- vals->pixel_matrix[0] = xlfd_round_double(vals->pixel_matrix[0]);
- vals->pixel_matrix[1] = xlfd_round_double(vals->pixel_matrix[1]);
- vals->pixel_matrix[2] = xlfd_round_double(vals->pixel_matrix[2]);
- vals->pixel_matrix[3] = xlfd_round_double(vals->pixel_matrix[3]);
- vals->point_matrix[0] = xlfd_round_double(vals->point_matrix[0]);
- vals->point_matrix[1] = xlfd_round_double(vals->point_matrix[1]);
- vals->point_matrix[2] = xlfd_round_double(vals->point_matrix[2]);
- vals->point_matrix[3] = xlfd_round_double(vals->point_matrix[3]);
-
- /* Fill in the deprecated fields for the benefit of rasterizers
- that do not handle the matrices. */
- vals->point = vals->point_matrix[3] * 10;
- vals->pixel = vals->pixel_matrix[3];
-
- return TRUE;
-}
-
-static Bool
-MatchScalable (FontScalablePtr a, FontScalablePtr b)
-{
- int i;
-
- /* Some asymmetry here: we assume that the first argument (a) is
- the table entry and the second (b) the item we're trying to match
- (the key). We'll consider the fonts matched if the relevant
- metrics match *and* if a) the table entry doesn't have charset
- subsetting or b) the table entry has identical charset subsetting
- to that in the key. We could add logic to check if the table
- entry has a superset of the charset required by the key, but
- we'll resist the urge for now. */
-
-#define EQUAL(a,b) ((a)[0] == (b)[0] && \
- (a)[1] == (b)[1] && \
- (a)[2] == (b)[2] && \
- (a)[3] == (b)[3])
-
- if (!(a->x == b->x &&
- a->y == b->y &&
- (a->width == b->width || a->width == 0 || b->width == 0 || b->width == -1) &&
- (!(b->values_supplied & PIXELSIZE_MASK) ||
- ((a->values_supplied & PIXELSIZE_MASK) ==
- (b->values_supplied & PIXELSIZE_MASK) &&
- EQUAL(a->pixel_matrix, b->pixel_matrix))) &&
- (!(b->values_supplied & POINTSIZE_MASK) ||
- ((a->values_supplied & POINTSIZE_MASK) ==
- (b->values_supplied & POINTSIZE_MASK) &&
- EQUAL(a->point_matrix, b->point_matrix))) &&
- (a->nranges == 0 || a->nranges == b->nranges)))
- return FALSE;
-
- for (i = 0; i < a->nranges; i++)
- if (a->ranges[i].min_char_low != b->ranges[i].min_char_low ||
- a->ranges[i].min_char_high != b->ranges[i].min_char_high ||
- a->ranges[i].max_char_low != b->ranges[i].max_char_low ||
- a->ranges[i].max_char_high != b->ranges[i].max_char_high)
- return FALSE;
-
- return TRUE;
-}
-
-FontScaledPtr
-FontFileFindScaledInstance (FontEntryPtr entry, FontScalablePtr vals,
- int noSpecificSize)
-{
- FontScalableEntryPtr scalable;
- FontScalableExtraPtr extra;
- FontScalablePtr mvals;
- int dist, i;
- int mini;
- double mindist;
- register double temp, sum=0.0;
-
-#define NORMDIFF(a, b) ( \
- temp = (a)[0] - (b)[0], \
- sum = temp * temp, \
- temp = (a)[1] - (b)[1], \
- sum += temp * temp, \
- temp = (a)[2] - (b)[2], \
- sum += temp * temp, \
- temp = (a)[3] - (b)[3], \
- sum + temp * temp )
-
- scalable = &entry->u.scalable;
- extra = scalable->extra;
- if (noSpecificSize && extra->numScaled)
- {
- mini = 0;
- mindist = NORMDIFF(extra->scaled[0].vals.point_matrix,
- vals->point_matrix);
- for (i = 1; i < extra->numScaled; i++)
- {
- if (extra->scaled[i].pFont &&
- !extra->scaled[i].pFont->info.cachable) continue;
- mvals = &extra->scaled[i].vals;
- dist = NORMDIFF(mvals->point_matrix, vals->point_matrix);
- if (dist < mindist)
- {
- mindist = dist;
- mini = i;
- }
- }
- if (extra->scaled[mini].pFont &&
- !extra->scaled[mini].pFont->info.cachable) return 0;
- return &extra->scaled[mini];
- }
- else
- {
- /* See if we've scaled to this value yet */
- for (i = 0; i < extra->numScaled; i++)
- {
- if (extra->scaled[i].pFont &&
- !extra->scaled[i].pFont->info.cachable) continue;
- if (MatchScalable (&extra->scaled[i].vals, vals))
- return &extra->scaled[i];
- }
- }
- return 0;
-}
diff --git a/nx-X11/lib/font/fontfile/gunzip.c b/nx-X11/lib/font/fontfile/gunzip.c
deleted file mode 100644
index 8c9c317aa..000000000
--- a/nx-X11/lib/font/fontfile/gunzip.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/* $Xorg: gunzip.c,v 1.3 2000/08/17 19:46:37 cpqbld Exp $ */
-/* lib/font/fontfile/gunzip.c
- written by Mark Eichin <eichin@kitten.gen.ma.us> September 1996.
- intended for inclusion in X11 public releases. */
-/* $XFree86: xc/lib/font/fontfile/gunzip.c,v 1.4 2000/09/19 12:46:08 eich Exp $ */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fontmisc.h>
-#include <X11/fonts/bufio.h>
-#include <zlib.h>
-
-typedef struct _xzip_buf {
- z_stream z;
- int zstat;
- BufChar b[BUFFILESIZE];
- BufChar b_in[BUFFILESIZE];
- BufFilePtr f;
-} xzip_buf;
-
-static int BufZipFileClose ( BufFilePtr f, int flag );
-static int BufZipFileFill ( BufFilePtr f );
-static int BufZipFileSkip ( BufFilePtr f, int c );
-static int BufCheckZipHeader ( BufFilePtr f );
-
-BufFilePtr
-BufFilePushZIP (BufFilePtr f)
-{
- xzip_buf *x;
-
- x = (xzip_buf *) xalloc (sizeof (xzip_buf));
- if (!x) return 0;
- /* these are just for raw calloc/free */
- x->z.zalloc = Z_NULL;
- x->z.zfree = Z_NULL;
- x->z.opaque = Z_NULL;
- x->f = f;
-
- /* force inflateInit to allocate it's own history buffer */
- x->z.next_in = Z_NULL;
- x->z.next_out = Z_NULL;
- x->z.avail_in = x->z.avail_out = 0;
-
- /* using negative windowBits sets "nowrap" mode, which turns off
- zlib header checking [undocumented, for gzip compatibility only?] */
- x->zstat = inflateInit2(&(x->z), -MAX_WBITS);
- if (x->zstat != Z_OK) {
- xfree(x);
- return 0;
- }
-
- /* now that the history buffer is allocated, we provide the data buffer */
- x->z.next_out = x->b;
- x->z.avail_out = BUFFILESIZE;
- x->z.next_out = x->b_in;
- x->z.avail_in = 0;
-
- if (BufCheckZipHeader(x->f)) {
- xfree(x);
- return 0;
- }
-
- return BufFileCreate((char *)x,
- BufZipFileFill,
- 0,
- BufZipFileSkip,
- BufZipFileClose);
-}
-
-static int
-BufZipFileClose(BufFilePtr f, int flag)
-{
- xzip_buf *x = (xzip_buf *)f->private;
- inflateEnd (&(x->z));
- BufFileClose (x->f, flag);
- xfree (x);
- return 1;
-}
-
-/* here's the real work.
- -- we need to put stuff in f.buffer, update f.left and f.bufp,
- then return the first byte (or BUFFILEEOF).
- -- to do this, we need to get stuff into avail_in, and next_in,
- and call inflate appropriately.
- -- we may also need to add CRC maintenance - if inflate tells us
- Z_STREAM_END, we then have 4bytes CRC and 4bytes length...
- gzio.c:gzread shows most of the mechanism.
- */
-static int
-BufZipFileFill (BufFilePtr f)
-{
- xzip_buf *x = (xzip_buf *)f->private;
-
- /* we only get called when left == 0... */
- /* but just in case, deal */
- if (f->left >= 0) {
- f->left--;
- return *(f->bufp++);
- }
- /* did we run out last time? */
- switch (x->zstat) {
- case Z_OK:
- break;
- case Z_STREAM_END:
- case Z_DATA_ERROR:
- case Z_ERRNO:
- f->left = 0;
- return BUFFILEEOF;
- default:
- return BUFFILEEOF;
- }
- /* now we work to consume what we can */
- /* let zlib know what we can handle */
- x->z.next_out = x->b;
- x->z.avail_out = BUFFILESIZE;
-
- /* and try to consume all of it */
- while (x->z.avail_out > 0) {
- /* if we don't have anything to work from... */
- if (x->z.avail_in == 0) {
- /* ... fill the z buf from underlying file */
- int i, c;
- for (i = 0; i < sizeof(x->b_in); i++) {
- c = BufFileGet(x->f);
- if (c == BUFFILEEOF) break;
- x->b_in[i] = c;
- }
- x->z.avail_in += i;
- x->z.next_in = x->b_in;
- }
- /* so now we have some output space and some input data */
- x->zstat = inflate(&(x->z), Z_NO_FLUSH);
- /* the inflation output happens in the f buffer directly... */
- if (x->zstat == Z_STREAM_END) {
- /* deal with EOF, crc */
- break;
- }
- if (x->zstat != Z_OK) {
- break;
- }
- }
- f->bufp = x->b;
- f->left = BUFFILESIZE - x->z.avail_out;
-
- if (f->left >= 0) {
- f->left--;
- return *(f->bufp++);
- } else {
- return BUFFILEEOF;
- }
-}
-
-/* there should be a BufCommonSkip... */
-static int
-BufZipFileSkip (BufFilePtr f, int c)
-{
- /* BufFileRawSkip returns the count unchanged.
- BufCompressedSkip returns 0.
- That means it probably never gets called... */
- int retval = c;
- while(c--) {
- int get = BufFileGet(f);
- if (get == BUFFILEEOF) return get;
- }
- return retval;
-}
-
-/* now we need to duplicate check_header */
-/* contents:
- 0x1f, 0x8b -- magic number
- 1 byte -- method (Z_DEFLATED)
- 1 byte -- flags (mask with RESERVED -> fail)
- 4 byte -- time (discard)
- 1 byte -- xflags (discard)
- 1 byte -- "os" code (discard)
- [if flags & EXTRA_FIELD:
- 2 bytes -- LSBfirst length n
- n bytes -- extra data (discard)]
- [if flags & ORIG_NAME:
- n bytes -- null terminated name (discard)]
- [if flags & COMMENT:
- n bytes -- null terminated comment (discard)]
- [if flags & HEAD_CRC:
- 2 bytes -- crc of headers? (discard)]
- */
-
-/* gzip flag byte -- from gzio.c */
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
-#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define RESERVED 0xE0 /* bits 5..7: reserved */
-
-#define GET(f) do {c = BufFileGet(f); if (c == BUFFILEEOF) return c;} while(0)
-static int
-BufCheckZipHeader(BufFilePtr f)
-{
- int c, flags;
- GET(f); if (c != 0x1f) return 1; /* magic 1 */
- GET(f); if (c != 0x8b) return 2; /* magic 2 */
- GET(f); if (c != Z_DEFLATED) return 3; /* method */
- GET(f); if (c & RESERVED) return 4; /* reserved flags */
- flags = c;
- GET(f); GET(f); GET(f); GET(f); /* time */
- GET(f); /* xflags */
- GET(f); /* os code */
- if (flags & EXTRA_FIELD) {
- int len;
- GET(f); len = c;
- GET(f); len += (c<<8);
- while (len-- >= 0) {
- GET(f);
- }
- }
- if (flags & ORIG_NAME) {
- do { GET(f); } while (c != 0);
- }
- if (flags & COMMENT) {
- do { GET(f); } while (c != 0);
- }
- if (flags & HEAD_CRC) {
- GET(f); GET(f); /* header crc */
- }
- return 0;
-}
diff --git a/nx-X11/lib/font/fontfile/module/Imakefile b/nx-X11/lib/font/fontfile/module/Imakefile
deleted file mode 100644
index 0eebe085e..000000000
--- a/nx-X11/lib/font/fontfile/module/Imakefile
+++ /dev/null
@@ -1,21 +0,0 @@
-XCOMM $XFree86: xc/lib/font/fontfile/module/Imakefile,v 1.3 1999/06/13 13:47:35 dawes Exp $
-#include <Server.tmpl>
-
- INCLUDES = -I$(FONTINCSRC) -I../../include -I$(SERVERSRC)/include \
- -I$(XINCLUDESRC)
-
- DEFINES = -DLOADABLEFONTS
-
- SRCS = ffcheck.c register.c
- OBJS = ffcheck.o register.o
-
-SubdirLibraryRule($(OBJS))
-
-NormalLibraryObjectRule()
-NormalLintTarget($(SRCS))
-
-LinkSourceFile(ffcheck.c,..)
-LinkSourceFile(register.c,..)
-
-DependTarget()
-
diff --git a/nx-X11/lib/font/fontfile/printerfont.c b/nx-X11/lib/font/fontfile/printerfont.c
deleted file mode 100644
index 0b6c19c62..000000000
--- a/nx-X11/lib/font/fontfile/printerfont.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/* $Xorg: printerfont.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1991, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/printerfont.c,v 1.5tsi Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fntfilst.h>
-
-/*
- * Map FPE functions to renderer functions
- */
-
-#define PRINTERPATHPREFIX "PRINTER:"
-
-/* STUB
-int XpClientIsPrintClient(client,fpe)
-pointer client;
-FontPathElementPtr fpe;
-{ return 1; }
- */
-
-static int
-PrinterFontNameCheck (char *name)
-{
- if (strncmp(name,PRINTERPATHPREFIX,strlen(PRINTERPATHPREFIX)) != 0)
- return 0;
- name += strlen(PRINTERPATHPREFIX);
-#ifndef NCD
- return *name == '/';
-#else
- return ((strcmp(name, "built-ins") == 0) || (*name == '/'));
-#endif
-}
-
-static int
-PrinterFontInitFPE (FontPathElementPtr fpe)
-{
- int status;
- FontDirectoryPtr dir;
- char * name;
-
- name = fpe->name + strlen(PRINTERPATHPREFIX);
- status = FontFileReadDirectory (name, &dir);
- if (status == Successful)
- {
- if (dir->nonScalable.used > 0)
- if (!FontFileRegisterBitmapSource (fpe))
- {
- FontFileFreeFPE (fpe);
- return AllocError;
- }
- fpe->private = (pointer) dir;
- }
- return status;
-}
-
-/* Here we must check the client to see if it has a context attached to
- * it that allows us to access the printer fonts
- */
-
-static int
-PrinterFontOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
- char *name, int namelen,
- fsBitmapFormat format, fsBitmapFormatMask fmask,
- XID id, FontPtr *pFont, char **aliasName,
- FontPtr non_cachable_font)
-{
- if (XpClientIsPrintClient(client,fpe))
- return (FontFileOpenFont (client, fpe, flags, name, namelen, format,
- fmask, id, pFont, aliasName, non_cachable_font));
- return BadFontName;
-}
-
-static int
-PrinterFontListFonts (pointer client, FontPathElementPtr fpe, char *pat,
- int len, int max, FontNamesPtr names)
-{
- if (XpClientIsPrintClient(client,fpe))
- return FontFileListFonts (client, fpe, pat, len, max, names);
- return BadFontName;
-}
-
-static int
-PrinterFontStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
- pointer *privatep)
-{
- if (XpClientIsPrintClient(client,fpe))
- return FontFileStartListFontsWithInfo(client, fpe, pat, len,
- max, privatep);
- return BadFontName;
-}
-
-static int
-PrinterFontListNextFontWithInfo(pointer client, FontPathElementPtr fpe,
- char **namep, int *namelenp,
- FontInfoPtr *pFontInfo,
- int *numFonts, pointer private)
-{
- if (XpClientIsPrintClient(client,fpe))
- return FontFileListNextFontWithInfo(client, fpe, namep, namelenp,
- pFontInfo, numFonts, private);
- return BadFontName;
-}
-
-static int
-PrinterFontStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
- pointer *privatep)
-{
- if (XpClientIsPrintClient(client,fpe))
- return FontFileStartListFontsAndAliases(client, fpe, pat, len,
- max, privatep);
- return BadFontName;
-}
-
-static int
-PrinterFontListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
- char **namep, int *namelenp,
- char **resolvedp, int *resolvedlenp,
- pointer private)
-{
- if (XpClientIsPrintClient(client,fpe))
- return FontFileListNextFontOrAlias(client, fpe, namep, namelenp,
- resolvedp, resolvedlenp, private);
- return BadFontName;
-}
-
-void
-PrinterFontRegisterFpeFunctions (void)
-{
- RegisterFPEFunctions(PrinterFontNameCheck,
- PrinterFontInitFPE,
- FontFileFreeFPE,
- FontFileResetFPE,
- PrinterFontOpenFont,
- FontFileCloseFont,
- PrinterFontListFonts,
- PrinterFontStartListFontsWithInfo,
- PrinterFontListNextFontWithInfo,
- NULL,
- NULL,
- NULL,
- PrinterFontStartListFontsAndAliases,
- PrinterFontListNextFontOrAlias,
- FontFileEmptyBitmapSource);
-}
diff --git a/nx-X11/lib/font/fontfile/register.c b/nx-X11/lib/font/fontfile/register.c
deleted file mode 100644
index 5ddab0386..000000000
--- a/nx-X11/lib/font/fontfile/register.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* $Xorg: register.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1994, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/register.c,v 1.14 2001/01/17 19:43:30 dawes Exp $ */
-
-/*
- * This is in a separate source file so that small programs
- * such as mkfontdir that want to use the fontfile utilities don't
- * end up dragging in code from all the renderers, which is not small.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#else
-#define XFONT_BITMAP 1
-#endif
-
-#include <X11/fonts/fontmisc.h>
-#include <X11/fonts/fntfilst.h>
-#include <X11/fonts/bitmap.h>
-
-#ifdef LOADABLEFONTS
-#include <X11/fonts/fontmod.h>
-#endif
-
-/*
- * Translate monolithic build symbols to modular build symbols.
- * I chose to make the modular symbols 'canonical' because they
- * are prefixed with XFONT_, neatly avoiding name collisions
- * with other packages.
- */
-
-#ifdef BUILD_SPEEDO
-# define XFONT_SPEEDO 1
-#endif
-#ifdef BUILD_TYPE1
-# define XFONT_TYPE1 1
-#endif
-
-#ifdef BUILD_CID
-# define XFONT_CID 1
-#endif
-#ifdef BUILD_FREETYPE
-# define XFONT_FREETYPE 1
-#endif
-
-void
-FontFileRegisterFpeFunctions(void)
-{
-#ifndef LOADABLEFONTS
-
-#ifdef XFONT_BITMAP
- BitmapRegisterFontFileFunctions ();
-#endif
-#ifdef XFONT_SPEEDO
- SpeedoRegisterFontFileFunctions ();
-#endif
-#ifdef XFONT_TYPE1
- Type1RegisterFontFileFunctions();
-#endif
-#ifdef XFONT_CID
- CIDRegisterFontFileFunctions();
-#endif
-#ifdef XFONT_FREETYPE
- FreeTypeRegisterFontFileFunctions();
-#endif
-
-#else
- {
- int i;
-
- if (FontModuleList) {
- for (i = 0; FontModuleList[i].name; i++) {
- if (FontModuleList[i].initFunc)
- FontModuleList[i].initFunc();
- }
- }
- }
-#endif
-
- FontFileRegisterLocalFpeFunctions ();
-}
-
diff --git a/nx-X11/lib/font/fontfile/renderers.c b/nx-X11/lib/font/fontfile/renderers.c
deleted file mode 100644
index f110ba817..000000000
--- a/nx-X11/lib/font/fontfile/renderers.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/* $Xorg: renderers.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
-
-/*
-
-Copyright 1991, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/lib/font/fontfile/renderers.c,v 1.7 2002/12/09 17:30:00 dawes Exp $ */
-
-/*
- * Author: Keith Packard, MIT X Consortium
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fntfilst.h>
-extern void ErrorF(const char *f, ...);
-
-static FontRenderersRec renderers;
-
-/*
- * XXX Maybe should allow unregistering renders. For now, just clear the
- * list at each new generation.
- */
-extern unsigned long serverGeneration;
-static unsigned long rendererGeneration = 0;
-
-Bool
-FontFileRegisterRenderer (FontRendererPtr renderer)
-{
- return FontFilePriorityRegisterRenderer(renderer, 0);
-}
-
-Bool
-FontFilePriorityRegisterRenderer (FontRendererPtr renderer, int priority)
-{
- int i;
- struct _FontRenderersElement *new;
-
- if (rendererGeneration != serverGeneration) {
- rendererGeneration = serverGeneration;
- renderers.number = 0;
- if (renderers.renderers)
- xfree(renderers.renderers);
- renderers.renderers = NULL;
- }
-
- for (i = 0; i < renderers.number; i++) {
- if (!strcmp (renderers.renderers[i].renderer->fileSuffix,
- renderer->fileSuffix)) {
- if(renderers.renderers[i].priority >= priority) {
- if(renderers.renderers[i].priority == priority) {
- if (rendererGeneration == 1)
- ErrorF("Warning: font renderer for \"%s\" "
- "already registered at priority %d\n",
- renderer->fileSuffix, priority);
- }
- return TRUE;
- } else {
- break;
- }
- }
- }
-
- if(i >= renderers.number) {
- new = xrealloc (renderers.renderers, sizeof(*new) * (i + 1));
- if (!new)
- return FALSE;
- renderers.renderers = new;
- renderers.number = i + 1;
- }
- renderer->number = i;
- renderers.renderers[i].renderer = renderer;
- renderers.renderers[i].priority = priority;
- return TRUE;
-}
-
-FontRendererPtr
-FontFileMatchRenderer (char *fileName)
-{
- int i;
- int fileLen;
- FontRendererPtr r;
-
- fileLen = strlen (fileName);
- for (i = 0; i < renderers.number; i++)
- {
- r = renderers.renderers[i].renderer;
- if (fileLen >= r->fileSuffixLen &&
- !strcmp (fileName + fileLen - r->fileSuffixLen, r->fileSuffix))
- {
- return r;
- }
- }
- return 0;
-}