summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:50 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:50 +0000
commit4349bf0fa125e2a1c32b0b49c974ff5fa588cdbe (patch)
tree2e4b857f2103cfbcdfcfd53b47334166e139a273
parent3795e9702b3b3a6fe0594d09cdd110adeb5e42f9 (diff)
-rw-r--r--include/X11/fonts/bdfint.h28
-rw-r--r--include/X11/fonts/bitmap.h62
-rw-r--r--include/X11/fonts/bufio.h96
-rw-r--r--include/X11/fonts/fntfil.h110
-rw-r--r--include/X11/fonts/fntfilio.h18
-rw-r--r--include/X11/fonts/fntfilst.h44
-rw-r--r--include/X11/fonts/fontmisc.h62
-rw-r--r--include/X11/fonts/fontxlfd.h8
-rw-r--r--include/X11/fonts/pcf.h8
-rw-r--r--src/Speedo/bics-iso.h1
-rw-r--r--src/Speedo/do_char.c123
-rw-r--r--src/Speedo/do_trns.c40
-rw-r--r--src/Speedo/out_bl2d.c49
-rw-r--r--src/Speedo/out_blk.c35
-rw-r--r--src/Speedo/out_scrn.c56
-rw-r--r--src/Speedo/out_util.c25
-rw-r--r--src/Speedo/reset.c9
-rw-r--r--src/Speedo/set_spcs.c75
-rw-r--r--src/Speedo/set_trns.c119
-rw-r--r--src/Speedo/spdo_prv.h8
-rw-r--r--src/Speedo/speedo.h201
-rw-r--r--src/Speedo/spencode.c6
-rw-r--r--src/Speedo/sperr.c24
-rw-r--r--src/Speedo/spfile.c150
-rw-r--r--src/Speedo/spfont.c116
-rw-r--r--src/Speedo/spfuncs.c61
-rw-r--r--src/Speedo/spglyph.c41
-rw-r--r--src/Speedo/spinfo.c60
-rw-r--r--src/Speedo/spint.h42
-rw-r--r--src/Type1/arith.c47
-rw-r--r--src/Type1/arith.h19
-rw-r--r--src/Type1/blues.h4
-rw-r--r--src/Type1/curves.c39
-rw-r--r--src/Type1/curves.h10
-rw-r--r--src/Type1/fontfcn.c462
-rw-r--r--src/Type1/fontfcn.h153
-rw-r--r--src/Type1/hints.c103
-rw-r--r--src/Type1/hints.h18
-rw-r--r--src/Type1/lines.c3
-rw-r--r--src/Type1/lines.h6
-rw-r--r--src/Type1/objects.c198
-rw-r--r--src/Type1/objects.h129
-rw-r--r--src/Type1/paths.c211
-rw-r--r--src/Type1/paths.h90
-rw-r--r--src/Type1/pictures.h6
-rw-r--r--src/Type1/regions.c261
-rw-r--r--src/Type1/regions.h69
-rw-r--r--src/Type1/scanfont.c1672
-rw-r--r--src/Type1/spaces.c239
-rw-r--r--src/Type1/spaces.h104
-rw-r--r--src/Type1/t1funcs.c1219
-rw-r--r--src/Type1/t1imager.h94
-rw-r--r--src/Type1/t1info.c703
-rw-r--r--src/Type1/t1intf.h109
-rw-r--r--src/Type1/t1io.c165
-rw-r--r--src/Type1/t1malloc.c134
-rw-r--r--src/Type1/t1snap.c17
-rw-r--r--src/Type1/t1stdio.h39
-rw-r--r--src/Type1/t1stub.c22
-rw-r--r--src/Type1/token.c143
-rw-r--r--src/Type1/token.h4
-rw-r--r--src/Type1/tokst.h68
-rw-r--r--src/Type1/trig.h6
-rw-r--r--src/Type1/type1.c364
-rw-r--r--src/Type1/util.c86
-rw-r--r--src/Type1/util.h48
-rw-r--r--src/bitmap/bdfread.c147
-rw-r--r--src/bitmap/bdfutils.c74
-rw-r--r--src/bitmap/bitmap.c40
-rw-r--r--src/bitmap/bitmapfunc.c93
-rw-r--r--src/bitmap/bitmaputil.c37
-rw-r--r--src/bitmap/bitscale.c435
-rw-r--r--src/bitmap/fontink.c17
-rw-r--r--src/bitmap/pcfread.c348
-rw-r--r--src/bitmap/pcfwrite.c79
-rw-r--r--src/bitmap/snfread.c115
-rw-r--r--src/bitmap/snfstr.h8
-rw-r--r--src/fc/fsconvert.c257
-rw-r--r--src/fc/fserve.c3581
-rw-r--r--src/fc/fserve.h30
-rw-r--r--src/fc/fservestr.h63
-rw-r--r--src/fc/fsio.c742
-rw-r--r--src/fc/fsio.h137
-rw-r--r--src/fc/fslibos.h7
-rw-r--r--src/fontfile/bitsource.c28
-rw-r--r--src/fontfile/bufio.c74
-rw-r--r--src/fontfile/decompress.c35
-rw-r--r--src/fontfile/defaults.c7
-rw-r--r--src/fontfile/dirfile.c87
-rw-r--r--src/fontfile/ffcheck.c139
-rw-r--r--src/fontfile/fileio.c14
-rw-r--r--src/fontfile/filewr.c11
-rw-r--r--src/fontfile/fontdir.c233
-rw-r--r--src/fontfile/fontfile.c194
-rw-r--r--src/fontfile/fontscale.c43
-rw-r--r--src/fontfile/gunzip.c36
-rw-r--r--src/fontfile/printerfont.c113
-rw-r--r--src/fontfile/register.c39
-rw-r--r--src/fontfile/renderers.c71
-rw-r--r--src/util/atom.c38
-rw-r--r--src/util/fontaccel.c10
-rw-r--r--src/util/fontnames.c12
-rw-r--r--src/util/fontutil.c88
-rw-r--r--src/util/fontxlfd.c144
-rw-r--r--src/util/format.c18
-rw-r--r--src/util/miscutil.c41
-rw-r--r--src/util/patcache.c34
-rw-r--r--src/util/private.c57
-rw-r--r--src/util/utilbitmap.c28
109 files changed, 10448 insertions, 6097 deletions
diff --git a/include/X11/fonts/bdfint.h b/include/X11/fonts/bdfint.h
index 04e4c41..c389bfb 100644
--- a/include/X11/fonts/bdfint.h
+++ b/include/X11/fonts/bdfint.h
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/bdfint.h,v 1.5 2001/12/14 19:56:45 dawes Exp $ */
#ifndef BDFINT_H
#define BDFINT_H
@@ -67,16 +68,23 @@ typedef struct BDFSTAT {
BOOL haveDefaultCh;
} bdfFileState;
-extern unsigned char *bdfGetLine();
+extern void bdfError ( char * message, ... );
+extern void bdfWarning ( char *message, ... );
+extern unsigned char * bdfGetLine ( FontFilePtr file, unsigned char *buf,
+ int len );
+extern Atom bdfForceMakeAtom ( char *str, int *size );
+extern Atom bdfGetPropertyValue ( char *s );
+extern int bdfIsInteger ( char *str );
+extern unsigned char bdfHexByte ( unsigned char *s );
+extern Bool bdfSpecialProperty ( FontPtr pFont, FontPropPtr prop,
+ char isString, bdfFileState *bdfState );
+extern int bdfReadFont( FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan );
+extern int bdfReadFontInfo( FontInfoPtr pFontInfo, FontFilePtr file );
-extern void bdfError(
-#if NeedVarargsPrototypes
- char* message, ...
-#endif
-);
-extern void bdfWarning();
-extern Atom bdfForceMakeAtom();
-extern Atom bdfGetPropertyValue();
-extern unsigned char bdfHexByte();
+extern void FontCharInkMetrics ( FontPtr pFont, CharInfoPtr pCI,
+ xCharInfo *pInk );
+extern void FontCharReshape ( FontPtr pFont, CharInfoPtr pSrc,
+ CharInfoPtr pDst );
#endif /* BDFINT_H */
diff --git a/include/X11/fonts/bitmap.h b/include/X11/fonts/bitmap.h
index 027b869..29989e3 100644
--- a/include/X11/fonts/bitmap.h
+++ b/include/X11/fonts/bitmap.h
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/include/bitmap.h,v 1.10 2001/12/14 19:56:53 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -35,13 +36,20 @@ from The Open Group.
#ifndef _BITMAP_H_
#define _BITMAP_H_
-#include <fntfilio.h>
+#include "fntfilio.h"
+#ifndef FONTMODULE
#include <stdio.h> /* just for NULL */
+#else
+#include "xf86_ansic.h"
+#endif
/*
* Internal format used to store bitmap fonts
*/
+/* number of encoding entries in one segment */
+#define BITMAP_FONT_SEGMENT_SIZE 128
+
typedef struct _BitmapExtra {
Atom *glyphNames;
int *sWidths;
@@ -56,17 +64,53 @@ typedef struct _BitmapFont {
CharInfoPtr metrics; /* font metrics, including glyph pointers */
xCharInfo *ink_metrics; /* ink metrics */
char *bitmaps; /* base of bitmaps, useful only to free */
- CharInfoPtr *encoding; /* array of char info pointers */
+ CharInfoPtr **encoding; /* array of arrays of char info pointers */
CharInfoPtr pDefault; /* default character */
BitmapExtraPtr bitmapExtra; /* stuff not used by X server */
} BitmapFontRec, *BitmapFontPtr;
-extern int bitmapReadFont(), bitmapReadFontInfo();
-extern int bitmapGetGlyphs(), bitmapGetMetrics();
-extern int bitmapGetBitmaps(), bitmapGetExtents();
-extern void bitmapUnloadFont();
-
-extern void bitmapComputeFontBounds();
-extern void bitmapComputeFontInkBounds();
+#define ACCESSENCODING(enc,i) \
+(enc[(i)/BITMAP_FONT_SEGMENT_SIZE]?\
+(enc[(i)/BITMAP_FONT_SEGMENT_SIZE][(i)%BITMAP_FONT_SEGMENT_SIZE]):\
+0)
+#define ACCESSENCODINGL(enc,i) \
+(enc[(i)/BITMAP_FONT_SEGMENT_SIZE][(i)%BITMAP_FONT_SEGMENT_SIZE])
+
+#define SEGMENT_MAJOR(n) ((n)/BITMAP_FONT_SEGMENT_SIZE)
+#define SEGMENT_MINOR(n) ((n)%BITMAP_FONT_SEGMENT_SIZE)
+#define NUM_SEGMENTS(n) \
+ (((n)+BITMAP_FONT_SEGMENT_SIZE-1)/BITMAP_FONT_SEGMENT_SIZE)
+
+extern int bitmapGetGlyphs ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs );
+extern int bitmapGetMetrics ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, xCharInfo **glyphs );
+
+extern void bitmapComputeFontBounds ( FontPtr pFont );
+extern void bitmapComputeFontInkBounds ( FontPtr pFont );
+extern Bool bitmapAddInkMetrics ( FontPtr pFont );
+extern int bitmapComputeWeight ( FontPtr pFont );
+
+extern int BitmapOpenBitmap ( FontPathElementPtr fpe, FontPtr *ppFont,
+ int flags, FontEntryPtr entry, char *fileName,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font );
+extern int BitmapGetInfoBitmap ( FontPathElementPtr fpe,
+ FontInfoPtr pFontInfo, FontEntryPtr entry,
+ char *fileName );
+extern void BitmapRegisterFontFileFunctions ( void );
+extern int BitmapGetRenderIndex ( FontRendererPtr renderer );
+
+extern int BitmapOpenScalable ( FontPathElementPtr fpe, FontPtr *pFont,
+ int flags, FontEntryPtr entry, char *fileName,
+ FontScalablePtr vals, fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font );
+extern int BitmapGetInfoScalable ( FontPathElementPtr fpe,
+ FontInfoPtr pFontInfo, FontEntryPtr entry,
+ FontNamePtr fontName, char *fileName,
+ FontScalablePtr vals );
#endif /* _BITMAP_H_ */
diff --git a/include/X11/fonts/bufio.h b/include/X11/fonts/bufio.h
index 493f3ce..402685f 100644
--- a/include/X11/fonts/bufio.h
+++ b/include/X11/fonts/bufio.h
@@ -27,6 +27,12 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/include/bufio.h,v 1.7 2001/12/14 19:56:53 dawes Exp $ */
+
+#ifndef ___BUFIO_H___
+#define ___BUFIO_H___ 1
+
+#include <X11/Xfuncproto.h>
#ifdef TEST
@@ -39,80 +45,41 @@ from The Open Group.
#define BUFFILEEOF -1
typedef unsigned char BufChar;
+typedef struct _buffile *BufFilePtr;
typedef struct _buffile {
BufChar *bufp;
int left;
+ int eof;
BufChar buffer[BUFFILESIZE];
- int (*io)(/* BufFilePtr f */);
- int (*skip)(/* BufFilePtr f, int count */);
- int (*close)(/* BufFilePtr f */);
+ int (*input)( BufFilePtr /* f */);
+ int (*output)( int /* c */, BufFilePtr /* f */);
+ int (*skip)( BufFilePtr /* f */, int /* count */);
+ int (*close)( BufFilePtr /* f */, int /* doClose */);
char *private;
-} BufFileRec, *BufFilePtr;
+} BufFileRec;
-extern BufFilePtr BufFileCreate (
-#if NeedFunctionPrototypes
+extern BufFilePtr BufFileCreate (
char*,
- int (*)(),
- int (*)(),
- int (*)()
-#endif
-);
-extern BufFilePtr BufFileOpenRead (
-#if NeedFunctionPrototypes
- int
-#endif
-);
-
-extern BufFilePtr BufFileOpenWrite (
-#if NeedFunctionPrototypes
- int
-#endif
-);
-
-extern BufFilePtr BufFilePushCompressed (
-#if NeedFunctionPrototypes
- BufFilePtr
-#endif
-);
+ int (*)(BufFilePtr),
+ int (*)(int, BufFilePtr),
+ int (*)(BufFilePtr, int),
+ int (*)(BufFilePtr, int));
+extern BufFilePtr BufFileOpenRead ( int );
+extern BufFilePtr BufFileOpenWrite ( int );
+extern BufFilePtr BufFilePushCompressed ( BufFilePtr );
#ifdef X_GZIP_FONT_COMPRESSION
-extern BufFilePtr BufFilePushZIP (
-#if NeedFunctionPrototypes
- BufFilePtr
-#endif
-);
-#endif
-extern int BufFileClose (
-#if NeedFunctionPrototypes
- BufFilePtr,
- int
+extern BufFilePtr BufFilePushZIP ( BufFilePtr );
#endif
-);
-extern int BufFileFlush (
-#if NeedFunctionPrototypes
- BufFilePtr
-#endif
-);
+extern int BufFileClose ( BufFilePtr, int );
+extern int BufFileFlush ( BufFilePtr, int );
+extern int BufFileRead ( BufFilePtr, char*, int );
+extern int BufFileWrite ( BufFilePtr, char*, int );
+extern void BufFileFree ( BufFilePtr );
-extern int BufFileRead (
-#if NeedFunctionPrototypes
- BufFilePtr,
- char*,
- int
-#endif
-);
-
-extern int BufFileWrite (
-#if NeedFunctionPrototypes
- BufFilePtr,
- char*,
- int
-#endif
-);
-
-#define BufFileGet(f) ((f)->left-- ? *(f)->bufp++ : (*(f)->io) (f))
-#define BufFilePut(c,f) (--(f)->left ? *(f)->bufp++ = (c) : (*(f)->io) (c,f))
-#define BufFileSkip(f,c) ((*(f)->skip) (f, c))
+#define BufFileGet(f) ((f)->left-- ? *(f)->bufp++ : ((f)->eof = (*(f)->input) (f)))
+#define BufFilePut(c,f) (--(f)->left ? *(f)->bufp++ = ((unsigned char)(c)) : (*(f)->output) ((unsigned char)(c),f))
+#define BufFileSkip(f,c) ((f)->eof = (*(f)->skip) (f, c))
#ifndef TRUE
#define TRUE 1
@@ -120,3 +87,6 @@ extern int BufFileWrite (
#ifndef FALSE
#define FALSE 0
#endif
+
+#endif /* ___BUFIO_H___ */
+
diff --git a/include/X11/fonts/fntfil.h b/include/X11/fonts/fntfil.h
index 6999e51..a8d9780 100644
--- a/include/X11/fonts/fntfil.h
+++ b/include/X11/fonts/fntfil.h
@@ -25,6 +25,7 @@ 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/include/fntfil.h,v 1.10 2002/12/09 17:30:00 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -32,6 +33,9 @@ in this Software without prior written authorization from The Open Group.
#ifndef _FONTFILE_H_
#define _FONTFILE_H_
+
+#include "fontxlfd.h"
+
typedef struct _FontEntry *FontEntryPtr;
typedef struct _FontTable *FontTablePtr;
typedef struct _FontName *FontNamePtr;
@@ -71,10 +75,104 @@ typedef struct _FontRenderer *FontRendererPtr;
#define FontAliasFile "fonts.alias"
#define FontScalableFile "fonts.scale"
-extern FontEntryPtr FontFileFindNameInDir ();
-extern FontEntryPtr FontFileFindNameInScalableDir ();
-extern FontDirectoryPtr FontFileMakeDir ();
-extern FontRendererPtr FontFileMatchRenderer ();
-extern char *FontFileSaveString ();
-extern FontScaledPtr FontFileFindScaledInstance ();
+extern int FontFileNameCheck ( char *name );
+extern int FontFileInitFPE ( FontPathElementPtr fpe );
+extern int FontFileResetFPE ( FontPathElementPtr fpe );
+extern int FontFileFreeFPE ( FontPathElementPtr fpe );
+extern 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 );
+extern void FontFileCloseFont ( FontPathElementPtr fpe, FontPtr pFont );
+extern int FontFileOpenBitmap ( FontPathElementPtr fpe, FontPtr *pFont,
+ int flags, FontEntryPtr entry,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask );
+extern int FontFileListFonts ( pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ FontNamesPtr names );
+extern int FontFileStartListFontsWithInfo ( pointer client,
+ FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep );
+extern int FontFileListNextFontWithInfo ( pointer client,
+ FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo,
+ int *numFonts, pointer private );
+extern int FontFileStartListFontsAndAliases ( pointer client,
+ FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep );
+extern int FontFileListNextFontOrAlias ( pointer client,
+ FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ char **resolvedp, int *resolvedlenp,
+ pointer private );
+extern void FontFileRegisterLocalFpeFunctions ( void );
+
+
+extern FontEntryPtr FontFileAddEntry ( FontTablePtr table,
+ FontEntryPtr prototype );
+extern Bool FontFileAddFontAlias ( FontDirectoryPtr dir, char *aliasName,
+ char *fontName );
+extern Bool FontFileAddFontFile ( FontDirectoryPtr dir, char *fontName,
+ char *fileName );
+extern int FontFileCountDashes ( char *name, int namelen );
+extern FontEntryPtr FontFileFindNameInDir ( FontTablePtr table,
+ FontNamePtr pat );
+extern FontEntryPtr FontFileFindNameInScalableDir ( FontTablePtr table,
+ FontNamePtr pat,
+ FontScalablePtr vals );
+extern int FontFileFindNamesInDir ( FontTablePtr table, FontNamePtr pat,
+ int max, FontNamesPtr names );
+extern int FontFileFindNamesInScalableDir ( FontTablePtr table,
+ FontNamePtr pat, int max,
+ FontNamesPtr names,
+ FontScalablePtr vals,
+ int alias_behavior, int *newmax );
+
+extern void FontFileFreeDir ( FontDirectoryPtr dir );
+extern void FontFileFreeEntry ( FontEntryPtr entry );
+extern void FontFileFreeTable ( FontTablePtr table );
+extern Bool FontFileInitTable ( FontTablePtr table, int size );
+extern FontDirectoryPtr FontFileMakeDir ( char *dirName, int size );
+extern Bool FontFileMatchName ( char *name, int length, FontNamePtr pat );
+extern char * FontFileSaveString ( char *s );
+extern void FontFileSortDir ( FontDirectoryPtr dir );
+extern void FontFileSortTable ( FontTablePtr table );
+
+extern void FontDefaultFormat ( int *bit, int *byte, int *glyph, int *scan );
+
+extern Bool FontFileRegisterRenderer ( FontRendererPtr renderer );
+extern Bool FontFilePriorityRegisterRenderer ( FontRendererPtr renderer,
+ int priority );
+extern FontRendererPtr FontFileMatchRenderer ( char *fileName );
+
+extern Bool FontFileAddScaledInstance ( FontEntryPtr entry,
+ FontScalablePtr vals, FontPtr pFont,
+ char *bitmapName );
+extern void FontFileSwitchStringsToBitmapPointers ( FontDirectoryPtr dir );
+extern void FontFileRemoveScaledInstance ( FontEntryPtr entry, FontPtr pFont );
+extern Bool FontFileCompleteXLFD ( FontScalablePtr vals, FontScalablePtr def );
+extern FontScaledPtr FontFileFindScaledInstance ( FontEntryPtr entry,
+ FontScalablePtr vals,
+ int noSpecificSize );
+
+extern Bool FontFileRegisterBitmapSource ( FontPathElementPtr fpe );
+extern void FontFileUnregisterBitmapSource ( FontPathElementPtr fpe );
+extern void FontFileEmptyBitmapSource ( void );
+extern int FontFileMatchBitmapSource ( FontPathElementPtr fpe,
+ FontPtr *pFont, int flags,
+ FontEntryPtr entry,
+ FontNamePtr zeroPat,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ Bool noSpecificSize );
+
+extern int FontFileReadDirectory ( char *directory, FontDirectoryPtr *pdir );
+extern Bool FontFileDirectoryChanged ( FontDirectoryPtr dir );
+
#endif /* _FONTFILE_H_ */
diff --git a/include/X11/fonts/fntfilio.h b/include/X11/fonts/fntfilio.h
index ffb146b..1044da0 100644
--- a/include/X11/fonts/fntfilio.h
+++ b/include/X11/fonts/fntfilio.h
@@ -25,12 +25,16 @@ 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/include/fntfilio.h,v 1.7 2001/12/14 19:56:54 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
*/
-#include <bufio.h>
+#ifndef _FNTFILIO_H_
+#define _FNTFILIO_H_
+
+#include "bufio.h"
typedef BufFilePtr FontFilePtr;
@@ -43,8 +47,10 @@ typedef BufFilePtr FontFilePtr;
#define FontFileEOF BUFFILEEOF
-extern FontFilePtr FontFileOpen ();
-extern FontFilePtr FontFileOpenWrite ();
-extern FontFilePtr FontFileOpenFd ();
-extern FontFilePtr FontFileOpenWriteFd ();
-extern int FontFileClose ();
+extern FontFilePtr FontFileOpen ( const char *name );
+extern int FontFileClose ( FontFilePtr f );
+extern FontFilePtr FontFileOpenWrite ( const char *name );
+extern FontFilePtr FontFileOpenWriteFd ( int fd );
+extern FontFilePtr FontFileOpenFd ( int fd );
+
+#endif /* _FNTFILIO_H_ */
diff --git a/include/X11/fonts/fntfilst.h b/include/X11/fonts/fntfilst.h
index 8e90090..8be46f2 100644
--- a/include/X11/fonts/fntfilst.h
+++ b/include/X11/fonts/fntfilst.h
@@ -25,6 +25,7 @@ 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/include/fntfilst.h,v 3.9 2002/12/10 22:23:52 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -33,13 +34,15 @@ in this Software without prior written authorization from The Open Group.
#ifndef _FONTFILEST_H_
#define _FONTFILEST_H_
+#ifndef FONTMODULE
#include <X11/Xos.h>
+#endif
#ifndef XP_PSTEXT
#include "fontmisc.h"
#endif
#include "fontstruct.h"
-#include "fntfil.h"
#include "fontxlfd.h"
+#include "fntfil.h"
typedef struct _FontName {
char *name;
@@ -116,6 +119,7 @@ typedef struct _FontDirectory {
unsigned long alias_mtime;
FontTableRec scalable;
FontTableRec nonScalable;
+ char *attributes;
} FontDirectoryRec;
/* Capability bits: for definition of capabilities bitmap in the
@@ -127,17 +131,45 @@ typedef struct _FontDirectory {
typedef struct _FontRenderer {
char *fileSuffix;
int fileSuffixLen;
- int (*OpenBitmap)(/* fpe, pFont, flags, entry, fileName, format, fmask */);
- int (*OpenScalable)(/* fpe, pFont, flags, entry, fileName, vals, format, fmask */);
- int (*GetInfoBitmap)(/* fpe, pFontInfo, entry, fileName */);
- int (*GetInfoScalable)(/* fpe, pFontInfo, entry, fileName, vals */);
+ int (*OpenBitmap)(FontPathElementPtr /* fpe */,
+ FontPtr * /* pFont */,
+ int /* flags */,
+ FontEntryPtr /* entry */,
+ char * /* fileName */,
+ fsBitmapFormat /* format */,
+ fsBitmapFormatMask /* mask */,
+ FontPtr /* non_cachable_font */);
+ int (*OpenScalable)(FontPathElementPtr /* fpe */,
+ FontPtr * /* pFont */,
+ int /* flags */,
+ FontEntryPtr /* entry */,
+ char * /* fileName */,
+ FontScalablePtr /* vals */,
+ fsBitmapFormat /* format */,
+ fsBitmapFormatMask /* fmask */,
+ FontPtr /* non_cachable_font */);
+ int (*GetInfoBitmap)(FontPathElementPtr /* fpe */,
+ FontInfoPtr /* pFontInfo */,
+ FontEntryPtr /* entry */,
+ char * /*fileName */);
+ int (*GetInfoScalable)(FontPathElementPtr /* fpe */,
+ FontInfoPtr /* pFontInfo */,
+ FontEntryPtr /* entry */,
+ FontNamePtr /* fontName */,
+ char * /* fileName */,
+ FontScalablePtr /* vals */);
int number;
int capabilities; /* Bitmap components defined above */
} FontRendererRec;
typedef struct _FontRenders {
int number;
- FontRendererPtr *renderers;
+ struct _FontRenderersElement {
+ /* In order to preserve backward compatibility, the
+ priority field is made invisible to renderers */
+ FontRendererPtr renderer;
+ int priority;
+ } *renderers;
} FontRenderersRec, *FontRenderersPtr;
typedef struct _BitmapInstance {
diff --git a/include/X11/fonts/fontmisc.h b/include/X11/fonts/fontmisc.h
index 22ee61e..6439ba1 100644
--- a/include/X11/fonts/fontmisc.h
+++ b/include/X11/fonts/fontmisc.h
@@ -25,6 +25,7 @@ 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/include/fontmisc.h,v 3.16 2001/12/14 19:56:54 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -33,13 +34,9 @@ in this Software without prior written authorization from The Open Group.
#ifndef _FONTMISC_H_
#define _FONTMISC_H_
+#ifndef FONTMODULE
#include <X11/Xfuncs.h>
-
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#else
-extern int rand();
-#endif
#include <stdio.h>
#ifndef X_NOT_POSIX
@@ -48,19 +45,10 @@ extern int rand();
extern int close();
#endif
-typedef unsigned char *pointer;
-typedef int Bool;
+#endif /* FONTMODULE */
+
+#include "X11/Xdefs.h"
-#ifndef X_PROTOCOL
-#ifndef _XSERVER64
-typedef unsigned long Atom;
-typedef unsigned long XID;
-#else
-#include <X11/Xmd.h>
-typedef CARD32 XID;
-typedef CARD32 Atom;
-#endif
-#endif
#ifndef LSBFirst
#define LSBFirst 0
@@ -76,49 +64,69 @@ typedef CARD32 Atom;
#define FALSE 0
#endif
-extern char *NameForAtom ();
+extern Atom MakeAtom ( char *string, unsigned len, int makeit );
+extern int ValidAtom ( Atom atom );
+extern char *NameForAtom (Atom atom);
+
+#ifndef OS_H
+extern pointer Xalloc(unsigned long);
+extern pointer Xrealloc(pointer, unsigned long);
+extern void Xfree(pointer);
+extern pointer Xcalloc(unsigned long);
+#endif
+extern int f_strcasecmp(const char *s1, const char *s2);
+#ifndef xalloc
#define xalloc(n) Xalloc ((unsigned) n)
#define xfree(p) Xfree ((pointer) p)
#define xrealloc(p,n) Xrealloc ((pointer)p,n)
+#define xcalloc(n,s) Xcalloc((unsigned) n * (unsigned) s)
+#endif
#define lowbit(x) ((x) & (~(x) + 1))
-#define assert(x)
+#undef assert
+#define assert(x) ((void)0)
+
+#ifndef strcasecmp
+#if defined(NEED_STRCASECMP) && !defined(FONTMODULE)
+#define strcasecmp(s1,s2) f_strcasecmp(s1,s2)
+#endif
+#endif
extern void
BitOrderInvert(
-#if NeedFunctionPrototypes
register unsigned char *,
register int
-#endif
);
extern void
TwoByteSwap(
-#if NeedFunctionPrototypes
register unsigned char *,
register int
-#endif
);
extern void
FourByteSwap(
-#if NeedFunctionPrototypes
register unsigned char *,
register int
-#endif
);
extern int
RepadBitmap (
-#if NeedFunctionPrototypes
char*,
char*,
unsigned,
unsigned,
int,
int
-#endif
);
+extern void CopyISOLatin1Lowered(
+ char * /*dest*/,
+ char * /*source*/,
+ int /*length*/
+);
+
+extern void register_fpe_functions(void);
+
#endif /* _FONTMISC_H_ */
diff --git a/include/X11/fonts/fontxlfd.h b/include/X11/fonts/fontxlfd.h
index 759d41e..49769bc 100644
--- a/include/X11/fonts/fontxlfd.h
+++ b/include/X11/fonts/fontxlfd.h
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/include/fontxlfd.h,v 1.6 2001/12/14 19:56:55 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -63,7 +64,6 @@ from The Open Group.
#define XLFD_NDIGITS 3 /* Round numbers in pixel and
point arrays to this many
digits for repeatability */
-double xlfd_round_double();
typedef struct _FontScalable {
int values_supplied; /* Bitmap identifying what advanced
@@ -87,8 +87,10 @@ typedef struct _FontScalable {
fsRange *ranges;
} FontScalableRec, *FontScalablePtr;
-extern Bool FontParseXLFDName();
-extern fsRange *FontParseRanges();
+
+extern double xlfd_round_double ( double x );
+extern Bool FontParseXLFDName ( char *fname, FontScalablePtr vals, int subst );
+extern fsRange *FontParseRanges ( char *name, int *nranges );
#define FONT_XLFD_REPLACE_NONE 0
#define FONT_XLFD_REPLACE_STAR 1
diff --git a/include/X11/fonts/pcf.h b/include/X11/fonts/pcf.h
index 510a8a6..57f739d 100644
--- a/include/X11/fonts/pcf.h
+++ b/include/X11/fonts/pcf.h
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/pcf.h,v 1.4 2001/12/14 19:56:47 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -88,4 +89,11 @@ typedef struct _PCFTable {
#define PCF_GLYPH_NAMES (1<<7)
#define PCF_BDF_ACCELERATORS (1<<8)
+extern int pcfReadFont ( FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan );
+extern int pcfReadFontInfo ( FontInfoPtr pFontInfo, FontFilePtr file );
+extern int pmfReadFont ( FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan );
+extern int pcfWriteFont ( FontPtr pFont, FontFilePtr file );
+
#endif /* _PCF_H_ */
diff --git a/src/Speedo/bics-iso.h b/src/Speedo/bics-iso.h
index f520562..d3cd35b 100644
--- a/src/Speedo/bics-iso.h
+++ b/src/Speedo/bics-iso.h
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/Speedo/bics-iso.h,v 1.7 2001/12/14 19:56:41 dawes Exp $ */
int sp_bics_map[] = {
32, 0,
diff --git a/src/Speedo/do_char.c b/src/Speedo/do_char.c
index 0ae416b..f28af7c 100644
--- a/src/Speedo/do_char.c
+++ b/src/Speedo/do_char.c
@@ -21,6 +21,7 @@ INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
*/
+/* $XFree86: xc/lib/font/Speedo/do_char.c,v 1.4 2001/08/27 19:49:50 dawes Exp $ */
/***************************** D O - C H A R . C *****************************
* *
@@ -52,24 +53,16 @@ WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
/***** STATIC FUNCTIONS *****/
-#if PROTOS_AVAIL
static boolean sp_make_simp_char(PROTO_DECL2 ufix8 FONTFAR *pointer,ufix8 format);
static boolean sp_make_comp_char(PROTO_DECL2 ufix8 FONTFAR *pointer);
static ufix8 FONTFAR *sp_get_char_org(PROTO_DECL2 ufix16 char_index,boolean top_level);
static fix15 sp_get_posn_arg(PROTO_DECL2 ufix8 FONTFAR *STACKFAR *ppointer,ufix8 format);
static fix15 sp_get_scale_arg(PROTO_DECL2 ufix8 FONTFAR *STACKFAR *ppointer,ufix8 format);
-#else
-static boolean sp_make_simp_char(); /* Process simple character data */
-static boolean sp_make_comp_char(); /* Process compound character data */
-static ufix8 FONTFAR *sp_get_char_org(); /* Look up char in character directory */
-static fix15 sp_get_posn_arg(); /* Read Xpos Ypos args in DOCH instruction */
-static fix15 sp_get_scale_arg(); /* read Xscale Yscale args in DOCH instruction */
-#endif
-FUNCTION ufix16 get_char_id(char_index)
+FUNCTION ufix16 get_char_id(
GDECL
-ufix16 char_index; /* Index to character in char directory */
+ufix16 char_index) /* Index to character in char directory */
/*
* Returns character id for specified character index in currently
* selected font.
@@ -97,9 +90,9 @@ return 0xffff & NEXT_WORD(pointer); /* Return character id */
#if INCL_METRICS
-FUNCTION fix31 get_char_width(char_index)
+FUNCTION fix31 get_char_width(
GDECL
-ufix16 char_index; /* Index to character in char directory */
+ufix16 char_index) /* Index to character in char directory */
/*
* Returns character set width for specified character index in currently
* selected font in units of 1/65536 em.
@@ -131,10 +124,10 @@ return set_width; /* Return in 1/65536 em units */
#endif
#if INCL_METRICS
-FUNCTION fix15 get_track_kern(track, point_size)
+FUNCTION fix15 get_track_kern(
GDECL
-fix15 track; /* Track required (0 - 3) */
-fix15 point_size; /* Point size (units of whole points) */
+fix15 track, /* Track required (0 - 3) */
+fix15 point_size) /* Point size (units of whole points) */
/*
* Returns inter-character spacing adjustment in units of 1/256
* points for the specified kerning track and point size.
@@ -153,16 +146,16 @@ fix15 point_size; /* Point size (units of whole points) */
*/
{
ufix8 FONTFAR *pointer; /* Pointer to character data */
-fix15 no_tracks; /* Number of kerning tracks in font */
-ufix8 format; /* Track kerning format byte */
-fix15 i; /* Track counter */
-fix15 min_pt_size; /* Minimum point size for track */
-fix15 max_pt_size; /* Maximum point size for track */
-fix15 min_adj; /* Adjustment for min point size */
-fix15 max_adj; /* Adjustment for max point size */
-fix31 delta_pt_size;/* Max point size - min point size */
-fix31 delta_adj; /* Min adjustment - max adjustment */
-fix15 adj = 0; /* Interpolated adjustment */
+fix15 no_tracks; /* Number of kerning tracks in font */
+ufix8 format; /* Track kerning format byte */
+fix15 i; /* Track counter */
+fix15 min_pt_size = 0; /* Minimum point size for track */
+fix15 max_pt_size = 0; /* Maximum point size for track */
+fix15 min_adj = 0; /* Adjustment for min point size */
+fix15 max_adj = 0; /* Adjustment for max point size */
+fix31 delta_pt_size; /* Max point size - min point size */
+fix31 delta_adj; /* Min adjustment - max adjustment */
+fix15 adj = 0; /* Interpolated adjustment */
if (track == 0) /* Track zero selected? */
{
@@ -220,10 +213,10 @@ return adj; /* Return interpolated adjustment (1/256 points
#endif
#if INCL_METRICS
-FUNCTION fix31 get_pair_kern(char_index1, char_index2)
+FUNCTION fix31 get_pair_kern(
GDECL
-ufix16 char_index1; /* Index to first character in char directory */
-ufix16 char_index2; /* Index to second character in char directory */
+ufix16 char_index1, /* Index to first character in char directory */
+ufix16 char_index2) /* Index to second character in char directory */
/*
* Returns inter-character spacing adjustment in units of 1/65536 em
* for the specified pair of characters.
@@ -243,7 +236,7 @@ fix15 nn; /* Number of kern pairs in first partition */
fix15 base; /* Index to first record in rem kern pairs */
fix15 i; /* Index to kern pair being tested */
fix31 adj = 0; /* Returned value of adjustment */
-fix15 adj_base; /* Adjustment base for relative adjustments */
+fix15 adj_base = 0; /* Adjustment base for relative adjustments */
if (!sp_globals.specs_valid) /* Font specs not defined? */
{
@@ -310,10 +303,10 @@ return adj; /* Return pair kerning adjustment */
#if INCL_METRICS
#ifdef old
-FUNCTION boolean get_char_bbox(char_index, bbox)
+FUNCTION boolean get_char_bbox(
GDECL
-ufix16 char_index;
-bbox_t *bbox;
+ufix16 char_index,
+bbox_t *bbox)
{
/*
* returns true if character exists, false if it doesn't
@@ -368,10 +361,10 @@ return TRUE;
#else /* new code, 4/25/91 */
-FUNCTION boolean get_char_bbox(char_index, bbox)
+FUNCTION boolean get_char_bbox(
GDECL
-ufix16 char_index;
-bbox_t *bbox;
+ufix16 char_index,
+bbox_t *bbox)
{
/*
* returns true if character exists, false if it doesn't
@@ -447,10 +440,10 @@ return TRUE;
#if INCL_ISW
-FUNCTION boolean make_char_isw(char_index,imported_setwidth)
+FUNCTION boolean make_char_isw(
GDECL
-ufix16 char_index;
-ufix32 imported_setwidth;
+ufix16 char_index,
+ufix32 imported_setwidth)
{
fix15 xmin; /* Minimum X ORU value in font */
fix15 xmax; /* Maximum X ORU value in font */
@@ -481,17 +474,17 @@ if (sp_globals.isw_modified_constants)
return (return_value);
}
-FUNCTION boolean make_char(char_index)
+FUNCTION boolean make_char(
GDECL
-ufix16 char_index; /* Index to character in char directory */
+ufix16 char_index) /* Index to character in char directory */
{
sp_globals.import_setwidth_act = FALSE;
return (do_make_char(char_index));
}
-FUNCTION static boolean do_make_char(char_index)
+FUNCTION static boolean do_make_char(GDECL ufix16 char_index)
#else
-FUNCTION boolean make_char(char_index)
+FUNCTION boolean make_char(GDECL ufix16 char_index)
#endif
/*
* Outputs specified character using the currently selected font and
@@ -500,8 +493,6 @@ FUNCTION boolean make_char(char_index)
* previously set.
* Reports Error 12 and returns FALSE if character data not available.
*/
-GDECL
-ufix16 char_index;
{
ufix8 FONTFAR *pointer; /* Pointer to character data */
fix15 x_orus;
@@ -594,10 +585,10 @@ else
}
}
-FUNCTION static boolean sp_make_simp_char(pointer, format)
+FUNCTION static boolean sp_make_simp_char(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to first byte of position argument */
-ufix8 format; /* Character format byte */
+ufix8 FONTFAR *pointer, /* Pointer to first byte of position argument */
+ufix8 format) /* Character format byte */
/*
* Called by sp_make_char() to output a simple (non-compound) character.
* Returns TRUE on completion.
@@ -655,9 +646,9 @@ if (fn_begin_char(sp_globals.Psw, Pmin, Pmax)) /* Signal start of character
return TRUE;
}
-FUNCTION static boolean sp_make_comp_char(pointer)
+FUNCTION static boolean sp_make_comp_char(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to first byte of position argument */
+ufix8 FONTFAR *pointer) /* Pointer to first byte of position argument */
/*
* Called by sp_make_char() to output a compound character.
* Returns FALSE if data for any sub-character is not available.
@@ -796,10 +787,10 @@ return TRUE;
}
#if INCL_LCD /* Dynamic load character data supported? */
-FUNCTION static ufix8 FONTFAR *sp_get_char_org(char_index, top_level)
+FUNCTION static ufix8 FONTFAR *sp_get_char_org(
GDECL
-ufix16 char_index; /* Index of character to be accessed */
-boolean top_level; /* Not a compound character element */
+ufix16 char_index, /* Index of character to be accessed */
+boolean top_level) /* Not a compound character element */
/*
* Called by sp_get_char_id(), sp_get_char_width(), sp_make_char() and
* sp_make_comp_char() to get a pointer to the start of the character data
@@ -864,10 +855,10 @@ return pchar_data->org; /* Return pointer into character data buff
#if INCL_LCD
#else /* Dynamic load character data not supported? */
-FUNCTION static ufix8 FONTFAR *sp_get_char_org(char_index, top_level)
+FUNCTION static ufix8 FONTFAR *sp_get_char_org(
GDECL
-ufix16 char_index; /* Index of character to be accessed */
-boolean top_level; /* Not a compound character element */
+ufix16 char_index, /* Index of character to be accessed */
+boolean top_level) /* Not a compound character element */
/*
* Called by sp_get_char_id(), sp_get_char_width(), sp_make_char() and
* sp_make_comp_char() to get a pointer to the start of the character data
@@ -915,10 +906,10 @@ return sp_globals.pfont->org + char_offset; /* Return pointer into font buf
#endif
-FUNCTION static fix15 sp_get_posn_arg(ppointer, format)
+FUNCTION static fix15 sp_get_posn_arg(
GDECL
-ufix8 FONTFAR * STACKFAR *ppointer; /* Pointer to first byte of position argument */
-ufix8 format; /* Format of DOCH arguments */
+ufix8 FONTFAR * STACKFAR *ppointer, /* Pointer to first byte of position argument */
+ufix8 format) /* Format of DOCH arguments */
/*
* Called by sp_make_comp_char() to read a position argument from the
* specified point in the font/char buffer.
@@ -939,10 +930,10 @@ default:
}
}
-FUNCTION static fix15 sp_get_scale_arg(ppointer, format)
+FUNCTION static fix15 sp_get_scale_arg(
GDECL
-ufix8 FONTFAR *STACKFAR *ppointer; /* Pointer to first byte of position argument */
-ufix8 format; /* Format of DOCH arguments */
+ufix8 FONTFAR *STACKFAR *ppointer, /* Pointer to first byte of position argument */
+ufix8 format) /* Format of DOCH arguments */
/*
* Called by sp_make_comp_char() to read a scale argument from the
* specified point in the font/char buffer.
@@ -956,10 +947,10 @@ else
return (fix15)ONE_SCALE;
}
#if INCL_ISW || INCL_SQUEEZING
-FUNCTION static void preview_bounding_box(pointer,format)
+FUNCTION static void preview_bounding_box(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to first byte of position argument */
-ufix8 format; /* Character format byte */
+ufix8 FONTFAR *pointer, /* Pointer to first byte of position argument */
+ufix8 format) /* Character format byte */
{
point_t Pmin, Pmax; /* Transformed corners of bounding box */
@@ -984,9 +975,9 @@ x */
}
#endif
#if INCL_ISW
-FUNCTION static boolean reset_xmax(xmax)
+FUNCTION static boolean reset_xmax(
GDECL
-fix31 xmax;
+fix31 xmax)
{
fix15 xmin; /* Minimum X ORU value in font */
diff --git a/src/Speedo/do_trns.c b/src/Speedo/do_trns.c
index b003284..25bc02a 100644
--- a/src/Speedo/do_trns.c
+++ b/src/Speedo/do_trns.c
@@ -21,6 +21,7 @@ INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
*/
+/* $XFree86: xc/lib/font/Speedo/do_trns.c,v 1.4 2001/08/27 19:49:50 dawes Exp $ */
/**************************** D O _ T R N S . C ******************************
* *
@@ -53,21 +54,16 @@ WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
/***** STATIC FUNCTIONS *****/
-#if PROTOS_AVAIL
static void sp_split_curve(PROTO_DECL2 point_t P1,point_t P2,point_t P3,fix15 depth);
static ufix8 FONTFAR *sp_get_args(PROTO_DECL2 ufix8 FONTFAR *pointer,ufix8 format,point_t STACKFAR *pP);
-#else
-static void sp_split_curve(); /* Split Bezier curve into vectors */
-static ufix8 FONTFAR *sp_get_args(); /* Read X Y argument pair */
-#endif
-FUNCTION ufix8 FONTFAR *read_bbox(pointer, pPmin, pPmax, set_flag)
+FUNCTION ufix8 FONTFAR *read_bbox(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to next byte in char data */
-point_t STACKFAR *pPmin; /* Lower left corner of bounding box */
-point_t STACKFAR *pPmax; /* Upper right corner of bounding box */
-boolean set_flag; /* flag to indicate whether global oru bbox should be saved */
+ufix8 FONTFAR *pointer, /* Pointer to next byte in char data */
+point_t STACKFAR *pPmin, /* Lower left corner of bounding box */
+point_t STACKFAR *pPmax, /* Upper right corner of bounding box */
+boolean set_flag) /* flag to indicate whether global oru bbox should be saved */
/*
* Called by make_simp_char() and make_comp_char() to read the
* bounding box data from the font.
@@ -79,7 +75,7 @@ boolean set_flag; /* flag to indicate whether global oru bbox should be saved */
*/
{
ufix8 format1;
-ufix8 format;
+ufix8 format = 0;
fix15 i;
point_t P;
@@ -155,9 +151,9 @@ printf("BBOX %6.1f(Xint 0), %6.1f(Yint 0), %6.1f(Xint %d), %6.1f(Yint %d)\n",
return pointer;
}
-FUNCTION void proc_outl_data(pointer)
+FUNCTION void proc_outl_data(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to next byte in char data */
+ufix8 FONTFAR *pointer) /* Pointer to next byte in char data */
/*
* Called by make_simp_char() and make_comp_char() to read the
* outline data from the font.
@@ -310,12 +306,12 @@ record_yint((fix15)(sp_globals.y_int - sp_globals.Y_int_org)); /* Record yint da
}
}
-FUNCTION static void sp_split_curve(P1, P2, P3, depth)
+FUNCTION static void sp_split_curve(
GDECL
-point_t P1; /* First control point of Bezier curve */
-point_t P2; /* Second control point of Bezier curve */
-point_t P3; /* End point of Bezier curve */
-fix15 depth; /* Levels of recursive subdivision required */
+point_t P1, /* First control point of Bezier curve */
+point_t P2, /* Second control point of Bezier curve */
+point_t P3, /* End point of Bezier curve */
+fix15 depth) /* Levels of recursive subdivision required */
/*
* Called by proc_outl_data() to subdivide Bezier curves into an
* appropriate number of vectors, whenever curves are not enabled
@@ -369,11 +365,11 @@ else
}
}
-FUNCTION static ufix8 FONTFAR *sp_get_args(pointer, format, pP)
+FUNCTION static ufix8 FONTFAR *sp_get_args(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to next byte in char data */
-ufix8 format; /* Format specifiaction of argument pair */
-point_t STACKFAR *pP; /* Resulting transformed point */
+ufix8 FONTFAR *pointer, /* Pointer to next byte in char data */
+ufix8 format, /* Format specifiaction of argument pair */
+point_t STACKFAR *pP) /* Resulting transformed point */
/*
* Called by read_bbox() and proc_outl_data() to read an X Y argument
* pair from the font.
diff --git a/src/Speedo/out_bl2d.c b/src/Speedo/out_bl2d.c
index d14f8c3..74a7310 100644
--- a/src/Speedo/out_bl2d.c
+++ b/src/Speedo/out_bl2d.c
@@ -21,6 +21,7 @@ INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
*/
+/* $XFree86: xc/lib/font/Speedo/out_bl2d.c,v 1.4 2001/01/17 19:43:17 dawes Exp $ */
/*************************** O U T _ B L 2 D . C *****************************
* *
@@ -54,21 +55,15 @@ WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
/***** STATIC FUNCTIONS *****/
#if INCL_2D
-#if PROTOS_AVAIL
static void sp_draw_vector_to_2d(PROTO_DECL2 fix15 x0,fix15 y0,fix15 x1,fix15 y1,band_t GLOBALFAR *band);
static void sp_add_intercept_2d(PROTO_DECL2 fix15 y,fix15 x);
static void sp_proc_intercepts_2d(PROTO_DECL1);
-#else
-static void sp_add_intercept_2d();
-static void sp_proc_intercepts_2d();
-static void sp_draw_vector_to_2d();
-#endif
#endif
#if INCL_2D
-FUNCTION boolean init_2d(specsarg)
+FUNCTION boolean init_2d(
GDECL
-specs_t GLOBALFAR *specsarg;
+specs_t GLOBALFAR *specsarg)
/*
* init_out_2d() is called by sp_set_specs() to initialize the output module.
* Returns TRUE if output module can accept requested specifications.
@@ -87,11 +82,11 @@ return TRUE;
#endif
#if INCL_2D
-FUNCTION boolean begin_char_2d(Psw, Pmin, Pmax)
+FUNCTION boolean begin_char_2d(
GDECL
-point_t Psw;
-point_t Pmin;
-point_t Pmax;
+point_t Psw,
+point_t Pmin,
+point_t Pmax)
/* Called once at the start of the character generation process
* Initializes intercept table, either calculates pixel maxima or
* decides that they need to be collected
@@ -113,10 +108,10 @@ return TRUE;
#if INCL_2D
-FUNCTION void begin_contour_2d(P1, outside)
+FUNCTION void begin_contour_2d(
GDECL
-point_t P1;
-boolean outside;
+point_t P1,
+boolean outside)
/* Called at the start of each contour
*/
{
@@ -133,9 +128,9 @@ sp_globals.y0_spxl = P1.y;
#endif
#if INCL_2D
-FUNCTION void line_2d(P1)
+FUNCTION void line_2d(
GDECL
-point_t P1;
+point_t P1)
/*
* Called for each vector in the transformed character
* "draws" vector into intercept table
@@ -180,13 +175,13 @@ sp_globals.x0_spxl = P1.x;
sp_globals.y0_spxl = P1.y; /* update endpoint */
}
-FUNCTION static void sp_draw_vector_to_2d(x0, y0, x1, y1, band)
+FUNCTION static void sp_draw_vector_to_2d(
GDECL
-fix15 x0; /* X coordinate */
-fix15 y0; /* Y coordinate */
-fix15 x1;
-fix15 y1;
-band_t GLOBALFAR *band;
+fix15 x0, /* X coordinate */
+fix15 y0, /* Y coordinate */
+fix15 x1,
+fix15 y1,
+band_t GLOBALFAR *band)
{
register fix15 how_many_y; /* # of intercepts at y = n + 1/2 */
register fix15 yc; /* Current scan-line */
@@ -290,7 +285,6 @@ if (how_many_y < 0)
#if INCL_2D
FUNCTION boolean end_char_2d()
-GDECL
/* Called when all character data has been output
* Return TRUE if output process is complete
* Return FALSE to repeat output of the transformed data beginning
@@ -530,11 +524,11 @@ else
#endif
#if INCL_2D
-FUNCTION static void sp_add_intercept_2d(y, x)
+FUNCTION static void sp_add_intercept_2d(
GDECL
-fix15 y; /* Y coordinate in relative pixel units */
+fix15 y, /* Y coordinate in relative pixel units */
/* (0 is lowest sample in band) */
-fix15 x; /* X coordinate of intercept in subpixel units */
+fix15 x) /* X coordinate of intercept in subpixel units */
/* Called by line() to add an intercept to the intercept list structure
*/
@@ -609,7 +603,6 @@ if (++sp_globals.next_offset >= MAX_INTERCEPTS) /* Intercept buffer full? */
#if INCL_2D
FUNCTION static void sp_proc_intercepts_2d()
-GDECL
/* Called by sp_make_char to output accumulated intercept lists
* Clips output to xmin, xmax, sp_globals.ymin, ymax boundaries
*/
diff --git a/src/Speedo/out_blk.c b/src/Speedo/out_blk.c
index 71e39af..e56eb1b 100644
--- a/src/Speedo/out_blk.c
+++ b/src/Speedo/out_blk.c
@@ -21,7 +21,7 @@ INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
*/
-
+/* $XFree86: xc/lib/font/Speedo/out_blk.c,v 1.3 2001/01/17 19:43:17 dawes Exp $ */
/*************************** O U T _ B L K . C *********************************
@@ -58,20 +58,15 @@ WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
/***** STATIC FUNCTIONS *****/
#if INCL_BLACK
-#if PROTOS_AVAIL
static void sp_add_intercept_black(PROTO_DECL2 fix15 y, fix15 x);
static void sp_proc_intercepts_black(PROTO_DECL1);
-#else
-static void sp_add_intercept_black();
-static void sp_proc_intercepts_black();
-#endif
#endif
#if INCL_BLACK
-FUNCTION boolean init_black(specsarg)
+FUNCTION boolean init_black(
GDECL
-specs_t GLOBALFAR *specsarg;
+specs_t GLOBALFAR *specsarg)
/*
* init_out0() is called by sp_set_specs() to initialize the output module.
* Returns TRUE if output module can accept requested specifications.
@@ -89,11 +84,11 @@ return (TRUE);
#if INCL_BLACK
-FUNCTION boolean begin_char_black(Psw, Pmin, Pmax)
+FUNCTION boolean begin_char_black(
GDECL
-point_t Psw;
-point_t Pmin;
-point_t Pmax;
+point_t Psw,
+point_t Pmin,
+point_t Pmax)
/* Called once at the start of the character generation process
*/
{
@@ -110,10 +105,10 @@ return TRUE;
#if INCL_BLACK
-FUNCTION void begin_contour_black(P1, outside)
+FUNCTION void begin_contour_black(
GDECL
-point_t P1;
-boolean outside;
+point_t P1,
+boolean outside)
/* Called at the start of each contour
*/
{
@@ -129,9 +124,9 @@ sp_globals.y_pxl = (sp_globals.y0_spxl + sp_globals.pixrnd) >> sp_globals.pixshi
#endif
#if INCL_BLACK
-FUNCTION void line_black(P1)
+FUNCTION void line_black(
GDECL
-point_t P1;
+point_t P1)
/* Called for each vector in the transformed character
*/
{
@@ -522,11 +517,11 @@ else
#endif
#if INCL_BLACK
-FUNCTION LOCAL void sp_add_intercept_black(y, x)
+FUNCTION LOCAL void sp_add_intercept_black(
GDECL
-fix15 y; /* Y coordinate in relative pixel units */
+fix15 y, /* Y coordinate in relative pixel units */
/* (0 is lowest sample in band) */
-fix15 x; /* X coordinate of intercept in subpixel units */
+fix15 x) /* X coordinate of intercept in subpixel units */
/* Called by line() to add an intercept to the intercept list structure
*/
diff --git a/src/Speedo/out_scrn.c b/src/Speedo/out_scrn.c
index 3d04db6..e17f7f6 100644
--- a/src/Speedo/out_scrn.c
+++ b/src/Speedo/out_scrn.c
@@ -21,6 +21,7 @@ INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
*/
+/* $XFree86: xc/lib/font/Speedo/out_scrn.c,v 1.5 2001/01/17 19:43:17 dawes Exp $ */
/*************************** O U T _ S C R N . C *****************************
@@ -56,19 +57,14 @@ WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
/***** STATIC FUNCTIONS *****/
-#if PROTOS_AVAIL
static void sp_add_intercept_screen(PROTO_DECL2 fix15 y,fix31 x);
static void sp_proc_intercepts_screen(PROTO_DECL1);
-#else
-static void sp_add_intercept_screen();
-static void sp_proc_intercepts_screen();
-#endif
#if INCL_SCREEN
-FUNCTION boolean init_screen(specsarg)
+FUNCTION boolean init_screen(
GDECL
-specs_t FONTFAR *specsarg;
+specs_t FONTFAR *specsarg)
/*
* init_out0() is called by sp_set_specs() to initialize the output module.
* Returns TRUE if output module can accept requested specifications.
@@ -84,11 +80,11 @@ return (TRUE);
#if INCL_SCREEN
-FUNCTION boolean begin_char_screen(Psw, Pmin, Pmax)
+FUNCTION boolean begin_char_screen(
GDECL
-point_t Psw;
-point_t Pmin;
-point_t Pmax;
+point_t Psw,
+point_t Pmin,
+point_t Pmax)
/* Called once at the start of the character generation process
*/
{
@@ -111,10 +107,10 @@ return TRUE;
#if INCL_SCREEN
-FUNCTION void begin_contour_screen(P1, outside)
+FUNCTION void begin_contour_screen(
GDECL
-point_t P1;
-boolean outside;
+point_t P1,
+boolean outside)
/* Called at the start of each contour
*/
{
@@ -130,10 +126,10 @@ sp_globals.y_pxl = (sp_globals.y0_spxl + sp_globals.pixrnd) >> sp_globals.pixshi
#endif
#if INCL_SCREEN
-FUNCTION void curve_screen(P1, P2, P3, depth)
+FUNCTION void curve_screen(
GDECL
-point_t P1, P2, P3;
-fix15 depth;
+point_t P1, point_t P2, point_t P3,
+fix15 depth)
{
fix31 X0;
fix31 Y0;
@@ -187,9 +183,9 @@ sp_globals.y0_spxl = P3.y;
sp_globals.y_pxl = (P3.y + sp_globals.pixrnd) >> sp_globals.pixshift; /* calculate new end-scan sp_globals.line */
}
-FUNCTION void scan_curve_screen(X0,Y0,X1,Y1,X2,Y2,X3,Y3)
+FUNCTION void scan_curve_screen(
GDECL
-fix31 X0,Y0,X1,Y1,X2,Y2,X3,Y3;
+fix31 X0, fix31 Y0, fix31 X1, fix31 Y1, fix31 X2, fix31 Y2, fix31 X3, fix31 Y3)
/* Called for each curve in the transformed character if curves out enabled
*/
{
@@ -200,7 +196,7 @@ fix31 Pctrl1y;
fix31 Pctrl2x;
fix31 Pctrl2y;
-#if DBGCRV
+#ifdef DBGCRV
printf("SCAN_CURVE_SCREEN(%6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f)\n",
(real)(X0-32768) / 65536.0, (real)(Y0-32768) / 65536.0,
(real)(X1-32768) / 65536.0, (real)(Y1-32768) / 65536.0,
@@ -214,7 +210,7 @@ if (((Y3 >> 16)) == (Y0 >> 16) || (Y3+1) == Y0 || Y3 == (Y0+1))
}
if ((X3 >> 16) == (X0 >> 16))
{
- vert_line_screen(X3,(Y0>>16),(Y3>>16));
+ vert_line_screen(X3,(fix15)(Y0>>16),(fix15)(Y3>>16));
return;
}
Pmidx = (X0 + (X1 + X2) * 3 + X3 + 4 ) >> 3;
@@ -233,13 +229,13 @@ Pctrl2y = (Y2 + Y3 + 1 ) >> 1;
scan_curve_screen(Pmidx,Pmidy, Pctrl1x,Pctrl1y, Pctrl2x,Pctrl2y, X3,Y3);
}
-FUNCTION void vert_line_screen(x,y1,y2)
+FUNCTION void vert_line_screen(
GDECL
-fix31 x;
-fix15 y1, y2;
+fix31 x,
+fix15 y1, fix15 y2)
{
-#if DBGCRV
+#ifdef DBGCRV
printf("VERT_LINE_SCREEN(%6.4f, %6.4f, %6.4f)\n",
(real)(x - 32768) / 65536.0,
(real)(y1 - 32768) / 65536.0,
@@ -287,9 +283,9 @@ else if (y2 > y1) /* Line goes upwards ? */
#if INCL_SCREEN
-FUNCTION void line_screen(P1)
+FUNCTION void line_screen(
GDECL
-point_t P1;
+point_t P1)
/* Called for each vector in the transformed character
*/
{
@@ -683,11 +679,11 @@ else
#endif
#if INCL_SCREEN
-FUNCTION LOCAL void sp_add_intercept_screen(y, x)
+FUNCTION LOCAL void sp_add_intercept_screen(
GDECL
-fix15 y; /* Y coordinate in relative pixel units */
+fix15 y, /* Y coordinate in relative pixel units */
/* (0 is lowest sample in band) */
-fix31 x; /* X coordinate of intercept in subpixel units */
+fix31 x) /* X coordinate of intercept in subpixel units */
/* Called by line() to add an intercept to the intercept list structure
*/
diff --git a/src/Speedo/out_util.c b/src/Speedo/out_util.c
index b3316a5..357763f 100644
--- a/src/Speedo/out_util.c
+++ b/src/Speedo/out_util.c
@@ -21,6 +21,7 @@ INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
*/
+/* $XFree86: xc/lib/font/Speedo/out_util.c,v 1.3 2001/01/17 19:43:17 dawes Exp $ */
#define DEBUG 0
@@ -37,9 +38,9 @@ WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
#define ABS(X) ( (X < 0) ? -X : X)
#if INCL_BLACK || INCL_2D || INCL_SCREEN
-FUNCTION void init_char_out(Psw,Pmin,Pmax)
+FUNCTION void init_char_out(
GDECL
-point_t Psw, Pmin, Pmax;
+point_t Psw, point_t Pmin, point_t Pmax)
{
sp_globals.set_width.x = (fix31)Psw.x << sp_globals.poshift;
sp_globals.set_width.y = (fix31)Psw.y << sp_globals.poshift;
@@ -64,11 +65,11 @@ else
sp_globals.first_pass = TRUE;
}
-FUNCTION void begin_sub_char_out(Psw, Pmin, Pmax)
+FUNCTION void begin_sub_char_out(
GDECL
-point_t Psw;
-point_t Pmin;
-point_t Pmax;
+point_t Psw,
+point_t Pmin,
+point_t Pmax)
/* Called at the start of each sub-character in a composite character
*/
{
@@ -89,10 +90,10 @@ if (!sp_globals.extents_running)
}
}
-FUNCTION void curve_out(P1, P2, P3,depth)
+FUNCTION void curve_out(
GDECL
-point_t P1, P2, P3;
-fix15 depth;
+point_t P1, point_t P2, point_t P3,
+fix15 depth)
/* Called for each curve in the transformed character if curves out enabled
*/
{
@@ -216,10 +217,10 @@ sp_globals.first_offset = sp_globals.next_offset;
-FUNCTION void set_first_band_out(Pmin, Pmax)
+FUNCTION void set_first_band_out(
GDECL
-point_t Pmin;
-point_t Pmax;
+point_t Pmin,
+point_t Pmax)
{
sp_globals.ymin = Pmin.y;
diff --git a/src/Speedo/reset.c b/src/Speedo/reset.c
index 786ec43..7711951 100644
--- a/src/Speedo/reset.c
+++ b/src/Speedo/reset.c
@@ -21,6 +21,7 @@ INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
*/
+/* $XFree86: xc/lib/font/Speedo/reset.c,v 1.3 2001/01/17 19:43:17 dawes Exp $ */
@@ -85,9 +86,9 @@ sp_globals.outline_device_set = FALSE;
}
#if INCL_KEYS
-FUNCTION void set_key(key)
+FUNCTION void set_key(
GDECL
-ufix8 key[]; /* Specified decryption key */
+ufix8 key[]) /* Specified decryption key */
/*
* Dynamically sets font decryption key.
*/
@@ -102,9 +103,9 @@ sp_globals.key8 = key[8];
-FUNCTION ufix16 get_cust_no(font_buff)
+FUNCTION ufix16 get_cust_no(
GDECL
-buff_t font_buff;
+buff_t font_buff)
/*
returns customer number from font
*/
diff --git a/src/Speedo/set_spcs.c b/src/Speedo/set_spcs.c
index d060a4b..14ab53e 100644
--- a/src/Speedo/set_spcs.c
+++ b/src/Speedo/set_spcs.c
@@ -21,6 +21,7 @@ INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
*/
+/* $XFree86: xc/lib/font/Speedo/set_spcs.c,v 1.4 2001/08/27 19:49:50 dawes Exp $ */
/*************************** S E T _ S P C S . C *****************************
@@ -52,24 +53,17 @@ WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
/****** STATIC FUNCTIONS *****/
-#if PROTOS_AVAIL
static boolean sp_setup_consts(PROTO_DECL2 fix15 xmin, fix15 xmax,
fix15 ymin, fix15 ymax);
static void sp_setup_tcb(PROTO_DECL2 tcb_t GLOBALFAR *ptcb);
static fix15 sp_setup_mult(PROTO_DECL2 fix31 input_mult);
static fix31 sp_setup_offset(PROTO_DECL2 fix31 input_offset);
-#else
-static void sp_setup_tcb(); /* Set up transformation control block */
-static fix15 sp_setup_mult(); /* Convert mult to internal form */
-static fix31 sp_setup_offset(); /* Convert offset to internal form */
-static boolean sp_setup_consts(); /* Set up scaling constants */
-#endif
-FUNCTION boolean set_specs(specsarg)
+FUNCTION boolean set_specs(
GDECL
-specs_t STACKFAR *specsarg; /* Bundle of conversion specifications */
+specs_t STACKFAR *specsarg) /* Bundle of conversion specifications */
/*
* Called by host software to set character generation specifications
*/
@@ -336,10 +330,10 @@ return TRUE;
#if INCL_MULTIDEV
#if INCL_BLACK || INCL_SCREEN || INCL_2D
-FUNCTION boolean set_bitmap_device(bfuncs,size)
+FUNCTION boolean set_bitmap_device(
GDECL
-bitmap_t *bfuncs;
-ufix16 size;
+bitmap_t *bfuncs,
+ufix16 size)
{
if (size != sizeof(sp_globals.bitmap_device))
@@ -351,10 +345,10 @@ sp_globals.bitmap_device_set = TRUE;
#endif
#if INCL_OUTLINE
-FUNCTION boolean set_outline_device(ofuncs,size)
+FUNCTION boolean set_outline_device(
GDECL
-outline_t *ofuncs;
-ufix16 size;
+outline_t *ofuncs,
+ufix16 size)
{
if (size != sizeof(sp_globals.outline_device))
@@ -368,15 +362,20 @@ sp_globals.outline_device_set = TRUE;
#ifdef old
-FUNCTION boolean sp_setup_consts(xmin, xmax, ymin, ymax)
+FUNCTION boolean sp_setup_consts(
+GDECL
+fix15 xmin, /* Minimum X ORU value in font */
+fix15 xmax, /* Maximum X ORU value in font */
+fix15 ymin, /* Minimum Y ORU value in font */
+fix15 ymax) /* Maximum Y ORU value in font */
#else
-static FUNCTION boolean sp_setup_consts(xmin, xmax, ymin, ymax)
-#endif
+static FUNCTION boolean sp_setup_consts(
GDECL
-fix15 xmin; /* Minimum X ORU value in font */
-fix15 xmax; /* Maximum X ORU value in font */
-fix15 ymin; /* Minimum Y ORU value in font */
-fix15 ymax; /* Maximum Y ORU value in font */
+fix15 xmin, /* Minimum X ORU value in font */
+fix15 xmax, /* Maximum X ORU value in font */
+fix15 ymin, /* Minimum Y ORU value in font */
+fix15 ymax) /* Maximum Y ORU value in font */
+#endif
/*
* Sets the following constants used for fixed point arithmetic:
* sp_globals.multshift multipliers and products; range is 14 to 8
@@ -403,7 +402,7 @@ fix31 offset; /* Constant in transformation */
fix15 i; /* Loop counter */
fix15 x, y; /* Successive corners of bounding box in ORUs */
fix31 pixval; /* Successive pixel values multiplied by orus per em */
-fix15 xx, yy; /* Bounding box corner that produces max pixel value */
+fix15 xx = 0, yy = 0;/* Bounding box corner that produces max pixel value */
/* Determine numerator and denominator of largest multiplier value */
mult = sp_globals.pspecs->xxmult >> 16;
@@ -531,12 +530,14 @@ return TRUE;
}
#ifdef old
-FUNCTION void sp_setup_tcb(ptcb)
+FUNCTION void sp_setup_tcb(
+GDECL
+tcb_t GLOBALFAR *ptcb) /* Pointer to transformation control bloxk */
#else
-static FUNCTION void sp_setup_tcb(ptcb)
-#endif
+static FUNCTION void sp_setup_tcb(
GDECL
-tcb_t GLOBALFAR *ptcb; /* Pointer to transformation control bloxk */
+tcb_t GLOBALFAR *ptcb) /* Pointer to transformation control bloxk */
+#endif
/*
* Convert transformation coeffs to internal form
*/
@@ -559,9 +560,9 @@ SHOW(ptcb->yoffset);
type_tcb(ptcb); /* Classify transformation type */
}
-FUNCTION static fix15 sp_setup_mult(input_mult)
+FUNCTION static fix15 sp_setup_mult(
GDECL
-fix31 input_mult; /* Multiplier in input format */
+fix31 input_mult) /* Multiplier in input format */
/*
* Called by sp_setup_tcb() to convert multiplier in transformation
* matrix from external to internal form.
@@ -582,9 +583,9 @@ else
return -(fix15)((-input_mult + imrnd) / imdenom);
}
-FUNCTION static fix31 sp_setup_offset(input_offset)
+FUNCTION static fix31 sp_setup_offset(
GDECL
-fix31 input_offset; /* Multiplier in input format */
+fix31 input_offset) /* Multiplier in input format */
/*
* Called by sp_setup_tcb() to convert offset in transformation
* matrix from external to internal form.
@@ -599,9 +600,9 @@ imrnd = ((fix31)1 << imshift) >> 1;
return (((input_offset >> 1) + imrnd) >> imshift) + sp_globals.mprnd;
}
-FUNCTION void type_tcb(ptcb)
+FUNCTION void type_tcb(
GDECL
-tcb_t GLOBALFAR *ptcb; /* Pointer to transformation control bloxk */
+tcb_t GLOBALFAR *ptcb) /* Pointer to transformation control bloxk */
{
fix15 x_trans_type;
fix15 y_trans_type;
@@ -733,9 +734,9 @@ SHOW(ptcb->xpos);
SHOW(ptcb->ypos);
}
-FUNCTION fix31 read_long(pointer)
+FUNCTION fix31 read_long(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to first byte of encrypted 3-byte integer */
+ufix8 FONTFAR *pointer) /* Pointer to first byte of encrypted 3-byte integer */
/*
* Reads a 3-byte encrypted integer from the byte string starting at
* the specified point.
@@ -750,9 +751,9 @@ tmpfix31 += (fix31)((*pointer) ^ sp_globals.key6); /* Read le
return tmpfix31;
}
-FUNCTION fix15 read_word_u(pointer)
+FUNCTION fix15 read_word_u(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to first byte of unencrypted 2-byte integer */
+ufix8 FONTFAR *pointer) /* Pointer to first byte of unencrypted 2-byte integer */
/*
* Reads a 2-byte unencrypted integer from the byte string starting at
* the specified point.
diff --git a/src/Speedo/set_trns.c b/src/Speedo/set_trns.c
index 8ef34ac..b7f0e31 100644
--- a/src/Speedo/set_trns.c
+++ b/src/Speedo/set_trns.c
@@ -21,6 +21,7 @@ INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
*/
+/* $XFree86: xc/lib/font/Speedo/set_trns.c,v 1.5 2002/09/18 17:11:44 tsi Exp $ */
@@ -65,15 +66,9 @@ WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
/***** STATIC FUNCTIONS *****/
-#if PROTOS_AVAIL
static void sp_constr_update(PROTO_DECL1);
static ufix8 FONTFAR *sp_setup_pix_table(PROTO_DECL2 ufix8 FONTFAR *pointer,boolean short_form,fix15 no_X_ctrl_zones,fix15 no_Y_ctrl_zones);
static ufix8 FONTFAR *sp_setup_int_table(PROTO_DECL2 ufix8 FONTFAR *pointer,fix15 no_X_int_zones,fix15 no_Y_int_zones);
-#else
-static void sp_constr_update(); /* Update constraint table */
-static ufix8 FONTFAR *sp_setup_pix_table(); /* Read control zone table */
-static ufix8 FONTFAR *sp_setup_int_table(); /* Read interpolation zone table */
-#endif
FUNCTION void init_tcb()
@@ -86,13 +81,13 @@ GDECL
sp_globals.tcb = sp_globals.tcb0;
}
-FUNCTION void scale_tcb(ptcb, x_pos, y_pos, x_scale, y_scale)
+FUNCTION void scale_tcb(
GDECL
-tcb_t GLOBALFAR *ptcb; /* Transformation control block */
-fix15 x_pos; /* X position (outline res units) */
-fix15 y_pos; /* Y position (outline res units) */
-fix15 x_scale; /* X scale factor * ONE_SCALE */
-fix15 y_scale; /* Y scale factor * ONE_SCALE */
+tcb_t GLOBALFAR *ptcb, /* Transformation control block */
+fix15 x_pos, /* X position (outline res units) */
+fix15 y_pos, /* Y position (outline res units) */
+fix15 x_scale, /* X scale factor * ONE_SCALE */
+fix15 y_scale) /* Y scale factor * ONE_SCALE */
/*
* Called by make_comp_char() to apply position and scale for each of the
* components of a compound character.
@@ -115,10 +110,10 @@ ptcb->yoffset = MULT16(yx_mult, x_pos) + MULT16(yy_mult, y_pos) + y_offset;
type_tcb(ptcb); /* Reclassify transformation types */
}
-FUNCTION ufix8 FONTFAR *skip_interpolation_table(pointer,format)
+FUNCTION ufix8 FONTFAR *skip_interpolation_table(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to next byte in char data */
-ufix8 format; /* Character format byte */
+ufix8 FONTFAR *pointer, /* Pointer to next byte in char data */
+ufix8 format) /* Character format byte */
{
fix15 i,n;
ufix8 intsize[9];
@@ -133,8 +128,8 @@ intsize[6] = 2;
intsize[7] = 0;
intsize[8] = 0;
-n = ((format & BIT6)? (fix15)NEXT_BYTE(pointer): 0) +
- ((format & BIT7)? (fix15)NEXT_BYTE(pointer): 0);
+n = ((format & BIT6)? (fix15)NEXT_BYTE(pointer): 0);
+n += ((format & BIT7)? (fix15)NEXT_BYTE(pointer): 0);
for (i = 0; i < n; i++) /* For each entry in int table ... */
{
format = NEXT_BYTE(pointer); /* Read format byte */
@@ -150,10 +145,10 @@ for (i = 0; i < n; i++) /* For each entry in int table ... */
}
return pointer;
}
-FUNCTION ufix8 FONTFAR *skip_control_zone(pointer,format)
+FUNCTION ufix8 FONTFAR *skip_control_zone(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to next byte in char data */
-ufix8 format; /* Character format byte */
+ufix8 FONTFAR *pointer, /* Pointer to next byte in char data */
+ufix8 format) /* Character format byte */
{
fix15 i,n;
ufix16 tmpufix16;
@@ -175,10 +170,10 @@ return pointer;
#if INCL_RULES
#else
-FUNCTION ufix8 FONTFAR *plaid_tcb(pointer, format)
+FUNCTION ufix8 FONTFAR *plaid_tcb(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to next byte in char data */
-ufix8 format; /* Character format byte */
+ufix8 FONTFAR *pointer, /* Pointer to next byte in char data */
+ufix8 format) /* Character format byte */
/*
* Called by make_simp_char() and make_comp_char() to set up the controlled
* coordinate table and skip all other intelligent scaling rules embedded
@@ -211,10 +206,10 @@ return pointer;
#endif
#if INCL_RULES
-FUNCTION ufix8 FONTFAR *plaid_tcb(pointer, format)
+FUNCTION ufix8 FONTFAR *plaid_tcb(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to next byte in char data */
-ufix8 format; /* Character format byte */
+ufix8 FONTFAR *pointer, /* Pointer to next byte in char data */
+ufix8 format) /* Character format byte */
/*
* Called by make_simp_char() and make_comp_char() to set up the controlled
* coordinate table and process all intelligent scaling rules embedded
@@ -442,9 +437,9 @@ for (i = 0; i < n; i++)
}
#endif
-FUNCTION ufix8 FONTFAR *read_oru_table(pointer)
+FUNCTION ufix8 FONTFAR *read_oru_table(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to first byte in controlled coord table */
+ufix8 FONTFAR *pointer) /* Pointer to first byte in controlled coord table */
/*
* Called by plaid_tcb() to read the controlled coordinate table from the
* character data in the font.
@@ -525,15 +520,14 @@ for (i = 0; i < n; i++)
return pointer; /* Update pointer */
}
#if INCL_SQUEEZING || INCL_ISW
-FUNCTION static void calculate_x_pix(start_edge, end_edge, constr_nr,
- x_scale, x_offset, ppo, setwidth_pix)
+FUNCTION static void calculate_x_pix(
GDECL
-ufix8 start_edge, end_edge;
-ufix16 constr_nr;
-fix31 x_scale;
-fix31 x_offset;
-fix31 ppo;
-fix15 setwidth_pix;
+ufix8 start_edge, ufix8 end_edge,
+ufix16 constr_nr,
+fix31 x_scale,
+fix31 x_offset,
+fix31 ppo,
+fix15 setwidth_pix)
/*
* Called by sp_setup_pix_table() when X squeezing is necessary
* to insert the correct edge in the global pix array
@@ -593,14 +587,13 @@ if ((sp_globals.pspecs->flags & SQUEEZE_RIGHT) &&
#endif
#if INCL_SQUEEZING
-FUNCTION static void calculate_y_pix(start_edge, end_edge,constr_nr,
- top_scale, bottom_scale,ppo,em_top_pix, em_bot_pix)
+FUNCTION static void calculate_y_pix(
GDECL
-ufix8 start_edge, end_edge;
-ufix16 constr_nr;
-fix31 top_scale, bottom_scale;
-fix31 ppo;
-fix15 em_top_pix, em_bot_pix;
+ufix8 start_edge, ufix8 end_edge,
+ufix16 constr_nr,
+fix31 top_scale, fix31 bottom_scale,
+fix31 ppo,
+fix15 em_top_pix, fix15 em_bot_pix)
/*
* Called by sp_setup_pix_table() when Y squeezing is necessary
@@ -697,9 +690,9 @@ if ((sp_globals.pspecs->flags & SQUEEZE_BOTTOM) &&
FUNCTION boolean calculate_x_scale(x_factor, x_offset, no_X_ctrl_zones)
GDECL
-fix31 *x_factor;
-fix31 *x_offset;
-fix15 no_X_ctrl_zones; /* Number of X control zones */
+fix31 *x_factor,
+fix31 *x_offset,
+fix15 no_X_ctrl_zones) /* Number of X control zones */
/*
* Called by sp_setup_pix_table() when squeezing is included
* to determine whether X scaling is necessary. If it is, the
@@ -850,12 +843,11 @@ for (i=0; i < (no_X_ctrl_zones+1); i++)
return TRUE;
}
-FUNCTION boolean calculate_y_scale(top_scale, bottom_scale,
- first_Y_zone, no_Y_ctrl_zones)
+FUNCTION boolean calculate_y_scale(
GDECL
-fix31 *top_scale, *bottom_scale;
-fix15 first_Y_zone;
-fix15 no_Y_ctrl_zones;
+fix31 *top_scale, fix31 *bottom_scale,
+fix15 first_Y_zone,
+fix15 no_Y_ctrl_zones)
/*
* Called by sp_setup_pix_table() when squeezing is included
* to determine whether Y scaling is necessary. If it is,
@@ -929,12 +921,11 @@ return TRUE;
#if INCL_RULES
FUNCTION static ufix8 FONTFAR *sp_setup_pix_table(
- pointer, short_form, no_X_ctrl_zones, no_Y_ctrl_zones)
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to first byte in control zone table */
-boolean short_form; /* TRUE if 1 byte from/to specification */
-fix15 no_X_ctrl_zones; /* Number of X control zones */
-fix15 no_Y_ctrl_zones; /* Number of Y control zones */
+ufix8 FONTFAR *pointer, /* Pointer to first byte in control zone table */
+boolean short_form, /* TRUE if 1 byte from/to specification */
+fix15 no_X_ctrl_zones, /* Number of X control zones */
+fix15 no_Y_ctrl_zones) /* Number of Y control zones */
/*
* Called by plaid_tcb() to read the control zone table from the
* character data in the font.
@@ -1158,11 +1149,11 @@ return pointer;
#if INCL_RULES
-FUNCTION static ufix8 FONTFAR *sp_setup_int_table(pointer, no_X_int_zones, no_Y_int_zones)
+FUNCTION static ufix8 FONTFAR *sp_setup_int_table(
GDECL
-ufix8 FONTFAR *pointer; /* Pointer to first byte in interpolation zone table */
-fix15 no_X_int_zones; /* Number of X interpolation zones */
-fix15 no_Y_int_zones; /* Number of X interpolation zones */
+ufix8 FONTFAR *pointer, /* Pointer to first byte in interpolation zone table */
+fix15 no_X_int_zones, /* Number of X interpolation zones */
+fix15 no_Y_int_zones) /* Number of X interpolation zones */
/*
* Called by plaid_tcb() to read the interpolation zone table from the
* character data in the font.
@@ -1176,15 +1167,15 @@ fix15 i, j, k, l, n;
ufix8 format;
ufix8 format_copy;
ufix8 tmpufix8;
-fix15 start_orus;
+fix15 start_orus = 0;
ufix8 edge_org;
ufix8 edge;
ufix16 adj_factor;
fix15 adj_orus;
-fix15 end_orus;
+fix15 end_orus = 0;
fix31 zone_orus;
-fix15 start_pix;
-fix15 end_pix;
+fix15 start_pix = 0;
+fix15 end_pix = 0;
#if INCL_PLAID_OUT /* Plaid data monitoring included? */
diff --git a/src/Speedo/spdo_prv.h b/src/Speedo/spdo_prv.h
index 47c5252..272ffbf 100644
--- a/src/Speedo/spdo_prv.h
+++ b/src/Speedo/spdo_prv.h
@@ -21,6 +21,7 @@ INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
*/
+/* $XFree86: xc/lib/font/Speedo/spdo_prv.h,v 1.5 2001/01/17 19:43:18 dawes Exp $ */
@@ -31,11 +32,6 @@ WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
/***** CONFIGURATION DEFINITIONS *****/
-#ifndef INCL_PLAID_OUT
-#define INCL_PLAID_OUT 0 /* 1 to include plaid data monitoring */
-#endif /* 0 to omit plaid data monitoring */
-
-
/***** PRIVATE FONT HEADER OFFSET CONSTANTS *****/
#define FH_ORUMX 0 /* U Max ORU value 2 bytes */
#define FH_PIXMX 2 /* U Max Pixel value 2 bytes */
@@ -269,7 +265,7 @@ WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
#else
-#define GDECL SPEEDO_GLOBALS* sp_global_ptr;
+#define GDECL SPEEDO_GLOBALS* sp_global_ptr,
#define get_char_id(char_index) sp_get_char_id(sp_global_ptr,char_index)
#define get_char_width(char_index) sp_get_char_width(sp_global_ptr,char_index)
diff --git a/src/Speedo/speedo.h b/src/Speedo/speedo.h
index 277c6a6..a0b607f 100644
--- a/src/Speedo/speedo.h
+++ b/src/Speedo/speedo.h
@@ -21,6 +21,7 @@ INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
*/
+/* $XFree86: xc/lib/font/Speedo/speedo.h,v 3.6 2001/07/25 15:04:55 dawes Exp $ */
#ifndef _SPEEDO_H_
#define _SPEEDO_H_
@@ -94,9 +95,9 @@ WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
#define SHORT_LISTS 1 /* 1 to allocate small intercept lists */
#endif
-#ifndef PROTOS_AVAIL /* 1 to use function prototyping */
-#define PROTOS_AVAIL 0 /* 0 to suppress it */
-#endif
+#ifndef INCL_PLAID_OUT
+#define INCL_PLAID_OUT 0 /* 1 to include plaid data monitoring */
+#endif /* 0 to omit plaid data monitoring */
#ifndef FONTFAR /* if Intel mixed memory model implementation */
#define FONTFAR /* pointer type modifier for font buffer */
@@ -171,7 +172,7 @@ typedef CARD32 ufix32;
#endif
#ifndef NULL
-#define NULL 0
+#include <stddef.h>
#endif
#define FUNCTION
@@ -215,8 +216,6 @@ typedef CARD32 ufix32;
#endif
/***** STRUCTURE DEFINITIONS *****/
-#if PROTOS_AVAIL
-
#if REENTRANT_ALLOC
#define PROTO_DECL1 struct speedo_global_data GLOBALFAR *sp_global_ptr
#define PROTO_DECL2 PROTO_DECL1 ,
@@ -224,7 +223,6 @@ typedef CARD32 ufix32;
#define PROTO_DECL1 void
#define PROTO_DECL2
#endif
-#endif
typedef
struct buff_tag
@@ -280,11 +278,7 @@ typedef struct specs_tag
/* Bit 14: Clip top if set */
/* Bit 15: Clip bottom if set */
/* Bits 16-31 not used */
-#ifdef __STDC__
void *out_info; /* information for output module */
-#else
- char *out_info;
-#endif
}
specs_t; /* Specs structure for fw_set_specs */
@@ -365,7 +359,6 @@ typedef struct plaid_tag
#endif
#if INCL_MULTIDEV
-#if PROTOS_AVAIL
typedef struct bitmap_tag
{
void (*p_open_bitmap)(PROTO_DECL2 fix31 x_set_width, fix31 y_set_width, fix31 xorg, fix31 yorg, fix15 xsize,fix15 ysize);
@@ -383,25 +376,6 @@ typedef struct outline_tag
void (*p_close_contour)(PROTO_DECL1);
void (*p_close_outline)(PROTO_DECL1);
} outline_t;
-#else
-typedef struct bitmap_tag
- {
- void (*p_open_bitmap)();
- void (*p_set_bits)();
- void (*p_close_bitmap)();
- } bitmap_t;
-
-typedef struct outline_tag
- {
- void (*p_open_outline)();
- void (*p_start_char)();
- void (*p_start_contour)();
- void (*p_curve)();
- void (*p_line)();
- void (*p_close_contour)();
- void (*p_close_outline)();
- } outline_t;
-#endif
#endif
/* ---------------------------------------------------*/
@@ -521,7 +495,6 @@ typedef struct speedo_global_data
fix15 pixfix; /* Mask to remove fractional pixels */
fix15 onepix; /* 1.0 pixels in sub-pixel units */
-#if PROTOS_AVAIL
boolean (*init_out)(PROTO_DECL2 specs_t GLOBALFAR *specsarg);
boolean (*begin_char)(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
void (*begin_sub_char)(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
@@ -531,18 +504,6 @@ typedef struct speedo_global_data
void (*end_contour)(PROTO_DECL1);
void (*end_sub_char)(PROTO_DECL1);
boolean (*end_char)(PROTO_DECL1);
-#else /* if not protos */
- boolean (*init_out)();
- boolean (*begin_char)();
- void (*begin_sub_char)();
- void (*begin_contour)();
- void (*curve)();
- void (*line)();
- void (*end_contour)();
- void (*end_sub_char)();
- boolean (*end_char)();
-#endif /* end not protos */
-
specs_t GLOBALFAR *pspecs; /* Pointer to specifications bundle */
specs_t specs; /* copy specs onto stack */
ufix8 FONTFAR *font_org; /* Pointer to start of font data */
@@ -762,7 +723,6 @@ EXTERN SPEEDO_GLOBALS GLOBALFAR *sp_global_ptr;
*
***********************************************************************************/
-#if PROTOS_AVAIL
/* do_char.c functions */
ufix16 sp_get_char_id(PROTO_DECL2 ufix16 char_index);
boolean sp_make_char(PROTO_DECL2 ufix16 char_index);
@@ -927,155 +887,4 @@ void sp_record_int_zone(PROTO_DECL2 fix31 start, fix31 end); /* Record
void sp_end_plaid_data(PROTO_DECL1); /* Signal end of plaid data */
#endif
-#else /* NO PROTOTYPES AVAILABLE */
-
-
-
-/* do_char.c functions */
-boolean sp_make_char(); /* Make specified character */
-#if INCL_ISW
-fix31 sp_compute_isw_scale();
-static boolean sp_do_make_char();
-boolean sp_make_char_isw(); /* Make specified character with */
- /* imported set widths.*/
-static boolean sp_reset_xmax();
-#endif
-#if INCL_ISW || INCL_SQUEEZING
-static void sp_preview_bounding_box();
-#endif
-ufix16 sp_get_char_id(); /* Get character id for specified char */
-
-#if INCL_METRICS /* Metrics functions supported? */
-fix31 sp_get_char_width(); /* Get character width for specified char */
-fix15 sp_get_track_kern(); /* Get track kerning for specified size */
-fix31 sp_get_pair_kern(); /* Get kerning for specified char pair */
-boolean sp_get_char_bbox();
-#endif
-
-/* do_trns.c functions */
-ufix8 FONTFAR *sp_read_bbox(); /* Read bounding box */
-void sp_proc_outl_data(); /* Process outline data */
-
-/* out_0c.c functions */
-boolean sp_init_black();
-boolean sp_begin_char_black();
-void sp_begin_contour_black();
-void sp_line_black();
-boolean sp_end_char_black();
-
-/* out_util.c functions */
-#if INCL_BLACK || INCL_SCREEN || INCL_2D
-
-void sp_init_char_out();
-void sp_begin_sub_char_out();
-void sp_curve_out();
-void sp_end_contour_out();
-void sp_end_sub_char_out();
-void sp_init_intercepts_out();
-void sp_restart_intercepts_out();
-void sp_set_first_band_out();
-void sp_reduce_band_size_out();
-boolean sp_next_band_out();
-#endif
-
-#if INCL_USEROUT
-boolean sp_init_userout();
-#endif
-
-/* reset.c functions */
-void sp_reset(); /* Initialize Fontware mechanism */
-
-#if INCL_KEYS
-void sp_set_key();
-#endif
-ufix16 sp_get_cust_no();
-
-/* set_spcs.c functions */
-boolean sp_set_specs(); /* Set specifications */
-void sp_type_tcb(); /* Update transformation class in tcb */
-
-fix31 sp_read_long(); /* Read long as 3 bytes encrypted */
-fix15 sp_read_word_u(); /* Read word as 2 bytes unencrypted */
-
-/* set_trns.c functions */
-void sp_init_tcb(); /* Initialize current trans control block */
-void sp_scale_tcb(); /* Transform trans control block */
-ufix8 FONTFAR *sp_plaid_tcb(); /* Enable intelligent transformation */
-ufix8 FONTFAR *sp_skip_interpolation_table();
-ufix8 FONTFAR *sp_skip_control_zone();
-
-ufix8 FONTFAR *sp_read_oru_table(); /* Read controlled coord table */
-#if INCL_SQUEEZING || INCL_ISW
-static void sp_calculate_x_pix();
-#endif
-#if INCL_SQUEEZING
-static void sp_calculate_y_pix();
-boolean sp_calculate_x_scale();
-boolean sp_calculate_y_scale() ;
-#endif
-
-/* user defined functions */
-
-#if INCL_BLACK || INCL_SCREEN || INCL_2D
-void sp_open_bitmap();
-void sp_set_bitmap_bits();
-void sp_close_bitmap();
-#endif
-
-#if INCL_OUTLINE
-void sp_open_outline();
-void sp_start_new_char();
-void sp_start_contour();
-void sp_curve_to();
-void sp_line_to();
-void sp_close_contour();
-void sp_close_outline();
-#endif
-
-#if INCL_LCD /* Dynamic load character data supported? */
-buff_t *sp_load_char_data(); /* Load character data from font file */
-#endif
-
-#if INCL_PLAID_OUT /* Plaid data monitoring included? */
-void sp_record_xint(); /* Record xint data */
-void sp_record_yint(); /* Record yint data */
-void sp_begin_plaid_data(); /* Signal start of plaid data */
-void sp_begin_ctrl_zones(); /* Signal start of control zones */
-void sp_record_ctrl_zone(); /* Record control zone data */
-void sp_begin_int_zones(); /* Signal start of interpolation zones */
-void sp_record_int_zone(); /* Record interpolation zone data */
-void sp_end_plaid_data(); /* Signal end of plaid data */
-#endif
-
-boolean sp_init_screen(); /* If only screen-writer mode supported */
-boolean sp_begin_char_screen(); /* If screenwriter mode supported */
-void sp_begin_contour_screen(); /* If screenwriter mode supported */
-void sp_line_screen(); /* If screenwriter mode supported */
-void sp_curve_screen(); /* If screenwriter mode supported */
-void sp_scan_curve_screen();
-void sp_vert_line_screen();
-void sp_end_contour_screen();
-boolean sp_end_char_screen(); /* If screenwriter mode supported */
-
-
-boolean sp_init_outline(); /* If only vector output mode supported */
-boolean sp_begin_char_outline(); /* If only vector output mode supported */
-void sp_begin_sub_char_outline(); /* If only vector output mode supported */
-void sp_begin_contour_outline(); /* If only vector output mode supported */
-void sp_curve_outline(); /* If only vector output mode supported */
-void sp_line_outline(); /* If only vector output mode supported */
-void sp_end_contour_outline(); /* If only vector output mode supported */
-void sp_end_sub_char_outline(); /* If only vector output mode supported */
-boolean sp_end_char_outline(); /* If only vector output mode supported */
-
-boolean sp_init_2d(); /* If screen-writer and other modes supported */
-boolean sp_begin_char_2d(); /* If screen-writer and other modes supported */
-void sp_begin_contour_2d(); /* If screen-writer and other modes supported */
-void sp_line_2d(); /* If screen-writer and other modes supported */
-boolean sp_end_char_2d(); /* If screen-writer and other modes supported */
-
-#endif
-
-
-
#endif /* _SPEEDO_H_ */
diff --git a/src/Speedo/spencode.c b/src/Speedo/spencode.c
index b74e71d..0daccff 100644
--- a/src/Speedo/spencode.c
+++ b/src/Speedo/spencode.c
@@ -47,12 +47,14 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/Speedo/spencode.c,v 1.7 2001/12/14 19:56:41 dawes Exp $ */
#include "spint.h"
-#include "bics-iso.h"
+/* No longer needed with new encoding code */
+/* #include "bics-iso.h"
-int sp_bics_map_size = (sizeof(sp_bics_map) / (sizeof(int) * 2));
+int sp_bics_map_size = (sizeof(sp_bics_map) / (sizeof(int) * 2));*/
#ifdef EXTRAFONTS
#include "adobe-iso.h"
diff --git a/src/Speedo/sperr.c b/src/Speedo/sperr.c
index 8d94d85..8be42c6 100644
--- a/src/Speedo/sperr.c
+++ b/src/Speedo/sperr.c
@@ -52,10 +52,15 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/Speedo/sperr.c,v 1.7 2002/05/31 18:45:48 dawes Exp $ */
+
#include "spint.h"
-#if NeedVarargsPrototypes
+#ifndef FONTMODULE
#include <stdarg.h>
+#endif
+
+extern void ErrorF(const char* f, ...);
void
SpeedoErr(char *str, ...)
@@ -70,20 +75,6 @@ SpeedoErr(char *str, ...)
va_end(v);
}
-#else
-
-/* VARARGS1 */
-void
-SpeedoErr(str, a1)
- char *str;
- char *a1;
-{
- ErrorF("Speedo: ");
- ErrorF(str, a1);
-}
-#endif /* NeedVarargsPrototypes else */
-
-
/*
* Called by Speedo character generator to report an error.
*
@@ -91,8 +82,7 @@ SpeedoErr(str, a1)
* that happens many times, don't report it to user
*/
void
-sp_report_error(n)
- fix15 n;
+sp_report_error(fix15 n)
{
switch (n) {
case 1:
diff --git a/src/Speedo/spfile.c b/src/Speedo/spfile.c
index 2eac82e..a5c34b3 100644
--- a/src/Speedo/spfile.c
+++ b/src/Speedo/spfile.c
@@ -49,11 +49,18 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/Speedo/spfile.c,v 1.14 2001/12/14 19:56:41 dawes Exp $ */
-#include <stdio.h>
#include "fntfilst.h"
+#include "fontenc.h"
+#ifndef FONTMODULE
+#include <stdio.h>
+#else
+#include "xf86_ansic.h"
+#endif
#include "spint.h"
+#include "bics-unicode.h"
SpeedoFontPtr sp_fp_cur = (SpeedoFontPtr) 0;
@@ -122,8 +129,7 @@ static ufix8 mkey[] =
static fix15
-read_2b(ptr)
- ufix8 *ptr;
+read_2b(ufix8 *ptr)
{
fix15 tmp;
@@ -133,8 +139,7 @@ read_2b(ptr)
}
static fix31
-read_4b(ptr)
- ufix8 *ptr;
+read_4b(ufix8 *ptr)
{
fix31 tmp;
@@ -149,10 +154,7 @@ read_4b(ptr)
* loads the specified char's data
*/
buff_t *
-sp_load_char_data(file_offset, num, cb_offset)
- fix31 file_offset;
- fix15 num;
- fix15 cb_offset;
+sp_load_char_data(fix31 file_offset, fix15 num, fix15 cb_offset)
{
SpeedoMasterFontPtr master = sp_fp_cur->master;
@@ -172,10 +174,115 @@ sp_load_char_data(file_offset, num, cb_offset)
return &master->char_data;
}
+struct speedo_encoding {
+ char *name;
+ int *enc;
+ int enc_size;
+};
+
+/* Takes care of caching encodings already referenced */
+static int
+find_encoding(const char *fontname, const char *filename,
+ int **enc, int *enc_size)
+{
+ static struct speedo_encoding *known_encodings=0;
+ static int number_known_encodings=0;
+ static int known_encodings_size=0;
+
+ char *encoding_name;
+ int iso8859_1;
+ FontMapPtr mapping;
+ int i, j, k, size;
+ struct speedo_encoding *temp;
+ int *new_enc;
+ char *new_name;
+
+ iso8859_1 = 0;
+
+ encoding_name = FontEncFromXLFD(fontname, strlen(fontname));
+ if(!encoding_name) {
+ encoding_name="iso8859-1";
+ iso8859_1=1;
+ }
+ /* We don't go through the font library if asked for Latin-1 */
+ iso8859_1 = iso8859_1 || !strcmp(encoding_name, "iso8859-1");
+
+ for(i=0; i<number_known_encodings; i++) {
+ if(!strcmp(encoding_name, known_encodings[i].name)) {
+ *enc=known_encodings[i].enc;
+ *enc_size=known_encodings[i].enc_size;
+ return Successful;
+ }
+ }
+
+ /* it hasn't been cached yet, need to compute it */
+
+ /* ensure we've got enough storage first */
+
+ if(known_encodings==0) {
+ if((known_encodings=
+ (struct speedo_encoding*)xalloc(2*sizeof(struct speedo_encoding)))
+ ==0)
+ return AllocError;
+ number_known_encodings=0;
+ known_encodings_size=2;
+ }
+
+ if(number_known_encodings >= known_encodings_size) {
+ if((temp=
+ (struct speedo_encoding*)xrealloc(known_encodings,
+ 2*sizeof(struct speedo_encoding)*
+ known_encodings_size))==0)
+ return AllocError;
+ known_encodings=temp;
+ known_encodings_size*=2;
+ }
+
+ mapping=0;
+ if(!iso8859_1) {
+ mapping = FontEncMapFind(encoding_name,
+ FONT_ENCODING_UNICODE, -1, -1,
+ filename);
+ }
+#define SPEEDO_RECODE(c) \
+ (mapping? \
+ unicode_to_bics(FontEncRecode(c, mapping)): \
+ unicode_to_bics(c))
+
+ if((new_name = (char*)xalloc(strlen(encoding_name)))==0)
+ return AllocError;
+ strcpy(new_name, encoding_name);
+
+ /* For now, we limit ourselves to 256 glyphs */
+ size=0;
+ for(i=0; i < (mapping?mapping->encoding->size:256) && i < 256; i++)
+ if(SPEEDO_RECODE(i)>=0)
+ size++;
+ new_enc = (int*)xalloc(2*size*sizeof(int));
+ if(!new_enc) {
+ xfree(new_name);
+ return AllocError;
+ }
+ for(i=j=0; i < (mapping?mapping->encoding->size:256) && i < 256; i++)
+ if((k = SPEEDO_RECODE(i))>=0) {
+ new_enc[2*j] = i;
+ new_enc[2*j+1] = k;
+ j++;
+ }
+ known_encodings[number_known_encodings].name = new_name;
+ known_encodings[number_known_encodings].enc = new_enc;
+ known_encodings[number_known_encodings].enc_size = size;
+ number_known_encodings++;
+
+ *enc = new_enc;
+ *enc_size = size;
+ return Successful;
+#undef SPEEDO_RECODE
+}
+
int
-sp_open_master(filename, master)
- char *filename;
- SpeedoMasterFontPtr *master;
+sp_open_master(const char *fontname, const char *filename,
+ SpeedoMasterFontPtr *master)
{
SpeedoMasterFontPtr spmf;
ufix8 tmp[16];
@@ -273,8 +380,8 @@ sp_open_master(filename, master)
spmf->num_chars = read_2b(f_buffer + FH_NCHRL);
- spmf->enc = sp_bics_map;
- spmf->enc_size = sp_bics_map_size;
+ spmf->enc = 0;
+ spmf->enc_size = 0;
#ifdef EXTRAFONTS
{ /* choose the proper encoding */
@@ -291,7 +398,11 @@ sp_open_master(filename, master)
}
#endif
- /* XXX slam back to ISO Latin1 */
+ if(!spmf->enc)
+ if((ret=find_encoding(fontname, filename, &spmf->enc, &spmf->enc_size))
+ !=Successful)
+ goto cleanup;
+
spmf->first_char_id = spmf->enc[0];
/* size of extents array */
spmf->max_id = spmf->enc[(spmf->enc_size - 1) * 2];
@@ -308,8 +419,7 @@ cleanup:
}
void
-sp_close_master_font(spmf)
- SpeedoMasterFontPtr spmf;
+sp_close_master_font(SpeedoMasterFontPtr spmf)
{
if (!spmf)
return;
@@ -324,8 +434,7 @@ sp_close_master_font(spmf)
}
void
-sp_close_master_file(spmf)
- SpeedoMasterFontPtr spmf;
+sp_close_master_file(SpeedoMasterFontPtr spmf)
{
(void) fclose(spmf->fp);
spmf->state &= ~MasterFileOpen;
@@ -336,8 +445,7 @@ sp_close_master_file(spmf)
* reset the encryption key, and make sure the file is opened
*/
void
-sp_reset_master(spmf)
- SpeedoMasterFontPtr spmf;
+sp_reset_master(SpeedoMasterFontPtr spmf)
{
sp_set_key(spmf->key);
if (!(spmf->state & MasterFileOpen)) {
diff --git a/src/Speedo/spfont.c b/src/Speedo/spfont.c
index ebfc526..61ec6d4 100644
--- a/src/Speedo/spfont.c
+++ b/src/Speedo/spfont.c
@@ -21,6 +21,7 @@
*
* Author: Dave Lemke, Network Computing Devices Inc
*/
+/* $XFree86: xc/lib/font/Speedo/spfont.c,v 3.12 2001/12/14 19:56:41 dawes Exp $ */
/*
@@ -56,7 +57,9 @@ from The Open Group.
#include "FSproto.h"
#include "spint.h"
-#include <servermd.h>
+#include "servermd.h"
+#include "fontutil.h"
+#ifndef FONTMODULE
#ifdef _XOPEN_SOURCE
#include <math.h>
#else
@@ -64,6 +67,9 @@ from The Open Group.
#include <math.h>
#undef _XOPEN_SOURCE
#endif
+#else
+#include "xf86_ansic.h"
+#endif
#ifndef M_PI
#define M_PI 3.14159
@@ -78,19 +84,16 @@ from The Open Group.
#endif
-extern void SpeedoCloseFont();
-static int sp_get_glyphs();
-static int sp_get_metrics();
-static int sp_load_font();
+static void SpeedoCloseFont(FontPtr pfont);
static int
-sp_get_glyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
- FontPtr pFont;
- unsigned long count;
- register unsigned char *chars;
- FontEncoding charEncoding;
- unsigned long *glyphCount; /* RETURN */
- CharInfoPtr *glyphs; /* RETURN */
+sp_get_glyphs(
+ FontPtr pFont,
+ unsigned long count,
+ register unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
{
SpeedoFontPtr spf;
unsigned int firstCol;
@@ -196,13 +199,13 @@ sp_get_glyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
static CharInfoRec nonExistantChar;
static int
-sp_get_metrics(pFont, count, chars, charEncoding, glyphCount, glyphs)
- FontPtr pFont;
- unsigned long count;
- register unsigned char *chars;
- FontEncoding charEncoding;
- unsigned long *glyphCount; /* RETURN */
- xCharInfo **glyphs; /* RETURN */
+sp_get_metrics(
+ FontPtr pFont,
+ unsigned long count,
+ register unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ xCharInfo **glyphs) /* RETURN */
{
int ret;
SpeedoFontPtr spf;
@@ -219,15 +222,15 @@ sp_get_metrics(pFont, count, chars, charEncoding, glyphCount, glyphs)
}
int
-sp_open_font(fontname, filename, entry, vals, format, fmask, flags, spfont)
- char *fontname,
- *filename;
- FontEntryPtr entry;
- FontScalablePtr vals;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- Mask flags;
- SpeedoFontPtr *spfont;
+sp_open_font(
+ char *fontname,
+ char *filename,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ Mask flags,
+ SpeedoFontPtr *spfont)
{
SpeedoFontPtr spf;
SpeedoMasterFontPtr spmf;
@@ -239,7 +242,7 @@ sp_open_font(fontname, filename, entry, vals, format, fmask, flags, spfont)
spmf = (SpeedoMasterFontPtr) entry->u.scalable.extra->private;
if (!spmf)
{
- ret = sp_open_master(filename, &spmf);
+ ret = sp_open_master(fontname, filename, &spmf);
if (ret != Successful)
return ret;
entry->u.scalable.extra->private = (pointer) spmf;
@@ -314,15 +317,15 @@ sp_open_font(fontname, filename, entry, vals, format, fmask, flags, spfont)
}
static int
-sp_load_font(fontname, filename, entry, vals, format, fmask, pfont, flags)
+sp_load_font(
char *fontname,
- *filename;
- FontEntryPtr entry;
- FontScalablePtr vals;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- FontPtr pfont;
- Mask flags;
+ char *filename,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr pfont,
+ Mask flags)
{
SpeedoFontPtr spf;
SpeedoMasterFontPtr spmf;
@@ -377,8 +380,6 @@ sp_load_font(fontname, filename, entry, vals, format, fmask, pfont, flags)
pfont->unload_font = SpeedoCloseFont;
pfont->unload_glyphs = NULL;
pfont->refcnt = 0;
- pfont->maxPrivate = -1;
- pfont->devPrivates = (pointer *) 0;
/* have to hold on to master for min/max id */
sp_close_master_file(spmf);
@@ -387,15 +388,15 @@ sp_load_font(fontname, filename, entry, vals, format, fmask, pfont, flags)
}
int
-SpeedoFontLoad(ppfont, fontname, filename, entry, vals, format, fmask, flags)
- FontPtr *ppfont;
- char *fontname;
- char *filename;
- FontEntryPtr entry;
- FontScalablePtr vals;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- Mask flags;
+SpeedoFontLoad(
+ FontPtr *ppfont,
+ char *fontname,
+ char *filename,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ Mask flags)
{
FontPtr pfont;
int ret;
@@ -405,24 +406,22 @@ SpeedoFontLoad(ppfont, fontname, filename, entry, vals, format, fmask, flags)
hypot(vals->pixel_matrix[2], vals->pixel_matrix[3]) < 1.0)
return BadFontName;
- pfont = (FontPtr) xalloc(sizeof(FontRec));
- if (!pfont) {
+ if (!(pfont = CreateFontRec()))
return AllocError;
- }
+
ret = sp_load_font(fontname, filename, entry, vals, format, fmask,
pfont, flags);
if (ret == Successful)
*ppfont = pfont;
else
- xfree (pfont);
+ DestroyFontRec (pfont);
return ret;
}
void
-sp_close_font(spf)
- SpeedoFontPtr spf;
+sp_close_font(SpeedoFontPtr spf)
{
SpeedoMasterFontPtr spmf;
@@ -435,9 +434,8 @@ sp_close_font(spf)
xfree(spf);
}
-void
-SpeedoCloseFont(pfont)
- FontPtr pfont;
+static void
+SpeedoCloseFont(FontPtr pfont)
{
SpeedoFontPtr spf;
@@ -445,6 +443,6 @@ SpeedoCloseFont(pfont)
sp_close_font(spf);
xfree(pfont->info.isStringProp);
xfree(pfont->info.props);
- xfree(pfont->devPrivates);
- xfree(pfont);
+ DestroyFontRec(pfont);
+
}
diff --git a/src/Speedo/spfuncs.c b/src/Speedo/spfuncs.c
index 0cd09ee..18204eb 100644
--- a/src/Speedo/spfuncs.c
+++ b/src/Speedo/spfuncs.c
@@ -49,24 +49,27 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/Speedo/spfuncs.c,v 1.8 2001/12/14 19:56:42 dawes Exp $ */
+#ifndef FONTMODULE
#include <X11/Xos.h>
+#endif
#include "fntfilst.h"
+#include "fontutil.h"
#include "spint.h"
/* ARGSUSED */
-int
-SpeedoOpenScalable (fpe, pFont, flags, entry, fileName, vals, format, fmask,
- non_cachable_font)
- FontPathElementPtr fpe;
- FontPtr *pFont;
- int flags;
- FontEntryPtr entry;
- char *fileName;
- FontScalablePtr vals;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- FontPtr non_cachable_font; /* We don't do licensing */
+static int
+SpeedoOpenScalable (
+ FontPathElementPtr fpe,
+ FontPtr *pFont,
+ int flags,
+ FontEntryPtr entry,
+ char *fileName,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
{
char fullName[MAXFONTNAMELEN];
@@ -85,13 +88,13 @@ SpeedoOpenScalable (fpe, pFont, flags, entry, fileName, vals, format, fmask,
* and to simply save the values without doing the work.
*/
static int
-get_font_info(pinfo, fontname, filename, entry, vals, spfont)
- FontInfoPtr pinfo;
- char *fontname;
- char *filename;
- FontEntryPtr entry;
- FontScalablePtr vals;
- SpeedoFontPtr *spfont;
+get_font_info(
+ FontInfoPtr pinfo,
+ char *fontname,
+ char *filename,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ SpeedoFontPtr *spfont)
{
SpeedoFontPtr spf;
int err;
@@ -122,14 +125,14 @@ get_font_info(pinfo, fontname, filename, entry, vals, spfont)
}
/* ARGSUSED */
-int
-SpeedoGetInfoScaleable(fpe, pFontInfo, entry, fontName, fileName, vals)
- FontPathElementPtr fpe;
- FontInfoPtr pFontInfo;
- FontEntryPtr entry;
- FontNamePtr fontName;
- char *fileName;
- FontScalablePtr vals;
+static int
+SpeedoGetInfoScaleable(
+ FontPathElementPtr fpe,
+ FontInfoPtr pFontInfo,
+ FontEntryPtr entry,
+ FontNamePtr fontName,
+ char *fileName,
+ FontScalablePtr vals)
{
SpeedoFontPtr spf = NULL;
char fullName[MAXFONTNAMELEN];
@@ -147,8 +150,8 @@ SpeedoGetInfoScaleable(fpe, pFontInfo, entry, fontName, fileName, vals)
}
static FontRendererRec renderer = {
- ".spd", 4, (int (*)()) 0, SpeedoOpenScalable,
- (int (*)()) 0, SpeedoGetInfoScaleable, 0
+ ".spd", 4, NULL, SpeedoOpenScalable,
+ NULL, SpeedoGetInfoScaleable, 0
, CAP_MATRIX | CAP_CHARSUBSETTING
};
diff --git a/src/Speedo/spglyph.c b/src/Speedo/spglyph.c
index ff0f370..6db6302 100644
--- a/src/Speedo/spglyph.c
+++ b/src/Speedo/spglyph.c
@@ -49,9 +49,11 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/Speedo/spglyph.c,v 1.7 2001/12/14 19:56:42 dawes Exp $ */
#include <X11/X.h> /* for bit order #defines */
#include "spint.h"
+#include "fontutil.h"
#undef CLIP_BBOX_NOISE
@@ -62,12 +64,12 @@ static int bit_order,
scan;
unsigned long
-sp_compute_data_size(pfont, mappad, scanlinepad, start, end)
- FontPtr pfont;
+sp_compute_data_size(
+ FontPtr pfont,
int mappad,
- scanlinepad;
+ int scanlinepad,
unsigned long start,
- end;
+ unsigned long end)
{
unsigned long ch;
unsigned long size = 0;
@@ -121,8 +123,7 @@ sp_compute_data_size(pfont, mappad, scanlinepad, start, end)
}
static void
-finish_line(spf)
- SpeedoFontPtr spf;
+finish_line(SpeedoFontPtr spf)
{
int bpr = cfv->bpr;
CharInfoPtr ci = &spf->encoding[cfv->char_id - spf->master->first_char_id];
@@ -131,17 +132,14 @@ finish_line(spf)
bpr = GLYPH_SIZE(ci, cfv->scanpad);
}
if (bpr) { /* char may not have any metrics... */
- cfv->bp += bpr;
+ cfv->bp = (char *)cfv->bp + bpr;
}
assert(cfv->bp - sp_fp_cur->bitmaps <= sp_fp_cur->bitmap_size);
}
void
-sp_set_bitmap_bits(y, xbit1, xbit2)
- fix15 y;
- fix15 xbit1,
- xbit2;
+sp_set_bitmap_bits(fix15 y, fix15 xbit1, fix15 xbit2)
{
int nmiddle;
CARD8 startmask,
@@ -188,7 +186,7 @@ sp_set_bitmap_bits(y, xbit1, xbit2)
xbit1 = 0;
nmiddle = (xbit1 >> 3);
- dst = (CARD8 *) (cfv->bp + nmiddle);
+ dst = (CARD8 *)cfv->bp + nmiddle;
xbit2 -= (xbit1 & ~7);
nmiddle = (xbit2 >> 3);
xbit1 &= 7;
@@ -212,13 +210,8 @@ sp_set_bitmap_bits(y, xbit1, xbit2)
/* ARGSUSED */
void
-sp_open_bitmap(x_set_width, y_set_width, xorg, yorg, xsize, ysize)
- fix31 x_set_width;
- fix31 y_set_width;
- fix31 xorg;
- fix31 yorg;
- fix15 xsize;
- fix15 ysize;
+sp_open_bitmap(fix31 x_set_width, fix31 y_set_width, fix31 xorg, fix31 yorg,
+ fix15 xsize, fix15 ysize)
{
CharInfoPtr ci = &sp_fp_cur->encoding[cfv->char_id - sp_fp_cur->master->first_char_id];
@@ -314,10 +307,10 @@ sp_close_bitmap()
}
int
-sp_build_all_bitmaps(pfont, format, fmask)
- FontPtr pfont;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
+sp_build_all_bitmaps(
+ FontPtr pfont,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask)
{
int ret,
glyph = 1,
@@ -372,7 +365,7 @@ sp_build_all_bitmaps(pfont, format, fmask)
int j;
cfv->char_index = spmf->enc[i * 2 + 1];
cfv->char_id = spmf->enc[i * 2];
-#if DEBUG
+#ifdef DEBUG
fprintf(stderr, "build_all_sp_bitmaps:i = %d, Char ID = %d\n", i, cfv->char_id);
#endif
if (!cfv->char_id)
diff --git a/src/Speedo/spinfo.c b/src/Speedo/spinfo.c
index 05d3f24..d857485 100644
--- a/src/Speedo/spinfo.c
+++ b/src/Speedo/spinfo.c
@@ -49,10 +49,16 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/Speedo/spinfo.c,v 1.13 2002/09/10 16:14:33 tsi Exp $ */
#include "fntfilst.h"
+#include "fontutil.h"
#include "spint.h"
+#ifndef FONTMODULE
#include <math.h>
+#else
+#include "xf86_ansic.h"
+#endif
/* percentage of pointsize used to specify ascent & descent */
#define STRETCH_FACTOR 120
@@ -95,7 +101,9 @@ static fontProp extraProps[] = {
{ "RAW_POINT_SIZE", 0, },
{ "RAW_ASCENT", 0, },
{ "RAW_DESCENT", 0, },
- { "RAW_AVERAGE_WIDTH", 0, }
+ { "RAW_AVERAGE_WIDTH", 0, },
+ { "FONT_TYPE", 0, },
+ { "RASTERIZER_NAME", 0, }
};
/* this is a bit kludgy */
@@ -106,15 +114,14 @@ static fontProp extraProps[] = {
#define RAWASCENTPROP 4
#define RAWDESCENTPROP 5
#define RAWWIDTHPROP 6
-
+#define FONT_TYPEPROP 7
+#define RASTERIZER_NAMEPROP 8
#define NNAMEPROPS (sizeof(fontNamePropTable) / sizeof(fontProp))
#define NEXTRAPROPS (sizeof(extraProps) / sizeof(fontProp))
#define NPROPS (NNAMEPROPS + NEXTRAPROPS)
-extern Atom MakeAtom();
-
void
sp_make_standard_props()
{
@@ -130,9 +137,9 @@ sp_make_standard_props()
}
void
-sp_make_header(spf, pinfo)
- SpeedoFontPtr spf;
- FontInfoPtr pinfo;
+sp_make_header(
+ SpeedoFontPtr spf,
+ FontInfoPtr pinfo)
{
int pixel_size;
SpeedoMasterFontPtr spmf = spf->master;
@@ -172,10 +179,10 @@ sp_make_header(spf, pinfo)
}
static void
-adjust_min_max(minc, maxc, tmp)
+adjust_min_max(
xCharInfo *minc,
- *maxc,
- *tmp;
+ xCharInfo *maxc,
+ xCharInfo *tmp)
{
#define MINMAX(field,ci) \
if (minc->field > (ci)->field) \
@@ -199,11 +206,11 @@ adjust_min_max(minc, maxc, tmp)
void
-sp_compute_bounds(spf, pinfo, flags, sWidth)
- SpeedoFontPtr spf;
- FontInfoPtr pinfo;
- unsigned long flags;
- long *sWidth;
+sp_compute_bounds(
+ SpeedoFontPtr spf,
+ FontInfoPtr pinfo,
+ unsigned long flags,
+ long *sWidth)
{
int i,
id,
@@ -327,18 +334,18 @@ sp_compute_bounds(spf, pinfo, flags, sWidth)
}
void
-sp_compute_props(spf, fontname, pinfo, sWidth)
- SpeedoFontPtr spf;
- char *fontname;
- FontInfoPtr pinfo;
- long sWidth;
+sp_compute_props(
+ SpeedoFontPtr spf,
+ char *fontname,
+ FontInfoPtr pinfo,
+ long sWidth)
{
FontPropPtr pp;
int i,
nprops;
fontProp *fpt;
char *is_str;
- char *ptr1,
+ char *ptr1 = NULL,
*ptr2;
char *ptr3;
char tmpname[1024];
@@ -352,6 +359,7 @@ sp_compute_props(spf, fontname, pinfo, sWidth)
pinfo->isStringProp = (char *) 0;
xfree(pinfo->props);
pinfo->props = (FontPropPtr) 0;
+ pinfo->nprops = 0;
return;
}
bzero(pinfo->isStringProp, (sizeof(char) * nprops));
@@ -416,6 +424,16 @@ sp_compute_props(spf, fontname, pinfo, sWidth)
pp->value = MakeAtom(spf->master->copyright,
strlen(spf->master->copyright), TRUE);
break;
+ case FONT_TYPEPROP:
+ *is_str = TRUE;
+ pp->value = MakeAtom("Speedo", strlen("Speedo"), TRUE);
+ break;
+ case RASTERIZER_NAMEPROP:
+ *is_str = TRUE;
+ pp->value = MakeAtom("X Consortium Speedo Rasterizer",
+ strlen("X Consortium Speedo Rasterizer"),
+ TRUE);
+ break;
case RAWPIXELPROP:
*is_str = FALSE;
pp->value = 1000;
diff --git a/src/Speedo/spint.h b/src/Speedo/spint.h
index d915238..377edd8 100644
--- a/src/Speedo/spint.h
+++ b/src/Speedo/spint.h
@@ -47,12 +47,17 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/Speedo/spint.h,v 1.10 2001/12/14 19:56:42 dawes Exp $ */
#ifndef _SPINT_H_
#define _SPINT_H_
-#include <stdio.h>
#include "fntfilst.h"
+#ifndef XFree86LOADER
+#include <stdio.h>
+#else
+#include <xf86_ansic.h>
+#endif
#include <X11/Xfuncproto.h>
#include "speedo.h"
@@ -141,24 +146,27 @@ typedef struct _sp_font {
extern SpeedoFontPtr sp_fp_cur;
-extern int sp_open_font();
-extern int sp_open_master();
-extern void sp_close_font();
-extern void sp_close_master_font();
-extern void sp_close_master_file();
-extern void sp_reset_master();
-#if NeedVarargsPrototypes
+extern int sp_open_font(char *, char *, FontEntryPtr, FontScalablePtr,
+ fsBitmapFormat, fsBitmapFormatMask, Mask,
+ SpeedoFontPtr *);
+extern int sp_open_master(const char *, const char *, SpeedoMasterFontPtr *);
+extern void sp_close_font(SpeedoFontPtr);
+extern void sp_close_master_font(SpeedoMasterFontPtr);
+extern void sp_close_master_file(SpeedoMasterFontPtr);
+extern void sp_reset_master(SpeedoMasterFontPtr);
extern void SpeedoErr(char *fmt, ...);
-#else
-extern void SpeedoErr();
-#endif
-extern void sp_make_standard_props();
-extern void sp_make_header();
-extern void sp_compute_bounds();
-extern void sp_compute_props();
-extern int sp_build_all_bitmaps();
-extern unsigned long sp_compute_data_size();
+extern void sp_make_standard_props(void);
+extern void sp_make_header(SpeedoFontPtr, FontInfoPtr);
+extern void sp_compute_bounds(SpeedoFontPtr, FontInfoPtr, unsigned long, long *);
+extern void sp_compute_props(SpeedoFontPtr, char *, FontInfoPtr, long);
+extern int sp_build_all_bitmaps(FontPtr, fsBitmapFormat, fsBitmapFormatMask);
+extern unsigned long sp_compute_data_size(FontPtr, int, int, unsigned long,
+ unsigned long);
+
+extern int SpeedoFontLoad(FontPtr *, char *, char *, FontEntryPtr,
+ FontScalablePtr, fsBitmapFormat, fsBitmapFormatMask,
+ Mask);
extern int sp_bics_map[];
extern int sp_bics_map_size;
diff --git a/src/Type1/arith.c b/src/Type1/arith.c
index 65162ea..693b970 100644
--- a/src/Type1/arith.c
+++ b/src/Type1/arith.c
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/arith.c,v 1.6 2002/02/18 20:51:57 herrb Exp $ */
+
/* ARITH CWEB V0006 ******** */
/*
:h1.ARITH Module - Portable Module for Multiple Precision Fixed Point Arithmetic
@@ -48,9 +50,11 @@ assembly language, unlike C, will have 64-bit multiply products and
The included files are:
*/
+#include "os.h"
#include "objects.h"
#include "spaces.h"
#include "arith.h"
+
/*
:h3.
@@ -104,10 +108,8 @@ SIGNBITON tests the high order bit of a long 'w':
The two multiplicands must be positive.
*/
-void DLmult(product, u, v)
- register doublelong *product;
- register unsigned long u;
- register unsigned long v;
+void
+DLmult(doublelong *product, unsigned long u, unsigned long v)
{
#ifdef LONG64
/* printf("DLmult(? ?, %lx, %lx)\n", u, v); */
@@ -155,9 +157,9 @@ void DLmult(product, u, v)
Both the dividend and the divisor must be positive.
*/
-void DLdiv(quotient, divisor)
- doublelong *quotient; /* also where dividend is, originally */
- unsigned long divisor;
+void
+DLdiv(doublelong *quotient, /* also where dividend is, originally */
+ unsigned long divisor)
{
#ifdef LONG64
/* printf("DLdiv(%lx %lx)\n", quotient, divisor); */
@@ -213,7 +215,7 @@ void DLdiv(quotient, divisor)
divisor >>= 1;
if ((u1u2 >> (LONGSIZE - shift)) != 0 && shift != 0)
- abort("DLdiv: dividend too large");
+ Abort("DLdiv: dividend too large");
u1u2 = (u1u2 << shift) + ((shift == 0) ? 0 : u3u4 >> (LONGSIZE - shift));
u3u4 <<= shift;
@@ -276,7 +278,7 @@ void DLdiv(quotient, divisor)
*/
u1u2 = t;
if (HIGHDIGIT(u1u2) != 0)
- abort("divide algorithm error");
+ Abort("divide algorithm error");
u1u2 = ASSEMBLE(u1u2, LOWDIGIT(u3));
u3 = LOWDIGIT(u3u4);
q3q4 = ASSEMBLE(q3q4, qhat);
@@ -299,9 +301,9 @@ carry. Conversely, if there was a carry, the sum of the lows must be
less than the max of the lows. So, the test is "if and only if".
*/
-void DLadd(u, v)
- doublelong *u; /* u = u + v */
- doublelong *v;
+void
+DLadd(doublelong *u, /* u = u + v */
+ doublelong *v)
{
#ifdef LONG64
/* printf("DLadd(%lx %lx)\n", *u, *v); */
@@ -324,9 +326,9 @@ Testing for a borrow is even easier. If the v.low is greater than
u.low, there must be a borrow.
*/
-void DLsub(u, v)
- doublelong *u; /* u = u - v */
- doublelong *v;
+void
+DLsub(doublelong *u, /* u = u - v */
+ doublelong *v)
{
#ifdef LONG64
/* printf("DLsub(%lx %lx)\n", *u, *v); */
@@ -358,8 +360,8 @@ overflow will occur when the resulting value is passed back as
a fractpel.
*/
-fractpel FPmult(u, v)
- register fractpel u,v;
+fractpel
+FPmult(fractpel u, fractpel v)
{
doublelong w;
register int negative = FALSE; /* sign flag */
@@ -403,9 +405,8 @@ fractpel FPmult(u, v)
These values may be signed. The function returns the quotient.
*/
-fractpel FPdiv(dividend, divisor)
- register fractpel dividend;
- register fractpel divisor;
+fractpel
+FPdiv(fractpel dividend, fractpel divisor)
{
doublelong w; /* result will be built here */
int negative = FALSE; /* flag for sign bit */
@@ -451,8 +452,10 @@ an operator that first multiplies by one constant then divides by
another, keeping the intermediate result in extended precision.
*/
-fractpel FPstarslash(a, b, c)
- register fractpel a,b,c; /* result = a * b / c */
+fractpel
+FPstarslash(fractpel a, /* result = a * b / c */
+ fractpel b,
+ fractpel c)
{
doublelong w; /* result will be built here */
int negative = FALSE;
diff --git a/src/Type1/arith.h b/src/Type1/arith.h
index ab9412b..0eae659 100644
--- a/src/Type1/arith.h
+++ b/src/Type1/arith.h
@@ -26,21 +26,20 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/arith.h,v 1.5 2001/01/17 19:43:22 dawes Exp $ */
+
/*SHARED*/
#include <X11/Xmd.h> /* LONG64 */
-void DLmult(),DLdiv(),DLadd(),DLsub();
-
-fractpel FPmult();
-fractpel FPdiv();
-fractpel FPstarslash();
-
/*END SHARED*/
/*SHARED*/
+#undef SHORTSIZE
#define SHORTSIZE (sizeof(short)*8)
+#undef LONGSIZE
#define LONGSIZE (SHORTSIZE*2)
+#undef MAXSHORT
#define MAXSHORT ((1<<SHORTSIZE)-1)
/*END SHARED*/
@@ -67,4 +66,12 @@ typedef struct {
}
#endif
+extern void DLmult ( doublelong *product, unsigned long u, unsigned long v );
+extern void DLdiv ( doublelong *quotient, unsigned long divisor );
+extern void DLadd ( doublelong *u, doublelong *v );
+extern void DLsub ( doublelong *u, doublelong *v );
+extern fractpel FPmult ( fractpel u, fractpel v );
+extern fractpel FPdiv ( fractpel dividend, fractpel divisor );
+extern fractpel FPstarslash ( fractpel a, fractpel b, fractpel c );
+
/*END SHARED*/
diff --git a/src/Type1/blues.h b/src/Type1/blues.h
index 2480b14..c3943ec 100644
--- a/src/Type1/blues.h
+++ b/src/Type1/blues.h
@@ -28,8 +28,10 @@
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/blues.h,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+
-extern psobj *GetType1CharString();
+extern psobj *GetType1CharString ( psfont *fontP, unsigned char code );
#define TOPLEFT 1
#define BOTTOMRIGHT 2
diff --git a/src/Type1/curves.c b/src/Type1/curves.c
index d1033fe..206958a 100644
--- a/src/Type1/curves.c
+++ b/src/Type1/curves.c
@@ -29,6 +29,8 @@
/* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT */
/* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS */
/* SOFTWARE. */
+/* $XFree86: xc/lib/font/Type1/curves.c,v 1.8 2002/02/18 20:51:57 herrb Exp $ */
+
/*
:h1.CURVES Module - Stepping Beziers
@@ -42,6 +44,7 @@ through.
Include files needed:
*/
+#include "os.h"
#include "objects.h"
#include "spaces.h"
#include "paths.h"
@@ -88,8 +91,11 @@ struct bezierinfo {
to subdivide.
*/
-static int BezierTerminationTest(xa,ya,xb,yb,xc,yc,xd,yd)
-fractpel xa,ya,xb,yb,xc,yc,xd,yd;
+static int
+BezierTerminationTest(fractpel xa, fractpel ya,
+ fractpel xb, fractpel yb,
+ fractpel xc, fractpel yc,
+ fractpel xd, fractpel yd)
{
fractpel dmax;
dmax = ABS(xa - xb);
@@ -112,13 +118,12 @@ Bezier to define his curves as he did. If the input region 'R' is NULL,
the result is a path that is the 'flattened' curve; otherwise StepBezier
returns nothing special.
*/
-static struct segment *StepBezierRecurse(I,xA,yA,xB,yB,xC,yC,xD,yD)
- struct bezierinfo *I; /* Region under construction or NULL */
- fractpel xA,yA; /* A control point */
- fractpel xB,yB; /* B control point */
- fractpel xC,yC; /* C control point */
- fractpel xD,yD; /* D control point */
-
+static struct segment *
+StepBezierRecurse(struct bezierinfo *I, /* Region under construction or NULL */
+ fractpel xA, fractpel yA, /* A control point */
+ fractpel xB, fractpel yB, /* B control point */
+ fractpel xC, fractpel yC, /* C control point */
+ fractpel xD, fractpel yD) /* D control point */
{
if (BezierTerminationTest(xA,yA,xB,yB,xC,yC,xD,yD))
{
@@ -167,6 +172,7 @@ static struct segment *StepBezierRecurse(I,xA,yA,xB,yB,xC,yC,xD,yD)
StepBezierRecurse(I, xABCD, yABCD, xBCD, yBCD, xCD, yCD, xD, yD);
}
}
+ return NULL;
/*NOTREACHED*/
}
@@ -177,6 +183,7 @@ Intermediate values in the Bezier subdivision are 8 times bigger than
the starting values. If this overflows, a 'long', we are in trouble:
*/
+#undef BITS
#define BITS (sizeof(long)*8)
#define HIGHTEST(p) (((p)>>(BITS-4)) != 0) /* includes sign bit */
#define TOOBIG(xy) ((xy < 0) ? HIGHTEST(-xy) : HIGHTEST(xy))
@@ -187,12 +194,12 @@ the starting values. If this overflows, a 'long', we are in trouble:
This is the entry point called from outside the module.
*/
-struct segment *StepBezier(R, xA, yA, xB, yB, xC, yC, xD, yD)
- struct region *R; /* Region under construction or NULL */
- fractpel xA,yA; /* A control point */
- fractpel xB,yB; /* B control point */
- fractpel xC,yC; /* C control point */
- fractpel xD,yD; /* D control point */
+struct segment *
+StepBezier(struct region *R, /* Region under construction or NULL */
+ fractpel xA, fractpel yA, /* A control point */
+ fractpel xB, fractpel yB, /* B control point */
+ fractpel xC, fractpel yC, /* C control point */
+ fractpel xD, fractpel yD) /* D control point */
{
struct bezierinfo Info;
@@ -209,7 +216,7 @@ struct segment *StepBezier(R, xA, yA, xB, yB, xC, yC, xD, yD)
if ( TOOBIG(xB) || TOOBIG(yB) || TOOBIG(xC) || TOOBIG(yC)
|| TOOBIG(xD) || TOOBIG(yD) )
- abort("Beziers this big not yet supported");
+ Abort("Beziers this big not yet supported");
return(StepBezierRecurse(&Info,
(fractpel) 0, (fractpel) 0, xB, yB, xC, yC, xD, yD));
diff --git a/src/Type1/curves.h b/src/Type1/curves.h
index 4138a6f..ff2bf48 100644
--- a/src/Type1/curves.h
+++ b/src/Type1/curves.h
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/curves.h,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+
/*SHARED*/
#define StepConic(R,xA,yA,xB,yB,xC,yC,r) t1_StepConic(R,xA,yA,xB,yB,xC,yC,r)
@@ -33,8 +35,10 @@
#define FlattenConic(xM,yM,xC,yC,r) t1_StepConic(NULL,(fractpel)0,(fractpel)0,xM,yM,xC,yC,r)
#define FlattenBezier(xB,yB,xC,yC,xD,yD) t1_StepBezier(NULL,(fractpel)0,(fractpel)0,xB,yB,xC,yC,xD,yD)
-
+
+#if 0
struct segment *t1_StepConic();
-struct segment *t1_StepBezier();
-
+#endif
+extern struct segment *t1_StepBezier ( struct region *R, fractpel xA, fractpel yA, fractpel xB, fractpel yB, fractpel xC, fractpel yC, fractpel xD, fractpel yD );
+
/*END SHARED*/
diff --git a/src/Type1/fontfcn.c b/src/Type1/fontfcn.c
index 5516468..471a4ee 100644
--- a/src/Type1/fontfcn.c
+++ b/src/Type1/fontfcn.c
@@ -1,4 +1,4 @@
-/* $Xorg: fontfcn.c,v 1.5 2000/12/01 16:26:25 steve Exp $ */
+/* $Xorg: fontfcn.c,v 1.4 2000/08/17 19:46:30 cpqbld Exp $ */
/* Copyright International Business Machines,Corp. 1991
* All Rights Reserved
*
@@ -28,15 +28,55 @@
* SOFTWARE.
*/
/* Author: Katherine A. Hitchcock IBM Almaden Research Laboratory */
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/fontfcn.c,v 1.11 2001/11/23 19:21:31 dawes Exp $ */
+#ifndef FONTMODULE
#include <stdio.h>
#include <string.h>
+#else
+#include "Xmd.h" /* For INT32 declaration */
+#include "Xdefs.h" /* For Bool */
+#include "xf86_ansic.h"
+#endif
#include "t1imager.h"
#include "util.h"
+#ifdef BUILDCID
+#include "range.h"
+#include "Xdefs.h"
+#endif
+#include "fntfilst.h"
#include "fontfcn.h"
-#include "fontmisc.h"
-
-extern xobject Type1Char();
+
+extern struct segment *Type1Char ( char *env, XYspace S,
+ psobj *charstrP, psobj *subrsP,
+ psobj *osubrsP,
+ struct blues_struct *bluesP, int *modeP );
+
+#ifdef BUILDCID
+extern struct xobject *CIDChar ( char *env, XYspace S,
+ psobj *charstrP, psobj *subrsP,
+ psobj *osubrsP,
+ struct blues_struct *bluesP, int *modeP );
+static boolean initCIDFont( int cnt );
+#endif
+
/***================================================================***/
/* GLOBALS */
/***================================================================***/
@@ -45,7 +85,16 @@ char *CurFontEnv;
char *vm_base = NULL;
psfont *FontP = NULL;
psfont TheCurrentFont;
-
+#ifdef BUILDCID
+char CurCIDFontName[CID_PATH_MAX];
+char CurCMapName[CID_PATH_MAX];
+cidfont *CIDFontP = NULL;
+cmapres *CMapP = NULL;
+cidfont TheCurrentCIDFont;
+cmapres TheCurrentCMap;
+psfont *FDArrayP = NULL;
+int FDArrayIndex = 0;
+#endif
/***================================================================***/
/* SearchDict - look for name */
@@ -53,9 +102,8 @@ psfont TheCurrentFont;
/* return 0 - not found. */
/* return n - nth element in dictionary. */
/***================================================================***/
-int SearchDictName(dictP,keyP)
- psdict *dictP;
- psobj *keyP;
+int
+SearchDictName(psdict *dictP, psobj *keyP)
{
int i,n;
@@ -73,15 +121,68 @@ int SearchDictName(dictP,keyP)
}
return(0);
}
+
+#ifdef BUILDCID
+static boolean
+initCIDFont(int cnt)
+{
+ if (!(vm_init(cnt))) return(FALSE);
+ vm_base = vm_next_byte();
+ strcpy(CurCIDFontName, ""); /* initialize to none */
+ strcpy(CurCMapName, ""); /* initialize to none */
+ /* cause a font data reset on the next Type 1 font */
+ strcpy(CurFontName, ""); /* initialize to none */
+ CIDFontP = &TheCurrentCIDFont;
+ CMapP = &TheCurrentCMap;
+ CIDFontP->vm_start = vm_next_byte();
+ CIDFontP->spacerangecnt = 0;
+ CIDFontP->notdefrangecnt = 0;
+ CIDFontP->cidrangecnt = 0;
+ CIDFontP->spacerangeP = NULL;
+ CIDFontP->notdefrangeP = NULL;
+ CIDFontP->cidrangeP = NULL;
+ CIDFontP->CIDFontFileName.len = 0;
+ CIDFontP->CIDFontFileName.data.valueP = CurCIDFontName;
+ CMapP->CMapFileName.len = 0;
+ CMapP->CMapFileName.data.valueP = CurCMapName;
+ CMapP->firstRow = 0xFFFF;
+ CMapP->firstCol = 0xFFFF;
+ CMapP->lastRow = 0;
+ CMapP->lastCol = 0;
+ return(TRUE);
+}
+
/***================================================================***/
-boolean initFont(cnt)
-int cnt;
+boolean
+initCIDType1Font(void)
+{
+ strcpy(CurFontName, ""); /* initialize to none */
+ FontP = &FDArrayP[FDArrayIndex];
+ FontP->vm_start = vm_next_byte();
+ FontP->FontFileName.len = 0;
+ FontP->FontFileName.data.valueP = CurFontName;
+ FontP->Subrs.len = 0;
+ FontP->Subrs.data.stringP = NULL;
+ FontP->CharStringsP = NULL;
+ FontP->Private = NULL;
+ FontP->fontInfoP = NULL;
+ FontP->BluesP = NULL;
+ return(TRUE);
+}
+#endif
+
+boolean
+initFont(int cnt)
{
if (!(vm_init(cnt))) return(FALSE);
vm_base = vm_next_byte();
if (!(Init_BuiltInEncoding())) return(FALSE);
strcpy(CurFontName, ""); /* iniitialize to none */
+#ifdef BUILDCID
+ /* cause a font data reset on the next CID-keyed font */
+ strcpy(CurCIDFontName, ""); /* initialize to none */
+#endif
FontP = &TheCurrentFont;
FontP->vm_start = vm_next_byte();
FontP->FontFileName.len = 0;
@@ -89,8 +190,53 @@ int cnt;
return(TRUE);
}
/***================================================================***/
-static void resetFont(env)
- char *env;
+#ifdef BUILDCID
+static void
+resetCIDFont(char *cidfontname, char *cmapfile)
+{
+
+ vm_next = CIDFontP->vm_start;
+ vm_free = vm_size - ( vm_next - vm_base);
+ CIDFontP->spacerangecnt = 0;
+ CIDFontP->notdefrangecnt = 0;
+ CIDFontP->cidrangecnt = 0;
+ CIDFontP->spacerangeP = NULL;
+ CIDFontP->notdefrangeP = NULL;
+ CIDFontP->cidrangeP = NULL;
+ CIDFontP->CIDfontInfoP = NULL;
+ /* This will load the font into the FontP */
+ strcpy(CurCIDFontName,cidfontname);
+ strcpy(CurCMapName,cmapfile);
+ CIDFontP->CIDFontFileName.len = strlen(CurCIDFontName);
+ CIDFontP->CIDFontFileName.data.valueP = CurCIDFontName;
+ CMapP->CMapFileName.len = strlen(CurCMapName);
+ CMapP->CMapFileName.data.valueP = CurCMapName;
+ CMapP->firstRow = 0xFFFF;
+ CMapP->firstCol = 0xFFFF;
+ CMapP->lastRow = 0;
+ CMapP->lastCol = 0;
+}
+
+static void
+resetCIDType1Font(void)
+{
+
+ vm_next = FontP->vm_start;
+ vm_free = vm_size - ( vm_next - vm_base);
+ FontP->Subrs.len = 0;
+ FontP->Subrs.data.stringP = NULL;
+ FontP->CharStringsP = NULL;
+ FontP->Private = NULL;
+ FontP->fontInfoP = NULL;
+ FontP->BluesP = NULL;
+ /* This will load the font into the FontP */
+ FontP->FontFileName.len = strlen(CurFontName);
+ FontP->FontFileName.data.valueP = CurFontName;
+}
+#endif
+
+static void
+resetFont(char *env)
{
vm_next = FontP->vm_start;
@@ -107,9 +253,55 @@ static void resetFont(env)
FontP->FontFileName.data.valueP = CurFontName;
}
+
+#ifdef BUILDCID
/***================================================================***/
-int readFont(env)
-char *env;
+int
+readCIDFont(char *cidfontname, char *cmapfile)
+{
+ int rcode;
+
+ /* restore the virtual memory and eliminate old font */
+ resetCIDFont(cidfontname, cmapfile);
+ /* This will load the font into the FontP */
+ rcode = scan_cidfont(CIDFontP, CMapP);
+ if (rcode == SCAN_OUT_OF_MEMORY) {
+ /* free the memory and start again */
+ if (!(initCIDFont(vm_size * 2))) {
+ /* we are really out of memory */
+ return(SCAN_OUT_OF_MEMORY);
+ }
+ resetCIDFont(cidfontname, cmapfile);
+ rcode = scan_cidfont(CIDFontP, CMapP);
+ /* only double the memory twice, then report error */
+ if (rcode == SCAN_OUT_OF_MEMORY) {
+ /* free the memory and start again */
+ if (!(initCIDFont(vm_size * 2))) {
+ /* we are really out of memory */
+ return(SCAN_OUT_OF_MEMORY);
+ }
+ resetCIDFont(cidfontname, cmapfile);
+ rcode = scan_cidfont(CIDFontP, CMapP);
+ }
+ }
+ return(rcode);
+}
+
+int
+readCIDType1Font(void)
+{
+ int rcode;
+
+ resetCIDType1Font();
+
+ /* This will load the font into the FontP */
+ rcode = scan_cidtype1font(FontP);
+ return(rcode);
+}
+#endif
+
+int
+readFont(char *env)
{
int rcode;
@@ -119,26 +311,39 @@ char *env;
rcode = scan_font(FontP);
if (rcode == SCAN_OUT_OF_MEMORY) {
/* free the memory and start again */
+#ifdef BUILDCID
+ /* xfree(vm_base); */
+#else
xfree(vm_base);
+#endif
if (!(initFont(vm_size * 2))) {
/* we are really out of memory */
return(SCAN_OUT_OF_MEMORY);
}
resetFont(env);
rcode = scan_font(FontP);
+#ifdef BUILDCID
+ /* only double the memory twice, then report error */
+ if (rcode == SCAN_OUT_OF_MEMORY) {
+ /* free the memory and start again */
+ /* xfree(vm_base) */
+ if (!(initFont(vm_size * 2))) {
+ /* we are really out of memory */
+ return(SCAN_OUT_OF_MEMORY);
+ }
+ resetFont(env);
+ rcode = scan_font(FontP);
+ }
+#else
/* only double the memory once, then report error */
+#endif
}
return(rcode);
}
/***================================================================***/
-xobject fontfcnB(S,code,lenP,mode)
-XYspace S;
-unsigned char *code;
-int *lenP;
-int *mode;
+struct xobject *
+fontfcnB(struct XYspace *S, unsigned char *code, int *lenP, int *mode)
{
- path updateWidth();
-
psobj *charnameP; /* points to psobj that is name of character*/
int N;
psdict *CharStringsDictP; /* dictionary with char strings */
@@ -146,7 +351,7 @@ int *mode;
psobj *SubrsArrayP;
psobj *theStringP;
- path charpath; /* the path for this character */
+ struct xobject *charpath; /* the path for this character */
charnameP = &CodeName;
charnameP->len = *lenP;
@@ -168,16 +373,87 @@ int *mode;
SubrsArrayP = &(FontP->Subrs);
/* scale the Adobe fonts to 1 unit high */
/* call the type 1 routine to rasterize the character */
- charpath = Type1Char(FontP,S,theStringP,SubrsArrayP,NULL,
+ charpath = (struct xobject *)Type1Char((char *)FontP,S,theStringP,
+ SubrsArrayP,NULL,
FontP->BluesP , mode);
/* if Type1Char reported an error, then return */
if ( *mode == FF_PARSE_ERROR) return(NULL);
/* fill with winding rule unless path was requested */
if (*mode != FF_PATH) {
- charpath = Interior(charpath,WINDINGRULE+CONTINUITY);
+ charpath = (struct xobject *)Interior((struct segment *)charpath,
+ WINDINGRULE+CONTINUITY);
}
return(charpath);
}
+
+#ifdef BUILDCID
+/***================================================================***/
+/* CIDfontfcnA(cidfontname, cmapfile, mode) */
+/* */
+/* 1) initialize the font - global indicates it has been done */
+/* 2) load the font */
+/***================================================================***/
+Bool
+CIDfontfcnA(char *cidfontname, char *cmapfile, int *mode)
+{
+ int rcode, cidinit;
+
+ cidinit = 0;
+ if (CIDFontP == NULL || strcmp(CurCIDFontName, "") == 0) {
+ InitImager();
+ if (!(initCIDFont(VM_SIZE))) {
+ /* we are really out of memory */
+ *mode = SCAN_OUT_OF_MEMORY;
+ return(FALSE);
+ }
+ cidinit = 1;
+ }
+
+ /* if the cidfontname is null, then use font already loaded */
+
+ /* if not the same font name */
+ if (cidinit || (cidfontname && strcmp(cidfontname,CurCIDFontName) != 0) ||
+ (cmapfile && strcmp(cmapfile,CurCMapName) != 0)) {
+ /* restore the virtual memory and eliminate old font, read new one */
+ rcode = readCIDFont(cidfontname, cmapfile);
+ if (rcode != 0 ) {
+ strcpy(CurCIDFontName, ""); /* no CIDFont loaded */
+ strcpy(CurCMapName, ""); /* no CMap loaded */
+ *mode = rcode;
+ return(FALSE);
+ }
+ }
+ return(TRUE);
+
+}
+
+/***================================================================***/
+/* CIDType1fontfcnA(mode) */
+/* */
+/* 1) initialize the font - global indicates it has been done */
+/* 2) load the font */
+/***================================================================***/
+Bool
+CIDType1fontfcnA(int *mode)
+{
+ int rcode;
+
+ if (!(initCIDType1Font())) {
+ /* we are really out of memory */
+ *mode = SCAN_OUT_OF_MEMORY;
+ return(FALSE);
+ }
+
+ if ((rcode = readCIDType1Font()) != 0) {
+ strcpy(CurFontName, ""); /* no font loaded */
+ *mode = rcode;
+ return(FALSE);
+ }
+ return(TRUE);
+
+}
+#endif
+
/***================================================================***/
/* fontfcnA(env, mode) */
/* */
@@ -186,15 +462,18 @@ int *mode;
/* 1) initialize the font - global indicates it has been done */
/* 2) load the font */
/***================================================================***/
-Bool fontfcnA(env,mode)
-char *env;
-int *mode;
+Bool
+fontfcnA(char *env, int *mode)
{
int rc;
/* Has the FontP initialized? If not, then */
/* Initialize */
+#ifdef BUILDCID
+ if (FontP == NULL || strcmp(CurFontName, "") == 0) {
+#else
if (FontP == NULL) {
+#endif
InitImager();
if (!(initFont(VM_SIZE))) {
/* we are really out of memory */
@@ -218,6 +497,101 @@ int *mode;
return(TRUE);
}
+
+#ifdef BUILDCID
+/***================================================================***/
+/* CIDQueryFontLib(cidfontname,cmapfile,infoName,infoValue,rcodeP) */
+/* */
+/* cidfontname is a pointer to a string that contains the fontname. */
+/* */
+/* 1) initialize the font - global indicates it has been done */
+/* 2) load the font */
+/* 3) use the font to call getInfo for that value. */
+/***================================================================***/
+
+void
+CIDQueryFontLib(char *cidfontname, char *cmapfile, char *infoName,
+ pointer infoValue, /* parameter returned here */
+ int *rcodeP)
+{
+ int rc,N,i,cidinit;
+ psdict *dictP;
+ psobj nameObj;
+ psobj *valueP;
+
+ /* Has the CIDFontP initialized? If not, then */
+ /* Initialize */
+ cidinit = 0;
+ if (CIDFontP == NULL || strcmp(CurCIDFontName, "") == 0) {
+ InitImager();
+ if (!(initCIDFont(VM_SIZE))) {
+ *rcodeP = 1;
+ return;
+ }
+ cidinit = 1;
+ }
+ /* if the file name is null, then use font already loaded */
+ /* if the not same font name, reset and load next font */
+ if (cidinit || (cidfontname && strcmp(cidfontname,CurCIDFontName) != 0) ||
+ (cmapfile && strcmp(cmapfile,CurCMapName) != 0)) {
+ /* restore the virtual memory and eliminate old font */
+ rc = readCIDFont(cidfontname, cmapfile);
+ if (rc != 0 ) {
+ strcpy(CurCIDFontName, ""); /* no font loaded */
+ strcpy(CurCMapName, ""); /* no font loaded */
+ *rcodeP = 1;
+ return;
+ }
+ }
+ dictP = CIDFontP->CIDfontInfoP;
+ objFormatName(&nameObj,strlen(infoName),infoName);
+ N = SearchDictName(dictP,&nameObj);
+ /* if found */
+ if ( N > 0 ) {
+ *rcodeP = 0;
+ switch (dictP[N].value.type) {
+ case OBJ_ARRAY:
+ valueP = dictP[N].value.data.arrayP;
+ /* Just double check valueP. H.J. */
+ if (valueP == NULL) break;
+ if (strcmp(infoName,"FontMatrix") == 0) {
+ /* 6 elments, return them as floats */
+ for (i=0;i<6;i++) {
+ if (valueP->type == OBJ_INTEGER )
+ ((float *)infoValue)[i] = valueP->data.integer;
+ else
+ ((float *)infoValue)[i] = valueP->data.real;
+ valueP++;
+ }
+ }
+ if (strcmp(infoName,"FontBBox") == 0) {
+ /* 4 elments for Bounding Box. all integers */
+ for (i=0;i<4;i++) {
+ ((int *)infoValue)[i] = valueP->data.integer;
+ valueP++;
+ }
+ break;
+ case OBJ_INTEGER:
+ case OBJ_BOOLEAN:
+ *((int *)infoValue) = dictP[N].value.data.integer;
+ break;
+ case OBJ_REAL:
+ *((float *)infoValue) = dictP[N].value.data.real;
+ break;
+ case OBJ_NAME:
+ case OBJ_STRING:
+ *((char **)infoValue) = dictP[N].value.data.valueP;
+ break;
+ default:
+ *rcodeP = 1;
+ break;
+ }
+ }
+ }
+ else *rcodeP = 1;
+}
+#endif
+
/***================================================================***/
/* QueryFontLib(env, infoName,infoValue,rcodeP) */
/* */
@@ -228,11 +602,10 @@ int *mode;
/* 3) use the font to call getInfo for that value. */
/***================================================================***/
-void QueryFontLib(env,infoName,infoValue,rcodeP)
-char *env;
-char *infoName;
-pointer infoValue; /* parameter returned here */
-int *rcodeP;
+void
+QueryFontLib(char *env, char *infoName,
+ pointer infoValue, /* parameter returned here */
+ int *rcodeP)
{
int rc,N,i;
psdict *dictP;
@@ -268,8 +641,8 @@ int *rcodeP;
switch (dictP[N].value.type) {
case OBJ_ARRAY:
valueP = dictP[N].value.data.arrayP;
- /* don't dereference a NULL pointer, in the case of a bad font file */
- if (valueP == NULL) break;
+ /* Just double check valueP. H.J. */
+ if (valueP == NULL) break;
if (strcmp(infoName,"FontMatrix") == 0) {
/* 6 elments, return them as floats */
for (i=0;i<6;i++) {
@@ -306,3 +679,24 @@ int *rcodeP;
}
else *rcodeP = 1;
}
+
+#ifdef BUILDCID
+struct xobject *
+CIDfontfcnC(struct XYspace *S, psobj *theStringP,
+ psobj *SubrsArrayP, struct blues_struct *BluesP,
+ int *lenP, int *mode)
+{
+ struct xobject *charpath; /* the path for this character */
+
+ charpath = (struct xobject *)CIDChar((char *)FontP,S,theStringP,
+ SubrsArrayP,NULL,BluesP,mode);
+ /* if Type1Char reported an error, then return */
+ if ( *mode == FF_PARSE_ERROR) return(NULL);
+ /* fill with winding rule unless path was requested */
+ if (*mode != FF_PATH) {
+ charpath = (struct xobject *)Interior((struct segment *)charpath,
+ WINDINGRULE+CONTINUITY);
+ }
+ return(charpath);
+}
+#endif
diff --git a/src/Type1/fontfcn.h b/src/Type1/fontfcn.h
index cbf23a1..9383e42 100644
--- a/src/Type1/fontfcn.h
+++ b/src/Type1/fontfcn.h
@@ -27,6 +27,53 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/fontfcn.h,v 1.5 2001/01/17 19:43:22 dawes Exp $ */
+
+
+#ifdef BUILDCID
+/* Definition of a PostScript CIDFont resource */
+typedef struct cid_font {
+ char *vm_start;
+ int spacerangecnt;
+ int notdefrangecnt;
+ int cidrangecnt;
+ spacerange *spacerangeP;
+ cidrange *notdefrangeP;
+ cidrange *cidrangeP;
+ int binarydata; /* 1=binary data, 0=hex data */
+ long bytecnt;
+ psobj CIDFontFileName;
+ psdict *CIDfontInfoP;
+} cidfont;
+
+/* Definition of a PostScript CMap resource */
+typedef struct cmap_res {
+ unsigned short firstCol;
+ unsigned short lastCol;
+ unsigned short firstRow;
+ unsigned short lastRow;
+ psobj CMapFileName;
+ psdict *CMapInfoP;
+} cmapres;
+#endif
+
/* Definition of a PostScript FONT */
typedef struct ps_font {
char *vm_start;
@@ -40,10 +87,13 @@ struct blues_struct *BluesP;
/***================================================================***/
/* Routines in scan_font */
/***================================================================***/
-
-extern boolean Init_StdEnc();
-extern int scan_font();
-extern int GetFontInfo();
+
+extern boolean Init_BuiltInEncoding ( void );
+#ifdef BUILDCID
+extern int scan_cidfont ( cidfont *CIDFontP, cmapres *CMapP );
+extern int scan_cidtype1font ( psfont *FontP );
+#endif
+extern int scan_font ( psfont *FontP );
/***================================================================***/
/* Return codes from scan_font */
/***================================================================***/
@@ -55,7 +105,43 @@ extern int GetFontInfo();
#define SCAN_TRUE -5
#define SCAN_FALSE -6
#define SCAN_END -7
-
+
+#ifdef BUILDCID
+/***================================================================***/
+/* Name of CID FontInfo fields */
+/***================================================================***/
+#define CIDCOUNT 1
+#define CIDFONTNAME 2
+#define CIDFONTTYPE 3
+#define CIDVERSION 4
+#define CIDREGISTRY 5
+#define CIDORDERING 6
+#define CIDSUPPLEMENT 7
+#define CIDMAPOFFSET 8
+#define CIDFDARRAY 9
+#define CIDFDBYTES 10
+#define CIDFONTBBOX 11
+#define CIDFULLNAME 12
+#define CIDFAMILYNAME 13
+#define CIDWEIGHT 14
+#define CIDNOTICE 15
+#define CIDGDBYTES 16
+#define CIDUIDBASE 17
+#define CIDXUID 18
+
+/***================================================================***/
+/* Name of CMapInfo fields */
+/***================================================================***/
+#define CMAPREGISTRY 1
+#define CMAPORDERING 2
+#define CMAPSUPPLEMENT 3
+#define CMAPNAME 4
+#define CMAPVERSION 5
+#define CMAPTYPE 6
+#define CMAPWMODE 7
+#define CMAPCIDCOUNT 8
+#endif
+
/***================================================================***/
/* Name of FontInfo fields */
/***================================================================***/
@@ -96,3 +182,60 @@ extern int GetFontInfo();
#define LENIV 14
#define RNDSTEMUP 15
#define EXPANSIONFACTOR 16
+
+#ifdef BUILDCID
+/***================================================================***/
+/* Name of CID Type 1 Private values */
+/***================================================================***/
+#define CIDT1MINFEATURE 1
+#define CIDT1LENIV 2
+#define CIDT1LANGGROUP 3
+#define CIDT1BLUEVALUES 4
+#define CIDT1OTHERBLUES 5
+#define CIDT1BLUESCALE 6
+#define CIDT1BLUEFUZZ 7
+#define CIDT1BLUESHIFT 8
+#define CIDT1FAMBLUES 9
+#define CIDT1FAMOTHERBLUES 10
+#define CIDT1STDHW 11
+#define CIDT1STDVW 12
+#define CIDT1STEMSNAPH 13
+#define CIDT1STEMSNAPV 14
+#define CIDT1SUBMAPOFF 15
+#define CIDT1SDBYTES 16
+#define CIDT1SUBRCNT 17
+#define CIDT1FORCEBOLD 18
+#define CIDT1RNDSTEMUP 19
+#define CIDT1EXPFACTOR 20
+
+#define CID_BITMAP_UNDEFINED 0
+extern int SearchDictName ( psdict *dictP, psobj *keyP );
+#ifdef BUILDCID
+extern boolean initCIDType1Font ( void );
+#endif
+extern boolean initFont ( int cnt );
+#ifdef BUILDCID
+extern int readCIDFont ( char *cidfontname, char *cmapfile );
+extern int readCIDType1Font ( void );
+#endif
+extern int readFont ( char *env );
+extern struct xobject *fontfcnB ( struct XYspace *S, unsigned char *code,
+ int *lenP, int *mode );
+#ifdef BUILDCID
+extern Bool CIDfontfcnA ( char *cidfontname, char *cmapfile, int *mode );
+extern Bool CIDType1fontfcnA ( int *mode );
+#endif
+extern Bool fontfcnA ( char *env, int *mode );
+#ifdef BUILDCID
+extern void CIDQueryFontLib ( char *cidfontname, char *cmapfile,
+ char *infoName, pointer infoValue, int *rcodeP );
+#endif
+extern void QueryFontLib ( char *env, char *infoName, pointer infoValue,
+ int *rcodeP );
+#ifdef BUILDCID
+extern struct xobject *CIDfontfcnC ( struct XYspace *S, psobj *theStringP,
+ psobj *SubrsArrayP,
+ struct blues_struct *BluesP, int *lenP,
+ int *mode );
+#endif
+#endif
diff --git a/src/Type1/hints.c b/src/Type1/hints.c
index c3db5a4..5150647 100644
--- a/src/Type1/hints.c
+++ b/src/Type1/hints.c
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/hints.c,v 1.7 2002/02/18 20:51:57 herrb Exp $ */
+
/* HINTS CWEB V0006 ******** */
/*
:h1.HINTS Module - Processing Rasterization Hints
@@ -39,12 +41,13 @@ W. Pryor, Jr.
The included files are:
*/
+#include "os.h"
#include "objects.h"
#include "spaces.h"
#include "paths.h"
#include "regions.h"
#include "hints.h"
-
+
/*
:h3.Functions Provided to the TYPE1IMAGER User
@@ -81,7 +84,8 @@ static struct {
#define FPFLOOR(fp) TOFRACTPEL((fp) >> FRACTBITS)
#define FPROUND(fp) FPFLOOR((fp) + FPHALF)
-void InitHints()
+void
+InitHints(void)
{
int i;
@@ -96,8 +100,8 @@ void InitHints()
:h3.CloseHints(hintP) - Reverse hints that are still open
*/
-void CloseHints(hintP)
- struct fractpoint *hintP;
+void
+CloseHints(struct fractpoint *hintP)
{
int i;
@@ -120,10 +124,10 @@ void CloseHints(hintP)
:h3.ComputeHint(hP, currX, currY, hintP) - Compute the value of a hint
*/
-static void ComputeHint(hP, currX, currY, hintP)
- struct hintsegment *hP;
- fractpel currX, currY;
- struct fractpoint *hintP;
+static void
+ComputeHint(struct hintsegment *hP,
+ fractpel currX, fractpel currY,
+ struct fractpoint *hintP)
{
fractpel currRef, currWidth;
int idealWidth;
@@ -166,7 +170,7 @@ multiple of 90 degrees.
}
else /* error */
{
- abort("ComputeHint: invalid orientation");
+ Abort("ComputeHint: invalid orientation");
}
IfTrace4((HintDebug > 1),
@@ -200,7 +204,7 @@ multiple of 90 degrees.
}
else /* error */
{
- abort("ComputeHint: invalid hinttype");
+ Abort("ComputeHint: invalid hinttype");
}
IfTrace1((HintDebug > 1)," hintValue=%p", hintValue);
@@ -217,7 +221,7 @@ multiple of 90 degrees.
}
else /* error */
{
- abort("ComputeHint: invalid orientation");
+ Abort("ComputeHint: invalid orientation");
}
}
@@ -225,10 +229,10 @@ multiple of 90 degrees.
:h3.ProcessHint(hP, currX, currY, hintP) - Process a rasterization hint
*/
-void ProcessHint(hP, currX, currY, hintP)
- struct hintsegment *hP;
- fractpel currX, currY;
- struct fractpoint *hintP;
+void
+ProcessHint(struct hintsegment *hP,
+ fractpel currX, fractpel currY,
+ struct fractpoint *hintP)
{
struct fractpoint thisHint;
@@ -266,7 +270,7 @@ void ProcessHint(hP, currX, currY, hintP)
}
else /* error */
{
- abort("ProcessHint: invalid label");
+ Abort("ProcessHint: invalid label");
}
}
else if (hP->adjusttype == 'r') /* Reverse */
@@ -282,18 +286,18 @@ void ProcessHint(hP, currX, currY, hintP)
}
else /* error */
{
- abort("ProcessHint: label is not in use");
+ Abort("ProcessHint: label is not in use");
}
}
else /* error */
{
- abort("ProcessHint: invalid label");
+ Abort("ProcessHint: invalid label");
}
}
else /* error */
{
- abort("ProcessHint: invalid adjusttype");
+ Abort("ProcessHint: invalid adjusttype");
}
IfTrace3((HintDebug > 1)," label=%d, thisHint=(%p,%p)\n",
hP->label, thisHint.x, thisHint.y);
@@ -362,9 +366,9 @@ off of the edge's range; XofY() could be replace by FindXofY() to
call ourselves recursively if this were not true.
*/
-static pel SearchXofY(edge, y)
- register struct edgelist *edge; /* represents edge */
- register pel y; /* 'y' value to find edge for */
+static pel
+SearchXofY(register struct edgelist *edge, /* represents edge */
+ register pel y) /* 'y' value to find edge for */
{
register struct edgelist *e; /* loop variable */
@@ -385,7 +389,7 @@ static pel SearchXofY(edge, y)
else
return(XofY(edge, y));
- abort("bad subpath chain");
+ Abort("bad subpath chain");
/*NOTREACHED*/
}
/*
@@ -413,9 +417,10 @@ are at the top and the first edge is going up.
#define BLACKBELOW +1
#define NONE 0
-static int ImpliedHorizontalLine(e1, e2, y)
- register struct edgelist *e1,*e2; /* two edges to check */
- register int y; /* y where they might be connected */
+static int
+ImpliedHorizontalLine(struct edgelist *e1, /* two edges to check */
+ struct edgelist *e2,
+ int y) /* y where they might be connected */
{
register struct edgelist *e3,*e4;
@@ -466,7 +471,7 @@ Now we have everything to return the answer:
else if (ISBOTTOM(e1->flag) && y == e1->ymax)
return(!ISDOWN(e2->flag));
else
- abort("ImpliedHorizontalLine: why ask?");
+ Abort("ImpliedHorizontalLine: why ask?");
/*NOTREACHED*/
}
@@ -483,14 +488,14 @@ routine finds and fixes false breaks.
Also, this routine sets the ISTOP and ISBOTTOM flags in the edge lists.
*/
-static void FixSubPaths(R)
- register struct region *R; /* anchor of region */
+static void
+FixSubPaths(struct region *R) /* anchor of region */
{
register struct edgelist *e; /* fast loop variable */
register struct edgelist *edge; /* current edge in region */
register struct edgelist *next; /* next in subpath after 'edge' */
register struct edgelist *break1; /* first break after 'next' */
- register struct edgelist *break2; /* last break before 'edge' */
+ register struct edgelist *break2 = NULL; /* last break before 'edge' */
register struct edgelist *prev; /* previous edge for fixing links */
int left = TRUE;
@@ -505,7 +510,7 @@ static void FixSubPaths(R)
if (!ISBREAK(edge, next))
continue;
if (edge->ymax < next->ymin)
- abort("disjoint subpath?");
+ Abort("disjoint subpath?");
/*
'edge' now contains an edgelist at the bottom of an edge, and 'next'
contains the next subsequent edgelist in the subpath, which must be at
@@ -566,7 +571,7 @@ as 'next':
break1->subpath = break2->subpath;
if (ISBREAK(break1, break1->subpath))
- abort("unable to fix subpath break?");
+ Abort("unable to fix subpath break?");
break2->subpath = next;
@@ -626,10 +631,10 @@ get all the way to the outside without resolving ambiguity.
A debug tool.
*/
-static struct edgelist *before(); /* subroutine of DumpSubPaths */
+static struct edgelist *before(struct edgelist *e); /* subroutine of DumpSubPaths */
-static void DumpSubPaths(anchor)
- struct edgelist *anchor;
+static void
+DumpSubPaths(struct edgelist *anchor)
{
register struct edgelist *edge,*e,*e2;
@@ -672,8 +677,8 @@ static void DumpSubPaths(anchor)
}
}
-static struct edgelist *before(e)
- struct edgelist *e;
+static struct edgelist *
+before(struct edgelist *e)
{
struct edgelist *r;
for (r = e->subpath; r->subpath != e; r = r->subpath) { ; }
@@ -705,10 +710,10 @@ new x might exceed the region's bounds, updating those are the
responsibility of the caller.
*/
-static void writeXofY(e, y, x)
- struct edgelist *e; /* relevant edgelist */
- int y; /* y value */
- int x; /* new x value */
+static void
+writeXofY(struct edgelist *e,/* relevant edgelist */
+ int y, /* y value */
+ int x) /* new x value */
{
if (e->xmin > x) e->xmin = x;
if (e->xmax < x) e->xmax = x;
@@ -739,12 +744,12 @@ points (collapses) the white run as necessary if it is not. The
goal is to collapse the white run as little as possible.
*/
-static void CollapseWhiteRun(anchor, yblack, left, right, ywhite)
- struct edgelist *anchor; /* anchor of edge list */
- pel yblack; /* y of (hopefully) black run above or below */
- struct edgelist *left; /* edgelist at left of WHITE run */
- struct edgelist *right; /* edgelist at right of WHITE run */
- pel ywhite; /* y location of white run */
+static void
+CollapseWhiteRun(struct edgelist *anchor, /* anchor of edge list */
+ pel yblack, /* y of (hopefully) black run above or below */
+ struct edgelist *left, /* edgelist at left of WHITE run */
+ struct edgelist *right, /* edgelist at right of WHITE run */
+ pel ywhite) /* y location of white run */
{
struct edgelist *edge;
struct edgelist *swathstart = anchor;
@@ -810,8 +815,8 @@ This is the externally visible routine called from the REGIONS module
when the +CONTINUITY flag is on the Interior() fill rule.
*/
-void ApplyContinuity(R)
-struct region *R;
+void
+ApplyContinuity(struct region *R)
{
struct edgelist *left;
struct edgelist *right;
diff --git a/src/Type1/hints.h b/src/Type1/hints.h
index 79ef326..d5bb829 100644
--- a/src/Type1/hints.h
+++ b/src/Type1/hints.h
@@ -26,17 +26,23 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/hints.h,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+
/*SHARED*/
-#define InitHints() t1_InitHints()
-void t1_InitHints(); /* Initialize hint data structure */
+#define InitHints t1_InitHints
+extern void t1_InitHints ( void ); /* Initialize hint data structure */
#define CloseHints(hintP) t1_CloseHints(hintP)
-void t1_CloseHints(); /* Reverse hints that are still open */
+/* Reverse hints that are still open */
+extern void t1_CloseHints ( struct fractpoint *hintP );
#define ProcessHint(hP, currX, currY, hintP) t1_ProcessHint(hP, currX, currY, hintP)
-void t1_ProcessHint(); /* Process a rasterization hint */
-
+/* Process a rasterization hint */
+extern void t1_ProcessHint ( struct hintsegment *hP, fractpel currX, fractpel currY, struct fractpoint *hintP );
+
#define ApplyContinuity(R) t1_ApplyContinuity(R)
-void t1_ApplyContinuity(); /* fix false connection breaks in a region */
+/* fix false connection breaks in a region */
+extern void t1_ApplyContinuity ( struct region *R );
+
/*END SHARED*/
diff --git a/src/Type1/lines.c b/src/Type1/lines.c
index 3afcfc1..dec3f08 100644
--- a/src/Type1/lines.c
+++ b/src/Type1/lines.c
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/lines.c,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+
/* LINES CWEB V0003 ******** */
/*
:h1.LINES Module - Rasterizing Lines
@@ -40,6 +42,7 @@ The included files are:
#include "objects.h"
#include "spaces.h"
+#include "paths.h"
#include "regions.h"
#include "lines.h"
diff --git a/src/Type1/lines.h b/src/Type1/lines.h
index 8e2cc74..c0d7392 100644
--- a/src/Type1/lines.h
+++ b/src/Type1/lines.h
@@ -26,12 +26,14 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/lines.h,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+
/*SHARED*/
#define StepLine(R,x1,y1,x2,y2) t1_StepLine(R,x1,y1,x2,y2)
#define Bresenham(e,x1,y1,x2,y2) t1_Bresenham(e,x1,y1,x2,y2)
-void t1_StepLine(); /* check for special conditions, call Bresenham */
-void t1_Bresenham(); /* produce run ends for lines */
+extern void t1_StepLine ( struct region *R, fractpel x1, fractpel y1, fractpel x2, fractpel y2 );
+extern void t1_Bresenham ( pel *edgeP, fractpel x1, fractpel y1, fractpel x2, fractpel y2 );
/*END SHARED*/
diff --git a/src/Type1/objects.c b/src/Type1/objects.c
index 438e859..57168b4 100644
--- a/src/Type1/objects.c
+++ b/src/Type1/objects.c
@@ -26,6 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/objects.c,v 1.10 2002/02/18 20:51:57 herrb Exp $ */
/* OBJECTS CWEB V0025 ******** */
/*
:h1.OBJECTS Module - TYPE1IMAGER Objects Common Routines
@@ -53,8 +54,17 @@ system it is a pretty safe bet that these are external entry points and
you do do not need to include these header files.
*/
+#ifndef FONTMODULE
#include <string.h>
#include <ctype.h>
+#include <stdarg.h>
+#include "os.h"
+#else
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "os.h"
+#include "xf86_ansic.h"
+#endif
/*
override incorrect system functions; for example you might define
@@ -72,7 +82,9 @@ a macro for "strcpy" that diverts it to "my_strcpy".
#include "pictures.h"
#include "strokes.h"
#include "cluts.h"
-static char *TypeFmt();
+
+
+static char *TypeFmt(int type);
/*
:h3.The "pointer" Macro - Define a Generic Pointer
@@ -280,13 +292,12 @@ set to 1. So, a nun-NULL template must also have a "references" field.
PNM 3-26-91
*/
-struct xobject *t1_Allocate(size, template, extra) /* non-ANSI; type checking was too strict */
- register int size; /* number of bytes to allocate & initialize */
- register struct xobject *template; /* example structure to allocate */
- register int extra; /* any extra uninitialized bytes needed contiguously */
+struct xobject *
+t1_Allocate(int size, /* number of bytes to allocate & initialize */
+ pointer ptr, /* example structure to allocate */
+ int extra) /* any extra uninitialized bytes needed contiguously */
{
- extern char *xiMalloc(); /* standard C routine */
-
+ register struct xobject *template = (struct xobject *)ptr;
register struct xobject *r;
/*
@@ -295,14 +306,14 @@ struct xobject *t1_Allocate(size, template, extra) /* non-ANSI; type checking w
size = (size + sizeof(long) - 1) & -(int)sizeof(long);
extra = (extra + sizeof(long) - 1) & -(int)sizeof(long);
if (size + extra <= 0)
- abort("Non-positive allocate?");
+ Abort("Non-positive allocate?");
r = (struct xobject *) xiMalloc(size + extra);
while (r == NULL) {
if (!GimeSpace()) {
IfTrace1(TRUE, "malloc attempted %d bytes.\n",
size + extra);
- abort("We have REALLY run out of memory");
+ Abort("We have REALLY run out of memory");
}
r = (struct xobject *) xiMalloc(size + extra);
}
@@ -349,11 +360,13 @@ In either case, the object must not be the NULL pointer. This preserves
portability, as the C system xiFree() will not always accept NULL.
*/
-void Free(obj) /* non-ANSI to avoid overly strict type checking */
- register struct xobject *obj; /* structure to free */
+void
+Free(pointer objPtr)
{
+ struct xobject *obj = (struct xobject *)objPtr; /* structure to free */
+
if (obj->type == INVALIDTYPE)
- abort("Free of already freed object?");
+ Abort("Free of already freed object?");
obj->type = INVALIDTYPE;
if (MemoryDebug > 1) {
@@ -362,7 +375,7 @@ void Free(obj) /* non-ANSI to avoid overly strict type checking */
IfTrace4(TRUE,"Freeing at %x: %x %x %x\n", L, L[-1], L[0], L[1]);
}
- xiFree(obj);
+ xiFree((long *)obj);
}
/*
@@ -389,9 +402,11 @@ done is to change one of the old temporary handles to a permanent one.
3-26-91 PNM
*/
-struct xobject *t1_Permanent(obj) /* non-ANSI to avoid overly strict type checking */
- register struct xobject *obj; /* object to be made permanent */
+struct xobject *
+t1_Permanent(pointer objPtr)
{
+ struct xobject *obj = (struct xobject *)objPtr; /* object to be made permanent */
+
IfTrace1((MustTraceCalls),"Permanent(%z)\n", obj);
if ( (obj != NULL) && ( !(ISPERMANENT(obj->flag)) ) )
@@ -415,6 +430,7 @@ struct xobject *t1_Permanent(obj) /* non-ANSI to avoid overly strict type checki
return(obj);
}
+#ifdef notused
/*
:h3.Temporary() - Undoes the Effect of "Permanent()"
@@ -433,9 +449,11 @@ lost a permanent handle and gained a temporary one.
PNM 3-2-6-91
*/
-struct xobject *xiTemporary(obj) /* non-ANSI to avoid overly strict type checking */
- register struct xobject *obj; /* object to be made permanent */
+struct xobject *
+xiTemporary(pointer objPtr)
{
+ register struct xobject *obj
+ = (struct xobject *)objPtr; /* object to be made permanent */
IfTrace1((MustTraceCalls),"Temporary(%z)\n", obj);
if (obj != NULL) {
@@ -467,7 +485,8 @@ struct xobject *xiTemporary(obj) /* non-ANSI to avoid overly strict type checkin
}
return(obj);
}
-
+#endif /* notused */
+
/*
:h3.Dup() - Duplicate an Object
@@ -478,9 +497,11 @@ Note that Dup() retains the state of the permanent flag.
*/
-struct xobject *t1_Dup(obj) /* non-ANSI avoids overly strict type checking */
- register struct xobject *obj; /* object to be duplicated */
+struct xobject *
+t1_Dup(pointer objPtr)
{
+ register struct xobject *obj
+ = (struct xobject *)objPtr; /* object to be duplicated */
register char oldflag; /* copy of original object's flag byte */
IfTrace1((MustTraceCalls),"Dup(%z)\n", obj);
@@ -523,22 +544,28 @@ let each module provide us a routine (or macro) that duplicates the
objects it knows about.
*/
-struct xobject *t1_Copy(obj)
- register struct xobject *obj; /* object to be Copy'ed */
+struct xobject *
+t1_Copy(pointer objPtr)
{
+ register struct xobject *obj
+ = (struct xobject *)objPtr; /* object to be Copy'ed */
if (obj == NULL)
return(NULL);
if (ISPATHTYPE(obj->type))
- obj = (struct xobject *) CopyPath(obj);
+ obj = (struct xobject *) CopyPath((struct segment *)obj);
else
switch (obj->type) {
case SPACETYPE:
- obj = (struct xobject *) CopySpace(obj); break;
+ obj = (struct xobject *)
+ CopySpace((struct XYspace *)obj);
+ break;
case FONTTYPE:
obj = (struct xobject *) CopyFont(obj); break;
case REGIONTYPE:
- obj = (struct xobject *) CopyRegion(obj); break;
+ obj = (struct xobject *)
+ CopyRegion((struct region *)obj);
+ break;
case PICTURETYPE:
obj = (struct xobject *) CopyPicture(obj); break;
case LINESTYLETYPE:
@@ -560,9 +587,11 @@ struct xobject *t1_Copy(obj)
This can get complicated. Just like with Copy(), we let the experts
handle it.
*/
-struct xobject *Destroy(obj) /* non-ANSI avoids overly strict type checking */
- register struct xobject *obj; /* object to be destroyed */
+struct xobject *
+Destroy(pointer objPtr)
{
+ register struct xobject *obj
+ = (struct xobject *)objPtr; /* object to be destroyed */
IfTrace1((MustTraceCalls),"Destroy(%z)\n", obj);
if (obj == NULL)
@@ -572,11 +601,11 @@ struct xobject *Destroy(obj) /* non-ANSI avoids overly strict type checking */
return(NULL);
}
if (ISPATHTYPE(obj->type))
- KillPath(obj);
+ KillPath((struct segment *)obj);
else {
switch (obj->type) {
case REGIONTYPE:
- KillRegion(obj);
+ KillRegion((struct region *)obj);
break;
case SPACETYPE:
KillSpace(obj);
@@ -717,9 +746,11 @@ because permanent objects, by definition, are persistent. 3-2-6-91 PNM
:eol.
*/
-struct xobject *t1_Unique(obj)
- struct xobject *obj;
+struct xobject *
+t1_Unique(pointer objPtr)
{
+ struct xobject *obj = (struct xobject *)objPtr;
+
/* if the original object is not already unique, make a unique
copy...Note also that if the object was not permanent, we must
consume the old handle! 3-26-91 PNM
@@ -763,16 +794,16 @@ static char *ErrorMessage = NULL;
We provide a controlled way for the TYPE1IMAGER user to set and reset
our debugging and tracing:
*/
-void Pragmatics(username, value)
- char *username; /* name of the flag */
- int value; /* value to set it to */
+void
+Pragmatics(char *username, /* name of the flag */
+ int value) /* value to set it to */
{
register char *p; /* temporary loop variable */
#define NAMESIZE 40
char name[NAMESIZE]; /* buffer to store my copy of 'username' */
if (strlen(username) >= (unsigned)NAMESIZE)
- abort("Pragmatics name too large");
+ Abort("Pragmatics name too large");
strcpy(name, username);
for (p = name; *p != '\0'; p++)
*p = toupper(*p);
@@ -892,39 +923,19 @@ if it is already known that the object is temporary, it is faster to
just kill it rather than consume it, for example, KillSpace().
*/
-void Consume(n, obj1, obj2, obj3) /* non-ANSI avoids overly strict type checking */
- int n;
- struct xobject *obj1,*obj2,*obj3;
+void
+Consume(int n, ...)
{
- switch(n) {
-
- case 0:
- return;
-
- case 1:
- if (obj1 != NULL && !ISPERMANENT(obj1->flag))
- Destroy(obj1);
- return;
-
- case 2:
- if (obj1 != NULL && !ISPERMANENT(obj1->flag))
- Destroy(obj1);
- if (obj2 != NULL && !ISPERMANENT(obj2->flag))
- Destroy(obj2);
- return;
-
- case 3:
- if (obj1 != NULL && !ISPERMANENT(obj1->flag))
- Destroy(obj1);
- if (obj2 != NULL && !ISPERMANENT(obj2->flag))
- Destroy(obj2);
- if (obj3 != NULL && !ISPERMANENT(obj3->flag))
- Destroy(obj3);
- return;
-
- default:
- abort("Consume: too many objects");
- }
+ struct xobject *obj;
+ va_list ap;
+
+ va_start(ap, n);
+
+ while (n-- > 0) {
+ obj = va_arg(ap, struct xobject *);
+ if (obj != NULL && !ISPERMANENT(obj->flag))
+ Destroy(obj);
+ }
}
/*
:h4.ObjectPostMortem() - Prints as Much as We Can About a Bad Object
@@ -934,10 +945,8 @@ This is a subroutine of TypeErr() and ArgErr().
/*ARGSUSED*/
static void
-ObjectPostMortem(obj) /* non-ANSI avoids overly strict type checking */
- register struct xobject *obj;
+ObjectPostMortem(struct xobject *obj)
{
- extern struct XYspace *USER;
Pragmatics("Debug", 10);
IfTrace2(TRUE,"Bad object is of %s type %z\n", TypeFmt(obj->type), obj);
@@ -951,12 +960,14 @@ ObjectPostMortem(obj) /* non-ANSI avoids overly strict type checking */
:h3.TypeErr() - Handles "Invalid Object Type" Errors
*/
-struct xobject *TypeErr(name, obj, expect, ret) /* non-ANSI avoids overly strict type checking */
- char *name; /* Name of routine (for error message) */
- struct xobject *obj; /* Object in error */
- int expect; /* type expected */
- struct xobject *ret; /* object to return to caller */
+struct xobject *
+TypeErr(char *name, /* Name of routine (for error message) */
+ pointer objPtr, /* Object in error */
+ int expect, /* type expected */
+ pointer retPtr) /* object to return to caller */
{
+ struct xobject *obj = (struct xobject *)objPtr;
+ struct xobject *ret = (struct xobject *)retPtr;
/*
* This buffer must be large enough to hold 'name' plus
* two of the largest strings that can be returned by TypeFmt.
@@ -975,7 +986,7 @@ struct xobject *TypeErr(name, obj, expect, ret) /* non-ANSI avoids overly strict
ObjectPostMortem(obj);
if (MustCrash)
- abort("Terminating because of CrashOnUserError...");
+ Abort("Terminating because of CrashOnUserError...");
else
ErrorMessage = typemsg;
@@ -991,8 +1002,8 @@ struct xobject *TypeErr(name, obj, expect, ret) /* non-ANSI avoids overly strict
This is a subroutine of TypeErr().
*/
-static char *TypeFmt(type)
- int type; /* type field */
+static char *
+TypeFmt(int type) /* type field */
{
char *r;
@@ -1039,25 +1050,28 @@ is returned to the caller in case MustCrash is FALSE and ArgErr
returns to its caller.
*/
-struct xobject *ArgErr(string, obj, ret) /* non-ANSI avoids overly strict type checking */
- char *string; /* description of error */
- struct xobject *obj; /* object, if any, that was in error */
- struct xobject *ret; /* object returned to caller or NULL */
+struct xobject *
+ArgErr(char *string, /* description of error */
+ pointer objPtr, /* object, if any, that was in error */
+ pointer retPtr) /* object returned to caller or NULL */
{
+ struct xobject *obj = (struct xobject *)objPtr;
+ struct xobject *ret = (struct xobject *)retPtr;
+
if (MustCrash)
LineIOTrace = TRUE;
IfTrace1(TRUE,"ARGUMENT ERROR-- %s.\n", string);
if (obj != NULL)
ObjectPostMortem(obj);
if (MustCrash)
- abort("Terminating because of CrashOnUserError...");
+ Abort("Terminating because of CrashOnUserError...");
else
ErrorMessage = string;
return(ret);
}
/*
-:h3.abort() - Crash Due to Error
+:h3.Abort() - Crash Due to Error
Defined in objects.h to be FatalError(), the server's abort routine.
*/
@@ -1068,7 +1082,8 @@ Defined in objects.h to be FatalError(), the server's abort routine.
:h4.ErrorMsg() - Return the User an Error Message
*/
-char *ErrorMsg()
+char *
+ErrorMsg(void)
{
register char *r;
@@ -1087,7 +1102,8 @@ anyway.) Note that TYPE1IMAGER makes no assumptions about the size of an
:i1/portability assumptions/
*/
-void InitImager()
+void
+InitImager(void)
{
/* Check to see if we have been using our own malloc. If so,*/
@@ -1096,7 +1112,7 @@ void InitImager()
/* if (sizeof(short) != 2 || sizeof(INT32) != 4)
- abort("Fundamental TYPE1IMAGER assumptions invalid in this port");
+ Abort("Fundamental TYPE1IMAGER assumptions invalid in this port");
*/
InitSpaces();
InitFonts();
@@ -1112,14 +1128,18 @@ In some environments, constants and/or exception handling need to be
This only makes sense in a server environment; true TYPE1IMAGER needs do
nothing.
*/
-void TermImager()
+void
+TermImager(void)
{
return;
}
+#ifdef notused
/*
:h4.reportusage() - A Stub to Get a Clean Link with Portable PMP
*/
-void reportusage()
+void
+reportusage(void)
{
return;
}
+#endif
diff --git a/src/Type1/objects.h b/src/Type1/objects.h
index 30a9773..984ccbd 100644
--- a/src/Type1/objects.h
+++ b/src/Type1/objects.h
@@ -26,49 +26,119 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/objects.h,v 1.14 2002/12/24 17:42:59 tsi Exp $ */
/*SHARED*/
/*END SHARED*/
+#include <Xdefs.h>
+#include <Xfuncproto.h>
+#ifndef FONTMODULE
+#include <stdlib.h>
+#endif
/*SHARED*/
#define Permanent(obj) t1_Permanent(obj)
+#ifdef notused
#define Temporary(obj) t1_Temporary(obj)
+#endif
#define Destroy(obj) t1_Destroy(obj)
#define Dup(obj) t1_Dup(obj)
-#define InitImager() t1_InitImager()
-#define TermImager() t1_TermImager()
+#define InitImager t1_InitImager
+#define TermImager t1_TermImager
#define Pragmatics(f,v) t1_Pragmatics(f,v)
-#define ErrorMsg() t1_ErrorMsg()
+#define ErrorMsg t1_ErrorMsg
-struct xobject *t1_Permanent(); /* make an object permanent */
-struct xobject *t1_Temporary(); /* make an object temporary */
-struct xobject *t1_Destroy(); /* destroy an object */
-struct xobject *t1_Dup(); /* duplicate an object */
-void t1_InitImager(); /* initialize TYPE1IMAGER */
-void t1_TermImager(); /* terminate TYPE1IMAGER */
-void t1_Pragmatics(); /* set debug flags, etc. */
-char *t1_ErrorMsg(); /* return last TYPE1IMAGER error message */
+/* make an object permanent */
+extern struct xobject *t1_Permanent ( pointer obj );
+
+#ifdef notused
+/* make an object temporary */
+extern struct xobject *t1_Temporary( pointer obj );
+#endif
+
+/* destroy an object */
+extern struct xobject *t1_Destroy ( pointer obj );
+
+/* duplicate an object */
+extern struct xobject *t1_Dup ( pointer obj );
+
+
+extern void t1_InitImager ( void ); /* initialize TYPE1IMAGER */
+extern void t1_TermImager ( void ); /* terminate TYPE1IMAGER */
+/* set debug flags, etc. */
+extern void t1_Pragmatics ( char *username, int value );
+
+/* return last TYPE1IMAGER error message */
+extern char *t1_ErrorMsg ( void );
/*END SHARED*/
/*SHARED*/
-
-#define abort(line) FatalError(line)
+extern void xiFree ( long *addr );
+extern char *xiMalloc ( unsigned Size );
+extern void addmemory ( long *addr, long size );
+extern void delmemory ( void );
+
+#ifndef OS_H
+extern void FatalError(const char *f, ...)
+#if defined(__GNUC__) && \
+ ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ > 4)))
+__attribute((noreturn))
+#endif
+;
+
+extern void ErrorF(const char *f, ...);
+#endif
+
+#define Abort(line) FatalError(line)
#define Allocate(n,t,s) t1_Allocate(n,t,s)
#define Free(obj) t1_Free(obj)
-#define NonObjectFree(a) xiFree(a)
+#define NonObjectFree(a) xiFree((long *)(a))
#define Consume t1_Consume
#define ArgErr(s,o,r) t1_ArgErr(s,o,r)
#define TypeErr(n,o,e,r) t1_TypeErr(n,o,e,r)
#define Copy(obj) t1_Copy(obj)
#define Unique(obj) t1_Unique(obj)
-struct xobject *t1_Allocate(); /* allocate memory */
-void t1_Free(); /* free memory */
-struct xobject *t1_Unique(); /* make a unique temporary copy of an object */
-struct xobject *t1_ArgErr(); /* handle argument errors */
-struct xobject *t1_TypeErr(); /* handle 'bad type' argument errors */
-void t1_Consume(); /* consume a variable number of arguments */
-struct xobject *t1_Copy(); /* make a new copy, not reference bump PNM */
+/* allocate memory */
+extern struct xobject *t1_Allocate( int size, pointer template,
+ int extra );
+
+/* free memory */
+extern void t1_Free ( pointer obj );
+
+/* make a unique temporary copy of an object */
+extern struct xobject *t1_Unique ( pointer obj );
+
+/* handle argument errors */
+extern struct xobject *t1_ArgErr ( char *string, pointer obj, pointer ret );
+
+/* handle 'bad type' argument errors */
+extern struct xobject *t1_TypeErr ( char *name, pointer obj,
+ int expect, pointer ret );
+
+/* consume a variable number of arguments */
+extern void t1_Consume ( int n, ... );
+
+/* make a new copy, not reference bump PNM */
+extern struct xobject *t1_Copy ( pointer obj );
+
/*END SHARED*/
/*SHARED*/
@@ -82,7 +152,7 @@ struct xobject *t1_Copy(); /* make a new copy, not reference bump PNM */
#endif
#ifndef NULL
-#define NULL 0
+#include <stddef.h>
/*
The NULL pointer is system specific. (Most systems, however, use 0.)
TYPE1IMAGER could have its own NULL, independent of the rest of the system,
@@ -223,9 +293,10 @@ struct xobject {
#define IfTrace5(condition,model,arg0,arg1,arg2,arg3,arg4)
#define IfTrace6(condition,model,arg0,arg1,arg2,arg3,arg4,arg5)
-
+#if 0
void Trace0();
char *Trace1(),*Trace2(),*Trace3(),*Trace4(),*Trace5(),*Trace6();
+#endif
#ifdef GLOBALS
@@ -240,7 +311,11 @@ char *Trace1(),*Trace2(),*Trace3(),*Trace4(),*Trace5(),*Trace6();
extern char MustCheckArgs INITIALIZED(TRUE);
extern char MustTraceCalls INITIALIZED(FALSE);
+#ifdef BUILDCID
+extern char MustCrash INITIALIZED(FALSE);
+#else
extern char MustCrash INITIALIZED(TRUE);
+#endif
extern char InternalTrace INITIALIZED(TRUE);
extern char LineIOTrace INITIALIZED(TRUE);
@@ -281,11 +356,7 @@ We define other routines formatting parameters
#define DumpEdges(e) t1_DumpEdges(e)
#define FormatFP(s,p) t1_FormatFP(s,p)
-void t1_DumpArea(); /* dump a region structure */
-void t1_DumpText(); /* dump a textpath structure */
-void t1_DumpPath(); /* dump a path list */
-void t1_DumpSpace(); /* dump a coordinate space structure */
-void t1_DumpEdges(); /* dump a region's edge list */
-void t1_FormatFP(); /* dump a format a "fractpel" coordinate */
+/* dump a textpath structure */
+extern void t1_DumpText(void);
/*END SHARED*/
diff --git a/src/Type1/paths.c b/src/Type1/paths.c
index 35c3e41..6291d68 100644
--- a/src/Type1/paths.c
+++ b/src/Type1/paths.c
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/paths.c,v 1.7 2002/02/18 20:51:57 herrb Exp $ */
+
/* PATHS CWEB V0021 ******** */
/*
:h1 id=paths.PATHS Module - Path Operator Handler
@@ -42,6 +44,7 @@ The included files are:
*/
/* after the system includes (dsr) */
+#include "os.h"
#include "objects.h"
#include "spaces.h"
#include "paths.h"
@@ -51,6 +54,7 @@ The included files are:
#include "strokes.h" /* understands how to coerce stroke paths */
#include "trig.h"
+
/*
:h3.Routines Available to the TYPE1IMAGER User
@@ -112,10 +116,10 @@ text, which has some auxilliary things involved. We don't feel
competent to duplicate text in this module, so we call someone who
knows how (in the FONTS module).
*/
-struct segment *CopyPath(p0)
- register struct segment *p0; /* path to duplicate */
+struct segment *
+CopyPath(struct segment *p0) /* path to duplicate */
{
- register struct segment *p,*n,*last,*anchor;
+ register struct segment *p,*n = NULL,*last = NULL,*anchor;
for (p = p0, anchor = NULL; p != NULL; p = p->link) {
@@ -150,8 +154,8 @@ At this point we have a chain of newly allocated segments hanging off
Destroying a path is simply a matter of freeing each segment in the
linked list. Again, we let the experts handle text.
*/
-void KillPath(p)
- register struct segment *p; /* path to destroy */
+void
+KillPath(struct segment *p) /* path to destroy */
{
register struct segment *linkp; /* temp register holding next segment*/
@@ -194,15 +198,15 @@ This template is used as a generic segment structure for Allocate:
/* added reference field 1 to temporary template below 3-26-91 PNM */
static struct segment movetemplate = { MOVETYPE, 0, 1, sizeof(struct segment), 0,
- NULL, NULL, 0, 0 };
+ NULL, NULL, {0, 0} };
/*
:h3.Loc() - Create an "Invisible Line" Between (0,0) and a Point
*/
-struct segment *t1_Loc(S, x, y)
- register struct XYspace *S; /* coordinate space to interpret X,Y */
- double x,y; /* destination point */
+struct segment *
+t1_Loc(struct XYspace *S, /* coordinate space to interpret X,Y */
+ double x, double y) /* destination point */
{
register struct segment *r;
@@ -222,9 +226,9 @@ struct segment *t1_Loc(S, x, y)
:h3.ILoc() - Loc() With Integer Arguments
*/
-struct segment *ILoc(S, x, y)
- register struct XYspace *S; /* coordinate space to interpret X,Y */
- register int x,y; /* destination point */
+struct segment *
+ILoc(struct XYspace *S, /* coordinate space to interpret X,Y */
+ int x, int y) /* destination point */
{
register struct segment *r;
@@ -250,9 +254,8 @@ The symmetrical function AddLoc() is totally redundent with Join(),
so it is not provided.
*/
-struct segment *SubLoc(p1, p2)
- register struct segment *p1;
- register struct segment *p2;
+struct segment *
+SubLoc(struct segment *p1, struct segment *p2)
{
IfTrace2((MustTraceCalls),"SubLoc(%z, %z)\n", p1, p2);
@@ -277,9 +280,9 @@ conversion is unnecessary. PathSegment() is an internal routine
provided to the rest of TYPE1IMAGER for handling these cases.
*/
-struct segment *t1_PathSegment(type, x, y)
- int type; /* LINETYPE or MOVETYPE */
- fractpel x,y; /* where to go to, if known */
+struct segment *
+t1_PathSegment(int type, /* LINETYPE or MOVETYPE */
+ fractpel x, fractpel y) /* where to go to, if known */
{
register struct segment *r; /* newly created segment */
@@ -295,8 +298,8 @@ struct segment *t1_PathSegment(type, x, y)
This involves just creating and filling out a segment structure:
*/
-struct segment *Line(P)
- register struct segment *P; /* relevant coordinate space */
+struct segment *
+Line(struct segment *P) /* relevant coordinate space */
{
IfTrace1((MustTraceCalls),"..Line(%z)\n", P);
@@ -330,10 +333,10 @@ inversely related to the length |CD|. Point A is always point (0,0).
This is just a simple matter of filling out a 'beziersegment' structure:
*/
-struct beziersegment *Bezier(B, C, D)
- register struct segment *B; /* second control point */
- register struct segment *C; /* third control point */
- register struct segment *D; /* fourth control point (ending point) */
+struct beziersegment *
+Bezier(struct segment *B, /* second control point */
+ struct segment *C, /* third control point */
+ struct segment *D) /* fourth control point (ending point) */
{
/* added reference field of 1 to temporary template below 3-26-91 PNM */
static struct beziersegment template =
@@ -371,15 +374,10 @@ This is temporary code while we experiment with hints.
*/
/*SHARED LINE(S) ORIGINATED HERE*/
-struct hintsegment *Hint(S, ref, width, orientation, hinttype, adjusttype, direction, label)
- struct XYspace *S;
- float ref;
- float width;
- char orientation;
- char hinttype;
- char adjusttype;
- char direction;
- int label;
+struct hintsegment *
+Hint(struct XYspace *S, float ref, float width,
+ char orientation, char hinttype, char adjusttype, char direction,
+ int label)
{
/* added reference field of 1 to hintsegment template below 3-26-91 PNM */
static struct hintsegment template = { HINTTYPE, 0, 1, sizeof(struct hintsegment), 0,
@@ -446,8 +444,8 @@ types other than paths, and also check for certain path consistency
rules.
*/
-struct segment *Join(p1, p2)
- register struct segment *p1,*p2;
+struct segment *
+Join(struct segment *p1, struct segment *p2)
{
IfTrace2((MustTraceCalls && PathDebug > 1),"..Join(%z, %z)\n", p1, p2);
IfTrace2((MustTraceCalls && PathDebug <=1),"..Join(%x, %x)\n", p1, p2);
@@ -570,11 +568,11 @@ This internal function is quicker than a full-fledged join because
it can do much less checking.
*/
-struct segment *t1_JoinSegment(before, type, x, y, after)
- register struct segment *before; /* path to join before new segment */
- int type; /* type of new segment (MOVETYPE or LINETYPE) */
- fractpel x,y; /* x,y of new segment */
- register struct segment *after; /* path to join after new segment */
+struct segment *
+t1_JoinSegment(struct segment *before, /* path to join before new segment */
+ int type, /* type of new segment (MOVETYPE or LINETYPE) */
+ fractpel x, fractpel y, /* x,y of new segment */
+ struct segment *after) /* path to join after new segment */
{
register struct segment *r; /* returned path built here */
@@ -596,14 +594,14 @@ struct segment *t1_JoinSegment(before, type, x, y, after)
*/
-struct segment *t1_ClosePath(p0,lastonly)
- register struct segment *p0; /* path to close */
- register int lastonly; /* flag deciding to close all subpaths or... */
+struct segment *
+t1_ClosePath(struct segment *p0, /* path to close */
+ int lastonly) /* flag deciding to close all subpaths or... */
{
- register struct segment *p,*last,*start; /* used in looping through path */
+ register struct segment *p,*last = NULL,*start; /* used in looping through path */
register fractpel x,y; /* current position in path */
- register fractpel firstx,firsty; /* start position of sub path */
- register struct segment *lastnonhint; /* last non-hint segment in path */
+ register fractpel firstx = 0,firsty = 0; /* start position of sub path */
+ register struct segment *lastnonhint = NULL; /* last non-hint segment in path */
IfTrace1((MustTraceCalls),"ClosePath(%z)\n", p0);
if (p0 != NULL && p0->type == TEXTTYPE)
@@ -689,18 +687,22 @@ etc.
We need three subroutines:
*/
-static struct segment *SplitPath(); /* break a path at any point */
-static struct segment *DropSubPath(); /* breaks a path after first sub-path */
-static struct segment *ReverseSubPath(); /* reverses a single sub-path */
-
+/* break a path at any point */
+static struct segment *SplitPath ( struct segment *anchor,
+ struct segment *before );
+/* breaks a path after first sub-path */
+static struct segment *DropSubPath ( struct segment *p0 );
+/* reverses a single sub-path */
+static struct segment *ReverseSubPath ( struct segment *p );
+
/*
:h3.Reverse() - User Operator to Reverse a Path
This operator reverses the entire path.
*/
-struct segment *Reverse(p)
- register struct segment *p; /* full path to reverse */
+struct segment *
+Reverse(struct segment *p) /* full path to reverse */
{
register struct segment *r; /* output path built here */
register struct segment *nextp; /* contains next sub-path */
@@ -733,8 +735,8 @@ struct segment *Reverse(p)
:h4.ReverseSubPath() - Subroutine to Reverse a Single Sub-Path
*/
-static struct segment *ReverseSubPath(p)
- register struct segment *p; /* input path */
+static struct segment *
+ReverseSubPath(struct segment *p) /* input path */
{
register struct segment *r; /* reversed path will be created here */
register struct segment *nextp; /* temporary variable used in loop */
@@ -790,7 +792,7 @@ So, we add "dest" instead of subtracting it:
break;
default:
- abort("Reverse: bad path segment");
+ Abort("Reverse: bad path segment");
}
/*
We need to reverse the order of segments too, so we break this segment
@@ -821,8 +823,8 @@ breaks the input path after the first sub-path so that a pointer to
the original path now contains the first sub-path only.
*/
-static struct segment *DropSubPath(p0)
- register struct segment *p0; /* original path */
+static struct segment *
+DropSubPath(struct segment *p0) /* original path */
{
register struct segment *p; /* returned remainder here */
@@ -834,9 +836,8 @@ static struct segment *DropSubPath(p0)
return(SplitPath(p0, p));
}
-static struct segment *SplitPath(anchor, before)
- register struct segment *anchor;
- register struct segment *before;
+static struct segment *
+SplitPath(struct segment *anchor, struct segment *before)
{
register struct segment *r;
@@ -852,15 +853,14 @@ static struct segment *SplitPath(anchor, before)
}
static void
-UnClose(p0)
- register struct segment *p0;
+UnClose(struct segment *p0)
{
register struct segment *p;
for (p=p0; p->link->link != NULL; p=p->link) { ; }
if (!LASTCLOSED(p->link->flag))
- abort("UnClose: no LASTCLOSED");
+ Abort("UnClose: no LASTCLOSED");
Free(SplitPath(p0, p));
p0->flag &= ~ISCLOSED(ON);
@@ -874,8 +874,8 @@ This user operator reverses the sub-paths in a path, but leaves the
already established.
*/
-struct segment *ReverseSubPaths(p)
- register struct segment *p; /* input path */
+struct segment *
+ReverseSubPaths(struct segment *p) /* input path */
{
register struct segment *r; /* reversed path will be created here */
register struct segment *nextp; /* temporary variable used in loop */
@@ -951,9 +951,9 @@ The transform is described as a "space", that way we can use our
old friend the "iconvert" function, which should be very efficient.
*/
-struct segment *PathTransform(p0, S)
- register struct segment *p0; /* path to transform */
- register struct XYspace *S; /* pseudo space to transform in */
+struct segment *
+PathTransform(struct segment *p0, /* path to transform */
+ struct XYspace *S) /* pseudo space to transform in */
{
register struct segment *p; /* to loop through path with */
register fractpel newx,newy; /* current transformed position in path */
@@ -1025,7 +1025,7 @@ struct segment *PathTransform(p0, S)
default:
IfTrace1(TRUE,"path = %z\n", p);
- abort("PathTransform: invalid segment");
+ Abort("PathTransform: invalid segment");
}
oldx += savex;
oldy += savey;
@@ -1039,9 +1039,9 @@ struct segment *PathTransform(p0, S)
:h3.PathDelta() - Return a Path's Ending Point
*/
-void PathDelta(p, pt)
- register struct segment *p; /* input path */
- register struct fractpoint *pt; /* pointer to x,y to set */
+void
+PathDelta(struct segment *p, /* input path */
+ struct fractpoint *pt) /* pointer to x,y to set */
{
struct fractpoint mypoint; /* I pass this to TextDelta */
register fractpel x,y; /* working variables for path current point */
@@ -1067,8 +1067,8 @@ This function is called by image code, when we know the size of the
image in pels, and need to get a bounding box path that surrounds it.
The starting/ending handle is in the lower right hand corner.
*/
-struct segment *BoundingBox(h, w)
- register pel h,w; /* size of box */
+struct segment *
+BoundingBox(pel h, pel w) /* size of box */
{
register struct segment *path;
@@ -1086,10 +1086,10 @@ struct segment *BoundingBox(h, w)
:h3.QueryLoc() - Return the X,Y of a Locition
*/
-void QueryLoc(P, S, xP, yP)
- register struct segment *P; /* location to query, not consumed */
- register struct XYspace *S; /* XY space to return coordinates in */
- register double *xP,*yP; /* coordinates returned here */
+void
+QueryLoc(struct segment *P, /* location to query, not consumed */
+ struct XYspace *S, /* XY space to return coordinates in */
+ double *xP, double *yP) /* coordinates returned here */
{
IfTrace4((MustTraceCalls),"QueryLoc(P=%z, S=%z, (%x, %x))\n",
P, S, xP, yP);
@@ -1114,13 +1114,13 @@ a move segment, for example, he only needs to pass pointers to return
one control point.
*/
-void QueryPath(path, typeP, Bp, Cp, Dp, fP)
- register struct segment *path; /* path to check */
- register int *typeP; /* return the type of path here */
- register struct segment **Bp; /* return location of first point */
- register struct segment **Cp; /* return location of second point */
- register struct segment **Dp; /* return location of third point */
- register double *fP; /* return Conic sharpness */
+void
+QueryPath(struct segment *path, /* path to check */
+ int *typeP, /* return the type of path here */
+ struct segment **Bp, /* return location of first point */
+ struct segment **Cp, /* return location of second point */
+ struct segment **Dp, /* return location of third point */
+ double *fP) /* return Conic sharpness */
{
register int coerced = FALSE; /* did I coerce a text path? */
@@ -1177,7 +1177,7 @@ void QueryPath(path, typeP, Bp, Cp, Dp, fP)
break;
default:
- abort("QueryPath: unknown segment");
+ Abort("QueryPath: unknown segment");
}
if (coerced)
KillPath(path);
@@ -1188,11 +1188,13 @@ void QueryPath(path, typeP, Bp, Cp, Dp, fP)
Returns the bounding box by setting the user's variables.
*/
-void QueryBounds(p0, S, xminP, yminP, xmaxP, ymaxP)
- register struct segment *p0; /* object to check for bound */
- struct XYspace *S; /* coordinate space of returned values */
- double *xminP,*yminP; /* lower left hand corner (set by routine) */
- double *xmaxP,*ymaxP; /* upper right hand corner (set by routine) */
+void
+QueryBounds(struct segment *p0, /* object to check for bound */
+ struct XYspace *S, /* coordinate space of returned values */
+ double *xminP, /* lower left hand corner (set by routine) */
+ double *yminP,
+ double *xmaxP, /* upper right hand corner (set by routine) */
+ double *ymaxP)
{
register struct segment *path; /* loop variable for path segments */
register fractpel lastx,lasty; /* loop variables: previous endingpoint */
@@ -1219,7 +1221,7 @@ void QueryBounds(p0, S, xminP, yminP, xmaxP, ymaxP)
p0 = (struct segment *) DoStroke(Dup(p0));
/* no break here, we have a region in p0 */
case REGIONTYPE:
- p0 = RegionBounds(p0);
+ p0 = RegionBounds((struct region *)p0);
break;
case PICTURETYPE:
@@ -1317,7 +1319,7 @@ void QueryBounds(p0, S, xminP, yminP, xmaxP, ymaxP)
case HINTTYPE:
break;
default:
- abort("QueryBounds: unknown type");
+ Abort("QueryBounds: unknown type");
}
if (x < min.x) min.x = x;
@@ -1356,9 +1358,8 @@ done:
/*
:h3.BoxPath()
*/
-struct segment *BoxPath(S, h, w)
- struct XYspace *S;
- int h,w;
+struct segment *
+BoxPath(struct XYspace *S, int h, int w)
{
struct segment *path;
@@ -1375,8 +1376,8 @@ shorter. It can be used in conjunction with QueryPath(), for example,
to ask about an entire path.
*/
-struct segment *DropSegment(path)
- register struct segment *path;
+struct segment *
+DropSegment(struct segment *path)
{
IfTrace1((MustTraceCalls),"DropSegment(%z)\n", path);
if (path != NULL && path->type == STROKEPATHTYPE)
@@ -1397,8 +1398,8 @@ This routine takes the path and returns a new path consists of the
first segment only.
*/
-struct segment *HeadSegment(path)
- register struct segment *path; /* input path */
+struct segment *
+HeadSegment(struct segment *path) /* input path */
{
IfTrace1((MustTraceCalls),"HeadSegment(%z)\n", path);
if (path == NULL)
@@ -1423,8 +1424,8 @@ struct segment *HeadSegment(path)
:h3.DumpPath() - Display a Path on the Trace File
*/
-void DumpPath(p)
- register struct segment *p;
+void
+DumpPath(struct segment *p)
{
register fractpel x,y;
register fractpel lastx,lasty;
@@ -1466,8 +1467,6 @@ void DumpPath(p)
case BEZIERTYPE:
{
- register struct beziersegment *bp = (struct beziersegment *) p;
-
IfTrace4(TRUE,". bezier to (%p,%p), B=(%p,%p)",
x + lastx, y + lasty,
bp->B.x + lastx, bp->B.y + lasty);
@@ -1478,8 +1477,6 @@ void DumpPath(p)
case HINTTYPE:
{
- register struct hintsegment *hp = (struct hintsegment *) p;
-
IfTrace4(TRUE,". hint ref=(%p,%p), width=(%p,%p)",
hp->ref.x + lastx, hp->ref.y + lasty,
hp->width.x, hp->width.y);
@@ -1491,7 +1488,9 @@ void DumpPath(p)
break;
case TEXTTYPE:
+#ifdef notyet
DumpText(p);
+#endif
break;
default:
diff --git a/src/Type1/paths.h b/src/Type1/paths.h
index e52a760..3f1b389 100644
--- a/src/Type1/paths.h
+++ b/src/Type1/paths.h
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/paths.h,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+
/*SHARED*/
#define Loc(S,x,y) t1_Loc(S,(double)x,(double)y)
@@ -50,26 +52,53 @@
#define QueryPath(p,t,B,C,D,r) t1_QueryPath(p,t,B,C,D,r)
#define QueryBounds(p,S,x1,y1,x2,y2) t1_QueryBounds(p,S,x1,y1,x2,y2)
-
-struct segment *t1_Loc(); /* create a location object (or "move" segment) */
-struct segment *t1_ILoc(); /* integer argument version of same */
-struct segment *t1_Line(); /* straight line path segment */
-struct segment *t1_Join(); /* join two paths or regions together */
-struct segment *t1_ClosePath(); /* close a path or path set */
+
+/* create a location object (or "move" segment) */
+extern struct segment *t1_Loc ( struct XYspace *S, double x, double y );
+/* integer argument version of same */
+extern struct segment *t1_ILoc ( struct XYspace *S, int x, int y );
+/* straight line path segment */
+extern struct segment *t1_Line ( struct segment *P );
+/* join two paths or regions together */
+extern struct segment *t1_Join ( struct segment *p1, struct segment *p2 );
+/* close a path or path set */
+extern struct segment *t1_ClosePath ( struct segment *p0, int lastonly );
+#if 0
struct conicsegment *t1_Conic(); /* conic curve path segment */
+
struct conicsegment *t1_RoundConic(); /* ditto, specified another way */
struct conicsegment *t1_ArcP3(); /* circular path segment with three points */
struct conicsegment *t1_ArcCA(); /* ditto, with center point and angle */
-struct beziersegment *t1_Bezier(); /* Bezier third order curve path segment */
-struct hintsegment *t1_Hint(); /* produce a font 'hint' path segment */
-struct segment *t1_Reverse(); /* reverse the complete order of paths */
-struct segment *t1_ReverseSubPaths(); /* reverse only sub-paths; moves unchanged */
-struct segment *t1_SubLoc(); /* subtract two location objects */
-struct segment *t1_DropSegment(); /* Drop the first segment in a path */
-struct segment *t1_HeadSegment(); /* return the first segment in a path */
-void t1_QueryLoc(); /* Query location; return its (x,y) */
-void t1_QueryPath(); /* Query segment at head of a path */
-void t1_QueryBounds(); /* Query the bounding box of a path */
+#endif
+/* Bezier third order curve path segment */
+extern struct beziersegment *t1_Bezier ( struct segment *B, struct segment *C,
+ struct segment *D );
+/* produce a font 'hint' path segment */
+extern struct hintsegment *t1_Hint ( struct XYspace *S, float ref, float width,
+ char orientation, char hinttype,
+ char adjusttype, char direction,
+ int label );
+/* reverse the complete order of paths */
+extern struct segment *t1_Reverse ( struct segment *p );
+/* reverse only sub-paths; moves unchanged */
+extern struct segment *t1_ReverseSubPaths ( struct segment *p );
+/* subtract two location objects */
+extern struct segment *t1_SubLoc ( struct segment *p1, struct segment *p2 );
+/* Drop the first segment in a path */
+extern struct segment *t1_DropSegment ( struct segment *path );
+/* return the first segment in a path */
+extern struct segment *t1_HeadSegment ( struct segment *path );
+/* Query location; return its (x,y) */
+extern void t1_QueryLoc ( struct segment *P, struct XYspace *S, double *xP,
+ double *yP );
+/* Query segment at head of a path */
+extern void t1_QueryPath ( struct segment *path, int *typeP,
+ struct segment **Bp, struct segment **Cp,
+ struct segment **Dp, double *fP );
+/* Query the bounding box of a path */
+extern void t1_QueryBounds ( struct segment *p0, struct XYspace *S,
+ double *xminP, double *yminP,
+ double *xmaxP, double *ymaxP );
/*END SHARED*/
/*SHARED*/
@@ -83,15 +112,26 @@ void t1_QueryBounds(); /* Query the bounding box of a path */
#define JoinSegment(b,t,x,y,a) t1_JoinSegment(b,t,(fractpel)x,(fractpel)y,a)
#define Hypoteneuse(dx,dy) t1_Hypoteneuse(dx,dy)
#define BoxPath(S,h,w) t1_BoxPath(S,h,w)
-
-struct segment *t1_CopyPath(); /* duplicate a path */
-void t1_KillPath(); /* destroy a path */
-struct segment *t1_PathXform(); /* transform a path arbitrarily */
-void t1_PathDelta(); /* calculate the ending point of a path */
-struct segment *t1_PathSegment(); /* produce a MOVE or LINE segment */
-struct segment *t1_JoinSegment(); /* join a MOVE or LINE segment to a path */
+
+/* duplicate a path */
+extern struct segment *t1_CopyPath ( struct segment *p0 );
+/* destroy a path */
+extern void t1_KillPath ( struct segment *p );
+/* transform a path arbitrarily */
+extern struct segment *t1_PathXform ( struct segment *p0, struct XYspace *S );
+/* calculate the ending point of a path */
+extern void t1_PathDelta ( struct segment *p, struct fractpoint *pt );
+/* */
+extern struct segment *t1_BoundingBox ( pel h, pel w );
+/* produce a MOVE or LINE segment */
+extern struct segment *t1_PathSegment ( int type, fractpel x, fractpel y );
+/* join a MOVE or LINE segment to a path */
+extern struct segment *t1_JoinSegment ( struct segment *before, int type, fractpel x, fractpel y, struct segment *after );
+#if 0
double t1_Hypoteneuse(); /* returns the length of a line */
-struct segment *t1_BoxPath(); /* returns a rectangular path */
+#endif
+/* returns a rectangular path */
+extern struct segment *t1_BoxPath ( struct XYspace *S, int h, int w );
/*END SHARED*/
/*SHARED*/
@@ -195,3 +235,5 @@ is also used by the STROKES module.)
p2->last = NULL; } /* only first segment has non-NULL "last" */
/*END SHARED*/
+/* dump a path list */
+extern void t1_DumpPath ( struct segment *p );
diff --git a/src/Type1/pictures.h b/src/Type1/pictures.h
index 6a14292..aa02ce5 100644
--- a/src/Type1/pictures.h
+++ b/src/Type1/pictures.h
@@ -27,6 +27,8 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/pictures.h,v 1.4 2001/01/17 19:43:23 dawes Exp $ */
+
/* STUB */
#define CopyPicture(p) p
@@ -44,5 +46,5 @@ struct picture {
#define Phantom(o) t1_Phantom(o)
#define Snap(o) t1_Snap(o)
-struct segment *t1_Phantom();
-struct segment *t1_Snap();
+extern struct segment *t1_Phantom ( struct segment *p );
+extern struct segment *t1_Snap ( struct segment *p );
diff --git a/src/Type1/regions.c b/src/Type1/regions.c
index 2824887..724d3f5 100644
--- a/src/Type1/regions.c
+++ b/src/Type1/regions.c
@@ -26,6 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/regions.c,v 3.8 2002/02/18 20:51:57 herrb Exp $ */
/* REGIONS CWEB V0023 LOTS */
/*
:h1 id=regions.REGIONS Module - Regions Operator Handler
@@ -40,26 +41,31 @@ This module is responsible for creating and manipulating regions.
The included files are:
*/
+#include "os.h"
#include "objects.h"
#include "spaces.h"
-#include "regions.h"
#include "paths.h"
+#include "regions.h"
#include "curves.h"
#include "lines.h"
#include "pictures.h"
#include "fonts.h"
#include "hints.h"
#include "strokes.h" /* to pick up 'DoStroke' */
-static void newfilledge();
-static struct edgelist *splitedge();
-static void vertjoin();
-static int touches();
-static int crosses();
-static void edgemin();
-static void edgemax();
-static struct edgelist *NewEdge();
-static struct edgelist *swathxsort(); /* 'SortSwath' function */
-
+
+
+static void newfilledge ( struct region *R, fractpel xmin, fractpel xmax,
+ fractpel ymin, fractpel ymax, int isdown );
+static struct edgelist *splitedge ( struct edgelist *list, pel y );
+static void vertjoin ( struct edgelist *top, struct edgelist *bottom );
+static int touches ( int h, pel *left, pel *right );
+static int crosses ( int h, pel *left, pel *right );
+static void edgemin ( int h, pel *e1, pel *e2 );
+static void edgemax ( int h, pel *e1, pel *e2 );
+static struct edgelist *NewEdge ( pel xmin, pel xmax, pel ymin, pel ymax,
+ pel *xvalues, int isdown );
+static struct edgelist *swathxsort ( struct edgelist *before0,
+ struct edgelist *edge );
/*
:h3.Functions Provided to the TYPE1IMAGER User
@@ -128,19 +134,19 @@ set. The flag is used to optimize some paths.
/*SHARED LINE(S) ORIGINATED HERE*/
/*
-:h4."INFINITY" - A Constant Region Structure of Infinite Extent
+:h4."TT_INFINITY" - A Constant Region Structure of Infinite Extent
Infinity is the complement of a null area:
Note - removed the refcount = 1 init, replaced with references = 2 3-26-91 PNM
*/
-static struct region infinity = { REGIONTYPE,
+static struct region _infinity = { REGIONTYPE,
ISCOMPLEMENT(ON)+ISINFINITE(ON)+ISPERMANENT(ON)+ISIMMORTAL(ON), 2,
- 0, 0, 0, 0,
+ {0, 0}, {0, 0},
0, 0, 0, 0,
NULL, NULL,
0, 0, 0, 0, 0, NULL, NULL,
NULL, 0, NULL, NULL };
-struct region *INFINITY = &infinity;
+struct region *TT_INFINITY = &_infinity;
/*
:h4."EmptyRegion" - A Region Structure with Zero Area
@@ -153,7 +159,7 @@ Note - replaced refcount = 1 init with references = 2 3-26-91 PNM
/*SHARED LINE(S) ORIGINATED HERE*/
struct region EmptyRegion = { REGIONTYPE,
ISPERMANENT(ON)+ISIMMORTAL(ON), 2,
- 0, 0, 0, 0,
+ {0, 0}, {0, 0},
MAXPEL, MAXPEL, MINPEL, MINPEL,
NULL, NULL,
0, 0, 0, 0, 0, NULL, NULL,
@@ -221,14 +227,14 @@ associated (thresholded) picture.
Note - added conditional return based on references 3-26-91 PNM
*/
-void KillRegion(area)
- register struct region *area; /* area to free */
+void
+KillRegion(struct region *area) /* area to free */
{
register struct edgelist *p; /* loop variable */
register struct edgelist *next; /* loop variable */
if (area->references < 0)
- abort("KillRegion: negative reference count");
+ Abort("KillRegion: negative reference count");
if ( (--(area->references) > 1) ||
( (area->references == 1) && !ISPERMANENT(area->flag) ) )
return;
@@ -244,11 +250,11 @@ void KillRegion(area)
/*
:h3.CopyRegion() - Makes a Copy of a Region
*/
-struct region *CopyRegion(area)
- register struct region *area; /* region to duplicate */
+struct region *
+CopyRegion(struct region *area) /* region to duplicate */
{
register struct region *r; /* output region built here */
- register struct edgelist *last; /* loop variable */
+ register struct edgelist *last = NULL; /* loop variable */
register struct edgelist *p,*newp; /* loop variables */
r = (struct region *)Allocate(sizeof(struct region), area, 0);
@@ -278,11 +284,11 @@ edgelist structure to free all memory associated with it. Damn
clever, huh?
*/
-static struct edgelist *NewEdge(xmin, xmax, ymin, ymax, xvalues, isdown)
- pel xmin,xmax; /* X extent of edge */
- pel ymin,ymax; /* Y extent of edge */
- pel *xvalues; /* list of X values for entire edge */
- int isdown; /* flag: TRUE means edge progresses downward */
+static struct edgelist *
+NewEdge(pel xmin, pel xmax, /* X extent of edge */
+ pel ymin, pel ymax, /* Y extent of edge */
+ pel *xvalues, /* list of X values for entire edge */
+ int isdown) /* flag: TRUE means edge progresses downward */
{
static struct edgelist template = {
EDGETYPE, 0, 1, NULL, NULL,
@@ -294,7 +300,7 @@ static struct edgelist *NewEdge(xmin, xmax, ymin, ymax, xvalues, isdown)
IfTrace2((RegionDebug),"....new edge: ymin=%d, ymax=%d ",
(long)ymin, (long) ymax);
if (ymin >= ymax)
- abort("newedge: height not positive");
+ Abort("newedge: height not positive");
/*
We are going to copy the xvalues into a newly allocated area. It
helps performance if the values are all "long" aligned. We can test
@@ -302,7 +308,7 @@ if the xvalues are long aligned by ANDing the address with the
(sizeof(long) - 1)--if non zero, the xvalues are not aligned well. We
set 'iy' to the ymin value that would give us good alignment:
*/
- iy = ymin - (((int) xvalues) & (sizeof(long) - 1)) / sizeof(pel);
+ iy = ymin - (((unsigned long)xvalues) & (sizeof(long)-1)) / sizeof(pel);
r = (struct edgelist *)Allocate(sizeof(struct edgelist), &template,
(ymax - iy) * sizeof(pel));
@@ -347,9 +353,8 @@ of the list and set ymin=ymax.
*/
static void
-discard(left, right)
- register struct edgelist *left,*right; /* all edges between here exclusive */
- /* should be discarded */
+discard(struct edgelist *left, /* all edges between here exclusive */
+ struct edgelist *right) /* should be discarded */
{
register struct edgelist *beg,*end,*p;
@@ -361,7 +366,7 @@ discard(left, right)
for (p = beg; p != right; p = p->link) {
if (p->link == NULL && right != NULL)
- abort("discard(): ran off end");
+ Abort("discard(): ran off end");
IfTrace1((RegionDebug > 0),"discarding %x\n", p);
p->ymin = p->ymax = 32767;
end = p;
@@ -389,10 +394,9 @@ discard the second one. Everything should balance; we should discard
an even number of edges; of course, we abort if we don't.
*/
static void
-Unwind(area)
- register struct edgelist *area; /* input area modified in place */
+Unwind(struct edgelist *area) /* input area modified in place */
{
- register struct edgelist *last,*next; /* struct before and after current one */
+ register struct edgelist *last = NULL,*next; /* struct before and after current one */
register int y; /* ymin of current swath */
register int count,newcount; /* winding count registers */
@@ -422,7 +426,7 @@ Unwind(area)
} while (area != NULL && area->ymin == y);
if (count != 0)
- abort("Unwind: uneven edges");
+ Abort("Unwind: uneven edges");
}
}
/*
@@ -453,9 +457,9 @@ region, we allow the same ChangeDirection logic to be used by stroking.
/*SHARED LINE(S) ORIGINATED HERE*/
-struct region *Interior(p, fillrule)
- register struct segment *p; /* take interior of this path */
- register int fillrule; /* rule to follow if path crosses itself */
+struct region *
+Interior(struct segment *p, /* take interior of this path */
+ int fillrule) /* rule to follow if path crosses itself */
{
register fractpel x,y; /* keeps ending point of path segment */
fractpel lastx,lasty; /* previous x,y from path segment before */
@@ -488,11 +492,12 @@ user asked, >1: do it regardless).
/* if (fillrule != EVENODDRULE)
else */
return((struct region *)UniquePath(p));
- if (p->type == STROKEPATHTYPE)
+ if (p->type == STROKEPATHTYPE) {
if (fillrule == WINDINGRULE)
return((struct region *)DoStroke(p));
else
p = CoercePath(p);
+ }
R = (struct region *)Allocate(sizeof(struct region), &EmptyRegion, 0);
@@ -575,7 +580,8 @@ segment (or NULL), and each hint segment will be freed if necessary.
while ((nextP != NULL) && (nextP->type == HINTTYPE)) {
if (ProcessHints)
- ProcessHint(nextP, x + hint.x, y + hint.y, &hint);
+ ProcessHint((struct hintsegment *)nextP,
+ x + hint.x, y + hint.y, &hint);
{
register struct segment *saveP = nextP;
@@ -645,7 +651,7 @@ MOVETYPE at the end of the path, if it isn't closed:
break;
default:
- abort("Interior: path type error");
+ Abort("Interior: path type error");
}
/*
We're done with this segment. Advance to the next path segment in
@@ -693,11 +699,11 @@ emerging edgelist at 'anchor' by calling whatever "newedgefcn"
is appropriate.
*/
-void ChangeDirection(type, R, x, y, dy)
- int type; /* CD_FIRST, CD_CONTINUE, or CD_LAST */
- register struct region *R; /* region in which we are changing direction */
- fractpel x,y; /* current beginning x,y */
- fractpel dy; /* direction and magnitude of change in y */
+void
+ChangeDirection(int type, /* CD_FIRST, CD_CONTINUE, or CD_LAST */
+ struct region *R, /* region in which we are changing direction */
+ fractpel x, fractpel y, /* current beginning x,y */
+ fractpel dy) /* direction and magnitude of change in y */
{
register fractpel ymin,ymax; /* minimum and maximum Y since last call */
register fractpel x_at_ymin,x_at_ymax; /* their respective X's */
@@ -724,11 +730,11 @@ void ChangeDirection(type, R, x, y, dy)
}
if (ymax < ymin)
- abort("negative sized edge?");
+ Abort("negative sized edge?");
(*R->newedgefcn)(R, R->edgexmin, R->edgexmax, ymin, ymax,
- R->lastdy > 0, x_at_ymin, x_at_ymax);
+ R->lastdy > 0);
}
@@ -779,11 +785,11 @@ This function also has to keep the bounding box of the region
up to date.
*/
-static void newfilledge(R, xmin, xmax, ymin, ymax, isdown)
- register struct region *R; /* region being built */
- fractpel xmin,xmax; /* X range of this edge */
- fractpel ymin,ymax; /* Y range of this edge */
- int isdown; /* flag: TRUE means edge goes down, else up */
+static void
+newfilledge(struct region *R, /* region being built */
+ fractpel xmin, fractpel xmax, /* X range of this edge */
+ fractpel ymin, fractpel ymax, /* Y range of this edge */
+ int isdown) /* flag: TRUE means edge goes down, else up */
{
register pel pelxmin,pelymin,pelxmax,pelymax; /* pel versions of bounds */
@@ -836,10 +842,10 @@ exactly where the bottom part belongs.
#define TOP(e) ((e)->ymin) /* the top of an edge (for readability */
#define BOTTOM(e) ((e)->ymax) /* the bottom of an edge (for readability */
-struct edgelist *SortSwath(anchor, edge, swathfcn)
- struct edgelist *anchor; /* list being built */
- register struct edgelist *edge; /* incoming edge or pair of edges */
- struct edgelist *(*swathfcn)(); /* horizontal sorter */
+struct edgelist *
+SortSwath(struct edgelist *anchor, /* list being built */
+ struct edgelist *edge, /* incoming edge or pair of edges */
+ SwathFunc swathfcn) /* horizontal sorter */
{
register struct edgelist *before,*after;
struct edgelist base;
@@ -951,12 +957,12 @@ is guaranteed not to change the address of the old swath while splitting
it.
*/
-static struct edgelist *splitedge(list, y)
- struct edgelist *list; /* area to split */
- register pel y; /* Y value to split list at */
+static struct edgelist *
+splitedge(struct edgelist *list, /* area to split */
+ pel y) /* Y value to split list at */
{
register struct edgelist *new; /* anchor for newly built list */
- register struct edgelist *last; /* end of newly built list */
+ register struct edgelist *last = NULL; /* end of newly built list */
register struct edgelist *r; /* temp pointer to new structure */
register struct edgelist *lastlist; /* temp pointer to last 'list' value */
@@ -968,9 +974,9 @@ static struct edgelist *splitedge(list, y)
if (y < list->ymin)
break;
if (y >= list->ymax)
- abort("splitedge: above top of list");
+ Abort("splitedge: above top of list");
if (y == list->ymin)
- abort("splitedge: would be null");
+ Abort("splitedge: would be null");
r = (struct edgelist *)Allocate(sizeof(struct edgelist), list, 0);
/*
@@ -1010,7 +1016,7 @@ list at 'lastlist', and add the broken off part to the end of 'new'.
Then, we return the caller a pointer to 'new':
*/
if (new == NULL)
- abort("null splitedge");
+ Abort("null splitedge");
lastlist->link = NULL;
last->link = list;
IfTrace1((RegionDebug > 1),"yields %x\n", new);
@@ -1027,7 +1033,7 @@ static void vertjoin(top, bottom)
register struct edgelist *bottom; /* bottommost region */
{
if (BOTTOM(top) > TOP(bottom))
- abort("vertjoin not disjoint");
+ Abort("vertjoin not disjoint");
for (; top->link != NULL; top=top->link) { ; }
@@ -1045,13 +1051,13 @@ all swath functions, this function returns a pointer to the edge
BEFORE the given edge in the sort.
*/
-static struct edgelist *swathxsort(before0, edge)
- register struct edgelist *before0; /* edge before this swath */
- register struct edgelist *edge; /* input edge */
+static struct edgelist *
+swathxsort(struct edgelist *before0, /* edge before this swath */
+ struct edgelist *edge) /* input edge */
{
register struct edgelist *before;
register struct edgelist *after;
- register pel y;
+ register pel y = 0;
before = before0;
after = before->link;
@@ -1121,9 +1127,9 @@ fun comes in they overlap the existing edges. Then some edges
will disappear.
*/
-struct edgelist *SwathUnion(before0, edge)
- register struct edgelist *before0; /* edge before the swath */
- register struct edgelist *edge; /* list of two edges to be unioned */
+struct edgelist *
+SwathUnion(struct edgelist *before0, /* edge before the swath */
+ struct edgelist *edge) /* list of two edges to be unioned */
{
register int h; /* saves height of edge */
register struct edgelist *rightedge; /* saves right edge of 'edge' */
@@ -1135,7 +1141,7 @@ struct edgelist *SwathUnion(before0, edge)
h0 = h = edge->ymax - edge->ymin;
if (h <= 0)
- abort("SwathUnion: 0 height swath?");
+ Abort("SwathUnion: 0 height swath?");
before = before0;
after = before->link;
@@ -1271,6 +1277,7 @@ were overlapped and have been combined with the new incoming 'edge':
}
return(before);
}
+#ifdef notused
/*
:h3.swathrightmost() - Simply Sorts New Edge to Rightmost of Swath
@@ -1278,9 +1285,9 @@ Like all swath functions, this function returns a pointer to the edge
BEFORE the given edge in the sort.
*/
-static struct edgelist *swathrightmost(before, edge)
- register struct edgelist *before; /* edge before this swath */
- register struct edgelist *edge; /* input edge */
+static struct edgelist *
+swathrightmost(struct edgelist *before, /* edge before this swath */
+ struct edgelist *edge) /* input edge */
{
register struct edgelist *after;
@@ -1294,6 +1301,7 @@ static struct edgelist *swathrightmost(before, edge)
return(before);
}
+#endif
/*
:h3.touches() - Returns the Remaining Height When Two Edges Touch
@@ -1301,9 +1309,8 @@ So, it will return 0 if they never touch. Allows incredibly(?) mnemonic
if (touches(...)) construct.
*/
-static int touches(h, left, right)
- register int h;
- register pel *left,*right;
+static int
+touches(int h, pel *left, pel *right)
{
for (; h > 0; h--)
if (*left++ >= *right++)
@@ -1316,9 +1323,8 @@ static int touches(h, left, right)
So, it will return 0 if they never cross.
*/
-static int crosses(h, left, right)
- register int h;
- register pel *left,*right;
+static int
+crosses(int h, pel *left, pel *right)
{
for (; h > 0; h--)
if (*left++ > *right++)
@@ -1329,10 +1335,8 @@ static int crosses(h, left, right)
:h3.cedgemin() - Stores the Mininum of an Edge and an X Value
*/
-static void cedgemin(h, e1, x)
- register int h;
- register pel *e1;
- register pel x;
+static void
+cedgemin(int h, pel *e1, pel x)
{
for (; --h >= 0; e1++)
if (*e1 > x)
@@ -1342,10 +1346,8 @@ static void cedgemin(h, e1, x)
:h3.cedgemax() - Stores the Maximum of an Edge and an X Value
*/
-static void cedgemax(h, e1, x)
- register int h;
- register pel *e1;
- register pel x;
+static void
+cedgemax(int h, pel *e1, pel x)
{
for (; --h >= 0; e1++)
if (*e1 < x)
@@ -1355,9 +1357,8 @@ static void cedgemax(h, e1, x)
:h3.edgemin() - Stores the Mininum of Two Edges in First Edge
*/
-static void edgemin(h, e1, e2)
- register int h;
- register pel *e1,*e2;
+static void
+edgemin(int h, pel *e1, pel *e2)
{
for (; --h >= 0; e1++,e2++)
if (*e1 > *e2)
@@ -1367,9 +1368,8 @@ static void edgemin(h, e1, e2)
:h3.edgemax() - Stores the Maximum of Two Edges in First Edge
*/
-static void edgemax(h, e1, e2)
- register int h;
- register pel *e1,*e2;
+static void
+edgemax(int h, pel *e1, pel *e2)
{
for (; --h >= 0; e1++,e2++)
if (*e1 < *e2)
@@ -1387,9 +1387,8 @@ region.
*/
void
-MoveEdges(R, dx, dy)
- register struct region *R; /* region to modify */
- register fractpel dx,dy; /* delta X and Y to move edge list by */
+MoveEdges(struct region *R, /* region to modify */
+ fractpel dx, fractpel dy) /* delta X and Y to move edge list by */
{
register struct edgelist *edge; /* for looping through edges */
@@ -1436,8 +1435,8 @@ From now on we will deal with dx and dy as integer pel values:
It is an open question whether it pays in general to do this.
*/
-void UnJumble(region)
- struct region *region; /* region to sort */
+void
+UnJumble(struct region *region) /* region to sort */
{
register struct edgelist *anchor; /* new lists built here */
register struct edgelist *edge; /* edge pointer for loop */
@@ -1447,7 +1446,7 @@ void UnJumble(region)
for (edge=region->anchor; VALIDEDGE(edge); edge=next) {
if (edge->link == NULL)
- abort("UnJumble: unpaired edge?");
+ Abort("UnJumble: unpaired edge?");
next = edge->link->link;
edge->link->link = NULL;
anchor = SortSwath(anchor, edge, t1_SwathUnion);
@@ -1462,10 +1461,9 @@ void UnJumble(region)
/*
*/
-
+#ifdef notused
static void
-OptimizeRegion(R)
- struct region *R; /* region to optimize */
+OptimizeRegion(struct region *R) /* region to optimize */
{
register pel *xP; /* pel pointer for inner loop */
register int x; /* holds X value */
@@ -1486,15 +1484,16 @@ OptimizeRegion(R)
if (xmin != xmax || (xmin != R->xmin && xmax != R->xmax))
R->flag &= ~ISRECTANGULAR(ON);
if (xmin < e->xmin || xmax > e->xmax)
- abort("Tighten: existing edge bound was bad");
+ Abort("Tighten: existing edge bound was bad");
if (xmin < R->xmin || xmax > R->xmax)
- abort("Tighten: existing region bound was bad");
+ Abort("Tighten: existing region bound was bad");
e->xmin = xmin;
e->xmax = xmax;
}
R->flag |= ISOPTIMIZED(ON);
}
-
+#endif
+
/*
:h2.Miscelaneous Routines
@@ -1506,10 +1505,10 @@ it gets a shorter 'dy'.
*/
/*ARGSUSED*/
-void MoreWorkArea(R, x1, y1, x2, y2)
- struct region *R; /* region we are generating */
- fractpel x1,y1; /* starting point of line */
- fractpel x2,y2; /* ending point of line */
+void
+MoreWorkArea(struct region *R, /* region we are generating */
+ fractpel x1, fractpel y1, /* starting point of line */
+ fractpel x2, fractpel y2) /* ending point of line */
{
register int idy; /* integer dy of line */
@@ -1538,10 +1537,10 @@ clipping box is specified in REGION coordinates, that is, in
coordinates relative to the region (0,0) point
*/
-struct region *BoxClip(R, xmin, ymin, xmax, ymax)
- register struct region *R; /* region to clip */
- register pel xmin,ymin; /* upper left hand corner of rectangle */
- register pel xmax,ymax; /* lower right hand corner */
+struct region *
+BoxClip(struct region *R, /* region to clip */
+ pel xmin, pel ymin, /* upper left hand corner of rectangle */
+ pel xmax, pel ymax) /* lower right hand corner */
{
struct edgelist anchor; /* pretend edgelist to facilitate discards */
register struct edgelist *e,*laste;
@@ -1618,8 +1617,8 @@ couldn't have it be consumed) and this would probably require
unnecessary CopyRegions in most cases.
*/
-struct region *CoerceRegion(tp)
- register struct textpath *tp; /* input TEXTTYPE */
+struct region *
+CoerceRegion(struct textpath *tp) /* input TEXTTYPE */
{
struct segment *path; /* temporary character path */
struct region *R; /* returned region */
@@ -1634,11 +1633,9 @@ struct region *CoerceRegion(tp)
:h3.RegionBounds() - Returns Bounding Box of a Region
*/
-struct segment *RegionBounds(R)
- register struct region *R;
+struct segment *
+RegionBounds(struct region *R)
{
- extern struct XYspace *IDENTITY;
-
register struct segment *path; /* returned path */
path = BoxPath(IDENTITY, R->ymax - R->ymin, R->xmax - R->xmin);
@@ -1653,8 +1650,8 @@ struct segment *RegionBounds(R)
:h3.DumpArea() - Display a Region
*/
-void DumpArea(area)
- register struct region *area;
+void
+DumpArea(struct region *area)
{
IfTrace1(TRUE,"Dumping area %x,", area);
IfTrace4(TRUE," X %d:%d Y %d:%d;", (long) area->xmin,
@@ -1675,25 +1672,23 @@ void DumpArea(area)
/*ARGSUSED*/
static void
-edgecheck(edge, oldmin, oldmax)
- struct edgelist *edge;
- int oldmin,oldmax;
+edgecheck(struct edgelist *edge, int oldmin, int oldmax)
{
if (edge->type != EDGETYPE)
- abort("EDGE ERROR: non EDGETYPE in list");
+ Abort("EDGE ERROR: non EDGETYPE in list");
/*
The following check is not valid if the region is jumbled so I took it
out:
*/
/* if (edge->ymin < oldmax && edge->ymin != oldmin)
- abort("EDGE ERROR: overlapping swaths"); */
+ Abort("EDGE ERROR: overlapping swaths"); */
}
static pel RegionDebugYMin = MINPEL;
static pel RegionDebugYMax = MAXPEL;
-void DumpEdges(edges)
- register struct edgelist *edges;
+void
+DumpEdges(struct edgelist *edges)
{
register struct edgelist *p,*p2;
register pel ymin = MINPEL;
diff --git a/src/Type1/regions.h b/src/Type1/regions.h
index 3870cf4..9d27e76 100644
--- a/src/Type1/regions.h
+++ b/src/Type1/regions.h
@@ -26,6 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/regions.h,v 1.8 2001/06/15 08:09:20 alanh Exp $ */
/*SHARED*/
#define Interior(p,rule) t1_Interior(p,rule)
@@ -33,21 +34,27 @@
#define Intersect(a1,a2) t1_Intersect(a1,a2)
#define Complement(area) t1_Complement(area)
#define Overlap(a1,a2) t1_OverLap(a1,a2)
-
-struct region *t1_Interior(); /* returns the interior of a closed path */
+
+
+/* returns the interior of a closed path */
+extern struct region *t1_Interior ( struct segment *p, int fillrule );
+#if 0
struct region *t1_Union(); /* set union of paths or regions */
struct region *t1_Intersect(); /* set intersection of regions */
struct region *t1_Complement(); /* complement of a region */
int t1_Overlap(); /* returns a Boolean; TRUE if regions overlap */
-
-#define INFINITY t1_Infinity
+#endif
+
+#define TT_INFINITY t1_Infinity
/*END SHARED*/
/*SHARED*/
#define ChangeDirection(type,R,x,y,dy) t1_ChangeDirection(type,R,x,y,dy)
-void t1_ChangeDirection(); /* called when we change direction in Y */
+/* called when we change direction in Y */
+extern void t1_ChangeDirection ( int type, struct region *R, fractpel x,
+ fractpel y, fractpel dy );
#define CD_FIRST -1 /* enumeration of ChangeDirection type */
#define CD_CONTINUE 0 /* enumeration of ChangeDirection type */
#define CD_LAST 1 /* enumeration of ChangeDirection type */
@@ -63,17 +70,37 @@ void t1_ChangeDirection(); /* called when we change direction in Y */
#define MoveEdges(R,dx,dy) t1_MoveEdges(R,dx,dy)
#define UnJumble(R) t1_UnJumble(R)
-void t1_MoreWorkArea(); /* get longer edge list for stepping */
-struct region *t1_CopyRegion(); /* duplicate a region */
-void t1_KillRegion(); /* destroy a region */
-struct region *t1_BoxClip(); /* clip a region to a rectangle */
-struct edgelist *t1_SortSwath(); /* sort edges onto growing edge list */
-struct edgelist *t1_SwathUnion(); /* 'union' two edges into a swath */
-struct segment *t1_RegionBounds(); /* returns bounding box of a region */
-struct region *t1_CoerceRegion(); /* force text to become a true region */
-void t1_MoveEdges(); /* moves the edge values in a region */
-void t1_UnJumble(); /* sort the edges and reset the jumbled flag */
+typedef struct edgelist *(*SwathFunc)(struct edgelist *, struct edgelist *);
+
+/* get longer edge list for stepping */
+extern void t1_MoreWorkArea ( struct region *R, fractpel x1, fractpel y1,
+ fractpel x2, fractpel y2 );
+/* duplicate a region */
+extern struct region *t1_CopyRegion ( struct region *area );
+/* destroy a region */
+extern void t1_KillRegion ( struct region *area );
+/* clip a region to a rectangle */
+extern struct region *t1_BoxClip ( struct region *R, pel xmin, pel ymin,
+ pel xmax, pel ymax );
+/* sort edges onto growing edge list */
+extern struct edgelist *t1_SortSwath ( struct edgelist *anchor,
+ struct edgelist *edge,
+ SwathFunc swathfcn );
+/* 'union' two edges into a swath */
+extern struct edgelist *t1_SwathUnion ( struct edgelist *before0,
+ struct edgelist *edge );
+/* returns bounding box of a region */
+extern struct segment *t1_RegionBounds ( struct region *R );
+#ifdef notdef
+/* force text to become a true region */
+struct region *t1_CoerceRegion(struct textpath *tp);
+#endif
+/* moves the edge values in a region */
+extern void t1_MoveEdges ( struct region *R, fractpel dx, fractpel dy );
+/* sort the edges and reset the jumbled flag */
+extern void t1_UnJumble ( struct region *region );
+
/*END SHARED*/
/*SHARED*/
@@ -95,9 +122,11 @@ void t1_UnJumble(); /* sort the edges and reset the jumbled flag */
else if (x2 > R->edgexmax) R->edgexmax = x2; \
}
+#ifndef FONTMODULE
#ifndef __sxg__
#include <limits.h>
#endif
+#endif
#ifdef SHRT_MIN
#define MINPEL SHRT_MIN
#else
@@ -122,6 +151,9 @@ to be made unique for that reason (i.e., references > 1).
/*END SHARED*/
/*SHARED*/
+typedef void (*NewEdgeFunc)(struct region *,
+ fractpel, fractpel, fractpel, fractpel, int);
+
struct region {
XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
/* type = REGIONTYPE */
@@ -144,7 +176,7 @@ scratchpad areas used while the region is being built:
struct edgelist *lastedge,*firstedge; /* last and first edges in subpath */
pel *edge; /* pointer to array of X values for edge */
fractpel edgeYstop; /* Y value where 'edges' array ends */
- void (*newedgefcn)(); /* function to use when building a new edge */
+ NewEdgeFunc newedgefcn; /* function to use when building a new edge */
struct strokeinfo *strokeinfo; /* scratchpad info during stroking only */
} ;
/*
@@ -211,3 +243,8 @@ Interior() rule enumerations:
#define CONTINUITY 0x80 /* can be added to above rules; e.g. WINDINGRULE+CONTINUITY */
/*END SHARED*/
+
+/* dump a region structure */
+extern void t1_DumpArea ( struct region *area );
+/* dump a region's edge list */
+extern void t1_DumpEdges ( struct edgelist *edges );
diff --git a/src/Type1/scanfont.c b/src/Type1/scanfont.c
index 71dd687..b8aff94 100644
--- a/src/Type1/scanfont.c
+++ b/src/Type1/scanfont.c
@@ -1,4 +1,4 @@
-/* $Xorg: scanfont.c,v 1.4 2000/12/01 16:26:25 steve Exp $ */
+/* $Xorg: scanfont.c,v 1.3 2000/08/17 19:46:32 cpqbld Exp $ */
/* Copyright International Business Machines,Corp. 1991
* All Rights Reserved
*
@@ -28,15 +28,55 @@
* SOFTWARE.
*/
/* Author: Katherine A. Hitchcock IBM Almaden Research Laboratory */
-
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/scanfont.c,v 1.15 2001/07/25 15:04:55 dawes Exp $ */
+
+#ifndef FONTMODULE
#include <string.h>
+#else
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "xf86_ansic.h"
+#endif
#include "t1stdio.h"
#include "util.h"
#include "token.h"
+#ifdef BUILDCID
+#include "range.h"
+#endif
+#include "objects.h"
+#include "spaces.h"
#include "fontfcn.h"
#include "blues.h"
-
+#ifdef BUILDCID
+#define CID_BUFSIZE 80
+
+extern psfont *FDArrayP;
+static spacerange *spacerangeP;
+static cidrange *notdefrangeP;
+static cidrange *cidrangeP;
+extern int FDArrayIndex;
+static boolean CIDWantFontInfo;
+static boolean InFDArray;
+static psobj inputFile1;
+#endif
static int rc;
static boolean InPrivateDict;
@@ -60,357 +100,358 @@ typedef struct /* Builtin Standard Encoding */
} EncodingTable;
static EncodingTable StdEnc[] = {
- 040 , "space",
- 041 , "exclam",
- 042 , "quotedbl",
- 043 , "numbersign",
- 044 , "dollar",
- 045 , "percent",
- 046 , "ampersand",
- 047 , "quoteright",
- 050 , "parenleft",
- 051 , "parenright",
- 052 , "asterisk",
- 053 , "plus",
- 054 , "comma",
- 055 , "hyphen",
- 056 , "period",
- 057 , "slash",
- 060 , "zero",
- 061 , "one",
- 062 , "two",
- 063 , "three",
- 064 , "four",
- 065 , "five",
- 066 , "six",
- 067 , "seven",
- 070 , "eight",
- 071 , "nine",
- 072 , "colon",
- 073 , "semicolon",
- 074 , "less",
- 075 , "equal",
- 076 , "greater",
- 077 , "question",
- 0100 , "at",
- 0101 , "A",
- 0102 , "B",
- 0103 , "C",
- 0104 , "D",
- 0105 , "E",
- 0106 , "F",
- 0107 , "G",
- 0110 , "H",
- 0111 , "I",
- 0112 , "J",
- 0113 , "K",
- 0114 , "L",
- 0115 , "M",
- 0116 , "N",
- 0117 , "O",
- 0120 , "P",
- 0121 , "Q",
- 0122 , "R",
- 0123 , "S",
- 0124 , "T",
- 0125 , "U",
- 0126 , "V",
- 0127 , "W",
- 0130 , "X",
- 0131 , "Y",
- 0132 , "Z",
- 0133 , "bracketleft",
- 0134 , "backslash",
- 0135 , "bracketright",
- 0136 , "asciicircum",
- 0137 , "underscore",
- 0140 , "quoteleft",
- 0141 , "a",
- 0142 , "b",
- 0143 , "c",
- 0144 , "d",
- 0145 , "e",
- 0146 , "f",
- 0147 , "g",
- 0150 , "h",
- 0151 , "i",
- 0152 , "j",
- 0153 , "k",
- 0154 , "l",
- 0155 , "m",
- 0156 , "n",
- 0157 , "o",
- 0160 , "p",
- 0161 , "q",
- 0162 , "r",
- 0163 , "s",
- 0164 , "t",
- 0165 , "u",
- 0166 , "v",
- 0167 , "w",
- 0170 , "x",
- 0171 , "y",
- 0172 , "z",
- 0173 , "braceleft",
- 0174 , "bar",
- 0175 , "braceright",
- 0176 , "asciitilde",
- 0241 , "exclamdown",
- 0242 , "cent",
- 0243 , "sterling",
- 0244 , "fraction",
- 0245 , "yen",
- 0246 , "florin",
- 0247 , "section",
- 0250 , "currency",
- 0251 , "quotesingle",
- 0252 , "quotedblleft",
- 0253 , "guillemotleft",
- 0254 , "guilsinglleft",
- 0255 , "guilsinglright",
- 0256 , "fi",
- 0257 , "fl",
- 0261 , "endash",
- 0262 , "dagger",
- 0263 , "daggerdbl",
- 0264 , "periodcentered",
- 0266 , "paragraph",
- 0267 , "bullet",
- 0270 , "quotesinglbase",
- 0271 , "quotedblbase",
- 0272 , "quotedblright",
- 0273 , "guillemotright",
- 0274 , "ellipsis",
- 0275 , "perthousand",
- 0277 , "questiondown",
- 0301 , "grave",
- 0302 , "acute",
- 0303 , "circumflex",
- 0304 , "tilde",
- 0305 , "macron",
- 0306 , "breve",
- 0307 , "dotaccent",
- 0310 , "dieresis",
- 0312 , "ring",
- 0313 , "cedilla",
- 0315 , "hungarumlaut",
- 0316 , "ogonek",
- 0317 , "caron",
- 0320 , "emdash",
- 0341 , "AE",
- 0343 , "ordfeminine",
- 0350 , "Lslash",
- 0351 , "Oslash",
- 0352 , "OE",
- 0353 , "ordmasculine",
- 0361 , "ae",
- 0365 , "dotlessi",
- 0370 , "lslash",
- 0371 , "oslash",
- 0372 , "oe",
- 0373 , "germandbls",
- 0, 0
+ { 040 , "space" },
+ { 041 , "exclam" },
+ { 042 , "quotedbl" },
+ { 043 , "numbersign" },
+ { 044 , "dollar" },
+ { 045 , "percent" },
+ { 046 , "ampersand" },
+ { 047 , "quoteright" },
+ { 050 , "parenleft" },
+ { 051 , "parenright" },
+ { 052 , "asterisk" },
+ { 053 , "plus" },
+ { 054 , "comma" },
+ { 055 , "hyphen" },
+ { 056 , "period" },
+ { 057 , "slash" },
+ { 060 , "zero" },
+ { 061 , "one" },
+ { 062 , "two" },
+ { 063 , "three" },
+ { 064 , "four" },
+ { 065 , "five" },
+ { 066 , "six" },
+ { 067 , "seven" },
+ { 070 , "eight" },
+ { 071 , "nine" },
+ { 072 , "colon" },
+ { 073 , "semicolon" },
+ { 074 , "less" },
+ { 075 , "equal" },
+ { 076 , "greater" },
+ { 077 , "question" },
+ { 0100 , "at" },
+ { 0101 , "A" },
+ { 0102 , "B" },
+ { 0103 , "C" },
+ { 0104 , "D" },
+ { 0105 , "E" },
+ { 0106 , "F" },
+ { 0107 , "G" },
+ { 0110 , "H" },
+ { 0111 , "I" },
+ { 0112 , "J" },
+ { 0113 , "K" },
+ { 0114 , "L" },
+ { 0115 , "M" },
+ { 0116 , "N" },
+ { 0117 , "O" },
+ { 0120 , "P" },
+ { 0121 , "Q" },
+ { 0122 , "R" },
+ { 0123 , "S" },
+ { 0124 , "T" },
+ { 0125 , "U" },
+ { 0126 , "V" },
+ { 0127 , "W" },
+ { 0130 , "X" },
+ { 0131 , "Y" },
+ { 0132 , "Z" },
+ { 0133 , "bracketleft" },
+ { 0134 , "backslash" },
+ { 0135 , "bracketright" },
+ { 0136 , "asciicircum" },
+ { 0137 , "underscore" },
+ { 0140 , "quoteleft" },
+ { 0141 , "a" },
+ { 0142 , "b" },
+ { 0143 , "c" },
+ { 0144 , "d" },
+ { 0145 , "e" },
+ { 0146 , "f" },
+ { 0147 , "g" },
+ { 0150 , "h" },
+ { 0151 , "i" },
+ { 0152 , "j" },
+ { 0153 , "k" },
+ { 0154 , "l" },
+ { 0155 , "m" },
+ { 0156 , "n" },
+ { 0157 , "o" },
+ { 0160 , "p" },
+ { 0161 , "q" },
+ { 0162 , "r" },
+ { 0163 , "s" },
+ { 0164 , "t" },
+ { 0165 , "u" },
+ { 0166 , "v" },
+ { 0167 , "w" },
+ { 0170 , "x" },
+ { 0171 , "y" },
+ { 0172 , "z" },
+ { 0173 , "braceleft" },
+ { 0174 , "bar" },
+ { 0175 , "braceright" },
+ { 0176 , "asciitilde" },
+ { 0241 , "exclamdown" },
+ { 0242 , "cent" },
+ { 0243 , "sterling" },
+ { 0244 , "fraction" },
+ { 0245 , "yen" },
+ { 0246 , "florin" },
+ { 0247 , "section" },
+ { 0250 , "currency" },
+ { 0251 , "quotesingle" },
+ { 0252 , "quotedblleft" },
+ { 0253 , "guillemotleft" },
+ { 0254 , "guilsinglleft" },
+ { 0255 , "guilsinglright" },
+ { 0256 , "fi" },
+ { 0257 , "fl" },
+ { 0261 , "endash" },
+ { 0262 , "dagger" },
+ { 0263 , "daggerdbl" },
+ { 0264 , "periodcentered" },
+ { 0266 , "paragraph" },
+ { 0267 , "bullet" },
+ { 0270 , "quotesinglbase" },
+ { 0271 , "quotedblbase" },
+ { 0272 , "quotedblright" },
+ { 0273 , "guillemotright" },
+ { 0274 , "ellipsis" },
+ { 0275 , "perthousand" },
+ { 0277 , "questiondown" },
+ { 0301 , "grave" },
+ { 0302 , "acute" },
+ { 0303 , "circumflex" },
+ { 0304 , "tilde" },
+ { 0305 , "macron" },
+ { 0306 , "breve" },
+ { 0307 , "dotaccent" },
+ { 0310 , "dieresis" },
+ { 0312 , "ring" },
+ { 0313 , "cedilla" },
+ { 0315 , "hungarumlaut" },
+ { 0316 , "ogonek" },
+ { 0317 , "caron" },
+ { 0320 , "emdash" },
+ { 0341 , "AE" },
+ { 0343 , "ordfeminine" },
+ { 0350 , "Lslash" },
+ { 0351 , "Oslash" },
+ { 0352 , "OE" },
+ { 0353 , "ordmasculine" },
+ { 0361 , "ae" },
+ { 0365 , "dotlessi" },
+ { 0370 , "lslash" },
+ { 0371 , "oslash" },
+ { 0372 , "oe" },
+ { 0373 , "germandbls" },
+ { 0, 0 }
};
static EncodingTable ISO8859Enc[] = {
- 32, "space",
- 33, "exclam",
- 34, "quotedbl",
- 35, "numbersign",
- 36, "dollar",
- 37, "percent",
- 38, "ampersand",
- 39, "quoteright",
- 40, "parenleft",
- 41, "parenright",
- 42, "asterisk",
- 43, "plus",
- 44, "comma",
- 45, "minus",
- 46, "period",
- 47, "slash",
- 48, "zero",
- 49, "one",
- 50, "two",
- 51, "three",
- 52, "four",
- 53, "five",
- 54, "six",
- 55, "seven",
- 56, "eight",
- 57, "nine",
- 58, "colon",
- 59, "semicolon",
- 60, "less",
- 61, "equal",
- 62, "greater",
- 63, "question",
- 64, "at",
- 65, "A",
- 66, "B",
- 67, "C",
- 68, "D",
- 69, "E",
- 70, "F",
- 71, "G",
- 72, "H",
- 73, "I",
- 74, "J",
- 75, "K",
- 76, "L",
- 77, "M",
- 78, "N",
- 79, "O",
- 80, "P",
- 81, "Q",
- 82, "R",
- 83, "S",
- 84, "T",
- 85, "U",
- 86, "V",
- 87, "W",
- 88, "X",
- 89, "Y",
- 90, "Z",
- 91, "bracketleft",
- 92, "backslash",
- 93, "bracketright",
- 94, "asciicircum",
- 95, "underscore",
- 96, "quoteleft",
- 97, "a",
- 98, "b",
- 99, "c",
- 100, "d",
- 101, "e",
- 102, "f",
- 103, "g",
- 104, "h",
- 105, "i",
- 106, "j",
- 107, "k",
- 108, "l",
- 109, "m",
- 110, "n",
- 111, "o",
- 112, "p",
- 113, "q",
- 114, "r",
- 115, "s",
- 116, "t",
- 117, "u",
- 118, "v",
- 119, "w",
- 120, "x",
- 121, "y",
- 122, "z",
- 123, "braceleft",
- 124, "bar",
- 125, "braceright",
- 126, "asciitilde",
- 161, "exclamdown",
- 162, "cent",
- 163, "sterling",
- 164, "currency",
- 165, "yen",
- 166, "brokenbar",
- 167, "section",
- 168, "dieresis",
- 169, "copyright",
- 170, "ordfeminine",
- 171, "guillemotleft",
- 172, "logicalnot",
- 173, "hyphen",
- 174, "registered",
- 175, "macron",
- 176, "degree",
- 177, "plusminus",
- 178, "twosuperior",
- 179, "threesuperior",
- 180, "acute",
- 181, "mu",
- 182, "paragraph",
- 183, "periodcentered",
- 184, "cedilla",
- 185, "onesuperior",
- 186, "ordmasculine",
- 187, "guillemotright",
- 188, "onequarter",
- 189, "onehalf",
- 190, "threequarters",
- 191, "questiondown",
- 192, "Agrave",
- 193, "Aacute",
- 194, "Acircumflex",
- 195, "Atilde",
- 196, "Adieresis",
- 197, "Aring",
- 198, "AE",
- 199, "Ccedilla",
- 200, "Egrave",
- 201, "Eacute",
- 202, "Ecircumflex",
- 203, "Edieresis",
- 204, "Igrave",
- 205, "Iacute",
- 206, "Icircumflex",
- 207, "Idieresis",
- 208, "Eth",
- 209, "Ntilde",
- 210, "Ograve",
- 211, "Oacute",
- 212, "Ocircumflex",
- 213, "Otilde",
- 214, "Odieresis",
- 215, "multiply",
- 216, "Oslash",
- 217, "Ugrave",
- 218, "Uacute",
- 219, "Ucircumflex",
- 220, "Udieresis",
- 221, "Yacute",
- 222, "Thorn",
- 223, "germandbls",
- 224, "agrave",
- 225, "aacute",
- 226, "acircumflex",
- 227, "atilde",
- 228, "adieresis",
- 229, "aring",
- 230, "ae",
- 231, "ccedilla",
- 232, "egrave",
- 233, "eacute",
- 234, "ecircumflex",
- 235, "edieresis",
- 236, "igrave",
- 237, "iacute",
- 238, "icircumflex",
- 239, "idieresis",
- 240, "eth",
- 241, "ntilde",
- 242, "ograve",
- 243, "oacute",
- 244, "ocircumflex",
- 245, "otilde",
- 246, "odieresis",
- 247, "divide",
- 248, "oslash",
- 249, "ugrave",
- 250, "uacute",
- 251, "ucircumflex",
- 252, "udieresis",
- 253, "yacute",
- 254, "thorn",
- 255, "ydieresis",
- 0, 0
+ { 32, "space" },
+ { 33, "exclam" },
+ { 34, "quotedbl" },
+ { 35, "numbersign" },
+ { 36, "dollar" },
+ { 37, "percent" },
+ { 38, "ampersand" },
+ { 39, "quoteright" },
+ { 40, "parenleft" },
+ { 41, "parenright" },
+ { 42, "asterisk" },
+ { 43, "plus" },
+ { 44, "comma" },
+ { 45, "minus" },
+ { 46, "period" },
+ { 47, "slash" },
+ { 48, "zero" },
+ { 49, "one" },
+ { 50, "two" },
+ { 51, "three" },
+ { 52, "four" },
+ { 53, "five" },
+ { 54, "six" },
+ { 55, "seven" },
+ { 56, "eight" },
+ { 57, "nine" },
+ { 58, "colon" },
+ { 59, "semicolon" },
+ { 60, "less" },
+ { 61, "equal" },
+ { 62, "greater" },
+ { 63, "question" },
+ { 64, "at" },
+ { 65, "A" },
+ { 66, "B" },
+ { 67, "C" },
+ { 68, "D" },
+ { 69, "E" },
+ { 70, "F" },
+ { 71, "G" },
+ { 72, "H" },
+ { 73, "I" },
+ { 74, "J" },
+ { 75, "K" },
+ { 76, "L" },
+ { 77, "M" },
+ { 78, "N" },
+ { 79, "O" },
+ { 80, "P" },
+ { 81, "Q" },
+ { 82, "R" },
+ { 83, "S" },
+ { 84, "T" },
+ { 85, "U" },
+ { 86, "V" },
+ { 87, "W" },
+ { 88, "X" },
+ { 89, "Y" },
+ { 90, "Z" },
+ { 91, "bracketleft" },
+ { 92, "backslash" },
+ { 93, "bracketright" },
+ { 94, "asciicircum" },
+ { 95, "underscore" },
+ { 96, "quoteleft" },
+ { 97, "a" },
+ { 98, "b" },
+ { 99, "c" },
+ { 100, "d" },
+ { 101, "e" },
+ { 102, "f" },
+ { 103, "g" },
+ { 104, "h" },
+ { 105, "i" },
+ { 106, "j" },
+ { 107, "k" },
+ { 108, "l" },
+ { 109, "m" },
+ { 110, "n" },
+ { 111, "o" },
+ { 112, "p" },
+ { 113, "q" },
+ { 114, "r" },
+ { 115, "s" },
+ { 116, "t" },
+ { 117, "u" },
+ { 118, "v" },
+ { 119, "w" },
+ { 120, "x" },
+ { 121, "y" },
+ { 122, "z" },
+ { 123, "braceleft" },
+ { 124, "bar" },
+ { 125, "braceright" },
+ { 126, "asciitilde" },
+ { 160, "space" },
+ { 161, "exclamdown" },
+ { 162, "cent" },
+ { 163, "sterling" },
+ { 164, "currency" },
+ { 165, "yen" },
+ { 166, "brokenbar" },
+ { 167, "section" },
+ { 168, "dieresis" },
+ { 169, "copyright" },
+ { 170, "ordfeminine" },
+ { 171, "guillemotleft" },
+ { 172, "logicalnot" },
+ { 173, "hyphen" },
+ { 174, "registered" },
+ { 175, "macron" },
+ { 176, "degree" },
+ { 177, "plusminus" },
+ { 178, "twosuperior" },
+ { 179, "threesuperior" },
+ { 180, "acute" },
+ { 181, "mu" },
+ { 182, "paragraph" },
+ { 183, "periodcentered" },
+ { 184, "cedilla" },
+ { 185, "onesuperior" },
+ { 186, "ordmasculine" },
+ { 187, "guillemotright" },
+ { 188, "onequarter" },
+ { 189, "onehalf" },
+ { 190, "threequarters" },
+ { 191, "questiondown" },
+ { 192, "Agrave" },
+ { 193, "Aacute" },
+ { 194, "Acircumflex" },
+ { 195, "Atilde" },
+ { 196, "Adieresis" },
+ { 197, "Aring" },
+ { 198, "AE" },
+ { 199, "Ccedilla" },
+ { 200, "Egrave" },
+ { 201, "Eacute" },
+ { 202, "Ecircumflex" },
+ { 203, "Edieresis" },
+ { 204, "Igrave" },
+ { 205, "Iacute" },
+ { 206, "Icircumflex" },
+ { 207, "Idieresis" },
+ { 208, "Eth" },
+ { 209, "Ntilde" },
+ { 210, "Ograve" },
+ { 211, "Oacute" },
+ { 212, "Ocircumflex" },
+ { 213, "Otilde" },
+ { 214, "Odieresis" },
+ { 215, "multiply" },
+ { 216, "Oslash" },
+ { 217, "Ugrave" },
+ { 218, "Uacute" },
+ { 219, "Ucircumflex" },
+ { 220, "Udieresis" },
+ { 221, "Yacute" },
+ { 222, "Thorn" },
+ { 223, "germandbls" },
+ { 224, "agrave" },
+ { 225, "aacute" },
+ { 226, "acircumflex" },
+ { 227, "atilde" },
+ { 228, "adieresis" },
+ { 229, "aring" },
+ { 230, "ae" },
+ { 231, "ccedilla" },
+ { 232, "egrave" },
+ { 233, "eacute" },
+ { 234, "ecircumflex" },
+ { 235, "edieresis" },
+ { 236, "igrave" },
+ { 237, "iacute" },
+ { 238, "icircumflex" },
+ { 239, "idieresis" },
+ { 240, "eth" },
+ { 241, "ntilde" },
+ { 242, "ograve" },
+ { 243, "oacute" },
+ { 244, "ocircumflex" },
+ { 245, "otilde" },
+ { 246, "odieresis" },
+ { 247, "divide" },
+ { 248, "oslash" },
+ { 249, "ugrave" },
+ { 250, "uacute" },
+ { 251, "ucircumflex" },
+ { 252, "udieresis" },
+ { 253, "yacute" },
+ { 254, "thorn" },
+ { 255, "ydieresis" },
+ { 0, 0 }
};
static psobj *StdEncArrayP = NULL;
psobj *ISOLatin1EncArrayP = NULL;
-static psobj *MakeEncodingArrayP(encodingTable)
- EncodingTable *encodingTable;
+static psobj *
+MakeEncodingArrayP(EncodingTable *encodingTable)
{
int i;
psobj *encodingArrayP;
@@ -433,7 +474,8 @@ static psobj *MakeEncodingArrayP(encodingTable)
return(encodingArrayP);
}
-boolean Init_BuiltInEncoding()
+boolean
+Init_BuiltInEncoding(void)
{
StdEncArrayP = MakeEncodingArrayP(StdEnc);
ISOLatin1EncArrayP = MakeEncodingArrayP(ISO8859Enc);
@@ -442,8 +484,8 @@ boolean Init_BuiltInEncoding()
/********************************************************************/
/***================================================================***/
-static int getNextValue(valueType)
- int valueType;
+static int
+getNextValue(int valueType)
{
scan_token(inputP);
if (tokenType != valueType) {
@@ -455,7 +497,8 @@ static int getNextValue(valueType)
/***================================================================***/
/* This routine will set the global rc if there is an error */
/***================================================================***/
-static int getInt()
+static int
+getInt(void)
{
scan_token(inputP);
if (tokenType != TOKEN_INTEGER) {
@@ -472,23 +515,16 @@ static int getInt()
* See Sec 10.3 of ``Adobe Type 1 Font Format'' v1.1,
* for parsing Encoding.
*/
-static int getEncoding(arrayP)
- psobj *arrayP;
+static int
+getEncoding(psobj *arrayP)
{
-
scan_token(inputP);
- if ((tokenType == TOKEN_NAME)
- &&
- (((tokenLength==16) && (!strncmp(tokenStartP,"StandardEncoding",16))) ||
- (((tokenLength==17) && (!strncmp(tokenStartP,"ISOLatin1Encoding",17))))))
+ if ((tokenType == TOKEN_NAME && (tokenLength==16 || tokenLength==17)))
{
- /* Adobe Standard Encoding */
-
- if (tokenLength == 16)
- arrayP->data.valueP = (char *) StdEncArrayP;
- else
- arrayP->data.valueP = (char *) ISOLatin1EncArrayP;
-
+ if((tokenLength==16) && (!strncmp(tokenStartP,"StandardEncoding",16)))
+ arrayP->data.valueP = (char *) StdEncArrayP;
+ else
+ arrayP->data.valueP = (char *) ISOLatin1EncArrayP;
arrayP->len = 256;
return(SCAN_OK);
}
@@ -586,45 +622,92 @@ static int getEncoding(arrayP)
return (SCAN_ERROR);
}
/***================================================================***/
-static int getArray(arrayP)
- psobj *arrayP;
+#ifdef BUILDCID
+static int
+getFDArray(psobj *arrayP)
+{
+ int rc;
+
+ /* get the number of items in the FDArray */
+ scan_token(inputP);
+ if (tokenType == TOKEN_INTEGER) {
+ /* an FD array must contain at least one element */
+ if (tokenValue.integer <= 0)
+ return(SCAN_ERROR);
+ arrayP->len = tokenValue.integer;
+ } else
+ return(SCAN_ERROR);
+
+ /* get the token "array" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || strncmp(tokenStartP, "array", 5) != 0)
+ return(SCAN_ERROR);
+
+ /* format the array in memory, save pointer to the beginning */
+ arrayP->data.valueP = tokenStartP;
+
+ /* allocate FDArray */
+ FDArrayP = (psfont *)vm_alloc(arrayP->len*(sizeof(psfont)));
+ if (!(FDArrayP)) return(SCAN_OUT_OF_MEMORY);
+
+ /* get a specified number of font dictionaries */
+ for (FDArrayIndex = 0; FDArrayIndex < arrayP->len; FDArrayIndex++) {
+ /* get "dup" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || strncmp(tokenStartP, "dup", 3) != 0)
+ return(SCAN_ERROR);
+ /* get an integer digit */
+ scan_token(inputP);
+ if (tokenType != TOKEN_INTEGER)
+ return(SCAN_ERROR);
+
+ /* read a CID version of a Type 1 font */
+ if (!CIDType1fontfcnA(&rc))
+ return(rc);
+
+ /* get "put" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || strncmp(tokenStartP, "put", 3) != 0)
+ return(SCAN_ERROR);
+ }
+ return(SCAN_OK);
+}
+#endif
+
+static int
+getArray(psobj *arrayP)
{
int N; /* count the items in the array */
psobj *objP;
- int scanning;
- char *tmp; /* If some font file has /foo/foo,
- * e.g. ftp://ftp.cdrom.com/pub/os2/fonts/future.zip
- * we will treat it as /foo.
- */
- if (!(tmp = strdup(tokenStartP)))
- return(SCAN_OUT_OF_MEMORY);
-
- scanning = 1;
- while (scanning == 1) {
+ /* That is totally a kludge. If some stupid font file has
+ * /foo/foo # ftp://ftp.cdrom.com/pub/os2/fonts/future.zip
+ * we will treat it as /foo.
+ * H.J. */
+ char tmp [1024];
+
+ strncpy (tmp, tokenStartP, sizeof (tmp));
+ tmp [sizeof (tmp) - 1] = '\0';
+
+restart:
scan_token(inputP);
switch (tokenType)
{
- case TOKEN_LEFT_BRACE:
- case TOKEN_LEFT_BRACKET:
- scanning = 0;
- break;
-
- case TOKEN_LITERAL_NAME:
- tokenStartP[tokenLength] = '\0';
- if (strcmp (tokenStartP, tmp) == 0) {
- /* Ok, if we see /foo/foo, let's go back to the top of the loop,
- * otherwise drop out of the loop. */
- continue;
- }
+ case TOKEN_LEFT_BRACE:
+ case TOKEN_LEFT_BRACKET:
+ break;
- default:
- free(tmp);
- return(SCAN_ERROR);
- }
- }
- free(tmp);
+ case TOKEN_LITERAL_NAME:
+ tokenStartP[tokenLength] = '\0';
+ if (strcmp (tokenStartP, tmp) == 0)
+ {
+ /* Ok, We see /foo/foo. Let's restart. */
+ goto restart;
+ }
+ default:
+ return(SCAN_ERROR);
+ }
/* format the array in memory, save pointer to the beginning */
arrayP->data.valueP = tokenStartP;
/* loop, picking up next object, until right BRACE or BRACKET */
@@ -655,8 +738,8 @@ static int getArray(arrayP)
/* NOTREACHED*/
}
/***================================================================***/
-static int getName(nameP)
- char *nameP;
+static int
+getName(char *nameP)
{
do {
scan_token(inputP);
@@ -670,8 +753,8 @@ static int getName(nameP)
return(SCAN_OK);
}
/***================================================================***/
-static int getNbytes(N)
- int N;
+static int
+getNbytes(int N)
{
int I;
@@ -693,8 +776,8 @@ static int getNbytes(N)
/* It means that the CharStrings does not have as many characters */
/* as the dictionary said it would and that is ok. */
/***================================================================***/
-static int getLiteralName(nameObjP)
- psobj *nameObjP;
+static int
+getLiteralName(psobj *nameObjP)
{
do {
scan_token(inputP);
@@ -722,8 +805,8 @@ static int getLiteralName(nameObjP)
*/
/***================================================================***/
-static int BuildSubrs(FontP)
- psfont *FontP;
+static int
+BuildSubrs(psfont *FontP)
{
int N; /* number of values in Subrs */
int I; /* index into Subrs */
@@ -797,8 +880,8 @@ static int BuildSubrs(FontP)
*/
/***================================================================***/
-static int BuildCharStrings(FontP)
- psfont *FontP;
+static int
+BuildCharStrings(psfont *FontP)
{
int N; /* number of values in CharStrings */
int i; /* loop thru Subrs */
@@ -852,13 +935,104 @@ static int BuildCharStrings(FontP)
}
/***================================================================***/
+#ifdef BUILDCID
+/***================================================================***/
+/*
+ * BuildCIDFontInfo Dictionary
+ */
+/***================================================================***/
+static int
+BuildCIDFontInfo(cidfont *CIDfontP)
+{
+ psdict *dictP;
+
+ /* allocate the private dictionary (max number of entries + 1) */
+ dictP = (psdict *)vm_alloc(20*sizeof(psdict));
+ if (!(dictP)) return(SCAN_OUT_OF_MEMORY);
+
+ CIDfontP->CIDfontInfoP = dictP;
+ CIDfontP->CIDfontInfoP[0].key.len = 18; /* number of actual entries */
+ objFormatName(&(dictP[CIDCOUNT].key),8,"CIDCount");
+ objFormatInteger(&(dictP[CIDCOUNT].value),-1);
+ objFormatName(&(dictP[CIDFONTNAME].key),11,"CIDFontName");
+ objFormatName(&(dictP[CIDFONTNAME].value),0,NULL);
+ objFormatName(&(dictP[CIDFONTTYPE].key),11,"CIDFontType");
+ objFormatInteger(&(dictP[CIDFONTTYPE].value),-1);
+ objFormatName(&(dictP[CIDVERSION].key),14,"CIDFontVersion");
+ objFormatInteger(&(dictP[CIDVERSION].value),-1);
+ objFormatName(&(dictP[CIDREGISTRY].key),8,"Registry");
+ objFormatString(&(dictP[CIDREGISTRY].value),0,NULL);
+ objFormatName(&(dictP[CIDORDERING].key),8,"Ordering");
+ objFormatString(&(dictP[CIDORDERING].value),0,NULL);
+ objFormatName(&(dictP[CIDSUPPLEMENT].key),10,"Supplement");
+ objFormatInteger(&(dictP[CIDSUPPLEMENT].value),-1);
+ objFormatName(&(dictP[CIDMAPOFFSET].key),12,"CIDMapOffset");
+ objFormatInteger(&(dictP[CIDMAPOFFSET].value),-1);
+ objFormatName(&(dictP[CIDFDARRAY].key),7,"FDArray");
+ objFormatArray(&(dictP[CIDFDARRAY].value),0,NULL);
+ objFormatName(&(dictP[CIDFDBYTES].key),7,"FDBytes");
+ objFormatInteger(&(dictP[CIDFDBYTES].value),-1);
+ objFormatName(&(dictP[CIDFONTBBOX].key),8,"FontBBox");
+ objFormatArray(&(dictP[CIDFONTBBOX].value),0,NULL);
+ objFormatName(&(dictP[CIDFULLNAME].key),8,"FullName");
+ objFormatString(&(dictP[CIDFULLNAME].value),0,NULL);
+ objFormatName(&(dictP[CIDFAMILYNAME].key),10,"FamilyName");
+ objFormatString(&(dictP[CIDFAMILYNAME].value),0,NULL);
+ objFormatName(&(dictP[CIDWEIGHT].key),6,"Weight");
+ objFormatString(&(dictP[CIDWEIGHT].value),0,NULL);
+ objFormatName(&(dictP[CIDNOTICE].key),6,"Notice");
+ objFormatString(&(dictP[CIDNOTICE].value),0,NULL);
+ objFormatName(&(dictP[CIDGDBYTES].key),7,"GDBytes");
+ objFormatInteger(&(dictP[CIDGDBYTES].value),-1);
+ objFormatName(&(dictP[CIDUIDBASE].key),7,"UIDBase");
+ objFormatInteger(&(dictP[CIDUIDBASE].value),0);
+ objFormatName(&(dictP[CIDXUID].key),4,"XUID");
+ objFormatInteger(&(dictP[CIDXUID].value),0);
+ return(SCAN_OK);
+}
+/***================================================================***/
+/*
+ * BuildCMapInfo Dictionary
+ */
+/***================================================================***/
+static int
+BuildCMapInfo(cmapres *CMapP)
+{
+ psdict *dictP;
+
+ /* allocate the private dictionary (max number of entries + 1) */
+ dictP = (psdict *)vm_alloc(20*sizeof(psdict));
+ if (!(dictP)) return(SCAN_OUT_OF_MEMORY);
+
+ CMapP->CMapInfoP = dictP;
+ CMapP->CMapInfoP[0].key.len = 8; /* number of actual entries */
+ objFormatName(&(dictP[CMAPREGISTRY].key),8,"Registry");
+ objFormatString(&(dictP[CMAPREGISTRY].value),0,NULL);
+ objFormatName(&(dictP[CMAPORDERING].key),8,"Ordering");
+ objFormatString(&(dictP[CMAPORDERING].value),0,NULL);
+ objFormatName(&(dictP[CMAPSUPPLEMENT].key),10,"Supplement");
+ objFormatInteger(&(dictP[CMAPSUPPLEMENT].value),-1);
+ objFormatName(&(dictP[CMAPNAME].key),8,"CMapName");
+ objFormatString(&(dictP[CMAPNAME].value),0,NULL);
+ objFormatName(&(dictP[CMAPVERSION].key),11,"CMapVersion");
+ objFormatInteger(&(dictP[CMAPVERSION].value),-1);
+ objFormatName(&(dictP[CMAPTYPE].key),8,"CMapType");
+ objFormatInteger(&(dictP[CMAPTYPE].value),-1);
+ objFormatName(&(dictP[CMAPWMODE].key),5,"WMode");
+ objFormatInteger(&(dictP[CMAPWMODE].value),-1);
+ objFormatName(&(dictP[CMAPCIDCOUNT].key),8,"CIDCount");
+ objFormatInteger(&(dictP[CMAPCIDCOUNT].value),-1);
+ return(SCAN_OK);
+}
+#endif
+
/***================================================================***/
/*
* BuildFontInfo Dictionary
*/
/***================================================================***/
-static int BuildFontInfo(fontP)
- psfont *fontP;
+static int
+BuildFontInfo(psfont *fontP)
{
psdict *dictP;
@@ -904,13 +1078,77 @@ static int BuildFontInfo(fontP)
objFormatReal(&(dictP[UNDERLINETHICKNESS].value),0.0);
return(SCAN_OK);
}
+#ifdef BUILDCID
+/***================================================================***/
+/*
+ * BuildCIDType1Private Dictionary
+ */
+/***================================================================***/
+static int
+BuildCIDType1Private(psfont *fontP)
+{
+ psdict *Private;
+
+ /* allocate the private dictionary */
+ Private = (psdict *)vm_alloc(21*sizeof(psdict));
+
+ if (!(Private)) return(SCAN_OUT_OF_MEMORY);
+
+ fontP->Private = Private;
+ fontP->Private[0].key.len = 20; /* number of actual entries */
+
+ objFormatName(&(Private[CIDT1MINFEATURE].key),10,"MinFeature");
+ objFormatArray(&(Private[CIDT1MINFEATURE].value),0,NULL);
+ objFormatName(&(Private[CIDT1LENIV].key),5,"lenIV");
+ objFormatInteger(&(Private[CIDT1LENIV].value),DEFAULTLENIV);
+ objFormatName(&(Private[CIDT1LANGGROUP].key),13,"LanguageGroup");
+ objFormatInteger(&(Private[CIDT1LANGGROUP].value),DEFAULTLANGUAGEGROUP);
+ objFormatName(&(Private[CIDT1BLUEVALUES].key),10,"BlueValues");
+ objFormatArray(&(Private[CIDT1BLUEVALUES].value),0,NULL);
+ objFormatName(&(Private[CIDT1OTHERBLUES].key),10,"OtherBlues");
+ objFormatArray(&(Private[CIDT1OTHERBLUES].value),0,NULL);
+ objFormatName(&(Private[CIDT1BLUESCALE].key),9,"BlueScale");
+ objFormatReal(&(Private[CIDT1BLUESCALE].value),DEFAULTBLUESCALE);
+ objFormatName(&(Private[CIDT1BLUEFUZZ].key),8,"BlueFuzz");
+ objFormatInteger(&(Private[CIDT1BLUEFUZZ].value),DEFAULTBLUEFUZZ);
+ objFormatName(&(Private[CIDT1BLUESHIFT].key),9,"BlueShift");
+ objFormatInteger(&(Private[CIDT1BLUESHIFT].value),DEFAULTBLUESHIFT);
+ objFormatName(&(Private[CIDT1FAMBLUES].key),11,"FamilyBlues");
+ objFormatArray(&(Private[CIDT1FAMBLUES].value),0,NULL);
+ objFormatName(&(Private[CIDT1FAMOTHERBLUES].key),16,"FamilyOtherBlues");
+ objFormatArray(&(Private[CIDT1FAMOTHERBLUES].value),0,NULL);
+ objFormatName(&(Private[CIDT1STDHW].key),5,"StdHW");
+ objFormatArray(&(Private[CIDT1STDHW].value),0,NULL);
+ objFormatName(&(Private[CIDT1STDVW].key),5,"StdVW");
+ objFormatArray(&(Private[CIDT1STDVW].value),0,NULL);
+ objFormatName(&(Private[CIDT1STEMSNAPH].key),9,"StemSnapH");
+ objFormatArray(&(Private[CIDT1STEMSNAPH].value),0,NULL);
+ objFormatName(&(Private[CIDT1STEMSNAPV].key),9,"StemSnapV");
+ objFormatArray(&(Private[CIDT1STEMSNAPV].value),0,NULL);
+ /* skip password */
+ objFormatName(&(Private[CIDT1SUBMAPOFF].key),13,"SubrMapOffset");
+ objFormatInteger(&(Private[CIDT1SUBMAPOFF].value),0);
+ objFormatName(&(Private[CIDT1SDBYTES].key),7,"SDBytes");
+ objFormatInteger(&(Private[CIDT1SDBYTES].value),0);
+ objFormatName(&(Private[CIDT1SUBRCNT].key),9,"SubrCount");
+ objFormatInteger(&(Private[CIDT1SUBRCNT].value),0);
+ objFormatName(&(Private[CIDT1FORCEBOLD].key),9,"ForceBold");
+ objFormatBoolean(&(Private[CIDT1FORCEBOLD].value),DEFAULTFORCEBOLD);
+ objFormatName(&(Private[CIDT1RNDSTEMUP].key),9,"RndStemUp");
+ objFormatBoolean(&(Private[CIDT1RNDSTEMUP].value),DEFAULTRNDSTEMUP);
+ objFormatName(&(Private[CIDT1EXPFACTOR].key),15,"ExpansionFactor");
+ objFormatReal(&(Private[CIDT1EXPFACTOR].value),
+ DEFAULTEXPANSIONFACTOR);
+ return(SCAN_OK);
+}
+#endif
/***================================================================***/
/*
* BuildPrivate Dictionary
*/
/***================================================================***/
-static int BuildPrivate(fontP)
- psfont *fontP;
+static int
+BuildPrivate(psfont *fontP)
{
psdict *Private;
@@ -968,8 +1206,8 @@ static int BuildPrivate(fontP)
/* */
/* */
/**********************************************************************/
-static int GetType1Blues(fontP)
- psfont *fontP;
+static int
+GetType1Blues(psfont *fontP)
{
psdict *PrivateDictP; /* the Private dict relating to hints */
struct blues_struct *blues; /* ptr for the blues struct we will allocate */
@@ -1238,9 +1476,8 @@ static int GetType1Blues(fontP)
/* */
/* Returns a psobj (string) */
/**********************************************************************/
-psobj *GetType1CharString(fontP, code)
-psfont *fontP;
-unsigned char code;
+psobj *
+GetType1CharString(psfont *fontP, unsigned char code)
{
int N; /* the 'Nth' entry in the CharStrings */
psobj *charnameP; /* points to psobj that is name of character*/
@@ -1282,8 +1519,8 @@ unsigned char code;
*/
/***================================================================***/
-static int FindDictValue(dictP)
- psdict *dictP;
+static int
+FindDictValue(psdict *dictP)
{
psobj LitName;
int N;
@@ -1303,7 +1540,14 @@ static int FindDictValue(dictP)
if ( V != SCAN_OK ) return(V);
break;
case OBJ_ARRAY:
+#ifdef BUILDCID
+ if (0 == strncmp(tokenStartP,"FDArray",7))
+ V = getFDArray(&(dictP[N].value));
+ else
+ V = getArray(&(dictP[N].value));
+#else
V = getArray(&(dictP[N].value));
+#endif
if ( V != SCAN_OK ) return(V);
break;
case OBJ_INTEGER:
@@ -1359,15 +1603,605 @@ static int FindDictValue(dictP)
}
/***================================================================***/
-
+
+#ifdef BUILDCID
+/*
+ * -------------------------------------------------------------------
+ * Scan the next token and convert it into an object
+ * Result is placed on the Operand Stack as next object
+ * -------------------------------------------------------------------
+ */
+int
+scan_cidfont(cidfont *CIDFontP, cmapres *CMapP)
+{
+ char filename[CID_PATH_MAX];
+ char cmapfile[CID_PATH_MAX];
+ char buf[CID_BUFSIZE];
+ char filetype[3];
+ FILE *fileP;
+ FILE *fileP1;
+ char *nameP;
+ char *p;
+ int namelen;
+ int i, j;
+ int cread, rangecnt;
+ unsigned int char_row, char_col;
+
+ InFDArray = FALSE;
+
+ filetype[0] = 'r';
+ filetype[1] = 'b';
+ filetype[2] = '\0';
+
+ /* copy the filename and remove leading or trailing blanks */
+ /* point to name and search for leading blanks */
+ nameP= CIDFontP->CIDFontFileName.data.nameP;
+ namelen = CIDFontP->CIDFontFileName.len;
+ while (nameP[0] == ' ') {
+ nameP++;
+ namelen--;
+ }
+ /* now remove any trailing blanks */
+ while ((namelen>0) && ( nameP[namelen-1] == ' ')) {
+ namelen--;
+ }
+ strncpy(filename,nameP,namelen);
+ filename[namelen] = '\0';
+ /* file name is now constructed */
+ inputFile.data.fileP = NULL;
+ filterFile.data.fileP = NULL;
+
+ /* check whether a CIDFont file */
+ if ((fileP = fopen(filename,filetype))) {
+ cread = fread(buf, 1, CID_BUFSIZE, fileP);
+ fclose(fileP);
+ if (cread > 17) {
+ if (strncmp(buf, "%!", 2) ||
+ (p = strstr(buf, "Resource-CIDFont")) == NULL)
+ return(SCAN_FILE_OPEN_ERROR);
+ } else
+ return(SCAN_FILE_OPEN_ERROR);
+ } else
+ return(SCAN_FILE_OPEN_ERROR);
+
+ /* copy the CMap file name and remove leading or trailing blanks */
+ /* point to name and search for leading blanks */
+ nameP = CMapP->CMapFileName.data.nameP;
+ namelen = CMapP->CMapFileName.len;
+ while (nameP[0] == ' ') {
+ nameP++;
+ namelen--;
+ }
+ /* now remove any trailing blanks */
+ while ((namelen>0) && ( nameP[namelen-1] == ' ')) {
+ namelen--;
+ }
+ strncpy(cmapfile,nameP,namelen);
+ cmapfile[namelen] = '\0';
+ /* CMap file name is now constructed */
+ inputFile1.data.fileP = NULL;
+
+ /* check whether a CMap file */
+ if ((fileP1 = fopen(cmapfile,filetype))) {
+ cread = fread(buf, 1, CID_BUFSIZE, fileP1);
+ fclose(fileP1);
+ if (cread > 17) {
+ if (strncmp(buf, "%!", 2) ||
+ (p = strstr(buf, "Resource-CMap")) == NULL)
+ return(SCAN_FILE_OPEN_ERROR);
+ } else
+ return(SCAN_FILE_OPEN_ERROR);
+ } else
+ return(SCAN_FILE_OPEN_ERROR);
+
+ /* read the specified CMap file */
+ inputP = &inputFile1;
+
+ if (!(fileP1 = fopen(cmapfile,filetype)))
+ return(SCAN_FILE_OPEN_ERROR);
+
+ objFormatFile(inputP,fileP1);
+
+ if ((rc = BuildCMapInfo(CMapP)) != 0)
+ return(rc);
+
+ /* Assume everything will be OK */
+ rc = 0;
+ rangecnt = 0;
+
+ do {
+ /* Scan the next token */
+ scan_token(inputP);
+ if (tokenType == TOKEN_INTEGER)
+ rangecnt = tokenValue.integer;
+
+ /* ==> tokenLength, tokenTooLong, tokenType, and */
+ /* tokenValue are now set */
+
+ switch (tokenType) {
+ case TOKEN_EOF:
+ case TOKEN_NONE:
+ case TOKEN_INVALID:
+ /* in this case we are done */
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ rc = SCAN_ERROR;
+ break;
+ case TOKEN_LITERAL_NAME:
+ /* Look up the name */
+ tokenStartP[tokenLength] = '\0';
+
+ rc = FindDictValue(CMapP->CMapInfoP);
+ /* we are not going to report errors */
+ rc = SCAN_OK;
+ break;
+ case TOKEN_NAME:
+ if (0 == strncmp(tokenStartP,"begincodespacerange",19)) {
+ CIDFontP->spacerangecnt++;
+ spacerangeP = (spacerange *)vm_alloc(sizeof(spacerange));
+ if (!spacerangeP) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ spacerangeP->next = NULL;
+ spacerangeP->rangecnt = rangecnt;
+ spacerangeP->spacecode =
+ (spacerangecode *)vm_alloc(rangecnt*sizeof(spacerangecode));
+ if (!spacerangeP->spacecode) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ for (i = 0; i < rangecnt; i++) {
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ spacerangeP->spacecode[i].srcCodeLo = 0;
+ for (j = 0; j < tokenLength; j++)
+ spacerangeP->spacecode[i].srcCodeLo +=
+ (unsigned char)tokenStartP[j] << (8 * (tokenLength - 1 - j));
+
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ spacerangeP->spacecode[i].srcCodeHi = 0;
+ for (j = 0; j < tokenLength; j++)
+ spacerangeP->spacecode[i].srcCodeHi +=
+ (unsigned char)tokenStartP[j] << (8 * (tokenLength - 1 - j));
+ }
+
+ if (CIDFontP->spacerangeP) {
+ if (CIDFontP->spacerangeP->next == NULL)
+ CIDFontP->spacerangeP->next = spacerangeP;
+ else {
+ spacerangeP->next = CIDFontP->spacerangeP->next;
+ CIDFontP->spacerangeP->next = spacerangeP;
+ }
+ } else
+ CIDFontP->spacerangeP = spacerangeP;
+
+ /* read "endcodespacerange" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || (tokenType == TOKEN_NAME &&
+ (strncmp(tokenStartP,"endcodespacerange",17) != 0))) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ }
+ if (0 == strncmp(tokenStartP,"begincidrange",13)) {
+ CIDFontP->cidrangecnt++;
+ cidrangeP = (cidrange *)vm_alloc(sizeof(cidrange));
+ if (!cidrangeP) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ cidrangeP->next = NULL;
+ cidrangeP->rangecnt = rangecnt;
+ cidrangeP->range =
+ (cidrangecode *)vm_alloc(rangecnt*sizeof(cidrangecode));
+ if (!cidrangeP->range) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ for (i = 0; i < rangecnt; i++) {
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ cidrangeP->range[i].srcCodeLo = 0;
+ for (j = 0; j < tokenLength; j++)
+ cidrangeP->range[i].srcCodeLo +=
+ (unsigned char)tokenStartP[j] << (8 * (tokenLength - 1 - j));
+ char_row = (cidrangeP->range[i].srcCodeLo >> 8) & 0xff;
+ char_col = cidrangeP->range[i].srcCodeLo & 0xff;
+ if (char_row < CMapP->firstRow)
+ CMapP->firstRow = char_row;
+ if (char_row > CMapP->lastRow)
+ CMapP->lastRow = char_row;
+ if (char_col < CMapP->firstCol)
+ CMapP->firstCol = char_col;
+ if (char_col > CMapP->lastCol)
+ CMapP->lastCol = char_col;
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ cidrangeP->range[i].srcCodeHi = 0;
+ for (j = 0; j < tokenLength; j++)
+ cidrangeP->range[i].srcCodeHi +=
+ (unsigned char)tokenStartP[j] << (8 * (tokenLength - 1 - j));
+ char_row = (cidrangeP->range[i].srcCodeHi >> 8) & 0xff;
+ char_col = cidrangeP->range[i].srcCodeHi & 0xff;
+ if (char_row < CMapP->firstRow)
+ CMapP->firstRow = char_row;
+ if (char_row > CMapP->lastRow)
+ CMapP->lastRow = char_row;
+ if (char_col < CMapP->firstCol)
+ CMapP->firstCol = char_col;
+ if (char_col > CMapP->lastCol)
+ CMapP->lastCol = char_col;
+ scan_token(inputP);
+ if (tokenType != TOKEN_INTEGER) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ cidrangeP->range[i].dstCIDLo = tokenValue.integer;
+ }
+
+ if (CIDFontP->cidrangeP) {
+ if (CIDFontP->cidrangeP->next == NULL)
+ CIDFontP->cidrangeP->next = cidrangeP;
+ else {
+ cidrangeP->next = CIDFontP->cidrangeP->next;
+ CIDFontP->cidrangeP->next = cidrangeP;
+ }
+ } else
+ CIDFontP->cidrangeP = cidrangeP;
+
+ /* read "endcidrange" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || (tokenType == TOKEN_NAME &&
+ (strncmp(tokenStartP,"endcidrange",11) != 0))) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ }
+
+ if (0 == strncmp(tokenStartP,"beginnotdefrange",16)) {
+ CIDFontP->notdefrangecnt++;
+ notdefrangeP = (cidrange *)vm_alloc(sizeof(cidrange));
+ if (!notdefrangeP) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ notdefrangeP->next = 0;
+ notdefrangeP->rangecnt = rangecnt;
+ notdefrangeP->range =
+ (cidrangecode *)vm_alloc(rangecnt*sizeof(cidrangecode));
+ if (!notdefrangeP->range) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ for (i = 0; i < rangecnt; i++) {
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ notdefrangeP->range[i].srcCodeLo = 0;
+ for (j = 0; j < tokenLength; j++)
+ notdefrangeP->range[i].srcCodeLo = (int)(tokenStartP[j] <<
+ (8 * (tokenLength - 1 - j)));
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ notdefrangeP->range[i].srcCodeHi = 0;
+ for (j = 0; j < tokenLength; j++)
+ notdefrangeP->range[i].srcCodeHi = (int)(tokenStartP[j] <<
+ (8 * (tokenLength - 1 - j)));
+ scan_token(inputP);
+ if (tokenType != TOKEN_INTEGER) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ notdefrangeP->range[i].dstCIDLo = tokenValue.integer;
+ }
+ if (CIDFontP->notdefrangeP) {
+ if (CIDFontP->notdefrangeP->next == NULL)
+ CIDFontP->notdefrangeP->next = notdefrangeP;
+ else {
+ notdefrangeP->next = CIDFontP->notdefrangeP->next;
+ CIDFontP->notdefrangeP->next = notdefrangeP;
+ }
+ } else
+ CIDFontP->notdefrangeP = notdefrangeP;
+
+ /* read "endnotdefrange" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || (tokenType == TOKEN_NAME &&
+ (strncmp(tokenStartP,"endnotdefrange",14) != 0))) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ }
+
+ if (0 == strncmp(tokenStartP,"endcmap",7)) {
+ if (CMapP->CMapInfoP[CMAPREGISTRY].value.data.valueP == NULL ||
+ CMapP->CMapInfoP[CMAPORDERING].value.data.valueP == NULL ||
+ CMapP->CMapInfoP[CMAPSUPPLEMENT].value.data.integer == -1) {
+ rc = SCAN_ERROR;
+ break;
+ } else {
+ rc = SCAN_FILE_EOF;
+ break;
+ }
+ }
+ break;
+ }
+ }
+ while (rc == 0);
+ fclose(inputP->data.fileP);
+ if (tokenTooLong)
+ rc = SCAN_OUT_OF_MEMORY;
+ if (rc == SCAN_OUT_OF_MEMORY) return(rc);
+
+ /* open the specified CIDFont file */
+ if (!(fileP = fopen(filename,filetype)))
+ return(SCAN_FILE_OPEN_ERROR);
+
+ inputP = &inputFile;
+ objFormatFile(inputP,fileP);
+ CIDWantFontInfo = TRUE;
+ TwoSubrs = FALSE;
+ rc = BuildCIDFontInfo(CIDFontP);
+ if (rc != 0) return(rc);
+
+ /* Assume everything will be OK */
+ rc = 0;
+
+ /* Loop until complete font is read */
+ do {
+ /* Scan the next token */
+ scan_token(inputP);
+
+ /* ==> tokenLength, tokenTooLong, tokenType, and tokenValue are */
+ /* now set */
+
+ switch (tokenType) {
+ case TOKEN_EOF:
+ case TOKEN_NONE:
+ case TOKEN_INVALID:
+ /* in this case we are done */
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ rc = SCAN_ERROR;
+ break;
+ case TOKEN_LITERAL_NAME:
+ /* Look up the name */
+ tokenStartP[tokenLength] = '\0';
+ if (0 == strncmp(tokenStartP,"FDArray",7))
+ InFDArray = TRUE;
+
+ if (CIDWantFontInfo) {
+ rc = FindDictValue(CIDFontP->CIDfontInfoP);
+ /* we are not going to report errors */
+ rc = SCAN_OK;
+ break;
+ }
+ break;
+ case TOKEN_STRING:
+ tokenStartP[tokenLength] = '\0';
+ if (0 == strncmp(tokenStartP,"Binary",6)) {
+ CIDFontP->binarydata = 1;
+ scan_token(inputP);
+ if (tokenType == TOKEN_INTEGER)
+ CIDFontP->bytecnt = tokenValue.integer;
+ else {
+ rc = SCAN_ERROR;
+ break;
+ }
+ } else if (0 == strncmp(tokenStartP,"Hex",3)) {
+ /* not yet supported */
+ rc = SCAN_ERROR;
+ break;
+#if 0
+ /* uncomment when the hex format is supported */
+ CIDFontP->binarydata = 0;
+ scan_token(inputP);
+ if (tokenType == TOKEN_INTEGER)
+ CIDFontP->bytecnt = tokenValue.integer;
+ else {
+ rc = SCAN_ERROR;
+ break;
+ }
+#endif
+ }
+ break;
+ case TOKEN_NAME:
+ /* end of PostScript and beginning of data */
+ if (0 == strncmp(tokenStartP,"StartData",9)) {
+ /* every CIDFont must have an FDArray */
+ /* check whether other required dictionary entries were found */
+ if (CIDFontP->CIDfontInfoP[CIDFDARRAY].value.data.arrayP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDFONTNAME].value.data.nameP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDFONTTYPE].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDVERSION].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDREGISTRY].value.data.valueP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDORDERING].value.data.valueP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDSUPPLEMENT].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDMAPOFFSET].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDFDBYTES].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDGDBYTES].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDCOUNT].value.data.integer == -1) {
+ rc = SCAN_ERROR;
+ break;
+ } else {
+ /* do Registry and Ordering entries match? */
+ if (strcmp(CIDFontP->CIDfontInfoP[CIDREGISTRY].value.data.valueP,
+ CMapP->CMapInfoP[CMAPREGISTRY].value.data.valueP) != 0 ||
+ strcmp(CIDFontP->CIDfontInfoP[CIDORDERING].value.data.valueP,
+ CMapP->CMapInfoP[CMAPORDERING].value.data.valueP) != 0) {
+ rc = SCAN_ERROR;
+ break;
+ } else {
+ fclose(inputP->data.fileP);
+ return(SCAN_OK);
+ }
+ }
+ }
+ break;
+ }
+
+ }
+ while (rc ==0);
+ fclose(inputP->data.fileP);
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ return(rc);
+}
+
+/*
+ * -------------------------------------------------------------------
+ * Scan the next token and convert it into an object
+ * Result is placed on the Operand Stack as next object
+ * -------------------------------------------------------------------
+ */
+int
+scan_cidtype1font(psfont *FontP)
+{
+ int i;
+ int begincnt = 0; /* counter for the number of unpaired begin operators */
+ int currentfilefound = 0;
+
+ WantFontInfo = TRUE;
+ InPrivateDict = FALSE;
+ TwoSubrs = FALSE;
+ rc = BuildFontInfo(FontP);
+ if (rc != 0) return(rc);
+
+ /* Assume everything will be OK */
+ rc = 0;
+ filterFile.data.fileP = NULL;
+
+ /* Loop until complete font is read */
+ do {
+ /* Scan the next token */
+ scan_token(inputP);
+
+ /* ==> tokenLength, tokenTooLong, tokenType, and tokenValue are */
+ /* now set */
+
+ switch (tokenType) {
+ case TOKEN_EOF:
+ case TOKEN_NONE:
+ case TOKEN_INVALID:
+ /* in this case we are done */
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ rc = SCAN_ERROR;
+ break;
+ case TOKEN_LITERAL_NAME:
+ /* Look up the name */
+ tokenStartP[tokenLength] = '\0';
+ if (InPrivateDict ) {
+ rc = FindDictValue(FontP->Private);
+ /* we are not going to report errors */
+ /* Sometimes the font file may test a value such as */
+ /* testing to see if the font is alreadly loaded with */
+ /* same UniqueID. We would faile on /UniqueID get */
+ /* because we are expecting a int to follow UniqueID*/
+ /* If the correct object type does not follow a Name*/
+ /* then we will skip over it without reporting error*/
+ rc = SCAN_OK;
+ break;
+ } /* end of reading Private dictionary */
+ else
+ if (0 == strncmp(tokenStartP,"Private",7) ) {
+ InPrivateDict = TRUE;
+ rc = BuildCIDType1Private(FontP);
+ break;
+ }
+ else
+ if (WantFontInfo) {
+ rc = FindDictValue(FontP->fontInfoP);
+ /* we are not going to report errors */
+ rc = SCAN_OK;
+ break;
+ }
+ break;
+ case TOKEN_NAME:
+ if (0 == strncmp(tokenStartP,"currentfile",11)) {
+ currentfilefound = 1;
+ break;
+ } else if (0 == strncmp(tokenStartP,"eexec",5)) {
+ if (currentfilefound == 1) {
+ currentfilefound = 0;
+ filterFile.data.fileP = CIDeexec(inputP->data.fileP);
+ if (filterFile.data.fileP == NULL) {
+ fclose(inputFile.data.fileP);
+ return(SCAN_FILE_OPEN_ERROR);
+ }
+ inputP = &filterFile;
+ } else {
+ rc = SCAN_ERROR;
+ break;
+ }
+ } else if (0 == strncmp(tokenStartP,"begin",5)) {
+ begincnt++;
+ currentfilefound = 0;
+ } else if (0 == strncmp(tokenStartP,"end",3)) {
+ currentfilefound = 0;
+ begincnt--;
+ if (begincnt == 0) {
+ if (filterFile.data.fileP != NULL) {
+ scan_token(inputP); /* get 'currentfile' */
+ scan_token(inputP); /* get 'closefile' */
+ inputP = &inputFile;
+ resetDecrypt();
+ inputP->data.fileP->b_cnt =
+ F_BUFSIZ - (inputP->data.fileP->b_ptr -
+ inputP->data.fileP->b_base);
+ if (inputP->data.fileP->b_cnt > 0) {
+ for (i = 0; i < inputP->data.fileP->b_cnt; i++)
+ if (*(inputP->data.fileP->b_ptr + i) == '%')
+ break;
+ if (i < inputP->data.fileP->b_cnt) {
+ inputP->data.fileP->b_cnt -= i;
+ inputP->data.fileP->b_ptr += i;
+ } else
+ inputP->data.fileP->b_cnt = 0;
+ }
+ }
+ rc = SCAN_OK;
+ return(rc);
+ }
+ if (begincnt < 0) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ }
+ break;
+ }
+
+ }
+ while (rc == 0);
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ return(rc);
+}
+#endif
+
/*
* -------------------------------------------------------------------
* Scan the next token and convert it into an object
* Result is placed on the Operand Stack as next object
* -------------------------------------------------------------------
*/
-int scan_font(FontP)
- psfont *FontP;
+int
+scan_font(psfont *FontP)
{
@@ -1403,7 +2237,7 @@ int scan_font(FontP)
filterFile.data.fileP = NULL;
inputP = &inputFile;
- if (fileP = T1Open(filename,filetype)) {
+ if ((fileP = T1Open(filename,filetype))) {
/* get the first byte of file */
V = _XT1getc(fileP);
/* if file starts with x'80' then skip next 5 bytes */
diff --git a/src/Type1/spaces.c b/src/Type1/spaces.c
index 8b28d37..8eb4b52 100644
--- a/src/Type1/spaces.c
+++ b/src/Type1/spaces.c
@@ -26,6 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/spaces.c,v 3.10 2002/02/18 20:51:57 herrb Exp $ */
/* SPACES CWEB V0021 ******** */
/*
:h1 id=spaces.SPACES Module - Handles Coordinate Spaces
@@ -37,6 +38,16 @@ This module is responsible for handling the TYPE1IMAGER "XYspace" object.
:h3.Include Files
*/
+
+#ifdef FONTMODULE
+#include "Xdefs.h" /* Bool declaration ??? */
+#include "Xmd.h" /* INT32 declaration ??? */
+#include "os.h"
+#include "xf86_ansic.h"
+#else
+#include "X11/Xos.h"
+#include "os.h"
+#endif
#include "objects.h"
#include "spaces.h"
#include "paths.h"
@@ -45,8 +56,12 @@ This module is responsible for handling the TYPE1IMAGER "XYspace" object.
#include "arith.h"
#include "trig.h"
-static void FindFfcn();
-static void FindIfcn();
+static void FindFfcn ( double cx, double cy,
+ convertFunc *fcnP );
+static void FindIfcn ( double cx, double cy,
+ fractpel *icxP, fractpel *icyP,
+ iconvertFunc *fcnP );
+
/*
:h3.Entry Points Provided to the TYPE1IMAGER User
*/
@@ -121,8 +136,8 @@ The XYspace structure represents the XYspace object.
static unsigned int SpaceID = 1;
-struct XYspace *CopySpace(S)
- register struct XYspace *S;
+struct XYspace *
+CopySpace(struct XYspace *S)
{
S = (struct XYspace *)Allocate(sizeof(struct XYspace), S, 0);
S->ID = NEXTID;
@@ -166,9 +181,9 @@ static struct XYspace identity = { SPACETYPE, ISPERMANENT(ON) + ISIMMORTAL(ON)
NULL, NULL,
NULL, NULL, NULL, NULL,
INVALIDID + 1, 0,
- FRACTFLOAT, 0.0, 0.0, FRACTFLOAT,
- 1.0/FRACTFLOAT, 0.0, 0.0, 1.0/FRACTFLOAT,
- 0, 0, 0, 0 };
+ {{{FRACTFLOAT, 0.0}, {0.0, FRACTFLOAT}},
+ {{1.0/FRACTFLOAT, 0.0}, {0.0, 1.0/FRACTFLOAT}}},
+ {{0, 0}, {0, 0}}};
struct XYspace *IDENTITY = &identity;
/*
@@ -182,12 +197,6 @@ static struct doublematrix contexts[MAXCONTEXTS];
static int nextcontext = 1;
/*SHARED LINE(S) ORIGINATED HERE*/
-
-#ifdef __STDC__
-#define pointer void *
-#else
-#define pointer char *
-#endif
/*
:h3.FindDeviceContext() - Find the Context Given a Device
@@ -197,8 +206,8 @@ transformation matrix in the context array. If it cannot find it,
it will allocate a new array entry and fill it out.
*/
-static int FindDeviceContext(device)
- pointer device; /* device token */
+static int
+FindDeviceContext(pointer device) /* device token */
{
double M[2][2]; /* temporary matrix */
float Xres,Yres; /* device resolution */
@@ -206,7 +215,7 @@ static int FindDeviceContext(device)
int rc = -1; /* return code for QueryDeviceState */
if (rc != 0) /* we only bother with this check once */
- abort("Context: QueryDeviceState didn't work");
+ Abort("Context: QueryDeviceState didn't work");
M[0][0] = M[1][0] = M[0][1] = M[1][1] = 0.0;
@@ -224,7 +233,7 @@ static int FindDeviceContext(device)
M[1][0] = -Yres; M[0][1] = -Xres;
break;
default:
- abort("QueryDeviceState returned invalid orientation");
+ Abort("QueryDeviceState returned invalid orientation");
}
return(FindContext(M));
}
@@ -237,8 +246,8 @@ the context array. If it cannot find it, it will allocate a new array
entry and fill it out.
*/
-int FindContext(M)
- double M[2][2]; /* array to search for */
+int
+FindContext(double M[2][2]) /* array to search for */
{
register int i; /* loop variable for search */
for (i=0; i < nextcontext; i++)
@@ -248,7 +257,7 @@ int FindContext(M)
if (i >= nextcontext) {
if (i >= MAXCONTEXTS)
- abort("Context: out of them");
+ Abort("Context: out of them");
LONGCOPY(contexts[i].normal, M, sizeof(contexts[i].normal));
MatrixInvert(M, contexts[i].inverse);
nextcontext++;
@@ -265,9 +274,9 @@ array index, then transforming IDENTITY space to create an appropriate
cooridnate space.
*/
-struct XYspace *Context(device, units)
- pointer device; /* device token */
- double units; /* multiples of one inch */
+struct XYspace *
+Context(pointer device, /* device token */
+ double units) /* multiples of one inch */
{
double M[2][2]; /* device transformation matrix */
register int n; /* will hold device context number */
@@ -308,11 +317,11 @@ So this subroutine, given an :f/M/and an object, finds the :f/D/ for that
object and modifies :f/M/ so it is :f/D sup <-1> times M times D/.
*/
-static void ConsiderContext(obj, M)
- register struct xobject *obj; /* object to be transformed */
- register double M[2][2]; /* matrix (may be changed) */
+static void
+ConsiderContext(struct xobject *obj, /* object to be transformed */
+ double M[2][2]) /* matrix (may be changed) */
{
- register int context; /* index in contexts array */
+ register int context = 0; /* index in contexts array */
if (obj == NULL) return;
@@ -360,19 +369,19 @@ These secondary routines come in many flavors to handle different
special cases as quickly as possible.
*/
-static void FXYConvert(pt, S, x, y)
- register struct fractpoint *pt; /* point to set */
- register struct XYspace *S; /* relevant coordinate space */
- register double x,y; /* user's coordinates of point */
+static void
+FXYConvert(struct fractpoint *pt, /* point to set */
+ struct XYspace *S, /* relevant coordinate space */
+ double x, double y) /* user's coordinates of point */
{
pt->x = (*S->xconvert)(S->tofract.normal[0][0], S->tofract.normal[1][0], x, y);
pt->y = (*S->yconvert)(S->tofract.normal[0][1], S->tofract.normal[1][1], x, y);
}
-static void IXYConvert(pt, S, x, y)
- register struct fractpoint *pt; /* point to set */
- register struct XYspace *S; /* relevant coordinate space */
- register long x,y; /* user's coordinates of point */
+static void
+IXYConvert(struct fractpoint *pt, /* point to set */
+ struct XYspace *S, /* relevant coordinate space */
+ long x, long y) /* user's coordinates of point */
{
pt->x = (*S->ixconvert)(S->itofract[0][0], S->itofract[1][0], x, y);
pt->y = (*S->iyconvert)(S->itofract[0][1], S->itofract[1][1], x, y);
@@ -385,10 +394,10 @@ precision in the answer with fixed point arithmetic. So, we force the
integers to floats, and do the arithmetic all with floats:
*/
-static void ForceFloat(pt, S, x, y)
- register struct fractpoint *pt; /* point to set */
- register struct XYspace *S; /* relevant coordinate space */
- register long x,y; /* user's coordinates of point */
+static void
+ForceFloat(struct fractpoint *pt, /* point to set */
+ struct XYspace *S, /* relevant coordinate space */
+ long x, long y) /* user's coordinates of point */
{
(*S->convert)(pt, S, (double) x, (double) y);
}
@@ -402,9 +411,9 @@ FXonly() and FYonly() are special cases when one of the coefficients
is 0.0.
*/
-static fractpel FXYboth(cx, cy, x, y)
- register double cx,cy; /* x and y coefficients */
- register double x,y; /* user x,y */
+static fractpel
+FXYboth(double cx, double cy, /* x and y coefficients */
+ double x, double y) /* user x,y */
{
register double r; /* temporary float */
@@ -413,9 +422,9 @@ static fractpel FXYboth(cx, cy, x, y)
}
/*ARGSUSED*/
-static fractpel FXonly(cx, cy, x, y)
- register double cx,cy; /* x and y coefficients */
- register double x,y; /* user x,y */
+static fractpel
+FXonly(double cx, double cy, /* x and y coefficients */
+ double x, double y) /* user x,y */
{
register double r; /* temporary float */
@@ -424,9 +433,9 @@ static fractpel FXonly(cx, cy, x, y)
}
/*ARGSUSED*/
-static fractpel FYonly(cx, cy, x, y)
- register double cx,cy; /* x and y coefficients */
- register double x,y; /* user x,y */
+static fractpel
+FYonly(double cx, double cy, /* x and y coefficients */
+ double x, double y) /* user x,y */
{
register double r; /* temporary float */
@@ -444,25 +453,25 @@ IXYboth() is the general purpose routine; IXonly() and IYonly() are
special cases when one of the coefficients is 0.
*/
-static fractpel IXYboth(cx, cy, x, y)
- register fractpel cx,cy; /* x and y coefficients */
- register long x,y; /* user x,y */
+static fractpel
+IXYboth(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
{
return(x * cx + y * cy);
}
/*ARGSUSED*/
-static fractpel IXonly(cx, cy, x, y)
- register fractpel cx,cy; /* x and y coefficients */
- register long x,y; /* user x,y */
+static fractpel
+IXonly(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
{
return(x * cx);
}
/*ARGSUSED*/
-static fractpel IYonly(cx, cy, x, y)
- register fractpel cx,cy; /* x and y coefficients */
- register long x,y; /* user x,y */
+static fractpel
+IYonly(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
{
return(y * cy);
}
@@ -485,25 +494,25 @@ Note that it is perfectly possible for us to calculate X with the
on how the functions in the XYspace structure are filled out.
*/
-static fractpel FPXYboth(cx, cy, x, y)
- register fractpel cx,cy; /* x and y coefficients */
- register long x,y; /* user x,y */
+static fractpel
+FPXYboth(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
{
return( FPmult(x, cx) + FPmult(y, cy) );
}
/*ARGSUSED*/
-static fractpel FPXonly(cx, cy, x, y)
- register fractpel cx,cy; /* x and y coefficients */
- register long x,y; /* user x,y */
+static fractpel
+FPXonly(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
{
return( FPmult(x, cx) );
}
/*ARGSUSED*/
-static fractpel FPYonly(cx, cy, x, y)
- register fractpel cx,cy; /* x and y coefficients */
- register long x,y; /* user x,y */
+static fractpel
+FPYonly(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
{
return( FPmult(y, cy) );
}
@@ -518,8 +527,8 @@ in an XYspace structure, and also fills the "helper"
functions that actually do the work.
*/
-static void FillOutFcns(S)
- register struct XYspace *S; /* functions will be set in this structure */
+static void
+FillOutFcns(struct XYspace *S) /* functions will be set in this structure */
{
S->convert = FXYConvert;
S->iconvert = IXYConvert;
@@ -542,9 +551,9 @@ This function tests for the special case of one of the coefficients
being zero:
*/
-static void FindFfcn(cx, cy, fcnP)
- register double cx,cy; /* x and y coefficients */
- register fractpel (**fcnP)(); /* pointer to function to set */
+static void
+FindFfcn(double cx, double cy, /* x and y coefficients */
+ convertFunc *fcnP) /* pointer to function to set */
{
if (cx == 0.0)
*fcnP = FYonly;
@@ -565,10 +574,10 @@ we store a NULL indicating that this we should do the conversion in
floating point.
*/
-static void FindIfcn(cx, cy, icxP, icyP, fcnP)
- register double cx,cy; /* x and y coefficients */
- register fractpel *icxP,*icyP; /* fixed point coefficients to set */
- register fractpel (**fcnP)(); /* pointer to function to set */
+static void
+FindIfcn(double cx, double cy, /* x and y coefficients */
+ fractpel *icxP, fractpel *icyP, /* fixed point coefficients to set */
+ iconvertFunc *fcnP) /* pointer to function to set */
{
register fractpel imax; /* maximum of cx and cy */
@@ -635,10 +644,10 @@ zero determinants, so by convention, we mark the matrix is invalid by
marking both X terms zero.
*/
-void UnConvert(S, pt, xp, yp)
- register struct XYspace *S; /* relevant coordinate space */
- register struct fractpoint *pt; /* device coordinates */
- double *xp,*yp; /* where to store resulting x,y */
+void
+UnConvert(struct XYspace *S, /* relevant coordinate space */
+ struct fractpoint *pt, /* device coordinates */
+ double *xp, double *yp) /* where to store resulting x,y */
{
double x,y;
@@ -668,9 +677,9 @@ get the same result if we did S, then R, then T on the space and mapping
an unmodified font through that space.
*/
-struct xobject *t1_Xform(obj, M)
- register struct xobject *obj; /* object to transform */
- register double M[2][2]; /* transformation matrix */
+struct xobject *
+t1_Xform(struct xobject *obj, /* object to transform */
+ double M[2][2]) /* transformation matrix */
{
if (obj == NULL)
return(NULL);
@@ -703,7 +712,8 @@ transformation matrix and keep the handles up to date.
if (ISPATHTYPE(obj->type)) {
struct XYspace pseudo; /* local temporary space */
PseudoSpace(&pseudo, M);
- return((struct xobject *) PathTransform(obj, &pseudo));
+ return((struct xobject *) PathTransform((struct segment *)obj,
+ &pseudo));
}
@@ -734,9 +744,10 @@ transformation matrix and keep the handles up to date.
This is the external user's entry point.
*/
-struct xobject *t1_Transform(obj, cxx, cyx, cxy, cyy)
- struct xobject *obj;
- double cxx,cyx,cxy,cyy; /* 2x2 transform matrix elements in row order */
+struct xobject *
+t1_Transform(struct xobject *obj,
+ double cxx, double cyx, /* 2x2 transform matrix elements */
+ double cxy, double cyy) /* in row order */
{
double M[2][2];
@@ -756,9 +767,9 @@ struct xobject *t1_Transform(obj, cxx, cyx, cxy, cyy)
This is a user operator.
*/
-struct xobject *t1_Scale(obj, sx, sy)
- struct xobject *obj; /* object to scale */
- double sx,sy; /* scale factors in x and y */
+struct xobject *
+t1_Scale(struct xobject *obj, /* object to scale */
+ double sx, double sy) /* scale factors in x and y */
{
double M[2][2];
IfTrace3((MustTraceCalls),"Scale(%z, %f, %f)\n", obj, &sx, &sy);
@@ -777,9 +788,9 @@ and accuracy within the DegreeSin() and DegreeCos() routines themselves.
*/
#ifdef notdef
-struct xobject *xiRotate(obj, degrees)
- struct xobject *obj; /* object to be transformed */
- double degrees; /* degrees of COUNTER-clockwise rotation */
+struct xobject *
+xiRotate(struct xobject *obj, /* object to be transformed */
+ double degrees) /* degrees of COUNTER-clockwise rotation */
{
double M[2][2];
@@ -804,9 +815,9 @@ subroutine takes the arbitrary matrix and builds a coordinate
space, with all its nifty function pointers.
*/
-void PseudoSpace(S, M)
- struct XYspace *S; /* coordinate space structure to fill out */
- double M[2][2]; /* matrix that will become 'tofract.normal' */
+void
+PseudoSpace(struct XYspace *S, /* coordinate space structure to fill out */
+ double M[2][2]) /* matrix that will become 'tofract.normal' */
{
S->type = SPACETYPE;
S->flag = ISPERMANENT(ON) + ISIMMORTAL(ON);
@@ -849,9 +860,9 @@ To remind myself, matrix multiplication goes rows of A times columns
of B.
The output matrix may be the same as one of the input matrices.
*/
-void MatrixMultiply(A, B, C)
- register double A[2][2],B[2][2]; /* input matrices */
- register double C[2][2]; /* output matrix */
+void
+MatrixMultiply(double A[2][2], double B[2][2], /* input matrices */
+ double C[2][2]) /* output matrix */
{
register double txx,txy,tyx,tyy;
@@ -871,9 +882,9 @@ void MatrixMultiply(A, B, C)
My reference for matrix inversion was :hp1/Elementary Linear Algebra/
by Paul C. Shields, Worth Publishers, Inc., 1968.
*/
-void MatrixInvert(M, Mprime)
- double M[2][2]; /* input matrix */
- double Mprime[2][2]; /* output inverted matrix */
+void
+MatrixInvert(double M[2][2], /* input matrix */
+ double Mprime[2][2]) /* output inverted matrix */
{
register double D; /* determinant of matrix M */
register double txx,txy,tyx,tyy;
@@ -885,7 +896,7 @@ void MatrixInvert(M, Mprime)
D = M[1][1] * M[0][0] - M[1][0] * M[0][1];
if (D == 0.0)
- abort("MatrixInvert: can't");
+ Abort("MatrixInvert: can't");
Mprime[0][0] = tyy / D;
Mprime[1][0] = -txy / D;
@@ -904,7 +915,8 @@ maps 72nds of an inch to pels on the default device.
struct XYspace *USER = &identity;
-void InitSpaces()
+void
+InitSpaces(void)
{
IDENTITY->type = SPACETYPE;
FillOutFcns(IDENTITY);
@@ -930,9 +942,10 @@ must be taken out before we return the matrix to the user. Fortunately,
this is simple: just multiply by the inverse of IDENTITY!
*/
-void QuerySpace(S, cxxP, cyxP, cxyP, cyyP)
- register struct XYspace *S; /* space asked about */
- register double *cxxP,*cyxP,*cxyP,*cyyP; /* where to put answer */
+void
+QuerySpace(struct XYspace *S, /* space asked about */
+ double *cxxP, double *cyxP, /* where to put answer */
+ double *cxyP, double *cyyP)
{
double M[2][2]; /* temp matrix to build user's answer */
@@ -959,9 +972,9 @@ We make sure we have N (FRACTBITS/4) digits past the decimal point.
*/
#define FRACTMASK ((1<<FRACTBITS)-1) /* mask for fractional part */
-void FormatFP(string, fpel)
- register char *string; /* output string */
- register fractpel fpel; /* fractional pel input */
+void
+FormatFP(char *string, /* output string */
+ fractpel fpel) /* fractional pel input */
{
char temp[8];
register char *s;
@@ -974,18 +987,18 @@ void FormatFP(string, fpel)
else
sign = "";
- sprintf(temp, "000%x", fpel & FRACTMASK);
+ sprintf(temp, "000%lx", fpel & FRACTMASK);
s = temp + strlen(temp) - (FRACTBITS/4);
- sprintf(string, "%s%d.%sx", sign, fpel >> FRACTBITS, s);
+ sprintf(string, "%s%d.%sx", sign, (int)(fpel >> FRACTBITS), s);
}
/*
:h3.DumpSpace() - Display a Coordinate Space
*/
/*ARGSUSED*/
-void DumpSpace(S)
- register struct XYspace *S;
+void
+DumpSpace(struct XYspace *S)
{
IfTrace4(TRUE,"--Coordinate space at %x,ID=%d,convert=%x,iconvert=%x\n",
S, S->ID, S->convert, S->iconvert);
diff --git a/src/Type1/spaces.h b/src/Type1/spaces.h
index 21eee17..efbcecb 100644
--- a/src/Type1/spaces.h
+++ b/src/Type1/spaces.h
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/spaces.h,v 3.4 2001/01/17 19:43:23 dawes Exp $ */
+
/*SHARED*/
#define USER t1_User
@@ -37,35 +39,26 @@
#define Scale(o,sx,sy) t1_Scale(o,sx,sy)
#define QuerySpace(S,f1,f2,f3,f4) t1_QuerySpace(S,f1,f2,f3,f4)
#define Warp(s1,o,s2) t1_Warp(s1,o,s2)
-
-struct XYspace *t1_Context(); /* creates a coordinate space for a device */
-struct xobject *t1_Transform(); /* transform an object */
+
+/* IDENTITY space */
+extern struct XYspace *IDENTITY;
+
+/* creates a coordinate space for a device */
+extern struct XYspace *Context(pointer device, double units);
+/* transform an object */
+extern struct xobject *t1_Transform ( struct xobject *obj, double cxx,
+ double cyx, double cxy, double cyy );
+#if 0
struct xobject *t1_Rotate(); /* rotate an object */
-struct xobject *t1_Scale(); /* scale an object */
+#endif
+/* scale an object */
+extern struct xobject *t1_Scale ( struct xobject *obj, double sx, double sy );
+#if 0
struct xobject *t1_Warp(); /* transform like delta of two spaces */
-void t1_QuerySpace(); /* returns coordinate space matrix */
-
-/*END SHARED*/
-/*SHARED*/
-
-#define DeviceResolution t1_DeviceResolution
-#define InitSpaces() t1_InitSpaces()
-#define CopySpace(s) t1_CopySpace(s)
-#define Xform(o,M) t1_Xform(o,M)
-#define UnConvert(S,pt,xp,yp) t1_UnConvert(S,pt,xp,yp)
-#define MatrixMultiply(A,B,C) t1_MMultiply(A,B,C)
-#define MatrixInvert(A,B) t1_MInvert(A,B)
-#define PseudoSpace(S,M) t1_PseudoSpace(S,M)
-#define FindContext(M) t1_FindContext(M)
-
-void t1_InitSpaces(); /* initialize pre-defined coordinate spaces */
-struct XYspace *t1_CopySpace(); /* duplicate a coordinate space */
-struct xobject *t1_Xform(); /* transform object by matrix */
-void t1_UnConvert(); /* return user coordinates from device coordinates */
-void t1_MMultiply(); /* multiply two matrices */
-void t1_MInvert(); /* invert a matrix */
-void t1_PseudoSpace(); /* force a coordinate space from a matrix */
-int t1_FindContext(); /* return the "context" represented by a matrix */
+#endif
+/* returns coordinate space matrix */
+extern void t1_QuerySpace ( struct XYspace *S, double *cxxP, double *cyxP,
+ double *cxyP, double *cyyP );
/*END SHARED*/
/*SHARED*/
@@ -108,15 +101,24 @@ struct doublematrix {
/*END SHARED*/
/*SHARED*/
+struct fractpoint {
+ fractpel x,y;
+} ;
+
+/*SHARED*/
+
+typedef fractpel (*convertFunc)(double, double, double, double);
+typedef fractpel (*iconvertFunc)(fractpel, fractpel, long, long);
+
struct XYspace {
XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
/* type = SPACETYPE */
- void (*convert)(); /* calculate "fractpoint" X,Y from float X,Y */
- void (*iconvert)(); /* calculate "fractpoint" X,Y from int X,Y */
- fractpel (*xconvert)(); /* subroutine of convert */
- fractpel (*yconvert)(); /* subroutine of convert */
- fractpel (*ixconvert)(); /* subroutine of iconvert */
- fractpel (*iyconvert)(); /* subroutine of iconvert */
+ void (*convert)(struct fractpoint *, struct XYspace *, double, double); /* calculate "fractpoint" X,Y from float X,Y */
+ void (*iconvert)(struct fractpoint *, struct XYspace *, long, long); /* calculate "fractpoint" X,Y from int X,Y */
+ convertFunc xconvert; /* subroutine of convert */
+ convertFunc yconvert; /* subroutine of convert */
+ iconvertFunc ixconvert; /* subroutine of iconvert */
+ iconvertFunc iyconvert; /* subroutine of iconvert */
int ID; /* unique identifier (used in font caching) */
unsigned char context; /* device context of coordinate space */
struct doublematrix tofract; /* xform to get to fractional pels */
@@ -126,15 +128,45 @@ struct XYspace {
#define INVALIDID 0 /* no valid space will have this ID */
/*END SHARED*/
+/*END SHARED*/
/*SHARED*/
-struct fractpoint {
- fractpel x,y;
-} ;
+#define DeviceResolution t1_DeviceResolution
+#define InitSpaces t1_InitSpaces
+#define CopySpace(s) t1_CopySpace(s)
+#define Xform(o,M) t1_Xform(o,M)
+#define UnConvert(S,pt,xp,yp) t1_UnConvert(S,pt,xp,yp)
+#define MatrixMultiply(A,B,C) t1_MMultiply(A,B,C)
+#define MatrixInvert(A,B) t1_MInvert(A,B)
+#define PseudoSpace(S,M) t1_PseudoSpace(S,M)
+#define FindContext(M) t1_FindContext(M)
+/* initialize pre-defined coordinate spaces */
+extern void t1_InitSpaces ( void );
+/* duplicate a coordinate space */
+extern struct XYspace *t1_CopySpace ( struct XYspace *S );
+/* transform object by matrix */
+extern struct xobject *t1_Xform ( struct xobject *obj, double M[2][2] );
+/* return user coordinates from device coordinates */
+extern void t1_UnConvert ( struct XYspace *S, struct fractpoint *pt,
+ double *xp, double *yp );
+/* multiply two matrices */
+extern void t1_MMultiply ( double A[2][2], double B[2][2], double C[2][2] );
+/* invert a matrix */
+extern void t1_MInvert ( double M[2][2], double Mprime[2][2] );
+/* force a coordinate space from a matrix */
+extern void t1_PseudoSpace ( struct XYspace *S, double M[2][2] );
+/* return the "context" represented by a matrix */
+int t1_FindContext(double M[2][2]);
+
/*END SHARED*/
/*SHARED*/
#define NULLCONTEXT 0
/*END SHARED*/
+
+/* dump a coordinate space structure */
+extern void t1_DumpSpace ( struct XYspace *S );
+/* dump a format a "fractpel" coordinate */
+extern void t1_FormatFP ( char *string, fractpel fpel );
diff --git a/src/Type1/t1funcs.c b/src/Type1/t1funcs.c
index ef113db..20b7b66 100644
--- a/src/Type1/t1funcs.c
+++ b/src/Type1/t1funcs.c
@@ -54,6 +54,24 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/t1funcs.c,v 3.30 2002/12/09 17:29:59 dawes Exp $ */
/*
@@ -82,8 +100,14 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-
+
+#ifndef FONTMODULE
#include <string.h>
+#ifdef BUILDCID
+#include <stdlib.h>
+#include <sys/types.h>
+#include <dirent.h>
+#endif
#ifdef _XOPEN_SOURCE
#include <math.h>
#else
@@ -92,54 +116,386 @@ from The Open Group.
#undef _XOPEN_SOURCE
#endif
#include "X11/Xfuncs.h"
+#ifdef USE_MMAP
+#include <sys/types.h>
+#include <sys/mman.h>
+#endif
+#else
+#include "Xmd.h"
+#include "Xdefs.h"
+#include "xf86_ansic.h"
+#endif
+
+#include "os.h"
#include "fntfilst.h"
+#include "fontutil.h"
#include "FSproto.h"
-#include "t1intf.h"
+#include "fontenc.h"
+#include "t1unicode.h"
+#ifdef BUILDCID
+#include "range.h"
+#endif
+
#include "objects.h"
#include "spaces.h"
+#include "paths.h"
#include "regions.h"
#include "t1stdio.h"
#include "util.h"
#include "fontfcn.h"
-
-int Type1OpenScalable ();
-static int Type1GetGlyphs();
-void Type1CloseFont();
-extern int Type1GetInfoScalable ();
-
-static int Type1GetMetrics ();
+#include "t1intf.h"
+
+
+static int Type1GetGlyphs ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs );
+
+#ifdef BUILDCID
+#define CMapDir "/CMap/"
+#define CFMDir "/CFM/"
+#define CIDFontDir "/CIDFont/"
+#endif
+
+static int Type1GetMetrics ( FontPtr pFont, unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount,
+ xCharInfo **glyphs );
+
#define minchar(p) ((p).min_char_low + ((p).min_char_high << 8))
#define maxchar(p) ((p).max_char_low + ((p).max_char_high << 8))
-static void fillrun();
-
+static void fillrun ( char *p, pel x0, pel x1, int bit );
extern psfont *FontP;
extern psobj *ISOLatin1EncArrayP;
-extern unsigned long *Xalloc();
-static void fill();
+#ifdef BUILDCID
+extern char CurCIDFontName[];
+extern char CurCMapName[];
+
+static CharInfoPtr CIDGetGlyph ( FontPtr pFont, unsigned int charcode,
+ CharInfoPtr pci );
+
+extern cidfont *CIDFontP;
+extern cmapres *CMapP;
+#endif
+
+static void fill ( char *dest, int h, int w, struct region *area, int byte,
+ int bit, int wordsize );
+
+#ifdef BUILDCID
+int
+CIDOpenScalable (FontPathElementPtr fpe,
+ FontPtr *ppFont,
+ int flags,
+ FontEntryPtr entry,
+ char *fileName,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
+{
+ FontPtr pFont;
+ int bit,
+ byte,
+ glyph,
+ scan,
+ image;
+ int pad,wordsize; /* scan & image in bits */
+ long *pool; /* memory pool for ximager objects */
+ int size; /* for memory size calculations */
+ struct XYspace *S; /* coordinate space for character */
+ register int i;
+ int nchars, len, rc;
+ cidglyphs *cid;
+ char *p;
+ double t1 = .001, t2 = 0.0, t3 = 0.0, t4 = .001;
+ double sxmult;
+ char CIDFontName[CID_NAME_MAX];
+ char CMapName[CID_NAME_MAX];
+ char cidfontname[CID_PATH_MAX];
+ char cmapname[CID_PATH_MAX];
+ char *path;
+ char cidfontpath[CID_PATH_MAX];
+ char cmappath[CID_PATH_MAX];
+#if defined(HAVE_CFM) || defined(CID_ALL_CHARS)
+ char cfmdir[CID_PATH_MAX];
+ char cfmfilename[CID_NAME_MAX];
+#endif
+#if defined(CID_ALL_CHARS)
+ char *cf;
+#endif
+ long sAscent, sDescent;
+
+ /* check the font name */
+ len = strlen(fileName);
+ if (len <= 0 || len > CID_NAME_MAX - 1)
+ return BadFontName;
+
+#if defined(HAVE_CFM) || defined(CID_ALL_CHARS)
+ strcpy(cfmdir, fileName);
+ p = strrchr(cfmdir, '/');
+ if (p) *p = '\0';
+#endif
+
+ path = fileName;
+ if (!(fileName = strrchr(fileName, '/')))
+ return BadFontName;
+
+ len = fileName - path;
+ strncpy(cidfontpath, path, len);
+ cidfontpath[len] = '\0';
+ strcpy(cmappath, cidfontpath);
+ strcat(cmappath, CMapDir);
+#ifdef HAVE_CFM
+ strcpy(cfmdir, cidfontpath);
+ strcat(cfmdir, CFMDir);
+#endif
+ strcat(cidfontpath, CIDFontDir);
+
+ fileName++;
+
+ /* extract the CIDFontName and CMapName from the font name */
+ /* check for <CIDFontName>--<CMapName> */
+ if ((p = strstr(fileName, "--"))) {
+ if (p == fileName)
+ return BadFontName;
+ else {
+ strcpy(CIDFontName, fileName);
+ CIDFontName[p - fileName] = '\0';
+ p += 2;
+ i = 0;
+ while (*p && *p != '.')
+ CMapName[i++] = *p++;
+ CMapName[i] = '\0';
+ if ((len = strlen(CMapName)) <= 0)
+ return BadFontName;
+ }
+ } else
+ return BadFontName;
+
+ /* The CMap files whose names end with -V are not yet supported */
+ len = strlen(CMapName);
+ if ((len >= 2 && CMapName[len - 2] == '-' && CMapName[len - 1] == 'V') ||
+ (len == 1 && CMapName[len - 1] == 'V'))
+ return BadFontName;
+
+ /* Reject ridiculously small font sizes that will blow up the math */
+ if (hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]) < 1.0 ||
+ hypot(vals->pixel_matrix[2], vals->pixel_matrix[3]) < 1.0)
+ return BadFontName;
+
+#ifdef CID_ALL_CHARS
+ if ((cf = getenv("CFMDIR")) == NULL)
+ strcat(cfmdir, CFMDir);
+ else {
+ strcpy(cfmdir, cf);
+ strcat(cfmdir, "/");
+ }
+#endif
+
+#if defined(HAVE_CFM) || defined(CID_ALL_CHARS)
+ strcpy(cfmfilename, cfmdir);
+ strcat(cfmfilename, CIDFontName);
+ strcat(cfmfilename, "--");
+ strcat(cfmfilename, CMapName);
+ strcat(cfmfilename, ".cfm");
+#endif
+
+ /* create a full-path name for a CIDFont file */
+ if (strlen(cidfontpath) + strlen(CIDFontName) + 2 >
+ CID_PATH_MAX)
+ return BadFontName;
+ strcpy(cidfontname, cidfontpath);
+ strcat(cidfontname, CIDFontName);
+
+ /* create a full-path name for a CMap file */
+ if (strlen(cmappath) + strlen(CMapName) + 2 > CID_PATH_MAX)
+ return BadFontName;
+ strcpy(cmapname, cmappath);
+ strcat(cmapname, CMapName);
+
+ /* set up default values */
+ FontDefaultFormat(&bit, &byte, &glyph, &scan);
+ /* get any changes made from above */
+ rc = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);
+ if (rc != Successful)
+ return rc;
+
+ pad = glyph * 8;
+ wordsize = scan * 8;
+
+#define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
+
+ if (!(pFont = CreateFontRec()))
+ return AllocError;
+
+ cid = (cidglyphs *)xalloc(sizeof(cidglyphs));
+ if (cid == NULL) {
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ bzero(cid, sizeof(cidglyphs));
+
+ /* heuristic for "maximum" size of pool we'll need: */
+ size = 200000 + 600 *
+ (int)hypot(vals->pixel_matrix[2], vals->pixel_matrix[3])
+ * sizeof(short);
+ if (size < 0 || NULL == (pool = (long *) xalloc(size))) {
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+
+ addmemory(pool, size);
+
+ /* load font if not already loaded */
+ if (!CIDfontfcnA(cidfontname, cmapname, &rc)) {
+ FontP = NULL;
+ delmemory();
+ xfree(pool);
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+
+ FontP = NULL;
+
+ S = (struct XYspace *) t1_Transform((struct xobject *)IDENTITY,
+ t1, t2, t3, t4);
+
+ S = (struct XYspace *) Permanent(t1_Transform((struct xobject *)S,
+ vals->pixel_matrix[0],
+ -vals->pixel_matrix[1],
+ vals->pixel_matrix[2],
+ -vals->pixel_matrix[3]));
+
+ /* multiplier for computation of raw values */
+ sxmult = hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]);
+ if (sxmult > EPS) sxmult = 1000.0 / sxmult;
+
+ pFont->info.firstRow = CMapP->firstRow;
+ pFont->info.firstCol = CMapP->firstCol;
+ pFont->info.lastRow = CMapP->lastRow;
+ pFont->info.lastCol = CMapP->lastCol;
+
+ nchars = (pFont->info.lastRow - pFont->info.firstRow + 1) *
+ (pFont->info.lastCol - pFont->info.firstCol + 1);
+
+ delmemory();
+ xfree(pool);
+
+ if (pFont->info.firstCol > pFont->info.lastCol)
+ {
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return BadFontName;
+ }
+
+ cid->glyphs = (CharInfoRec **)xalloc(nchars*sizeof(CharInfoRec *));
+ if (cid->glyphs == NULL) {
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ bzero(cid->glyphs, nchars*sizeof(CharInfoRec *));
+
+ pFont->info.defaultCh = 0;
+ pFont->format = format;
+
+ pFont->bit = bit;
+ pFont->byte = byte;
+ pFont->glyph = glyph;
+ pFont->scan = scan;
+
+ pFont->get_metrics = CIDGetMetrics;
+ pFont->get_glyphs = CIDGetGlyphs;
+ pFont->unload_font = CIDCloseFont;
+ pFont->unload_glyphs = NULL;
+ pFont->refcnt = 0;
+
+ len = strlen(cidfontname);
+ cid->CIDFontName = (char *)xalloc(len + 1);
+ if (cid->CIDFontName == NULL) {
+ xfree(cid->glyphs);
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ strcpy(cid->CIDFontName, cidfontname);
+
+ len = strlen(cmapname);
+ cid->CMapName = (char *)xalloc(len + 1);
+ if (cid->CMapName == NULL) {
+ xfree(cid->CIDFontName);
+ xfree(cid->glyphs);
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ strcpy(cid->CMapName, cmapname);
+
+ cid->pixel_matrix[0] = vals->pixel_matrix[0];
+ cid->pixel_matrix[1] = vals->pixel_matrix[1];
+ cid->pixel_matrix[2] = vals->pixel_matrix[2];
+ cid->pixel_matrix[3] = vals->pixel_matrix[3];
+
+ pFont->fontPrivate = (unsigned char *)cid;
+
+ pFont->info.fontAscent =
+ (CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[3].data.integer *
+ vals->pixel_matrix[3] +
+ (CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[3].data.integer >
+ 0 ? 500 : -500)) / 1000;
+
+ pFont->info.fontDescent =
+ -(int)((double)CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[1].data.integer
+ * vals->pixel_matrix[3] +
+ (CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[1].data.integer >
+ 0 ? 500 : -500)) / 1000;
+
+ /* Adobe does not put isFixedPitch entries in CID-keyed fonts. */
+ /* CID-keyed are not constant-width fonts. */
+ pFont->info.constantWidth = 0;
+
+ sAscent = CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[3].data.integer;
+ sDescent = -CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[1].data.integer;
+
+ if (strncmp(entry->name.name, "-bogus", 6)) {
+#ifdef CID_ALL_CHARS
+ ComputeBoundsAllChars(pFont, cfmfilename, sxmult);
+#else
+#ifdef HAVE_CFM
+ CIDFillFontInfo(pFont, vals, cidfontname, entry->name.name, cmapname,
+ cfmfilename, sAscent, sDescent, sxmult);
+#else
+ CIDFillFontInfo(pFont, vals, cidfontname, entry->name.name, cmapname,
+ sAscent, sDescent, sxmult);
+#endif /* HAVE_CFM */
+#endif /* CID_ALL_CHARS */
+ }
+
+ *ppFont = pFont;
+
+ return Successful;
+}
+#endif
/*ARGSUSED*/
-int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
- fmask, non_cachable_font)
- FontPathElementPtr fpe;
- FontPtr *ppFont;
- int flags;
- FontEntryPtr entry;
- char *fileName;
- FontScalablePtr vals;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- FontPtr non_cachable_font; /* We don't do licensing */
+int
+Type1OpenScalable (FontPathElementPtr fpe,
+ FontPtr *ppFont,
+ int flags,
+ FontEntryPtr entry,
+ char *fileName,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
{
- extern struct XYspace *IDENTITY;
- extern Bool fontfcnA();
- extern struct region *fontfcnB();
-
-
FontPtr pFont;
int bit,
byte,
@@ -147,7 +503,7 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
scan,
image;
int pad,wordsize; /* scan & image in bits */
- unsigned long *pool; /* memory pool for ximager objects */
+ long *pool; /* memory pool for ximager objects */
int size; /* for memory size calculations */
struct XYspace *S; /* coordinate space for character */
struct region *area;
@@ -156,7 +512,8 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
int len, rc, count = 0;
struct type1font *type1;
char *p;
- psobj *fontencoding = NULL;
+ FontMapPtr mapping = NULL;
+ int no_mapping;
psobj *fontmatrix;
long x0, total_width = 0, total_raw_width = 0;
double x1, y1, t1 = .001, t2 = 0.0, t3 = 0.0, t4 = .001;
@@ -179,24 +536,28 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
#define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
- pFont = (FontPtr) xalloc(sizeof(FontRec));
+ pFont = CreateFontRec();
if (pFont == NULL)
return AllocError;
-
+
type1 = (struct type1font *)xalloc(sizeof(struct type1font));
if (type1 == NULL) {
- xfree(pFont);
+ DestroyFontRec(pFont);
return AllocError;
}
bzero(type1, sizeof(struct type1font));
/* heuristic for "maximum" size of pool we'll need: */
- size = 200000 + 120 *
+#ifdef BUILDCID
+ size = 400000 + 600 *
+#else
+ size = 200000 + 600 *
+#endif
(int)hypot(vals->pixel_matrix[2], vals->pixel_matrix[3])
* sizeof(short);
- if (size < 0 || NULL == (pool = (unsigned long *) xalloc(size))) {
+ if (size < 0 || NULL == (pool = (long *) xalloc(size))) {
xfree(type1);
- xfree(pFont);
+ DestroyFontRec(pFont);
return AllocError;
}
@@ -209,7 +570,7 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
if (!fontfcnA(fileName, &rc)) {
delmemory();
xfree(type1);
- xfree(pFont);
+ DestroyFontRec(pFont);
xfree(pool);
return Type1ReturnCodeToXReturnCode(rc);
}
@@ -229,61 +590,103 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
assign(3, t4, .001);
}
- S = (struct XYspace *) t1_Transform(IDENTITY, t1, t2, t3, t4);
+ S = (struct XYspace *) t1_Transform((struct xobject *)IDENTITY,
+ t1, t2, t3, t4);
- S = (struct XYspace *) Permanent(t1_Transform(S, vals->pixel_matrix[0],
- -vals->pixel_matrix[1],
- vals->pixel_matrix[2],
- -vals->pixel_matrix[3]));
+ S = (struct XYspace *) Permanent(t1_Transform((struct xobject *)S,
+ vals->pixel_matrix[0],
+ -vals->pixel_matrix[1],
+ vals->pixel_matrix[2],
+ -vals->pixel_matrix[3]));
/* multiplier for computation of raw values */
sxmult = hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]);
if (sxmult > EPS) sxmult = 1000.0 / sxmult;
- p = entry->name.name + entry->name.length - 19;
- if (entry->name.ndashes == 14 &&
- p >= entry->name.name &&
- !strcmp (p, "-adobe-fontspecific"))
- {
- fontencoding = FontP->fontInfoP[ENCODING].value.data.arrayP;
+ no_mapping=0;
+ p = FontEncFromXLFD(entry->name.name, entry->name.length);
+
+ if(p==0) { /* XLFD does not specify an encoding */
+ mapping=0;
+ no_mapping=2; /* ISO 8859-1 */
}
- if (!fontencoding)
- fontencoding = ISOLatin1EncArrayP;
+ if(!strcmp(p, "adobe-fontspecific")) {
+ mapping=0;
+ no_mapping=1; /* font's native encoding vector */
+ }
+
+ if(!no_mapping) {
+ mapping = FontEncMapFind(p,
+ FONT_ENCODING_POSTSCRIPT, -1, -1,
+ fileName);
+ if(!mapping)
+ mapping = FontEncMapFind(p,
+ FONT_ENCODING_UNICODE, -1, -1,
+ fileName);
+ if(!mapping)
+ no_mapping=2;
+ else
+ no_mapping=0;
+ }
pFont->info.firstCol = 255;
- pFont->info.lastCol = FIRSTCOL;
+ pFont->info.lastCol = 0;
- for (i=0; i < 256-FIRSTCOL; i++) {
+ for (i=0; i < 256; i++) {
long h,w;
long paddedW;
int j;
char *codename;
- codename = fontencoding[i + FIRSTCOL].data.valueP;
- len = fontencoding[i + FIRSTCOL].len;
- if (len == 7 && strcmp(codename,".notdef")==0)
- continue;
-
+ if(no_mapping == 1) {
+ codename = FontP->fontInfoP[ENCODING].
+ value.data.arrayP[i].data.valueP;
+ len = FontP->fontInfoP[ENCODING].
+ value.data.arrayP[i].len;
+ } else if(no_mapping) {
+ codename = unicodetoPSname(i);
+ len = codename ? strlen(codename) : 0;
+ } else {
+ if(mapping->type == FONT_ENCODING_UNICODE) {
+ codename = unicodetoPSname(FontEncRecode(i, mapping));
+ } else
+ codename = FontEncName(i, mapping);
+ len=codename?strlen(codename):0;
+ }
+
+ /* Avoid multiply rasterising the undefined glyph */
+ if(len==7 && !strncmp(codename, ".notdef", 7)) {
+ len=0;
+ codename=0;
+ }
+
+ /* But do rasterise it at least once */
+ if(len==0) {
+ if(i==0) {
+ codename=".notdef";
+ len=7;
+ } else
+ continue;
+ }
+
/* See if this character is in the list of ranges specified
in the XLFD name */
- for (j = 0; j < vals->nranges; j++)
- if (i + FIRSTCOL >= minchar(vals->ranges[j]) &&
- i + FIRSTCOL <= maxchar(vals->ranges[j]))
- break;
+ if(i!=0) {
+ for (j = 0; j < vals->nranges; j++)
+ if (i >= minchar(vals->ranges[j]) &&
+ i <= maxchar(vals->ranges[j]))
+ break;
- /* If not, don't realize it. */
- if (vals->nranges && j == vals->nranges)
- continue;
-
- if (pFont->info.firstCol > i + FIRSTCOL)
- pFont->info.firstCol = i + FIRSTCOL;
- if (pFont->info.lastCol < i + FIRSTCOL)
- pFont->info.lastCol = i + FIRSTCOL;
+ /* If not, don't realize it. */
+ if (vals->nranges && j == vals->nranges)
+ continue;
+ }
rc = 0;
- area = fontfcnB(S, codename, &len, &rc);
+ area = (struct region *)fontfcnB(S, (unsigned char *)codename,
+ &len, &rc);
if (rc < 0) {
rc = Type1ReturnCodeToXReturnCode(rc);
break;
@@ -294,6 +697,11 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
if (area == NULL)
continue;
+ if (pFont->info.firstCol > i)
+ pFont->info.firstCol = i;
+ if (pFont->info.lastCol < i)
+ pFont->info.lastCol = i;
+
h = area->ymax - area->ymin;
w = area->xmax - area->xmin;
paddedW = PAD(w, pad);
@@ -356,16 +764,16 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
if (pFont->info.firstCol > pFont->info.lastCol)
{
xfree(type1);
- xfree(pFont);
+ DestroyFontRec(pFont);
return BadFontName;
}
- if (i != 256 - FIRSTCOL) {
+ if (i != 256) {
for (i--; i >= 0; i--)
if (glyphs[i].bits != NULL)
xfree(glyphs[i].bits);
xfree(type1);
- xfree(pFont);
+ DestroyFontRec(pFont);
return rc;
}
type1->pDefault = NULL;
@@ -385,8 +793,6 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
pFont->unload_font = Type1CloseFont;
pFont->unload_glyphs = NULL;
pFont->refcnt = 0;
- pFont->maxPrivate = -1;
- pFont->devPrivates = 0;
pFont->fontPrivate = (unsigned char *) type1;
@@ -408,15 +814,283 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
*ppFont = pFont;
return Successful;
}
+
+#ifdef BUILDCID
+unsigned int
+getCID(FontPtr pFont, unsigned int charcode)
+{
+ unsigned int cidcode = 0;
+ Bool charvalid = FALSE;
+ cidglyphs *cid;
+ int i, j;
+ unsigned int char_row, char_col, rangelo_row, rangelo_col, k;
+ unsigned int rangehi_row, rangehi_col;
+ spacerange *spacerangeP;
+ cidrange *notdefrangeP, *cidrangeP;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ if (cid == NULL)
+ return cidcode;
+
+ char_row = (charcode >> 8) & 0xff;
+ char_col = charcode & 0xff;
+
+ spacerangeP = CIDFontP->spacerangeP;
+ for (i = 0; i < CIDFontP->spacerangecnt; i++) {
+ for (j = 0; j < spacerangeP->rangecnt; j++) {
+ rangelo_row =
+ (spacerangeP->spacecode[j].srcCodeLo >> 8) & 0xff;
+ rangelo_col = spacerangeP->spacecode[j].srcCodeLo & 0xff;
+ rangehi_row =
+ (spacerangeP->spacecode[j].srcCodeHi >> 8) & 0xff;
+ rangehi_col = spacerangeP->spacecode[j].srcCodeHi & 0xff;
+ if (char_row >= rangelo_row && char_row <= rangehi_row &&
+ char_col >= rangelo_col && char_col <= rangehi_col) {
+ charvalid = TRUE;
+ break;
+ }
+ }
+ if (charvalid) break;
+ spacerangeP = spacerangeP->next;
+ }
+
+ if (charvalid) {
+ charvalid = FALSE;
+ cidrangeP = CIDFontP->cidrangeP;
+ for (i = 0; i < CIDFontP->cidrangecnt; i++) {
+ for (j = 0; j < cidrangeP->rangecnt; j++) {
+ rangelo_row =
+ (cidrangeP->range[j].srcCodeLo >> 8) & 0xff;
+ rangelo_col = cidrangeP->range[j].srcCodeLo & 0xff;
+ rangehi_row =
+ (cidrangeP->range[j].srcCodeHi >> 8) & 0xff;
+ rangehi_col = cidrangeP->range[j].srcCodeHi & 0xff;
+ if (char_row >= rangelo_row && char_row <= rangehi_row &&
+ char_col >= rangelo_col && char_col <= rangehi_col) {
+ charvalid = TRUE;
+ for (k = cidrangeP->range[j].srcCodeLo;
+ k <= cidrangeP->range[j].srcCodeHi; k++) {
+ if (k == charcode)
+ cidcode = cidrangeP->range[j].dstCIDLo + k -
+ cidrangeP->range[j].srcCodeLo;
+ }
+ break;
+ }
+ }
+ if (charvalid) break;
+ cidrangeP = cidrangeP->next;
+ }
+ }
+
+ if (charvalid) {
+ charvalid = FALSE;
+ notdefrangeP = CIDFontP->notdefrangeP;
+ for (i = 0; i < CIDFontP->notdefrangecnt; i++) {
+ for (j = 0; j < notdefrangeP->rangecnt; j++) {
+ rangelo_row =
+ (notdefrangeP->range[j].srcCodeLo >> 8) & 0xff;
+ rangelo_col = notdefrangeP->range[j].srcCodeLo & 0xff;
+ rangehi_row =
+ (notdefrangeP->range[j].srcCodeHi >> 8) & 0xff;
+ rangehi_col = notdefrangeP->range[j].srcCodeHi & 0xff;
+ if (char_row >= rangelo_row && char_row <= rangehi_row &&
+ char_col >= rangelo_col && char_col <= rangehi_col) {
+ charvalid = TRUE;
+ for (k = notdefrangeP->range[j].srcCodeLo;
+ k <= notdefrangeP->range[j].srcCodeHi; k++) {
+ if (k == charcode)
+ /* the whole range is mapped to a single CID code */
+ cidcode = notdefrangeP->range[j].dstCIDLo;
+ }
+ break;
+ }
+ }
+ if (charvalid) break;
+ notdefrangeP = notdefrangeP->next;
+ }
+ }
+
+ /* If you specify a CMap that has more CIDs than a specified CIDFont, */
+ /* the program could go beyond the number of entries in CIDMap. Make */
+ /* sure that that does not happen. */
+ if (cidcode < CIDFontP->CIDfontInfoP[CIDCOUNT].value.data.integer)
+ return cidcode;
+ else
+ return 0;
+}
+
+static CharInfoPtr
+CIDGetGlyph(FontPtr pFont, unsigned int charcode, CharInfoPtr pci)
+{
+ int rc;
+ CharInfoPtr cp = NULL;
+ unsigned int cidcode;
+
+ /* character code -> CID */
+ cidcode = getCID(pFont, charcode);
+
+ cp = CIDGetGlyphInfo(pFont, cidcode, pci, &rc);
+
+ if (rc != Successful && cidcode) {
+ cidcode = 0;
+ cp = CIDGetGlyphInfo(pFont, cidcode, pci, &rc);
+ }
+
+ return cp;
+}
+
+int
+CIDGetGlyphs(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
+{
+ unsigned int firstRow, numRows, code, char_row, char_col;
+ CharInfoPtr *glyphsBase;
+ register unsigned int c;
+ CharInfoPtr pci;
+ CharInfoPtr pDefault;
+ cidglyphs *cid;
+ register int firstCol;
+ int rc = 0;
+ int cid_valid = 0;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ FontP = NULL;
+
+ firstCol = pFont->info.firstCol;
+ pDefault = cid->pDefault;
+ glyphsBase = glyphs;
+
+ switch (charEncoding) {
+
+#define EXIST(pci) \
+ ((pci)->metrics.attributes || \
+ (pci)->metrics.ascent != -(pci)->metrics.descent || \
+ (pci)->metrics.leftSideBearing != (pci)->metrics.rightSideBearing)
+
+ case Linear8Bit:
+ case TwoD8Bit:
+ if (pFont->info.firstRow > 0)
+ break;
+ while (count--) {
+ c = (*chars++);
+ if (c >= firstCol && c <= pFont->info.lastCol) {
+ code = c - firstCol;
+ if (!(pci = (CharInfoRec *)cid->glyphs[code]) ||
+ ((long)pci->bits == CID_BITMAP_UNDEFINED)) {
+ /* load font if not already loaded */
+ if(!cid_valid) {
+ if(!CIDfontfcnA(cid->CIDFontName, cid->CMapName, &rc)) { FontP = NULL;
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+ cid_valid = 1;
+ }
+ pci = CIDGetGlyph(pFont, c, pci);
+ }
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ } else if (pDefault) {
+ *glyphs++ = pDefault;
+ cid->glyphs[code] = pDefault;
+ }
+ } else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ case Linear16Bit:
+ while (count--) {
+ char_row = *chars++;
+ char_col = *chars++;
+ c = char_row << 8;
+ c = (c | char_col);
+ if (pFont->info.firstRow <= char_row && char_row <=
+ pFont->info.lastRow && pFont->info.firstCol <= char_col &&
+ char_col <= pFont->info.lastCol) {
+ code = pFont->info.lastCol - pFont->info.firstCol + 1;
+ char_row = char_row - pFont->info.firstRow;
+ char_col = char_col - pFont->info.firstCol;
+ code = char_row * code + char_col;
+ if (!(pci = (CharInfoRec *)cid->glyphs[code]) ||
+ ((long)pci->bits == CID_BITMAP_UNDEFINED)) {
+ /* load font if not already loaded */
+ if(!cid_valid) {
+ if(!CIDfontfcnA(cid->CIDFontName, cid->CMapName, &rc)) { FontP = NULL;
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+ cid_valid = 1;
+ }
+ pci = CIDGetGlyph(pFont, c, pci);
+ }
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ } else if (pDefault) {
+ *glyphs++ = pDefault;
+ cid->glyphs[code] = pDefault;
+ }
+ } else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+
+ case TwoD16Bit:
+ firstRow = pFont->info.firstRow;
+ numRows = pFont->info.lastRow - firstRow + 1;
+ while (count--) {
+ char_row = (*chars++);
+ char_col = (*chars++);
+ c = char_row << 8;
+ c = (c | char_col);
+ if (pFont->info.firstRow <= char_row && char_row <=
+ pFont->info.lastRow && pFont->info.firstCol <= char_col &&
+ char_col <= pFont->info.lastCol) {
+ code = pFont->info.lastCol - pFont->info.firstCol + 1;
+ char_row = char_row - pFont->info.firstRow;
+ char_col = char_col - pFont->info.firstCol;
+ code = char_row * code + char_col;
+ if (!(pci = (CharInfoRec *)cid->glyphs[code]) ||
+ ((long)pci->bits == CID_BITMAP_UNDEFINED)) {
+ /* load font if not already loaded */
+ if(!cid_valid) {
+ if(!CIDfontfcnA(cid->CIDFontName, cid->CMapName, &rc)) { FontP = NULL;
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+ cid_valid = 1;
+ }
+ pci = CIDGetGlyph(pFont, c, pci);
+ }
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ } else if (pDefault) {
+ *glyphs++ = pDefault;
+ cid->glyphs[code] = pDefault;
+ }
+ } else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ }
+ *glyphCount = glyphs - glyphsBase;
+ return Successful;
+
+#undef EXIST
+}
+#endif
static int
-Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
- FontPtr pFont;
- unsigned long count;
- register unsigned char *chars;
- FontEncoding charEncoding;
- unsigned long *glyphCount; /* RETURN */
- CharInfoPtr *glyphs; /* RETURN */
+Type1GetGlyphs(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
{
unsigned int firstRow;
unsigned int numRows;
@@ -447,7 +1121,7 @@ Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
while (count--) {
c = (*chars++);
if (c >= firstCol &&
- (pci = &type1Font->glyphs[c-FIRSTCOL]) &&
+ (pci = &type1Font->glyphs[c]) &&
EXIST(pci))
*glyphs++ = pci;
else if (pDefault)
@@ -459,7 +1133,7 @@ Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
c = *chars++ << 8;
c = (c | *chars++);
if (c < 256 && c >= firstCol &&
- (pci = &type1Font->glyphs[c-FIRSTCOL]) &&
+ (pci = &type1Font->glyphs[c]) &&
EXIST(pci))
*glyphs++ = pci;
else if (pDefault)
@@ -474,7 +1148,7 @@ Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
r = (*chars++) - firstRow;
c = (*chars++);
if (r < numRows && c < 256 && c >= firstCol &&
- (pci = &type1Font->glyphs[(r << 8) + c - FIRSTCOL]) &&
+ (pci = &type1Font->glyphs[(r << 8) + c]) &&
EXIST(pci))
*glyphs++ = pci;
else if (pDefault)
@@ -487,15 +1161,67 @@ Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
#undef EXIST
}
-
+
+#ifdef BUILDCID
+static CharInfoRec nonExistantChar;
+
+int
+CIDGetMetrics(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ xCharInfo **glyphs) /* RETURN */
+{
+ int ret;
+ cidglyphs *cid;
+ CharInfoPtr oldDefault;
+ char cidafmname[CID_PATH_MAX];
+ char CIDFontName[CID_NAME_MAX];
+ char *ptr;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ strcpy(cidafmname, cid->CIDFontName);
+ if (!(ptr = strrchr(cidafmname, '/')))
+ return BadFontName;
+
+ *ptr = '\0';
+
+ strcpy(CIDFontName, ptr + 1);
+
+ if (!(ptr = strrchr(cidafmname, '/')))
+ return BadFontName;
+
+ *ptr = '\0';
+
+ strcat(cidafmname, "/AFM/");
+ strcat(cidafmname, CIDFontName);
+
+ strcat(cidafmname, ".afm");
+
+ oldDefault = cid->pDefault;
+ cid->pDefault = &nonExistantChar;
+
+ ret = CIDGetAFM(pFont, count, chars, charEncoding, glyphCount, (CharInfoPtr
+*)glyphs, cidafmname);
+ if (ret != Successful)
+ ret = CIDGetGlyphs(pFont, count, chars, charEncoding, glyphCount,
+ (CharInfoPtr *)glyphs);
+
+ *ptr = 0;
+ cid->pDefault = oldDefault;
+ return ret;
+}
+#endif
+
static int
-Type1GetMetrics(pFont, count, chars, charEncoding, glyphCount, glyphs)
- FontPtr pFont;
- unsigned long count;
- register unsigned char *chars;
- FontEncoding charEncoding;
- unsigned long *glyphCount; /* RETURN */
- xCharInfo **glyphs; /* RETURN */
+Type1GetMetrics(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ xCharInfo **glyphs) /* RETURN */
{
static CharInfoRec nonExistantChar;
@@ -510,15 +1236,75 @@ Type1GetMetrics(pFont, count, chars, charEncoding, glyphCount, glyphs)
type1Font->pDefault = oldDefault;
return ret;
}
-
-void Type1CloseFont(pFont)
- FontPtr pFont;
+
+#ifdef BUILDCID
+void
+CIDCloseFont(FontPtr pFont)
+{
+ register int i;
+ cidglyphs *cid;
+ int nchars;
+
+ if (pFont) {
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ if (cid) {
+
+ if (cid->CIDFontName && !strcmp(cid->CIDFontName, CurCIDFontName)
+ && cid->CMapName && !strcmp(cid->CMapName, CurCMapName)){
+ strcpy(CurCIDFontName, ""); /* initialize to none */
+ strcpy(CurCMapName, ""); /* initialize to none */
+ }
+
+ if (cid->CIDFontName)
+ xfree(cid->CIDFontName);
+
+ if (cid->CMapName)
+ xfree(cid->CMapName);
+
+ nchars = (pFont->info.lastRow - pFont->info.firstRow + 1) *
+ (pFont->info.lastCol - pFont->info.firstCol + 1);
+
+ for (i = 0; i < nchars; i++) {
+ if (cid->glyphs[i] && (cid->glyphs[i] != &nonExistantChar)) {
+ if (cid->glyphs[i]->bits)
+ xfree(cid->glyphs[i]->bits);
+ xfree(cid->glyphs[i]);
+ }
+ }
+
+ if (cid->glyphs)
+ xfree(cid->glyphs);
+
+ if (cid->AFMinfo)
+ xfree(cid->AFMinfo);
+#ifdef USE_MMAP
+ if (cid->CIDdata)
+ munmap(cid->CIDdata, cid->CIDsize);
+#endif
+ xfree(cid);
+ }
+
+ if (pFont->info.props)
+ xfree(pFont->info.props);
+
+ if (pFont->info.isStringProp)
+ xfree(pFont->info.isStringProp);
+
+ DestroyFontRec(pFont);
+ }
+}
+#endif
+
+void
+Type1CloseFont(FontPtr pFont)
{
register int i;
struct type1font *type1;
type1 = (struct type1font *) pFont->fontPrivate;
- for (i=0; i < 256 - FIRSTCOL; i++)
+ for (i=0; i < 256; i++)
if (type1->glyphs[i].bits != NULL)
xfree(type1->glyphs[i].bits);
xfree(type1);
@@ -529,20 +1315,15 @@ void Type1CloseFont(pFont)
if (pFont->info.isStringProp)
xfree(pFont->info.isStringProp);
- if (pFont->devPrivates)
- xfree(pFont->devPrivates);
-
- xfree(pFont);
+ DestroyFontRec(pFont);
}
-
-
-
-static void fill(dest, h, w, area, byte, bit, wordsize)
- register char *dest; /* destination bitmap */
- int h,w; /* dimensions of 'dest', w padded */
- register struct region *area; /* region to write to 'dest' */
- int byte,bit; /* flags; LSBFirst or MSBFirst */
- int wordsize; /* number of bits per word for LSB/MSB purposes */
+
+static void
+fill(char *dest, /* destination bitmap */
+ int h, int w, /* dimensions of 'dest', w padded */
+ struct region *area, /* region to write to 'dest' */
+ int byte, int bit, /* flags; LSBFirst or MSBFirst */
+ int wordsize) /* number of bits per word for LSB/MSB purposes */
{
register struct edgelist *edge; /* for looping through edges */
register char *p; /* current scan line in 'dest' */
@@ -609,7 +1390,7 @@ it:
break;
}
default:
- abort("xiFill: unknown format");
+ Abort("xiFill: unknown format");
}
}
@@ -617,10 +1398,10 @@ it:
#define ALLONES 0xFF
-static void fillrun(p, x0, x1, bit)
- register char *p; /* address of this scan line */
- pel x0,x1; /* left and right X */
- int bit; /* format: LSBFirst or MSBFirst */
+static void
+fillrun(char *p, /* address of this scan line */
+ pel x0, pel x1, /* left and right X */
+ int bit) /* format: LSBFirst or MSBFirst */
{
register int startmask,endmask; /* bits to set in first and last char*/
register int middle; /* number of chars between start and end + 1 */
@@ -643,33 +1424,61 @@ static void fillrun(p, x0, x1, bit)
else {
*p++ |= startmask;
while (--middle > 0)
- *p++ = ALLONES;
+ *p++ = (char)ALLONES;
*p |= endmask;
}
}
#define CAPABILITIES (CAP_MATRIX | CAP_CHARSUBSETTING)
+
+#ifdef BUILDCID
+FontRendererRec CIDRendererInfo[] = {
+ { ".cid", 4, NULL, CIDOpenScalable,
+ NULL, CIDGetInfoScalable, 0, CAPABILITIES }
+};
+#endif
+#ifdef BUILDCID
+FontRendererRec Type1RendererInfo[] = {
+#else
static FontRendererRec renderers[] = {
- { ".pfa", 4, (int (*)()) 0, Type1OpenScalable,
- (int (*)()) 0, Type1GetInfoScalable, 0, CAPABILITIES },
- { ".pfb", 4, (int (*)()) 0, Type1OpenScalable,
- (int (*)()) 0, Type1GetInfoScalable, 0, CAPABILITIES }
+#endif
+ { ".pfa", 4, NULL, Type1OpenScalable,
+ NULL, Type1GetInfoScalable, 0, CAPABILITIES },
+ { ".pfb", 4, NULL, Type1OpenScalable,
+ NULL, Type1GetInfoScalable, 0, CAPABILITIES }
};
-
+#ifdef BUILDCID
+void
+CIDRegisterFontFileFunctions(void)
+{
+ int i;
+
+ Type1InitStdProps();
+ for (i=0; i < sizeof(CIDRendererInfo) / sizeof(FontRendererRec); i++)
+ FontFileRegisterRenderer(&CIDRendererInfo[i]);
+}
+#endif
+
void
-Type1RegisterFontFileFunctions()
+Type1RegisterFontFileFunctions(void)
{
int i;
+#ifdef BUILDCID
+ Type1InitStdProps();
+ for (i=0; i < sizeof(Type1RendererInfo) / sizeof(FontRendererRec); i++)
+ FontFilePriorityRegisterRenderer(&Type1RendererInfo[i], -10);
+#else
T1InitStdProps();
for (i=0; i < sizeof(renderers) / sizeof(FontRendererRec); i++)
- FontFileRegisterRenderer(&renderers[i]);
+ FontFilePriorityRegisterRenderer(&renderers[i], -10);
+#endif
}
-int Type1ReturnCodeToXReturnCode(rc)
- int rc;
+int
+Type1ReturnCodeToXReturnCode(int rc)
{
switch(rc) {
case SCAN_OK:
@@ -688,7 +1497,165 @@ int Type1ReturnCodeToXReturnCode(rc)
/* fall through */
default:
/* this should not happen */
+#ifdef BUILDCID
+ ErrorF("Font return code cannot be converted to X return code: %d\n", rc);
+#else
ErrorF("Type1 return code not convertable to X return code: %d\n", rc);
+#endif
return rc;
}
}
+
+#ifdef BUILDCID
+CharInfoPtr
+CIDRenderGlyph(FontPtr pFont, psobj *charstringP, psobj *subarrayP,
+ struct blues_struct *bluesP, CharInfoPtr pci, int *mode)
+{
+ int bit,
+ byte,
+ glyph,
+ scan,
+ image;
+ int pad,wordsize; /* scan & image in bits */
+ long *pool; /* memory pool for ximager objects */
+ int size; /* for memory size calculations */
+ struct XYspace *S; /* coordinate space for character */
+ struct region *area;
+ CharInfoRec *glyphs;
+ int len, rc;
+ long x0;
+ double x1, y1, t1 = .001, t2 = 0.0, t3 = 0.0, t4 = .001;
+ double sxmult;
+ long h,w;
+ long paddedW;
+ cidglyphs *cid;
+ fsBitmapFormat format = 0;
+ fsBitmapFormatMask fmask = 0;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ /* set up default values */
+ FontDefaultFormat(&bit, &byte, &glyph, &scan);
+ /* get any changes made from above */
+ rc = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);
+ if (rc != Successful) {
+ *mode = rc;
+ return(NULL);
+ }
+
+ pad = glyph * 8;
+ wordsize = scan * 8;
+
+#define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
+
+ /* heuristic for "maximum" size of pool we'll need: */
+ size = 200000 + 600 *
+ (int)hypot(cid->pixel_matrix[2], cid->pixel_matrix[3])
+ * sizeof(short);
+ if (size < 0 || NULL == (pool = (long *) xalloc(size))) {
+ *mode = AllocError;
+ return(NULL);
+ }
+
+ addmemory(pool, size);
+
+ if (pci && (long)pci->bits == CID_BITMAP_UNDEFINED)
+ glyphs = pci;
+ else {
+ if (!(glyphs = (CharInfoRec *)xalloc(sizeof(CharInfoRec)))) {
+ delmemory();
+ xfree(pool);
+ *mode = AllocError;
+ return(NULL);
+ }
+ bzero(glyphs, sizeof(CharInfoRec));
+ }
+
+ S = (struct XYspace *) t1_Transform((struct xobject *)IDENTITY,
+ t1, t2, t3, t4);
+
+ S = (struct XYspace *) Permanent(t1_Transform((struct xobject *)S,
+ cid->pixel_matrix[0],
+ -cid->pixel_matrix[1],
+ cid->pixel_matrix[2],
+ -cid->pixel_matrix[3]));
+
+ /* multiplier for computation of raw values */
+ sxmult = hypot(cid->pixel_matrix[0], cid->pixel_matrix[1]);
+ if (sxmult > EPS) sxmult = 1000.0 / sxmult;
+
+ rc = 0;
+ area = (struct region *)CIDfontfcnC(S, charstringP, subarrayP, bluesP,
+ &len, &rc);
+ if (rc < 0 || area == NULL) {
+ delmemory();
+ xfree(pool);
+ if (pci != glyphs) xfree(glyphs);
+ *mode = Type1ReturnCodeToXReturnCode(rc);
+ return(NULL);
+ }
+
+ h = area->ymax - area->ymin;
+ w = area->xmax - area->xmin;
+ paddedW = PAD(w, pad);
+
+ if (h > 0 && w > 0) {
+ size = h * paddedW / 8;
+ glyphs[0].bits = (char *)xalloc(size);
+ if (glyphs[0].bits == NULL) {
+ Destroy(area);
+ delmemory();
+ xfree(pool);
+ if (pci != glyphs) xfree(glyphs);
+ *mode = AllocError;
+ return(NULL);
+ }
+ bzero(glyphs[0].bits, size);
+ }
+ else {
+ size = 0;
+ h = w = 0;
+ area->xmin = area->xmax = 0;
+ area->ymax = area->ymax = 0;
+ glyphs[0].bits = NULL;
+ }
+
+ glyphs[0].metrics.leftSideBearing = area->xmin;
+ x1 = (double)(x0 = area->ending.x - area->origin.x);
+ y1 = (double)(area->ending.y - area->origin.y);
+ glyphs[0].metrics.characterWidth =
+ (x0 + (x0 > 0 ? FPHALF : -FPHALF)) / (1 << FRACTBITS);
+ if (!glyphs[0].metrics.characterWidth && size == 0)
+ {
+ /* Zero size and zero extents: presumably caused by
+ the choice of transformation. Let's create a
+ small bitmap so we're not mistaken for an undefined
+ character. */
+ h = w = 1;
+ size = paddedW = PAD(w, pad);
+ glyphs[0].bits = (char *)xalloc(size);
+ if (glyphs[0].bits == NULL) {
+ Destroy(area);
+ delmemory();
+ xfree(pool);
+ if (pci != glyphs) xfree(glyphs);
+ *mode = AllocError;
+ return(NULL);
+ }
+ bzero(glyphs[0].bits, size);
+ }
+ glyphs[0].metrics.attributes =
+ NEARESTPEL((long)(hypot(x1, y1) * sxmult));
+ glyphs[0].metrics.rightSideBearing = w + area->xmin;
+ glyphs[0].metrics.descent = area->ymax - NEARESTPEL(area->origin.y);
+ glyphs[0].metrics.ascent = h - glyphs[0].metrics.descent;
+
+ if (h > 0 && w > 0)
+ fill(glyphs[0].bits, h, paddedW, area, byte, bit, wordsize);
+ Destroy(area);
+ delmemory();
+ xfree(pool);
+ *mode = Successful;
+ return(glyphs);
+}
+#endif
diff --git a/src/Type1/t1imager.h b/src/Type1/t1imager.h
index 472b36f..7d72495 100644
--- a/src/Type1/t1imager.h
+++ b/src/Type1/t1imager.h
@@ -27,41 +27,22 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/t1imager.h,v 1.5 2001/07/25 15:04:55 dawes Exp $ */
-#include "fontmisc.h"
-
-typedef pointer xobject;
-typedef pointer location;
-typedef pointer path;
-typedef pointer region;
-typedef pointer XYspace;
-
-#ifndef NOEXTERNS
-/*
-The following are the user entry locations to TYPE1IMAGER
-*/
-extern path t1_Bezier();
-extern path t1_ClosePath();
-extern xobject t1_Destroy();
-extern xobject t1_Dup();
-extern char *t1_ErrorMsg();
-extern void t1_InitImager();
-extern region t1_Interior();
-extern location t1_ILoc();
-extern xobject t1_Join();
-extern path t1_Line();
-extern xobject t1_Permanent();
-extern path t1_Phantom();
-extern location t1_Loc();
-extern xobject t1_Scale();
-extern xobject t1_Snap();
-extern location t1_SubLoc();
-extern xobject t1_Temporary();
-
-#endif
+
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h"
+
+typedef struct xobject *xobject;
+typedef struct segment *path;
+typedef struct region *region;
+typedef struct XYspace *XYspace;
+
#ifndef NULL
-#define NULL 0
+#include <stddef.h>
#endif
#ifndef TRUE
@@ -71,57 +52,13 @@ extern xobject t1_Temporary();
#ifndef FALSE
#define FALSE 0
#endif
-
-/*
-Here are some TYPE1IMAGER functions that are defined in terms of others:
-*/
-
-#define t1_AddLoc(p1,p2) t1_Join(p1,p2)
-
-#ifndef NONAMES
-/*
-Define the simple form of all the subroutine names:
-*/
-#define AddLoc(p1,p2) t1_AddLoc(p1,p2)
-#define Bezier(B,C,D) t1_Bezier(B,C,D)
-#define ClosePath(p) t1_ClosePath(p,0)
-#define Complement(area) t1_Complement(area)
-#define Destroy(o) t1_Destroy(o)
-#define Dup(o) t1_Dup(o)
-#define ErrorMsg() t1_ErrorMsg()
-#define HeadSegment(p) t1_HeadSegment(p)
-#define InitImager() t1_InitImager()
-#define Interior(p,rule) t1_Interior(p,rule)
-#define ILoc(S,x,y) t1_ILoc(S,x,y)
-#define Join(p1,p2) t1_Join(p1,p2)
-#define Line(P) t1_Line(P)
-#define Permanent(o) t1_Permanent(o)
-#define Phantom(o) t1_Phantom(o)
-#define Loc(S,x,y) t1_Loc(S,(double)x,(double)y)
-#define Scale(o,sx,sy) t1_Scale(o,(double)sx,(double)sy)
-#define Snap(o) t1_Snap(o)
-#define SubLoc(a,b) t1_SubLoc(a,b)
-#define Temporary(o) t1_Temporary(o)
-#define TermImager() t1_TermImager()
-#define Transform(o,cxx,cyx,cxy,cyy) t1_Transform(o,(double)cxx,(double)cyx,\
- (double)cxy,(double)cyy)
-
-#endif
-
+
+
#define WINDINGRULE -2
#define EVENODDRULE -3
#define CONTINUITY 0x80 /* can be added to above rules; e.g. WINDINGRULE+CONTINUITY */
-/*
-Stroke() line style constants:
-*/
-
-/*
-Coordinate space constants:
-*/
-#define IDENTITY t1_Identity
-extern XYspace *IDENTITY;
/*
Generic null object definition:
@@ -145,4 +82,3 @@ extern region *INFINITY;
#define FF_PARSE_ERROR 5
#define FF_PATH 1
-extern pointer xiStub();
diff --git a/src/Type1/t1info.c b/src/Type1/t1info.c
index dff6257..0ee137f 100644
--- a/src/Type1/t1info.c
+++ b/src/Type1/t1info.c
@@ -82,13 +82,66 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/t1info.c,v 1.18 2002/09/10 16:14:33 tsi Exp $ */
-#include <stdio.h>
#include "fntfilst.h"
+#include "fontutil.h"
+#ifndef FONTMODULE
+#include <stdio.h>
+#ifndef BUILDCID
+#include <math.h>
+#endif
+#else
+#include "xf86_ansic.h"
+#endif
#include "FSproto.h"
-#include "t1intf.h"
+
+#ifdef BUILDCID
+#ifndef FONTMODULE
+#ifdef _XOPEN_SOURCE
#include <math.h>
-
+#else
+#define _XOPEN_SOURCE
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "range.h"
+#endif
+
+#ifdef BUILDCID
+#include "util.h"
+#include "fontfcn.h"
+
+#if defined(HAVE_CFM) || defined(CID_ALL_CHARS)
+#ifndef DEFAULT_CFM_DIR
+#define DEFAULT_CFM_DIR "./"
+#endif
+char cfmDefaultDir[] = DEFAULT_CFM_DIR;
+#define CFMMAGIC 0x91239123
+#endif
+#endif
+#include "t1intf.h"
+
#define DECIPOINTSPERINCH 722.7
#define DEFAULTRES 75
#define DEFAULTPOINTSIZE 120
@@ -97,7 +150,22 @@ enum scaleType {
atom, truncate_atom, pixel_size, point_size, resolution_x,
resolution_y, average_width
};
-
+
+#ifdef BUILDCID
+extern cidfont *CIDFontP;
+static int stdpropsinit = 0;
+
+typedef struct cfm_rec {
+ xCharInfo maxbounds;
+ xCharInfo minbounds;
+ xCharInfo ink_maxbounds;
+ xCharInfo ink_minbounds;
+ INT32 totalrw;
+ INT16 maxo;
+ INT16 alle;
+} cfmrec;
+#endif
+
typedef struct _fontProp {
char *name;
long atom;
@@ -131,7 +199,9 @@ static fontProp extraProps[] = {
{ "RAW_ASCENT", 0, },
{ "RAW_DESCENT", 0, },
{ "RAW_AVERAGE_WIDTH", 0, },
- { "FACE_NAME", 0, }
+ { "FACE_NAME", 0, },
+ { "FONT_TYPE", 0, },
+ { "RASTERIZER_NAME", 0, }
};
/* this is a bit kludgy */
@@ -143,6 +213,8 @@ static fontProp extraProps[] = {
#define RAWDESCENTPROP 5
#define RAWWIDTHPROP 6
#define FACE_NAMEPROP 7
+#define FONT_TYPEPROP 8
+#define RASTERIZER_NAMEPROP 9
#define NNAMEPROPS (sizeof(fontNamePropTable) / sizeof(fontProp))
#define NEXTRAPROPS (sizeof(extraProps) / sizeof(fontProp))
@@ -151,9 +223,7 @@ static fontProp extraProps[] = {
/*ARGSUSED*/
static void
-FillHeader(pInfo, Vals)
- FontInfoPtr pInfo;
- FontScalablePtr Vals;
+FillHeader(FontInfoPtr pInfo, FontScalablePtr Vals)
{
/* OpenScalable in T1FUNCS sets the following:
pInfo->firstCol,
@@ -175,10 +245,7 @@ FillHeader(pInfo, Vals)
}
static void
-adjust_min_max(minc, maxc, tmp)
- xCharInfo *minc,
- *maxc,
- *tmp;
+adjust_min_max(xCharInfo *minc, xCharInfo *maxc, xCharInfo *tmp)
{
#define MINMAX(field,ci) \
if (minc->field > (ci)->field) \
@@ -203,10 +270,7 @@ adjust_min_max(minc, maxc, tmp)
}
static void
-ComputeBounds(pInfo, pChars, Vals)
- FontInfoPtr pInfo;
- CharInfoPtr pChars;
- FontScalablePtr Vals;
+ComputeBounds(FontInfoPtr pInfo, CharInfoPtr pChars, FontScalablePtr Vals)
{
int i;
xCharInfo minchar, maxchar;
@@ -224,7 +288,7 @@ ComputeBounds(pInfo, pChars, Vals)
maxlap = -32767;
totchars = pInfo->lastCol - pInfo->firstCol + 1;
- pChars += pInfo->firstCol - FIRSTCOL;
+ pChars += pInfo->firstCol;
pInfo->allExist = 1;
for (i = 0; i < totchars; i++,pChars++) {
xCharInfo *pmetrics = &pChars->metrics;
@@ -262,14 +326,252 @@ ComputeBounds(pInfo, pChars, Vals)
*/
FontComputeInfoAccelerators (pInfo);
}
-
+
+#ifdef BUILDCID
+#ifdef CID_ALL_CHARS
+void
+ComputeBoundsAllChars(FontPtr pFont, char *cfmfilename, double sxmult)
+{
+ FILE *cfm;
+ CARD32 magic;
+ int count = 0;
+ int maxlap, overlap, i, j, k, ret;
+ xCharInfo minchar, maxchar;
+ cidrange *cidrangeP;
+ unsigned char ccode[2];
+ unsigned long ccount;
+ xCharInfo *pmetrics;
+ long total_raw_width = 0, total_width = 0;
+ char cfmd[CID_PATH_MAX];
+ cfmrec *cfmp;
+ char *p;
+
+ if (!(cfm = fopen(cfmfilename, "w"))) {
+ fprintf(stderr,
+ "Unable to open the file %s. You are probably not logged in as root.\n",
+ cfmfilename);
+ p = strrchr(cfmfilename, '/');
+ if (p == NULL) exit(1);
+ strcpy(cfmd, cfmDefaultDir);
+ strcat(cfmd, p + 1);
+ if (!(cfm = fopen(cfmd, "w"))) {
+ fprintf(stderr,
+ "Switching to current directory. Unable to open the file %s.\n",
+ cfmd);
+ exit(1);
+ }
+ }
+
+ if ((cfmp = (cfmrec *)xalloc(sizeof(cfmrec))) == NULL) {
+ fprintf(stderr, "Unable to allocate memory.");
+ exit(1);
+ }
+ bzero(cfmp, sizeof(cfmrec));
+
+ minchar.ascent = minchar.descent =
+ minchar.leftSideBearing = minchar.rightSideBearing =
+ minchar.characterWidth = minchar.attributes = 32767;
+ maxchar.ascent = maxchar.descent =
+ maxchar.leftSideBearing = maxchar.rightSideBearing =
+ maxchar.characterWidth = maxchar.attributes = -32767;
+
+ maxlap = -32767;
+ cfmp->alle = 1;
+ cidrangeP = CIDFontP->cidrangeP;
+
+ /* go through all character codes specified in a given CMap */
+ for (i = 0; i < CIDFontP->cidrangecnt; i++) {
+ for (j = 0; j < cidrangeP->rangecnt; j++) {
+ for (k = cidrangeP->range[j].srcCodeLo;
+ k <= cidrangeP->range[j].srcCodeHi; k++) {
+ ccode[0] = (k >> 8) & 0xff;
+ ccode[1] = k & 0xff;
+ ret = CIDGetMetrics(pFont, 1, ccode, 2, &ccount, &pmetrics);
+ if (ret != Successful || (ret == Successful && pmetrics == NULL))
+ continue;
+ total_width += pmetrics->attributes;
+ total_raw_width += abs((int)(INT16)pmetrics->attributes);
+ if (pmetrics->attributes ||
+ pmetrics->ascent != -pmetrics->descent ||
+ pmetrics->leftSideBearing != pmetrics->rightSideBearing) {
+ count++;
+ adjust_min_max(&minchar, &maxchar, pmetrics);
+ overlap = pmetrics->rightSideBearing - pmetrics->characterWidth;
+ if (overlap > maxlap) maxlap = overlap;
+ }
+ else cfmp->alle = 0;
+ }
+ }
+ }
+
+ if (count)
+ {
+ total_raw_width = (total_raw_width * 10 + count / 2) / count;
+ if (total_width < 0)
+ {
+ /* Predominant direction is R->L */
+ total_raw_width = -total_raw_width;
+ }
+ }
+
+ cfmp->totalrw = (INT32)total_raw_width;
+
+ cfmp->maxbounds.leftSideBearing =
+ floor((double)maxchar.leftSideBearing * sxmult + 0.5);
+ cfmp->maxbounds.rightSideBearing =
+ floor((double)maxchar.rightSideBearing * sxmult + 0.5);
+ cfmp->maxbounds.characterWidth =
+ floor((double)maxchar.characterWidth * sxmult + 0.5);
+ cfmp->maxbounds.ascent =
+ floor((double)maxchar.ascent * sxmult + 0.5);
+ cfmp->maxbounds.descent =
+ floor((double)maxchar.descent * sxmult);
+ cfmp->maxbounds.attributes = maxchar.attributes;
+
+ cfmp->minbounds.leftSideBearing =
+ floor((double)minchar.leftSideBearing * sxmult + 0.5);
+ cfmp->minbounds.rightSideBearing =
+ floor((double)minchar.rightSideBearing * sxmult + 0.5);
+ cfmp->minbounds.characterWidth =
+ floor((double)minchar.characterWidth * sxmult + 0.5);
+ cfmp->minbounds.ascent =
+ floor((double)minchar.ascent * sxmult + 0.5);
+ cfmp->minbounds.descent =
+ floor((double)minchar.descent * sxmult + 0.5);
+ cfmp->minbounds.attributes = minchar.attributes;
+
+ cfmp->ink_maxbounds.leftSideBearing =
+ floor((double)maxchar.leftSideBearing * sxmult + 0.5);
+ cfmp->ink_maxbounds.rightSideBearing =
+ floor((double)maxchar.rightSideBearing * sxmult + 0.5);
+ cfmp->ink_maxbounds.characterWidth =
+ floor((double)maxchar.characterWidth * sxmult + 0.5);
+ cfmp->ink_maxbounds.ascent =
+ floor((double)maxchar.ascent * sxmult + 0.5);
+ cfmp->ink_maxbounds.descent =
+ floor((double)maxchar.descent * sxmult + 0.5);
+ cfmp->ink_maxbounds.attributes = maxchar.attributes;
+
+ cfmp->ink_minbounds.leftSideBearing =
+ floor((double)minchar.leftSideBearing * sxmult + 0.5);
+ cfmp->ink_minbounds.rightSideBearing =
+ floor((double)minchar.rightSideBearing * sxmult + 0.5);
+ cfmp->ink_minbounds.characterWidth =
+ floor((double)minchar.characterWidth * sxmult + 0.5);
+ cfmp->ink_minbounds.ascent =
+ floor((double)minchar.ascent * sxmult + 0.5);
+ cfmp->ink_minbounds.descent =
+ floor((double)minchar.descent * sxmult + 0.5);
+ cfmp->ink_minbounds.attributes = minchar.attributes;
+
+ cfmp->maxo = (INT32)(maxlap + -(minchar.leftSideBearing));
+
+ magic = CFMMAGIC;
+ fwrite(&magic, sizeof(CARD32), 1, cfm);
+ fwrite(cfmp, sizeof(cfmrec), 1, cfm);
+ xfree(cfmp);
+ fclose(cfm);
+}
+#else
+static long
+ComputeBoundsAll(FontPtr pFont)
+{
+ int count = 0;
+ int maxlap, overlap, i, j, k, ret;
+ xCharInfo minchar, maxchar;
+ cidrange *cidrangeP;
+ unsigned char ccode[2];
+ unsigned long ccount;
+ xCharInfo *pmetrics;
+ CharInfoRec *cinfo[1];
+ long total_raw_width = 0, total_width = 0;
+ FontInfoPtr pInfo = &(pFont->info);
+
+ minchar.ascent = minchar.descent =
+ minchar.leftSideBearing = minchar.rightSideBearing =
+ minchar.characterWidth = minchar.attributes = 32767;
+ maxchar.ascent = maxchar.descent =
+ maxchar.leftSideBearing = maxchar.rightSideBearing =
+ maxchar.characterWidth = maxchar.attributes = -32767;
+
+ maxlap = -32767;
+ pInfo->allExist = 1;
+ cidrangeP = CIDFontP->cidrangeP;
+
+ /* go through all character codes specified in a given CMap */
+ for (i = 0; i < CIDFontP->cidrangecnt; i++) {
+ for (j = 0; j < cidrangeP->rangecnt; j++) {
+ for (k = cidrangeP->range[j].srcCodeLo;
+ k <= cidrangeP->range[j].srcCodeHi; k++) {
+ ccode[0] = (k >> 8) & 0xff;
+ ccode[1] = k & 0xff;
+ ret = CIDGetMetrics(pFont, 1, ccode, 2, &ccount, (xCharInfo **)cinfo);
+ if (ret != Successful || cinfo == NULL)
+ continue;
+ pmetrics = &cinfo[0]->metrics;
+ total_width += pmetrics->attributes;
+ total_raw_width += abs((int)(INT16)pmetrics->attributes);
+ if (pmetrics->attributes ||
+ pmetrics->ascent != -pmetrics->descent ||
+ pmetrics->leftSideBearing != pmetrics->rightSideBearing) {
+ count++;
+ adjust_min_max(&minchar, &maxchar, pmetrics);
+ overlap = pmetrics->rightSideBearing - pmetrics->characterWidth;
+ if (overlap > maxlap) maxlap = overlap;
+ }
+ else pInfo->allExist = 0;
+ }
+ }
+ }
+
+ if (count)
+ {
+ total_raw_width = (total_raw_width * 10 + count / 2) / count;
+ if (total_width < 0)
+ {
+ /* Predominant direction is R->L */
+ total_raw_width = -total_raw_width;
+ }
+ }
+
+ pInfo->maxbounds.leftSideBearing = maxchar.leftSideBearing;
+ pInfo->maxbounds.rightSideBearing = maxchar.rightSideBearing;
+ pInfo->maxbounds.characterWidth = maxchar.characterWidth;
+ pInfo->maxbounds.ascent = maxchar.ascent;
+ pInfo->maxbounds.descent = maxchar.descent;
+ pInfo->maxbounds.attributes = maxchar.attributes;
+
+ pInfo->minbounds.leftSideBearing = minchar.leftSideBearing;
+ pInfo->minbounds.rightSideBearing = minchar.rightSideBearing;
+ pInfo->minbounds.characterWidth = minchar.characterWidth;
+ pInfo->minbounds.ascent = minchar.ascent;
+ pInfo->minbounds.descent = minchar.descent;
+ pInfo->minbounds.attributes = minchar.attributes;
+
+ pInfo->ink_maxbounds.leftSideBearing = maxchar.leftSideBearing;
+ pInfo->ink_maxbounds.rightSideBearing = maxchar.rightSideBearing;
+ pInfo->ink_maxbounds.characterWidth = maxchar.characterWidth;
+ pInfo->ink_maxbounds.ascent = maxchar.ascent;
+ pInfo->ink_maxbounds.descent = maxchar.descent;
+ pInfo->ink_maxbounds.attributes = maxchar.attributes;
+
+ pInfo->ink_minbounds.leftSideBearing = minchar.leftSideBearing;
+ pInfo->ink_minbounds.rightSideBearing = minchar.rightSideBearing;
+ pInfo->ink_minbounds.characterWidth = minchar.characterWidth;
+ pInfo->ink_minbounds.ascent = minchar.ascent;
+ pInfo->ink_minbounds.descent = minchar.descent;
+ pInfo->ink_minbounds.attributes = minchar.attributes;
+
+ pInfo->maxOverlap = maxlap + -(minchar.leftSideBearing);
+
+ return total_raw_width;
+}
+#endif
+#endif
+
static void
-ComputeProps(pInfo, Vals, Filename, sAscent, sDescent)
- FontInfoPtr pInfo;
- FontScalablePtr Vals;
- char *Filename;
- long *sAscent;
- long *sDescent;
+ComputeProps(FontInfoPtr pInfo, FontScalablePtr Vals, char *Filename,
+ long *sAscent, long *sDescent)
{
int infoint;
int infoBBox[4];
@@ -291,27 +593,163 @@ ComputeProps(pInfo, Vals, Filename, sAscent, sDescent)
*sDescent = -infoBBox[1];
}
}
+
+#ifdef BUILDCID
+#ifndef CID_ALL_CHARS
+static void
+CIDComputeStdProps(FontInfoPtr pInfo, FontScalablePtr Vals,
+ char *Filename, char *Cmapname, char *Fontname,
+ long sAscent, long sDescent, long sWidth)
+{
+ FontPropPtr pp;
+ int i,
+ nprops;
+ fontProp *fpt;
+ char *is_str;
+ char *ptr1 = NULL,
+ *ptr2;
+ char *ptr3;
+ char *infostrP;
+ int rc;
+ char scaledName[CID_PATH_MAX];
+
+ strcpy (scaledName, Fontname);
+ /* Fill in our copy of the fontname from the Vals structure */
+ FontParseXLFDName (scaledName, Vals, FONT_XLFD_REPLACE_VALUE);
+
+ /* This form of the properties is used by the X-client; the X-server
+ doesn't care what they are. */
+ nprops = pInfo->nprops = NPROPS;
+ pInfo->isStringProp = (char *) xalloc(sizeof(char) * nprops);
+ pInfo->props = (FontPropPtr) xalloc(sizeof(FontPropRec) * nprops);
+ if (!pInfo->isStringProp || !pInfo->props) {
+ xfree(pInfo->isStringProp);
+ pInfo->isStringProp = (char *) 0;
+ xfree(pInfo->props);
+ pInfo->props = (FontPropPtr) 0;
+ pInfo->nprops = 0;
+ return;
+ }
+ bzero(pInfo->isStringProp, (sizeof(char) * nprops));
+
+ ptr2 = scaledName;
+ for (i = NNAMEPROPS, pp = pInfo->props, fpt = fontNamePropTable, is_str = pInfo->isStringProp;
+ i;
+ i--, pp++, fpt++, is_str++) {
+
+ if (*ptr2)
+ {
+ ptr1 = ptr2 + 1;
+ if (!(ptr2 = strchr(ptr1, '-'))) ptr2 = strchr(ptr1, '\0');
+ }
+
+ pp->name = fpt->atom;
+ switch (fpt->type) {
+ case atom: /* Just copy info from scaledName */
+ *is_str = TRUE;
+ pp->value = MakeAtom(ptr1, ptr2 - ptr1, TRUE);
+ break;
+ case truncate_atom:
+ *is_str = TRUE;
+ for (ptr3 = ptr1; *ptr3; ptr3++)
+ if (*ptr3 == '[')
+ break;
+ pp->value = MakeAtom(ptr1, ptr3 - ptr1, TRUE);
+ break;
+ case pixel_size:
+ pp->value = (int)(fabs(Vals->pixel_matrix[3]) + .5);
+ break;
+ case point_size:
+ pp->value = (int)(fabs(Vals->point_matrix[3]) * 10.0 + .5);
+ break;
+ case resolution_x:
+ pp->value = Vals->x;
+ break;
+ case resolution_y:
+ pp->value = Vals->y;
+ break;
+ case average_width:
+ pp->value = Vals->width;
+ break;
+ }
+ }
+
+ for (i = 0, fpt = extraProps;
+ i < NEXTRAPROPS;
+ i++, is_str++, pp++, fpt++) {
+ pp->name = fpt->atom;
+ switch (i) {
+ case FONTPROP:
+ *is_str = TRUE;
+ pp->value = MakeAtom(scaledName, strlen(scaledName), TRUE);
+ break;
+ case COPYRIGHTPROP:
+ *is_str = TRUE;
+ CIDQueryFontLib(Filename, Cmapname, "Notice", &infostrP, &rc);
+ if (rc || !infostrP) {
+ infostrP = "Copyright Notice not available";
+ }
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case FACE_NAMEPROP:
+ *is_str = TRUE;
+ CIDQueryFontLib(Filename, Cmapname, "CIDFontName", &infostrP, &rc);
+ if (rc || !infostrP) {
+ infostrP = "(unknown)";
+ }
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case FONT_TYPEPROP:
+ *is_str = TRUE;
+ infostrP = "CIDFont";
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case RASTERIZER_NAMEPROP:
+ *is_str = TRUE;
+ infostrP = "X Consortium Type 1 Rasterizer";
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case RAWPIXELPROP:
+ *is_str = FALSE;
+ pp->value = 1000;
+ break;
+ case RAWPOINTPROP:
+ *is_str = FALSE;
+ pp->value = (long)(72270.0 / (double)Vals->y + .5);
+ break;
+ case RAWASCENTPROP:
+ *is_str = FALSE;
+ pp->value = sAscent;
+ break;
+ case RAWDESCENTPROP:
+ *is_str = FALSE;
+ pp->value = sDescent;
+ break;
+ case RAWWIDTHPROP:
+ *is_str = FALSE;
+ pp->value = sWidth;
+ break;
+ }
+ }
+}
+#endif
+#endif
static void
-ComputeStdProps(pInfo, Vals, Filename, Fontname, sAscent, sDescent, sWidth)
- FontInfoPtr pInfo;
- FontScalablePtr Vals;
- char *Filename;
- char *Fontname;
- long sAscent;
- long sDescent;
- long sWidth;
+ComputeStdProps(FontInfoPtr pInfo, FontScalablePtr Vals,
+ char *Filename, char *Fontname,
+ long sAscent, long sDescent, long sWidth)
{
FontPropPtr pp;
int i,
nprops;
fontProp *fpt;
char *is_str;
- char *ptr1,
+ char *ptr1 = NULL,
*ptr2;
char *ptr3;
char *infostrP;
- long rc;
+ int rc;
char scaledName[MAXFONTNAMELEN];
strcpy (scaledName, Fontname);
@@ -399,6 +837,16 @@ ComputeStdProps(pInfo, Vals, Filename, Fontname, sAscent, sDescent, sWidth)
}
pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
break;
+ case FONT_TYPEPROP:
+ *is_str = TRUE;
+ infostrP = "Type 1";
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case RASTERIZER_NAMEPROP:
+ *is_str = TRUE;
+ infostrP = "X Consortium Type 1 Rasterizer";
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
case RAWPIXELPROP:
*is_str = FALSE;
pp->value = 1000;
@@ -422,16 +870,46 @@ ComputeStdProps(pInfo, Vals, Filename, Fontname, sAscent, sDescent, sWidth)
}
}
}
-
+
+#ifdef BUILDCID
/*ARGSUSED*/
int
-Type1GetInfoScalable(fpe, pInfo, entry, fontName, fileName, Vals)
- FontPathElementPtr fpe;
- FontInfoPtr pInfo;
- FontEntryPtr entry;
- FontNamePtr fontName;
- char *fileName;
- FontScalablePtr Vals;
+CIDGetInfoScalable(FontPathElementPtr fpe,
+ FontInfoPtr pInfo,
+ FontEntryPtr entry,
+ FontNamePtr fontName,
+ char *fileName,
+ FontScalablePtr Vals)
+{
+ FontPtr pfont;
+ int flags = 0;
+ long format = 0; /* It doesn't matter what format for just info */
+ long fmask = 0;
+ int ret;
+
+ ret = CIDOpenScalable(fpe, &pfont, flags, entry, fileName, Vals,
+ format, fmask, NULL);
+ if (ret != Successful)
+ return ret;
+ *pInfo = pfont->info;
+
+ /* XXX - Set pointers in pfont->info to NULL so they are not freed. */
+ pfont->info.props = NULL;
+ pfont->info.isStringProp = NULL;
+
+ CIDCloseFont(pfont);
+ return Successful;
+}
+#endif
+
+/*ARGSUSED*/
+int
+Type1GetInfoScalable(FontPathElementPtr fpe,
+ FontInfoPtr pInfo,
+ FontEntryPtr entry,
+ FontNamePtr fontName,
+ char *fileName,
+ FontScalablePtr Vals)
{
FontPtr pfont;
int flags = 0;
@@ -439,7 +917,8 @@ Type1GetInfoScalable(fpe, pInfo, entry, fontName, fileName, Vals)
long fmask = 0;
int ret;
- ret = Type1OpenScalable(fpe, &pfont, flags, entry, fileName, Vals, format, fmask);
+ ret = Type1OpenScalable(fpe, &pfont, flags, entry, fileName, Vals,
+ format, fmask , NULL);
if (ret != Successful)
return ret;
*pInfo = pfont->info;
@@ -451,14 +930,120 @@ Type1GetInfoScalable(fpe, pInfo, entry, fontName, fileName, Vals)
Type1CloseFont(pfont);
return Successful;
}
-
+
+#ifdef BUILDCID
+#ifndef CID_ALL_CHARS
+void
+CIDFillFontInfo(FontPtr pFont, FontScalablePtr Vals,
+ char *Filename, char *Fontname, char *Cmapname,
+#ifdef HAVE_CFM
+ char *cfmfilename,
+#endif
+ long sAscent, long sDescent, double sxmult)
+{
+#ifdef HAVE_CFM
+ FILE *cfm;
+ cfmrec *cfmp;
+ int gotcfm = 0;
+ CARD32 magic;
+#endif
+ long sWidth = 0;
+ FontInfoPtr pInfo = &pFont->info;
+
+ FillHeader(pInfo, Vals);
+
+#ifdef HAVE_CFM
+ if ((cfm = fopen(cfmfilename,"r"))) {
+ fread(&magic,sizeof(CARD32),1,cfm);
+ if(magic == CFMMAGIC) {
+ if ((cfmp = (cfmrec *)xalloc(sizeof(cfmrec))) != NULL) {
+ fread(cfmp,sizeof(cfmrec),1,cfm);
+ sWidth = (long)cfmp->totalrw;
+ pInfo->allExist = cfmp->alle;
+ if (sxmult != 0) {
+ pInfo->maxbounds.leftSideBearing =
+ floor((double)cfmp->maxbounds.leftSideBearing /
+ sxmult + 0.5);
+ pInfo->maxbounds.rightSideBearing =
+ floor((double)cfmp->maxbounds.rightSideBearing /
+ sxmult + 0.5);
+ pInfo->maxbounds.characterWidth =
+ floor((double)cfmp->maxbounds.characterWidth /
+ sxmult + 0.5);
+ pInfo->maxbounds.ascent =
+ floor((double)cfmp->maxbounds.ascent /
+ sxmult + 0.5);
+ pInfo->maxbounds.descent =
+ floor((double)cfmp->maxbounds.descent /
+ sxmult + 0.5);
+ pInfo->maxbounds.attributes =
+ cfmp->maxbounds.attributes;
+
+ pInfo->minbounds.leftSideBearing =
+ cfmp->minbounds.leftSideBearing / sxmult;
+ pInfo->minbounds.rightSideBearing =
+ cfmp->minbounds.rightSideBearing / sxmult;
+ pInfo->minbounds.characterWidth =
+ cfmp->minbounds.characterWidth / sxmult;
+ pInfo->minbounds.ascent =
+ cfmp->minbounds.ascent / sxmult;
+ pInfo->minbounds.descent =
+ cfmp->minbounds.descent / sxmult;
+ pInfo->minbounds.attributes = cfmp->minbounds.attributes;
+
+ pInfo->ink_maxbounds.leftSideBearing =
+ cfmp->ink_maxbounds.leftSideBearing / sxmult;
+ pInfo->ink_maxbounds.rightSideBearing =
+ cfmp->ink_maxbounds.rightSideBearing / sxmult;
+ pInfo->ink_maxbounds.characterWidth =
+ cfmp->ink_maxbounds.characterWidth / sxmult;
+ pInfo->ink_maxbounds.ascent =
+ cfmp->ink_maxbounds.ascent / sxmult;
+ pInfo->ink_maxbounds.descent =
+ cfmp->ink_maxbounds.descent / sxmult;
+ pInfo->ink_maxbounds.attributes =
+ cfmp->ink_maxbounds.attributes;
+
+ pInfo->ink_minbounds.leftSideBearing =
+ cfmp->ink_minbounds.leftSideBearing / sxmult;
+ pInfo->ink_minbounds.rightSideBearing =
+ cfmp->ink_minbounds.rightSideBearing / sxmult;
+ pInfo->ink_minbounds.characterWidth =
+ cfmp->ink_minbounds.characterWidth / sxmult;
+ pInfo->ink_minbounds.ascent =
+ cfmp->ink_minbounds.ascent / sxmult;
+ pInfo->ink_minbounds.descent =
+ cfmp->ink_minbounds.descent / sxmult;
+ pInfo->ink_minbounds.attributes =
+ cfmp->ink_minbounds.attributes;
+ pInfo->ink_minbounds.attributes =
+ cfmp->ink_minbounds.attributes;
+
+ pInfo->maxOverlap = (short)cfmp->maxo;
+
+ gotcfm = 1;
+ }
+ xfree(cfmp);
+ }
+ }
+ fclose(cfm);
+ }
+
+ if (!gotcfm)
+#endif
+ sWidth = ComputeBoundsAll(pFont);
+
+ FontComputeInfoAccelerators(pInfo);
+
+ CIDComputeStdProps(pInfo, Vals, Filename, Cmapname, Fontname, sAscent,
+ sDescent, sWidth);
+}
+#endif /* CID_ALL_CHARS */
+#endif /* BUILDCID */
+
void
-T1FillFontInfo(pFont, Vals, Filename, Fontname, sWidth)
- FontPtr pFont;
- FontScalablePtr Vals;
- char *Filename;
- char *Fontname;
- long sWidth;
+T1FillFontInfo(FontPtr pFont, FontScalablePtr Vals,
+ char *Filename, char *Fontname, long sWidth)
{
FontInfoPtr pInfo = &pFont->info;
struct type1font *p = (struct type1font *)pFont->fontPrivate;
@@ -474,15 +1059,31 @@ T1FillFontInfo(pFont, Vals, Filename, Fontname, sWidth)
/* Called once, at renderer registration time */
void
-T1InitStdProps()
+#ifdef BUILDCID
+Type1InitStdProps(void)
+#else
+T1InitStdProps(void)
+#endif
{
int i;
fontProp *t;
+#ifdef BUILDCID
+ if (!stdpropsinit) {
+ stdpropsinit = 1;
+ i = sizeof(fontNamePropTable) / sizeof(fontProp);
+ for (t = fontNamePropTable; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+ i = sizeof(extraProps) / sizeof(fontProp);
+ for (t = extraProps; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+ }
+#else
i = sizeof(fontNamePropTable) / sizeof(fontProp);
for (t = fontNamePropTable; i; i--, t++)
t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
i = sizeof(extraProps) / sizeof(fontProp);
for (t = extraProps; i; i--, t++)
t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+#endif
}
diff --git a/src/Type1/t1intf.h b/src/Type1/t1intf.h
index 52cedb7..c1e0e44 100644
--- a/src/Type1/t1intf.h
+++ b/src/Type1/t1intf.h
@@ -27,10 +27,113 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
-
-#define FIRSTCOL 32
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/t1intf.h,v 1.7 2001/07/25 15:04:55 dawes Exp $ */
+
+#ifdef BUILDCID
+#include "AFM.h"
+#endif
struct type1font {
CharInfoPtr pDefault;
- CharInfoRec glyphs[256-FIRSTCOL];
+ CharInfoRec glyphs[256];
};
+
+#ifdef BUILDCID
+typedef struct cid_glyphs {
+ char *CIDFontName;
+ char *CMapName;
+ long dataoffset;
+ double pixel_matrix[4];
+ CharInfoPtr pDefault;
+ CharInfoRec **glyphs;
+ FontInfo *AFMinfo;
+#ifdef USE_MMAP
+ unsigned char *CIDdata;
+ long CIDsize;
+#endif
+} cidglyphs;
+#endif
+
+/*
+ * Function prototypes
+ */
+/* t1funcs.c */
+#ifdef BUILDCID
+extern int CIDOpenScalable ( FontPathElementPtr fpe, FontPtr *ppFont,
+ int flags, FontEntryPtr entry, char *fileName,
+ FontScalablePtr vals, fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font );
+#endif
+extern int Type1OpenScalable ( FontPathElementPtr fpe, FontPtr *ppFont,
+ int flags, FontEntryPtr entry, char *fileName,
+ FontScalablePtr vals, fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font );
+#ifdef BUILDCID
+extern unsigned int getCID ( FontPtr pFont, unsigned int charcode );
+extern int CIDGetGlyphs ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs );
+extern int CIDGetMetrics ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, xCharInfo **glyphs );
+extern void CIDCloseFont ( FontPtr pFont );
+#endif
+extern void Type1CloseFont ( FontPtr pFont );
+extern int Type1ReturnCodeToXReturnCode ( int rc );
+#ifdef BUILDCID
+extern CharInfoPtr CIDRenderGlyph ( FontPtr pFont, psobj *charstringP,
+ psobj *subarrayP,
+ struct blues_struct *bluesP,
+ CharInfoPtr pci, int *mode );
+#endif
+
+/* t1info.c */
+#ifdef CID_ALL_CHARS
+extern void ComputeBoundsAllChars ( FontPtr pFont, char *cfmfilename, double sxmult );
+#endif
+#ifdef BUILDCID
+extern int CIDGetInfoScalable ( FontPathElementPtr fpe, FontInfoPtr pInfo,
+ FontEntryPtr entry, FontNamePtr fontName,
+ char *fileName, FontScalablePtr Vals );
+#endif
+extern int Type1GetInfoScalable ( FontPathElementPtr fpe, FontInfoPtr pInfo,
+ FontEntryPtr entry, FontNamePtr fontName,
+ char *fileName, FontScalablePtr Vals );
+#ifdef BUILDCID
+extern void CIDFillFontInfo ( FontPtr pFont, FontScalablePtr Vals,
+ char *Filename, char *Fontname, char *Cmapname,
+#ifdef HAVE_CFM
+ char *cfmfilename,
+#endif
+ long sAscent, long sDescent, double sxmult );
+#endif
+extern void T1FillFontInfo ( FontPtr pFont, FontScalablePtr Vals,
+ char *Filename, char *Fontname, long sWidth );
+extern void Type1InitStdProps ( void );
+
+/* cidchar.c */
+extern CharInfoPtr CIDGetGlyphInfo ( FontPtr pFont, unsigned int cidcode,
+ CharInfoPtr pci, int *rc );
+extern int CIDGetAFM ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs,
+ char *cidafmfile );
diff --git a/src/Type1/t1io.c b/src/Type1/t1io.c
index cd5b77a..d5ce774 100644
--- a/src/Type1/t1io.c
+++ b/src/Type1/t1io.c
@@ -28,21 +28,47 @@
* SOFTWARE.
* Author: Carol H. Thompson IBM Almaden Research Center
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/t1io.c,v 3.9 2001/08/27 19:49:54 dawes Exp $ */
/*******************************************************************
* I/O package for Type 1 font reading
********************************************************************/
-
+
#ifndef STATIC
#define STATIC static
#endif
+#ifndef FONTMODULE
#include <fcntl.h>
+#include <unistd.h>
+#else
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "xf86_ansic.h"
+#endif
#include "t1stdio.h"
#include "t1hdigit.h"
#ifdef WIN32
#include <X11/Xw32defs.h>
#endif
-
+#include "Xdefs.h"
+
/* Constants and variables used in the decryption */
#define c1 ((unsigned short)52845)
#define c2 ((unsigned short)22719)
@@ -56,16 +82,22 @@ STATIC F_FILE TheFile;
STATIC unsigned char TheBuffer[F_BUFSIZ];
/* Our routines */
-F_FILE *T1Open(), *T1Eexec();
-int T1Close();
-int T1Read(), T1Getc(), T1Ungetc();
-STATIC int T1Decrypt(), T1Fill();
+static int T1Decrypt ( unsigned char *p, int len );
+static int T1Fill ( F_FILE *f );
+
+#ifdef BUILDCID
+void
+resetDecrypt(void)
+{
+ Decrypt = 0;
+}
+#endif
/* -------------------------------------------------------------- */
/*ARGSUSED*/
-F_FILE *T1Open(fn, mode)
- char *fn; /* Pointer to filename */
- char *mode; /* Pointer to open mode string */
+F_FILE *
+T1Open(char *fn, /* Pointer to filename */
+ char *mode) /* Pointer to open mode string */
{
F_FILE *of = &TheFile;
int oflags = O_RDONLY; /* We know we are only reading */
@@ -75,7 +107,7 @@ F_FILE *T1Open(fn, mode)
#ifdef O_BINARY /* VMS or DOS */
oflags |= O_BINARY;
#endif
- of->fd = open(fn, oflags);
+ of->fd = open(fn, oflags, 0);
if (of->fd < 0)
return NULL;
@@ -91,8 +123,8 @@ F_FILE *T1Open(fn, mode)
} /* end Open */
/* -------------------------------------------------------------- */
-int T1Getc(f) /* Read one character */
- F_FILE *f; /* Stream descriptor */
+int /* Read one character */
+T1Getc(F_FILE *f) /* Stream descriptor */
{
if (f->b_base == NULL) return EOF; /* already closed */
@@ -111,9 +143,9 @@ int T1Getc(f) /* Read one character */
} /* end Getc */
/* -------------------------------------------------------------- */
-int T1Ungetc(c, f) /* Put back one character */
- int c;
- F_FILE *f; /* Stream descriptor */
+int /* Put back one character */
+T1Ungetc(int c,
+ F_FILE *f) /* Stream descriptor */
{
if (c != EOF) {
f->ungotc = c;
@@ -124,11 +156,11 @@ int T1Ungetc(c, f) /* Put back one character */
} /* end Ungetc */
/* -------------------------------------------------------------- */
-int T1Read(buffP, size, n, f) /* Read n items into caller's buffer */
- char *buffP; /* Buffer to be filled */
- int size; /* Size of each item */
- int n; /* Number of items to read */
- F_FILE *f; /* Stream descriptor */
+int /* Read n items into caller's buffer */
+T1Read(char *buffP, /* Buffer to be filled */
+ int size, /* Size of each item */
+ int n, /* Number of items to read */
+ F_FILE *f) /* Stream descriptor */
{
int bytelen, cnt, i;
F_char *p = (F_char *)buffP;
@@ -162,23 +194,66 @@ int T1Read(buffP, size, n, f) /* Read n items into caller's buffer */
} /* end Read */
/* -------------------------------------------------------------- */
-int T1Close(f) /* Close the file */
- F_FILE *f; /* Stream descriptor */
+int /* Close the file */
+T1Close(F_FILE *f) /* Stream descriptor */
{
if (f->b_base == NULL) return 0; /* already closed */
f->b_base = NULL; /* no valid stream */
return close(f->fd);
} /* end Close */
-#ifdef __STDC__
-#define pointer void *
-#else
-#define pointer char *
-#endif
/* -------------------------------------------------------------- */
-F_FILE *T1eexec(f) /* Initialization */
- F_FILE *f; /* Stream descriptor */
+F_FILE * /* Initialization */
+T1eexec(F_FILE *f) /* Stream descriptor */
+{
+ int i, c;
+ int H;
+ unsigned char *p;
+ unsigned char randomP[8];
+
+ r = 55665; /* initial key */
+ asc = 1; /* indicate ASCII form */
+
+ /* Consume the 4 random bytes, determining if we are also to
+ ASCIIDecodeHex as we process our input. (See pages 63-64
+ of the Adobe Type 1 Font Format book.) */
+
+ /* Skip over any initial white space chars */
+ while (HighHexP[c=_XT1getc(f)] == HWHITE_SPACE) ;
+
+ /* If ASCII, the next 7 chars are guaranteed consecutive */
+ randomP[0] = c; /* store first non white space char */
+ T1Read((pointer)(randomP+1), 1, 3, f); /* read 3 more, for a total of 4 */
+ /* store first four chars */
+ for (i=0,p=randomP; i<4; i++) { /* Check 4 valid ASCIIEncode chars */
+ if (HighHexP[*p++] > LAST_HDIGIT) { /* non-ASCII byte */
+ asc = 0;
+ break;
+ }
+ }
+ if (asc) { /* ASCII form, convert first eight bytes to binary */
+ T1Read((pointer)(randomP+4), 1, 4, f); /* Need four more */
+ for (i=0,p=randomP; i<4; i++) { /* Convert */
+ H = HighHexP[*p++];
+ randomP[i] = H | LowHexP[*p++];
+ }
+ }
+
+ /* Adjust our key */
+ for (i=0,p=randomP; i<4; i++) {
+ r = (*p++ + r) * c1 + c2;
+ }
+
+ /* Decrypt the remaining buffered bytes */
+ f->b_cnt = T1Decrypt(f->b_ptr, f->b_cnt);
+ Decrypt = 1;
+ return (T1Feof(f))?NULL:f;
+} /* end eexec */
+
+#ifdef BUILDCID
+F_FILE * /* Initialization */
+CIDeexec(F_FILE *f) /* Stream descriptor */
{
int i, c;
int H;
@@ -218,19 +293,31 @@ F_FILE *T1eexec(f) /* Initialization */
r = (*p++ + r) * c1 + c2;
}
- /* Decrypt the remaining buffered bytes */
- f->b_cnt = T1Decrypt(f->b_ptr, f->b_cnt);
+ /* Decrypt up to, but not including, the first '%' sign */
+ if (f->b_cnt > 0) {
+ for (i = 0; i < f->b_cnt; i++)
+ if (*(f->b_ptr + i) == '%')
+ break;
+
+ if (i < f->b_cnt) {
+ if (i == 0)
+ f->b_cnt = 0;
+ else
+ f->b_cnt = T1Decrypt(f->b_ptr, i);
+ } else
+ f->b_cnt = T1Decrypt(f->b_ptr, f->b_cnt);
+ }
Decrypt = 1;
return (T1Feof(f))?NULL:f;
} /* end eexec */
-
+#endif
+
/* -------------------------------------------------------------- */
-STATIC int T1Decrypt(p, len)
- unsigned char *p;
- int len;
+STATIC int
+T1Decrypt(unsigned char *p, int len)
{
int n;
- int H, L;
+ int H = 0, L;
unsigned char *inp = p;
unsigned char *tblP;
@@ -272,11 +359,11 @@ STATIC int T1Decrypt(p, len)
} /* end Decrypt */
/* -------------------------------------------------------------- */
-STATIC int T1Fill(f) /* Refill stream buffer */
- F_FILE *f; /* Stream descriptor */
+STATIC int /* Refill stream buffer */
+T1Fill(F_FILE *f) /* Stream descriptor */
{
int rc;
-
+
rc = read(f->fd, f->b_base, F_BUFSIZ);
/* propagate any error or eof to current file */
if (rc <= 0) {
diff --git a/src/Type1/t1malloc.c b/src/Type1/t1malloc.c
index 5028c8c..08a3a8b 100644
--- a/src/Type1/t1malloc.c
+++ b/src/Type1/t1malloc.c
@@ -26,6 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/t1malloc.c,v 1.11 2002/02/18 20:51:57 herrb Exp $ */
/* MALLOC CWEB V0004 LOTS */
/*
:h1.MALLOC - Fast Memory Allocation
@@ -37,12 +38,16 @@ routines (malloc/free).
*/
-#include "objects.h" /* get #define for abort() */
+#ifdef FONTMODULE
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "os.h"
+#include "xf86_ansic.h"
+#else
+#include "os.h"
+#endif
+#include "objects.h" /* get #define for Abort() */
-static void combine();
-static void freeuncombinable();
-static void unhook();
-static void dumpchain();
/*
:h3.Define NULL
@@ -54,7 +59,7 @@ popular (in terms of reducing compiler complaints), however, if your
compiler is unhappy about it, you can redefine it on the command line:
*/
#ifndef NULL
-#define NULL 0
+#include <stddef.h>
#endif
/*
Of course, NULL is important because xiMalloc() is defined to return
@@ -165,6 +170,18 @@ asked for.
long AvailableWords = 0; /* number of words available in memory */
char mallocdebug = 0; /* a flag that enables some chatty printf's */
+
+/*
+:h3.Prototypes of static functions
+*/
+
+static void combine ( void );
+static void freeuncombinable ( long *addr, long size );
+static void unhook ( struct freeblock *p );
+static void dumpchain ( void );
+#ifdef notused
+static void reportarea ( long *area );
+#endif
/*
:h3.whocalledme() - Debug for Memory Leaks
@@ -178,9 +195,9 @@ We use it to see who is malloc-ing memory without free-ing it.
#if DEBUGWORDS
-static whocalledme(addr, stack)
- long *addr; /* address of memory block */
- long *stack; /* address of malloc's parameter on stack */
+static void
+whocalledme(long *addr, /* address of memory block */
+ long *stack) /* address of malloc's parameter on stack */
{
register long size; /* size of memory block */
register int i; /* loop index */
@@ -206,8 +223,8 @@ The actual beginning of the block is one 'long' before the address we
gave to the user. The block begins and ends with '-size' in words.
*/
-void xiFree(addr)
- register long *addr; /* user's memory to be returned */
+void
+xiFree(long *addr) /* user's memory to be returned */
{
register long size; /* amount of memory in this block */
register struct freeblock *p; /* identical to 'addr' */
@@ -223,9 +240,9 @@ Make sure this address looks OK; 'size' must be less than zero (meaning
the block is allocated) and should be repeated at the end of the block.
*/
if (size >= 0)
- abort("free: bad size");
+ Abort("free: bad size");
if (addr[-1 - size] != size)
- abort("free: mismatched size");
+ Abort("free: mismatched size");
/*
Now make this a 'freeblock' structure and tack it on the FRONT of the
free list (where uncombined blocks go):
@@ -264,7 +281,7 @@ In any event, that block will be moved to the end of the list (after
*/
static void
-combine()
+combine(void)
{
register struct freeblock *p; /* block we will try to combine */
register long *addr; /* identical to 'p' for 'long' access */
@@ -273,12 +290,12 @@ combine()
p = firstcombined->back;
if (p == &firstfree)
- abort("why are we combining?");
+ Abort("why are we combining?");
addr = (long *) p;
size = - p->size;
if (--uncombined < 0)
- abort("too many combine()s");
+ Abort("too many combine()s");
if (addr[-1] < 0 && addr[size] < 0) {
/*
@@ -302,8 +319,8 @@ First we attempt to combine this with the block immediately above:
*addr = COMBINED; /* might help debug */
addr -= size2;
if (addr[0] != size2)
- abort("bad block above");
- unhook(addr);
+ Abort("bad block above");
+ unhook((struct freeblock *)addr);
size += size2;
}
/*
@@ -317,7 +334,7 @@ below:
if (size2 > 0) { /* i.e., block below is free */
p->size = COMBINED;
if (size2 != ((long *) p)[size2 - 1])
- abort("bad block below");
+ Abort("bad block below");
unhook(p);
size += size2;
}
@@ -337,9 +354,8 @@ no neighbors.
*/
static void
-freeuncombinable(addr, size)
- register long *addr; /* address of the block to be freed */
- register long size; /* size of block in words */
+freeuncombinable(long *addr, /* address of the block to be freed */
+ long size) /* size of block in words */
{
register struct freeblock *p; /* a convenient synonym for 'addr' */
@@ -372,8 +388,7 @@ have to worry about the end cases.)
*/
static void
-unhook(p)
- register struct freeblock *p; /* block to unhook */
+unhook(struct freeblock *p) /* block to unhook */
{
p->back->fore = p->fore;
p->fore->back = p->back;
@@ -394,10 +409,10 @@ cache.
#ifdef TYPE1IMAGER
-static char *malloc_local();
+static char *malloc_local(unsigned size);
-char *xiMalloc(size)
- register unsigned size;
+char *
+xiMalloc(unsigned size)
{
char *memaddr;
@@ -418,11 +433,12 @@ memory, and it is also compatible with the definition of a "size_t"
in most systems.
*/
#ifdef TYPE1IMAGER
-static char *malloc_local(Size)
+static char *
+malloc_local(unsigned Size) /* number of bytes the user requested */
#else
-char *xiMalloc(Size)
+char *
+xiMalloc(unsigned Size)
#endif
- unsigned Size; /* number of bytes the user requested */
{
register long size = (long)Size; /* a working register for size */
register struct freeblock *p; /* tentative block to be returned */
@@ -454,7 +470,7 @@ only to be "unhook"ed:
unhook(p);
uncombined--;
if (mallocdebug) {
- printf("fast xiMalloc(%d) = %p, ", size, p);
+ printf("fast xiMalloc(%ld) = %p, ", size, p);
dumpchain();
}
AvailableWords += size; /* decreases AvailableWords */
@@ -511,7 +527,7 @@ flag that this block is allocated:
area[size - 1] = area[0] = - size;
if (mallocdebug) {
- printf("slow xiMalloc(%d) @ %08x, ", size, area);
+ printf("slow xiMalloc(%ld) @ %p, ", size, area);
dumpchain();
}
whocalledme(area, &Size);
@@ -548,9 +564,9 @@ boundary.
static long *freearea[MAXAREAS] = { NULL }; /* so we can report later */
-void addmemory(addr, size)
- register long *addr; /* beginning of free area */
- register long size; /* number of bytes of free area */
+void
+addmemory(long *addr, /* beginning of free area */
+ long size) /* number of bytes of free area */
{
register int i; /* loop index variable */
register long *aaddr; /* aligned beginning of free area */
@@ -571,7 +587,7 @@ We'll record where the area was that was given to us for later reports:
for (i=0; i < MAXAREAS; i++)
if (freearea[i] == NULL) break;
if (i >= MAXAREAS)
- abort("too many addmemory()s");
+ Abort("too many addmemory()s");
aaddr = (long *) ( ((long) addr + sizeof(double) - 1) & - (long)sizeof(double) );
size -= (char *) aaddr - (char *) addr;
freearea[i] = aaddr;
@@ -595,7 +611,8 @@ free list:
/*
:h3.delmemory() - Delete Memory Pool
*/
-void delmemory()
+void
+delmemory(void)
{
register int i;
@@ -615,7 +632,7 @@ void delmemory()
*/
static void
-dumpchain()
+dumpchain(void)
{
register struct freeblock *p; /* current free block */
register long size; /* size of block */
@@ -627,36 +644,36 @@ dumpchain()
for (p = firstfree.fore, i=uncombined; p != firstcombined;
p = p->fore) {
if (--i < 0)
- abort("too many uncombined areas");
+ Abort("too many uncombined areas");
size = p->size;
printf(". . . area @ %p, size = %ld\n", p, -size);
if (size >= 0 || size != ((int *) p)[-1 - size])
- abort("dumpchain: bad size");
+ Abort("dumpchain: bad size");
if (p->back != back)
- abort("dumpchain: bad back");
+ Abort("dumpchain: bad back");
back = p;
}
printf("DUMPING COMBINED FREE LIST:\n");
for (; p != &lastfree; p = p->fore) {
size = p->size;
- printf(". . . area @ %p, size = %d\n", p, size);
+ printf(". . . area @ %p, size = %ld\n", p, size);
if (size <= 0 || size != ((int *) p)[size - 1])
- abort("dumpchain: bad size");
+ Abort("dumpchain: bad size");
if (p->back != back)
- abort("dumpchain: bad back");
+ Abort("dumpchain: bad back");
back = p;
}
if (back != lastfree.back)
- abort("dumpchain: bad lastfree");
+ Abort("dumpchain: bad lastfree");
}
+#ifdef notused
/*
:h3.reportarea() - Display a Contiguous Set of Memory Blocks
*/
static void
-reportarea(area)
- register long *area; /* start of blocks (from addmemory) */
+reportarea(long *area) /* start of blocks (from addmemory) */
{
register long size; /* size of current block */
register long wholesize; /* size of original area */
@@ -673,7 +690,7 @@ reportarea(area)
register int i,j;
size = -size;
- printf("Allocated %5d bytes at %08x, first words=%08x %08x\n",
+ printf("Allocated %5ld bytes at %p, first words=%08lx %08lx\n",
size * sizeof(long), area + 1, area[1], area[2]);
#if DEBUGWORDS
printf(" ...Last operator: %s\n",
@@ -682,29 +699,29 @@ reportarea(area)
for (i = size - DEBUGWORDS; i < size - 2; i += 8) {
printf(" ...");
for (j=0; j<8; j++)
- printf(" %08x", area[i+j]);
+ printf(" %08lx", area[i+j]);
printf("\n");
}
}
else {
- printf("Free %d bytes at %x\n", size * sizeof(long),
+ printf("Free %ld bytes at %p\n", size * sizeof(long),
area);
if (size == 0)
- abort("zero sized memory block");
+ Abort("zero sized memory block");
for (p = firstfree.fore; p != NULL; p = p->fore)
if ((long *) p == area) break;
if ((long *) p != area)
- abort("not found on forward chain");
+ Abort("not found on forward chain");
for (p = lastfree.back; p != NULL; p = p->back)
if ((long *) p == area) break;
if ((long *) p != area)
- abort("not found on backward chain");
+ Abort("not found on backward chain");
}
if (area[0] != area[size - 1])
- abort("unmatched check sizes");
+ Abort("unmatched check sizes");
area += size;
wholesize -= size;
}
@@ -714,7 +731,8 @@ reportarea(area)
:h3.MemReport() - Display All of Memory
*/
-void MemReport()
+void
+MemReport(void)
{
register int i;
@@ -728,8 +746,10 @@ void MemReport()
:h3.MemBytesAvail - Display Number of Bytes Now Available
*/
-void MemBytesAvail()
+void
+MemBytesAvail(void)
{
- printf("There are now %d bytes available\n", AvailableWords *
+ printf("There are now %ld bytes available\n", AvailableWords *
sizeof(long) );
}
+#endif
diff --git a/src/Type1/t1snap.c b/src/Type1/t1snap.c
index fd26e36..90c396b 100644
--- a/src/Type1/t1snap.c
+++ b/src/Type1/t1snap.c
@@ -27,10 +27,13 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/t1snap.c,v 1.4 2001/01/17 19:43:24 dawes Exp $ */
+
#include "objects.h"
#include "spaces.h"
#include "paths.h"
+#include "pictures.h"
/*
:h2.Handle Functions
@@ -40,15 +43,15 @@
This is a user operator. Its new name is QueryHandle.
*/
-struct segment *t1_Phantom(obj)
- register struct xobject *obj; /* object to take the Phantom of */
+struct segment *
+t1_Phantom(struct segment *p) /* object to take the Phantom of */
{
struct fractpoint pt; /* handle size will built here */
- if (obj == NULL)
+ if (p == NULL)
pt.x = pt.y = 0;
else
- PathDelta(obj, &pt);
+ PathDelta(p, &pt);
return(PathSegment(MOVETYPE, pt.x, pt.y));
}
@@ -59,8 +62,8 @@ struct segment *t1_Phantom(obj)
This is a user operator.
*/
-struct xobject *t1_Snap(p)
- register struct segment *p; /* path to snap */
+struct segment *
+t1_Snap(struct segment *p) /* path to snap */
{
struct fractpoint pt; /* for finding length of path */
@@ -75,5 +78,5 @@ struct xobject *t1_Snap(p)
}
else
p = JoinSegment(p, MOVETYPE, -pt.x, -pt.y, NULL);
- return((struct xobject *)p);
+ return(p);
}
diff --git a/src/Type1/t1stdio.h b/src/Type1/t1stdio.h
index b18ac5c..d4e71e8 100644
--- a/src/Type1/t1stdio.h
+++ b/src/Type1/t1stdio.h
@@ -27,7 +27,11 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/t1stdio.h,v 1.10 2001/07/25 15:04:55 dawes Exp $ */
/* T1IO FILE structure and related stuff */
+#ifdef XFree86LOADER
+#undef FILE
+#endif
#define FILE F_FILE
typedef unsigned char F_char;
@@ -49,11 +53,12 @@ typedef struct F_FILE {
#define FIOERROR (0x40)
#ifndef NULL
-#define NULL 0 /* null pointer */
+#include <stddef.h>
#endif
+
#define EOF (-1) /* end of file */
#define F_BUFSIZ (512)
-
+
#define _XT1getc(f) \
( \
( ((f)->b_cnt > 0) && ((f)->flags == 0) ) ? \
@@ -63,6 +68,30 @@ typedef struct F_FILE {
#define T1Feof(f) (((f)->flags & FIOEOF) && ((f)->b_cnt==0))
-extern FILE *T1Open(), *T1eexec();
-extern int T1Close(), T1Ungetc(), T1Read();
-
+#ifdef BUILDCID
+extern F_FILE *CIDeexec ( FILE *f );
+#endif
+
+extern FILE *T1Open ( char *fn, char *mode );
+extern int T1Getc ( FILE *f );
+extern int T1Ungetc ( int c, FILE *f );
+extern int T1Read ( char *buffP, int size, int n, FILE *f );
+extern int T1Close ( FILE *f );
+extern FILE *T1eexec ( FILE *f );
+extern void resetDecrypt ( void );
+
+#undef fclose
+#undef fopen
+#undef ungetc
+#undef fgetc
+#undef fread
+#undef feof
+#undef ferror
+#define fclose(f) T1Close(f)
+#define fopen(name,mode) T1Open(name,mode)
+#define ungetc(c,f) T1Ungetc(c,f)
+#define fgetc(f) T1Getc(f)
+
+#define fread(bufP,size,n,f) T1Read(bufP,size,n,f)
+#define feof(f) (((f)->flags & FIOEOF) && ((f)->b_cnt==0))
+#define ferror(f) (((f)->flags & FIOERROR)?(f)->error:0)
diff --git a/src/Type1/t1stub.c b/src/Type1/t1stub.c
index 82be9b3..cfe6ea9 100644
--- a/src/Type1/t1stub.c
+++ b/src/Type1/t1stub.c
@@ -27,16 +27,28 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/t1stub.c,v 1.9 2002/02/18 20:51:57 herrb Exp $ */
-#include "objects.h" /* get #define for abort() */
-
-xiStub()
+#ifdef FONTMODULE
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "os.h"
+#include "xf86_ansic.h"
+#else
+#include <stdio.h>
+#include "os.h"
+#endif
+#include "objects.h" /* get #define for Abort() */
+
+static void
+xiStub(void)
{
printf("xiStub called\n");
- abort("xiStub called");
+ Abort("xiStub called");
}
-void t1_DumpText()
+void
+t1_DumpText(void)
{
xiStub();
}
diff --git a/src/Type1/token.c b/src/Type1/token.c
index 054e1ea..ef28990 100644
--- a/src/Type1/token.c
+++ b/src/Type1/token.c
@@ -27,6 +27,7 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/token.c,v 1.5 2001/01/17 19:43:24 dawes Exp $ */
/* Authors: Sig Nin & Carol Thompson IBM Almaden Research Laboratory */
#include "t1stdio.h"
#include "util.h"
@@ -97,8 +98,8 @@ static double Exp10T[128] = {
1e56, 1e57, 1e58, 1e59, 1e60, 1e61, 1e62, 1e63
};
-static double P10(exponent)
- long exponent;
+static double
+P10(long exponent)
{
double value, power;
@@ -201,15 +202,15 @@ isWHITE_SPACE(ch)\
#define DONE (256)
/* Get the next input character */
-static int next_char(ch)
- int ch;
+static int
+next_char(int ch)
{
return(next_ch());
}
/* Add character to token */
-static int add_char(ch)
- int ch;
+static int
+add_char(int ch)
{
save_ch(ch);
return(next_ch());
@@ -221,8 +222,8 @@ static int add_char(ch)
*/
/* Skip white space */
-static int skip_space(ch)
- int ch;
+static int
+skip_space(int ch)
{
do {
ch = next_ch();
@@ -231,8 +232,8 @@ static int skip_space(ch)
}
/* Skip comments */
-static int skip_comment(ch)
- int ch;
+static int
+skip_comment(int ch)
{
do {
ch = next_ch();
@@ -259,23 +260,23 @@ static long r_base;
static long r_value;
static long r_scale;
-static int add_sign(ch)
- int ch;
+static int
+add_sign(int ch)
{
m_sign = ch;
save_unsafe_ch(ch);
return(next_ch());
}
-static int add_1st_digits(ch)
- int ch;
+static int
+add_1st_digits(int ch)
{
m_sign = '+';
return(add_digits(ch));
}
-static int add_digits(ch)
- int ch;
+static int
+add_digits(int ch)
{
long value, p_value, scale;
int digit;
@@ -366,15 +367,15 @@ static int add_digits(ch)
return(ch);
}
-static int add_1st_decpt(ch)
- int ch;
+static int
+add_1st_decpt(int ch)
{
m_sign = '+';
return(add_decpt(ch));
}
-static int add_decpt(ch)
- int ch;
+static int
+add_decpt(int ch)
{
/* On entry, expect m_sign to be set to '+' or '-' */
m_value = 0;
@@ -383,8 +384,8 @@ static int add_decpt(ch)
return(next_ch());
}
-static int add_fraction(ch)
- int ch;
+static int
+add_fraction(int ch)
{
long value, scale;
int digit;
@@ -480,16 +481,16 @@ static int add_fraction(ch)
return(ch);
}
-static int add_e_sign(ch)
- int ch;
+static int
+add_e_sign(int ch)
{
e_sign = ch;
save_ch(ch);
return(next_ch());
}
-static int add_exponent(ch)
- int ch;
+static int
+add_exponent(int ch)
{
long value, p_value;
long scale = 0;
@@ -558,8 +559,8 @@ static int add_exponent(ch)
return(ch);
}
-static int add_radix(ch)
- int ch;
+static int
+add_radix(int ch)
{
if (2 <= m_value && m_value <= 36 && m_scale == 0) {
r_base = m_value;
@@ -572,8 +573,8 @@ static int add_radix(ch)
}
}
-static int add_r_digits(ch)
- int ch;
+static int
+add_r_digits(int ch)
{
unsigned long value;
long radix, scale;
@@ -654,8 +655,8 @@ static int add_r_digits(ch)
*/
/* Done: Radix Number */
-static int RADIX_NUMBER(ch)
- int ch;
+static int
+RADIX_NUMBER(int ch)
{
back_ch_not_white(ch);
if (r_scale == 0) {
@@ -669,8 +670,8 @@ static int RADIX_NUMBER(ch)
}
/* Done: Integer */
-static int INTEGER(ch)
- int ch;
+static int
+INTEGER(int ch)
{
back_ch_not_white(ch);
if (m_scale == 0) {
@@ -685,8 +686,8 @@ static int INTEGER(ch)
}
/* Done: Real */
-static int REAL(ch)
- int ch;
+static int
+REAL(int ch)
{
double temp;
@@ -722,8 +723,8 @@ static int REAL(ch)
*/
/* Done: Hex String */
-static int HEX_STRING(ch)
- int ch;
+static int
+HEX_STRING(int ch)
{
int value;
@@ -795,8 +796,8 @@ static int HEX_STRING(ch)
* "\\", "\(", and "\)", simply store the second
* character.
*/
-static void save_digraph(ch)
- int ch;
+static void
+save_digraph(int ch)
{
int value;
@@ -858,8 +859,8 @@ static void save_digraph(ch)
}
/* Done: String */
-static int STRING(ch)
- int ch;
+static int
+STRING(int ch)
{
int nest_level = 1;
@@ -925,8 +926,8 @@ static int STRING(ch)
* start out looking like something else).
*/
-static int AAH_NAME(ch)
- int ch;
+static int
+AAH_NAME(int ch)
{
do {
save_ch(ch);
@@ -939,8 +940,8 @@ static int AAH_NAME(ch)
}
/* Done: Name */
-static int NAME(ch)
- int ch;
+static int
+NAME(int ch)
{
save_unsafe_ch(ch);
ch = next_ch();
@@ -979,8 +980,8 @@ static int NAME(ch)
}
/* Done: Literal Name */
-static int LITERAL_NAME(ch)
- int ch;
+static int
+LITERAL_NAME(int ch)
{
if (isNAME(ch)) {
save_unsafe_ch(ch);
@@ -1017,8 +1018,8 @@ static int LITERAL_NAME(ch)
}
/* Done: immediate Name */
-static int IMMED_NAME(ch)
- int ch;
+static int
+IMMED_NAME(int ch)
{
ch = next_ch();
if (isNAME(ch)) {
@@ -1056,8 +1057,8 @@ static int IMMED_NAME(ch)
}
/* Done: Name found while looking for something else */
-static int OOPS_NAME(ch)
- int ch;
+static int
+OOPS_NAME(int ch)
{
back_ch_not_white(ch);
tokenType = TOKEN_NAME;
@@ -1070,40 +1071,40 @@ static int OOPS_NAME(ch)
*/
/* Done: Unmatched Right Angle-Bracket */
-static int RIGHT_ANGLE(ch)
- int ch;
+static int
+RIGHT_ANGLE(int ch)
{
tokenType = TOKEN_RIGHT_ANGLE;
return(DONE);
}
/* Done: Unmatched Right Parenthesis */
-static int RIGHT_PAREN(ch)
- int ch;
+static int
+RIGHT_PAREN(int ch)
{
tokenType = TOKEN_RIGHT_PAREN;
return(DONE);
}
/* Done: Left Brace */
-static int LEFT_BRACE(ch)
- int ch;
+static int
+LEFT_BRACE(int ch)
{
tokenType = TOKEN_LEFT_BRACE;
return(DONE);
}
/* Done: Right Brace */
-static int RIGHT_BRACE(ch)
- int ch;
+static int
+RIGHT_BRACE(int ch)
{
tokenType = TOKEN_RIGHT_BRACE;
return(DONE);
}
/* Done: Left Bracket */
-static int LEFT_BRACKET(ch)
- int ch;
+static int
+LEFT_BRACKET(int ch)
{
save_unsafe_ch(ch);
tokenType = TOKEN_LEFT_BRACKET;
@@ -1111,8 +1112,8 @@ static int LEFT_BRACKET(ch)
}
/* Done: Right Bracket */
-static int RIGHT_BRACKET(ch)
- int ch;
+static int
+RIGHT_BRACKET(int ch)
{
save_unsafe_ch(ch);
tokenType = TOKEN_RIGHT_BRACKET;
@@ -1120,16 +1121,16 @@ static int RIGHT_BRACKET(ch)
}
/* Done: Break */
-static int BREAK_SIGNAL(ch)
- int ch;
+static int
+BREAK_SIGNAL(int ch)
{
tokenType = TOKEN_BREAK;
return(DONE);
}
/* Done: No Token Found */
-static int NO_TOKEN(ch)
- int ch;
+static int
+NO_TOKEN(int ch)
{
tokenType = TOKEN_EOF;
return(DONE);
@@ -1159,13 +1160,13 @@ static int NO_TOKEN(ch)
*
* -------------------------------------------------------------------
*/
-void scan_token(inputP)
- psobj *inputP;
+void
+scan_token(psobj *inputP)
{
int ch;
unsigned char *stateP = s0;
unsigned char entry;
- int (*actionP)();
+ int (*actionP)(int);
/* Define input source */
inputFileP = inputP->data.fileP;
diff --git a/src/Type1/token.h b/src/Type1/token.h
index 2dfe3fa..caa2ca2 100644
--- a/src/Type1/token.h
+++ b/src/Type1/token.h
@@ -27,6 +27,8 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/token.h,v 1.4 2001/01/17 19:43:24 dawes Exp $ */
+
#ifndef TOKEN_H
#define TOKEN_H
@@ -56,7 +58,7 @@
#define TOKEN_IMMED_NAME (16)
/* Token routines */
-extern void scan_token();
+extern void scan_token( psobj *inputP );
/*
* -------------------------------------------------------------------------
diff --git a/src/Type1/tokst.h b/src/Type1/tokst.h
index de3f0ec..61f1ff9 100644
--- a/src/Type1/tokst.h
+++ b/src/Type1/tokst.h
@@ -27,6 +27,8 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/tokst.h,v 1.4 2001/01/17 19:43:24 dawes Exp $ */
+
/* -------------------------------------- */
/* --- MACHINE GENERATED, DO NOT EDIT --- */
/* -------------------------------------- */
@@ -291,41 +293,41 @@ static unsigned char si11[258] = { 0x53,0x54,
* state. There are several entries for each state.
*
*/
-static int AAH_NAME();
-static int BREAK_SIGNAL();
-static int HEX_STRING();
-static int IMMED_NAME();
-static int INTEGER();
-static int LEFT_BRACE();
-static int LEFT_BRACKET();
-static int LITERAL_NAME();
-static int NAME();
-static int NO_TOKEN();
-static int OOPS_NAME();
-static int RADIX_NUMBER();
-static int REAL();
-static int RIGHT_ANGLE();
-static int RIGHT_BRACE();
-static int RIGHT_BRACKET();
-static int RIGHT_PAREN();
-static int STRING();
-static int add_1st_decpt();
-static int add_1st_digits();
-static int add_char();
-static int add_decpt();
-static int add_digits();
-static int add_e_sign();
-static int add_exponent();
-static int add_fraction();
-static int add_r_digits();
-static int add_radix();
-static int add_sign();
-static int next_char();
-static int skip_comment();
-static int skip_space();
+static int AAH_NAME ( int ch );
+static int BREAK_SIGNAL ( int ch );
+static int HEX_STRING ( int ch );
+static int IMMED_NAME ( int ch );
+static int INTEGER ( int ch );
+static int LEFT_BRACE ( int ch );
+static int LEFT_BRACKET ( int ch );
+static int LITERAL_NAME ( int ch );
+static int NAME ( int ch );
+static int NO_TOKEN ( int ch );
+static int OOPS_NAME ( int ch );
+static int RADIX_NUMBER ( int ch );
+static int REAL ( int ch );
+static int RIGHT_ANGLE ( int ch );
+static int RIGHT_BRACE ( int ch );
+static int RIGHT_BRACKET ( int ch );
+static int RIGHT_PAREN ( int ch );
+static int STRING ( int ch );
+static int add_1st_decpt ( int ch );
+static int add_1st_digits ( int ch );
+static int add_char ( int ch );
+static int add_decpt ( int ch );
+static int add_digits ( int ch );
+static int add_exponent ( int ch );
+static int add_e_sign ( int ch );
+static int add_fraction ( int ch );
+static int add_radix ( int ch );
+static int add_r_digits ( int ch );
+static int add_sign ( int ch );
+static int next_char ( int ch );
+static int skip_comment ( int ch );
+static int skip_space ( int ch );
static struct cat {
- int (*actionRoutineP)();
+ int (*actionRoutineP)(int);
unsigned char *nextStateP;
} classActionTable[] = {
diff --git a/src/Type1/trig.h b/src/Type1/trig.h
index c742f96..f442a61 100644
--- a/src/Type1/trig.h
+++ b/src/Type1/trig.h
@@ -28,6 +28,12 @@
* SOFTWARE.
*/
/*SHARED*/
+
+/* $XFree86: xc/lib/font/Type1/trig.h,v 1.3 2001/01/17 19:43:24 dawes Exp $ */
+
+#undef DegreeCos
+#undef DegreeSin
+#undef sqrt
#define DegreeCos(d) xiStub()
#define DegreeSin(d) xiStub()
diff --git a/src/Type1/type1.c b/src/Type1/type1.c
index f1b11c0..5b83dd0 100644
--- a/src/Type1/type1.c
+++ b/src/Type1/type1.c
@@ -28,6 +28,24 @@
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/type1.c,v 1.9 2001/01/17 19:43:24 dawes Exp $ */
/*********************************************************************/
/* */
@@ -46,16 +64,24 @@
/******************/
/* Include Files: */
/******************/
+#ifndef FONTMODULE
#include <stdio.h> /* a system-dependent include, usually */
-
+#include <math.h>
+#else
+#include "Xdefs.h"
+#include "Xmd.h"
+#include "xf86_ansic.h"
+#endif
#include "objects.h"
#include "spaces.h"
#include "paths.h"
#include "fonts.h" /* understands about TEXTTYPEs */
#include "pictures.h" /* understands about handles */
+#include "range.h"
typedef struct xobject xobject;
#include "util.h" /* PostScript objects */
+#include "fontfcn.h"
#include "blues.h" /* Blues structure for font-level hints */
/**********************************/
@@ -66,7 +92,11 @@ typedef struct xobject xobject;
#define MAXPSFAKESTACK 32 /* Max depth of fake PostScript stack (local) */
#define MAXSTRLEN 512 /* Max length of a Type 1 string (local) */
#define MAXLABEL 256 /* Maximum number of new hints */
+#ifdef BUILDCID
+#define MAXSTEMS 500 /* Maximum number of VSTEM and HSTEM hints */
+#else
#define MAXSTEMS 128 /* Maximum number of VSTEM and HSTEM hints */
+#endif
#define EPS 0.001 /* Small number for comparisons */
/************************************/
@@ -106,14 +136,12 @@ typedef struct xobject xobject;
/*****************/
/* Useful macros */
/*****************/
-static double tmpx; /* Store macro argument in tmpx to avoid re-evaluation */
-static long tmpi; /* Store converted value in tmpi to avoid re-evaluation */
-#define FABS(x) (((tmpx = (x)) < 0.0) ? -tmpx : tmpx)
+#define FABS(x) fabs(x)
-#define CEIL(x) (((tmpi = (long) (tmpx = (x))) < (x)) ? ++tmpi : tmpi)
+#define CEIL(x) ceil(x)
-#define FLOOR(x) (((tmpi = (long) (tmpx = (x))) > (x)) ? --tmpi : tmpi)
+#define FLOOR(x) floor(x)
#define ROUND(x) FLOOR((x) + 0.5)
@@ -138,7 +166,14 @@ struct stem { /* representation of a STEM hint */
struct segment *rthint, *rtrevhint; /* right or top hint adjustment */
};
-extern struct XYspace *IDENTITY;
+struct xobject *Type1Char(char *env, struct XYspace *S,
+ psobj *charstrP, psobj *subrsP, psobj *osubrsP,
+ struct blues_struct *bluesP, int *modeP);
+#ifdef BUILDCID
+struct xobject *CIDChar(char *env, struct XYspace *S,
+ psobj *charstrP, psobj *subrsP, psobj *osubrsP,
+ struct blues_struct *bluesP, int *modeP);
+#endif
static double escapementX, escapementY;
static double sidebearingX, sidebearingY;
@@ -158,24 +193,57 @@ static int *ModeP;
/************************/
/* Forward declarations */
/************************/
-static double Div();
-static double PSFakePop();
-static void DoCommand();
-static void Escape();
-static void HStem();
-static void VStem();
-static void RLineTo();
-static void RRCurveTo();
-static void DoClosePath();
-static void CallSubr();
-static void Return();
-static void EndChar();
-static void RMoveTo();
-static void DotSection();
-static void Seac();
-static void Sbw();
-static void CallOtherSubr();
-static void SetCurrentPoint();
+static struct segment *Applyhint ( struct segment *p, int stemnumber,
+ int half );
+static struct segment *Applyrevhint ( struct segment *p, int stemnumber,
+ int half );
+static void CallOtherSubr ( int othersubrno );
+static void CallSubr ( int subrno );
+static struct segment *CenterStem ( double edge1, double edge2 );
+static void ClearCallStack ( void );
+static void ClearPSFakeStack ( void );
+static void ClearStack ( void );
+static void ComputeAlignmentZones ( void );
+static void ComputeStem ( int stemno );
+static void Decode ( int Code );
+static unsigned char Decrypt ( unsigned char cipher );
+static double Div ( double num1, double num2 );
+static void DoClosePath ( void );
+static void DoCommand ( int Code );
+static int DoRead ( int *CodeP );
+static void DotSection ( void );
+static void EndChar ( void );
+static void Escape ( int Code );
+static struct segment *FindStems ( double x, double y, double dx, double dy );
+static void FinitStems ( void );
+static void FlxProc ( double c1x2, double c1y2, double c3x0, double c3y0,
+ double c3x1, double c3y1, double c3x2, double c3y2,
+ double c4x0, double c4y0, double c4x1, double c4y1,
+ double c4x2, double c4y2, double epY, double epX,
+ int idmin );
+static void FlxProc1 ( void );
+static void FlxProc2 ( void );
+static void HintReplace ( void );
+static void HStem ( double y, double dy );
+static void InitStems ( void );
+static void PopCall ( psobj **CurrStrPP, int *CurrIndexP,
+ unsigned short *CurrKeyP );
+static double PSFakePop ( void );
+static void PSFakePush ( double Num );
+static void Push ( double Num );
+static void PushCall ( psobj *CurrStrP, int CurrIndex,
+ unsigned short CurrKey );
+static void Return ( void );
+static void RLineTo ( double dx, double dy );
+static void RMoveTo ( double dx, double dy );
+static void RRCurveTo ( double dx1, double dy1, double dx2, double dy2,
+ double dx3, double dy3 );
+static void Sbw ( double sbx, double sby, double wx, double wy );
+static void Seac ( double asb, double adx, double ady, unsigned char bchar,
+ unsigned char achar );
+static void SetCurrentPoint ( double x, double y );
+static void StartDecrypt ( void );
+static void VStem ( double x, double dx );
/*****************************************/
/* statics for Flex procedures (FlxProc) */
@@ -197,7 +265,7 @@ static int numalignmentzones; /* total number of alignment zones */
/* Fill in the alignment zone structures. */
/******************************************/
static void
-ComputeAlignmentZones()
+ComputeAlignmentZones(void)
{
int i;
double dummy, bluezonepixels, familyzonepixels;
@@ -276,7 +344,7 @@ static double wsoffsetX, wsoffsetY; /* White space offset - for VSTEM3,HSTEM3 *
static int wsset; /* Flag for whether we've set wsoffsetX,Y */
static void
-InitStems() /* Initialize the STEM hint data structures */
+InitStems(void) /* Initialize the STEM hint data structures */
{
InDotSection = FALSE;
currstartstem = numstems = 0;
@@ -284,7 +352,7 @@ InitStems() /* Initialize the STEM hint data structures */
}
static void
-FinitStems() /* Terminate the STEM hint data structures */
+FinitStems(void) /* Terminate the STEM hint data structures */
{
int i;
@@ -301,8 +369,7 @@ FinitStems() /* Terminate the STEM hint data structures */
/* inside the stem. */
/*******************************************************************/
static void
-ComputeStem(stemno)
- int stemno;
+ComputeStem(int stemno)
{
int verticalondevice, idealwidth;
double stemstart, stemwidth;
@@ -450,10 +517,10 @@ ComputeStem(stemno)
if (unitpixels < blues->BlueScale)
suppressovershoot = TRUE;
else
- if (alignmentzones[i].topzone)
+ if (alignmentzones[i].topzone) {
if (stemtop >= alignmentzones[i].bottomy + blues->BlueShift)
enforceovershoot = TRUE;
- else
+ } else
if (stembottom <= alignmentzones[i].topy - blues->BlueShift)
enforceovershoot = TRUE;
@@ -492,20 +559,21 @@ ComputeStem(stemno)
it falls at least one pixel beyond the flat position. */
if (enforceovershoot)
- if (overshoot < onepixel)
+ if (overshoot < onepixel) {
if (alignmentzones[i].topzone)
stemshift += onepixel - overshoot;
else
stemshift -= onepixel - overshoot;
-
+ }
/* SUPPRESS overshoot by aligning the stem to the alignment zone's
flat position. */
- if (suppressovershoot)
+ if (suppressovershoot) {
if (alignmentzones[i].topzone)
stemshift -= overshoot;
else
stemshift += overshoot;
+ }
}
/************************************************************/
@@ -569,9 +637,8 @@ ComputeStem(stemno)
/* hint value or the right/top hint value depending on where the */
/* point lies in the stem. */
/*********************************************************************/
-static struct segment *Applyhint(p, stemnumber, half)
-struct segment *p;
-int stemnumber, half;
+static struct segment *
+Applyhint(struct segment *p, int stemnumber, int half)
{
if (half == LEFT || half == BOTTOM)
return Join(p, stems[stemnumber].lbhint); /* left or bottom hint */
@@ -584,9 +651,8 @@ int stemnumber, half;
/* hint value or the right/top hint value depending on where the */
/* point lies in the stem. */
/*********************************************************************/
-static struct segment *Applyrevhint(p, stemnumber, half)
-struct segment *p;
-int stemnumber, half;
+static struct segment *
+Applyrevhint(struct segment *p, int stemnumber, int half)
{
if (half == LEFT || half == BOTTOM)
return Join(p, stems[stemnumber].lbrevhint); /* left or bottom hint */
@@ -602,8 +668,8 @@ int stemnumber, half;
/* The actual hintvalue is returned as a location. */
/* Hints are ignored inside a DotSection. */
/***********************************************************************/
-static struct segment *FindStems(x, y, dx, dy)
-double x, y, dx, dy;
+static struct segment *
+FindStems(double x, double y, double dx, double dy)
{
int i;
int newvert, newhor;
@@ -697,30 +763,26 @@ static double PSFakeStack[MAXPSFAKESTACK];
static int PSFakeTop;
static void
-ClearStack()
+ClearStack(void)
{
Top = -1;
}
static void
-Push(Num)
- double Num;
+Push(double Num)
{
if (++Top < MAXSTACK) Stack[Top] = Num;
else Error0("Push: Stack full\n");
}
static void
-ClearCallStack()
+ClearCallStack(void)
{
CallTop = -1;
}
static void
-PushCall(CurrStrP, CurrIndex, CurrKey)
- psobj *CurrStrP;
- int CurrIndex;
- unsigned short CurrKey;
+PushCall(psobj *CurrStrP, int CurrIndex, unsigned short CurrKey)
{
if (++CallTop < MAXCALLSTACK) {
CallStack[CallTop].currstrP = CurrStrP; /* save CharString pointer */
@@ -731,10 +793,7 @@ PushCall(CurrStrP, CurrIndex, CurrKey)
}
static void
-PopCall(CurrStrPP, CurrIndexP, CurrKeyP)
- psobj **CurrStrPP;
- int *CurrIndexP;
- unsigned short *CurrKeyP;
+PopCall(psobj **CurrStrPP, int *CurrIndexP, unsigned short *CurrKeyP)
{
if (CallTop >= 0) {
*CurrStrPP = CallStack[CallTop].currstrP; /* restore CharString pointer */
@@ -745,23 +804,22 @@ PopCall(CurrStrPP, CurrIndexP, CurrKeyP)
}
static void
-ClearPSFakeStack()
+ClearPSFakeStack(void)
{
PSFakeTop = -1;
}
/* PSFakePush: Pushes a number onto the fake PostScript stack */
static void
-PSFakePush(Num)
- double Num;
+PSFakePush(double Num)
{
if (++PSFakeTop < MAXPSFAKESTACK) PSFakeStack[PSFakeTop] = Num;
else Error0("PSFakePush: Stack full\n");
}
/* PSFakePop: Removes a number from the top of the fake PostScript stack */
-static double
-PSFakePop ()
+static double
+PSFakePop (void)
{
if (PSFakeTop >= 0) return(PSFakeStack[PSFakeTop--]);
else Error0Ret("PSFakePop : Stack empty\n", 0.0);
@@ -771,9 +829,8 @@ PSFakePop ()
/***********************************************************************/
/* Center a stem on the pixel grid -- used by HStem3 and VStem3 */
/***********************************************************************/
-static struct segment *CenterStem(edge1, edge2)
- double edge1;
- double edge2;
+static struct segment *
+CenterStem(double edge1, double edge2)
{
int idealwidth, verticalondevice;
double leftx, lefty, rightx, righty, center, width;
@@ -842,8 +899,8 @@ static struct segment *CenterStem(edge1, edge2)
static unsigned short r; /* Pseudo-random sequence of keys */
-static unsigned char Decrypt(cipher)
-unsigned char cipher;
+static unsigned char
+Decrypt(unsigned char cipher)
{
unsigned char plain;
@@ -853,8 +910,8 @@ unsigned char cipher;
}
/* Get the next byte from the codestring being interpreted */
-static int DoRead(CodeP)
- int *CodeP;
+static int
+DoRead(int *CodeP)
{
if (strindex >= CharStringP->len) return(FALSE); /* end of string */
*CodeP = Decrypt((unsigned char) CharStringP->data.stringP[strindex++]);
@@ -864,7 +921,8 @@ static int DoRead(CodeP)
/* Strip blues->lenIV bytes from CharString and update encryption key */
/* (the lenIV entry in the Private dictionary specifies the number of */
/* random bytes at the beginning of each CharString; default is 4) */
-static void StartDecrypt()
+static void
+StartDecrypt(void)
{
int Code;
@@ -875,8 +933,7 @@ static void StartDecrypt()
}
static void
-Decode(Code)
- int Code;
+Decode(int Code)
{
int Code1, Code2, Code3, Code4;
@@ -906,8 +963,7 @@ ended: Error0("Decode: Premature end of Type 1 CharString");
/* Interpret a command code */
static void
-DoCommand(Code)
- int Code;
+DoCommand(int Code)
{
switch(Code) {
case HSTEM: /* |- y dy HSTEM |- */
@@ -1025,8 +1081,7 @@ DoCommand(Code)
}
static void
-Escape(Code)
- int Code;
+Escape(int Code)
{
int i, Num;
struct segment *p;
@@ -1094,7 +1149,14 @@ Escape(Code)
if (Top < Num+1) Error0("DoCommand: Stack low\n");
for (i = 0; i < Num; i++) PSFakePush(Stack[Top - i - 2]);
Top -= Num + 2;
+#ifdef BUILDCID
+ if ((int)Stack[Top + Num + 2] > 3)
+ ClearPSFakeStack();
+ else
+ CallOtherSubr((int)Stack[Top + Num + 2]);
+#else
CallOtherSubr((int)Stack[Top + Num + 2]);
+#endif
break;
case POP: /* - POP number */
/* Removes a number from the top of the */
@@ -1121,8 +1183,7 @@ Escape(Code)
/* between coordinates y and y + dy */
/* y is relative to the left sidebearing point */
static void
-HStem(y, dy)
- double y, dy;
+HStem(double y, double dy)
{
IfTrace2((FontDebug), "Hstem %f %f\n", &y, &dy);
if (ProcessHints) {
@@ -1142,9 +1203,9 @@ HStem(y, dy)
/* Declares the horizontal range of a vertical stem zone */
/* between coordinates x and x + dx */
/* x is relative to the left sidebearing point */
+
static void
-VStem(x, dx)
- double x, dx;
+VStem(double x, double dx)
{
IfTrace2((FontDebug), "Vstem %f %f\n", &x, &dx);
if (ProcessHints) {
@@ -1163,8 +1224,7 @@ VStem(x, dx)
/* |- dx dy RLINETO |- */
/* Behaves like RLINETO in PostScript */
static void
-RLineTo(dx, dy)
- double dx, dy;
+RLineTo(double dx, double dy)
{
struct segment *B;
@@ -1187,8 +1247,8 @@ RLineTo(dx, dy)
/* (dx1+dx2) (dy1+dy2) (dx1+dx2+dx3) */
/* (dy1+dy2+dy3) RCURVETO in PostScript */
static void
-RRCurveTo(dx1, dy1, dx2, dy2, dx3, dy3)
- double dx1, dy1, dx2, dy2, dx3, dy3;
+RRCurveTo(double dx1, double dy1, double dx2, double dy2,
+ double dx3, double dy3)
{
struct segment *B, *C, *D;
@@ -1211,17 +1271,17 @@ RRCurveTo(dx1, dy1, dx2, dy2, dx3, dy3)
/* Since XIMAGER is not completely relative, */
/* we need to add up the delta values */
- C = Join(C, Dup(B));
- D = Join(D, Dup(C));
+ C = Join(C, (struct segment *)Dup(B));
+ D = Join(D, (struct segment *)Dup(C));
- path = Join(path, Bezier(B, C, D));
+ path = Join(path, (struct segment *)Bezier(B, C, D));
}
/* - CLOSEPATH |- */
/* Closes a subpath WITHOUT repositioning the */
/* current point */
static void
-DoClosePath()
+DoClosePath(void)
{
struct segment *CurrentPoint;
@@ -1235,8 +1295,7 @@ DoClosePath()
/* Calls a CharString subroutine with index */
/* subr# from the Subrs array */
static void
-CallSubr(subrno)
- int subrno;
+CallSubr(int subrno)
{
IfTrace1((FontDebug), "CallSubr %d\n", subrno);
if ((subrno < 0) || (subrno >= SubrsP->len))
@@ -1250,7 +1309,7 @@ CallSubr(subrno)
/* Returns from a Subrs array CharString */
/* subroutine called with CALLSUBR */
static void
-Return()
+Return(void)
{
IfTrace0((FontDebug), "Return\n");
PopCall(&CharStringP, &strindex, &r);
@@ -1265,7 +1324,7 @@ Return()
/* or STROKE depending on the value of PaintType in the */
/* font dictionary */
static void
-EndChar()
+EndChar(void)
{
IfTrace0((FontDebug), "EndChar\n");
@@ -1283,8 +1342,7 @@ EndChar()
/* |- dx dy RMOVETO |- */
/* Behaves like RMOVETO in PostScript */
static void
-RMoveTo(dx,dy)
- double dx,dy;
+RMoveTo(double dx, double dy)
{
struct segment *B;
@@ -1306,7 +1364,7 @@ RMoveTo(dx,dy)
/* Brackets an outline section for the dots in */
/* letters such as "i", "j", and "!". */
static void
-DotSection()
+DotSection(void)
{
IfTrace0((FontDebug), "DotSection\n");
InDotSection = !InDotSection;
@@ -1315,9 +1373,8 @@ DotSection()
/* |- asb adx ady bchar achar SEAC |- */
/* Standard Encoding Accented Character. */
static void
-Seac(asb, adx, ady, bchar, achar)
- double asb, adx, ady;
- unsigned char bchar, achar;
+Seac(double asb, double adx, double ady,
+ unsigned char bchar, unsigned char achar)
{
int Code;
struct segment *mypath;
@@ -1337,7 +1394,7 @@ Seac(asb, adx, ady, bchar, achar)
path = NULL;
/* Go find the CharString for the accent's code via an upcall */
- CharStringP = GetType1CharString(Environment, achar);
+ CharStringP = GetType1CharString((psfont *)Environment, achar);
StartDecrypt();
ClearStack();
@@ -1357,7 +1414,7 @@ Seac(asb, adx, ady, bchar, achar)
accentoffsetX = accentoffsetY = 0;
/* go find the CharString for the base char's code via an upcall */
- CharStringP = GetType1CharString(Environment, bchar);
+ CharStringP = GetType1CharString((psfont *)Environment, bchar);
StartDecrypt();
ClearStack();
@@ -1380,8 +1437,7 @@ Seac(asb, adx, ady, bchar, achar)
/* Set the left sidebearing point to (sbx,sby), */
/* set the character width vector to (wx,wy). */
static void
-Sbw(sbx, sby, wx, wy)
- double sbx, sby, wx, wy;
+Sbw(double sbx, double sby, double wx, double wy)
{
IfTrace4((FontDebug), "SBW %f %f %f %f\n", &sbx, &sby, &wx, &wy);
@@ -1398,8 +1454,8 @@ Sbw(sbx, sby, wx, wy)
/* num1 num2 DIV quotient */
/* Behaves like DIV in the PostScript language */
-static double Div(num1, num2)
- double num1, num2;
+static double
+Div(double num1, double num2)
{
IfTrace2((FontDebug), "Div %f %f\n", &num1, &num2);
return(num1 / num2);
@@ -1485,14 +1541,11 @@ static double Div(num1, num2)
/* Calling sequence: 'idmin epX epY 3 0 callothersubr' */
/* Computes Flex values, and renders the Flex path, */
/* and returns (leaves) ending coordinates on stack */
-static void
-FlxProc(c1x2, c1y2, c3x0, c3y0, c3x1, c3y1, c3x2, c3y2,
- c4x0, c4y0, c4x1, c4y1, c4x2, c4y2, epY, epX, idmin)
- double c1x2, c1y2;
- double c3x0, c3y0, c3x1, c3y1, c3x2, c3y2;
- double c4x0, c4y0, c4x1, c4y1, c4x2, c4y2;
- double epX, epY;
- int idmin;
+static void
+FlxProc(double c1x2, double c1y2, double c3x0, double c3y0,
+ double c3x1, double c3y1, double c3x2, double c3y2,
+ double c4x0, double c4y0, double c4x1, double c4y1,
+ double c4x2, double c4y2, double epY, double epX, int idmin)
{
double dmin;
double c1x0, c1y0, c1x1, c1y1;
@@ -1656,7 +1709,8 @@ FlxProc(c1x2, c1y2, c3x0, c3y0, c3x1, c3y1, c3x2, c3y2,
/* FlxProc1() = OtherSubrs[1]; Part of Flex */
/* Calling sequence: '0 1 callothersubr' */
/* Saves and clears path, then restores currentpoint */
-static void FlxProc1()
+static void
+FlxProc1(void)
{
struct segment *CurrentPoint;
@@ -1669,7 +1723,8 @@ static void FlxProc1()
/* FlxProc2() = OtherSubrs[2]; Part of Flex */
/* Calling sequence: '0 2 callothersubr' */
/* Returns currentpoint on stack */
-static void FlxProc2()
+static void
+FlxProc2(void)
{
struct segment *CurrentPoint;
double CurrentX, CurrentY;
@@ -1686,7 +1741,8 @@ static void FlxProc2()
/* HintReplace() = OtherSubrs[3]; Hint Replacement */
/* Calling sequence: 'subr# 1 3 callothersubr pop callsubr' */
/* Reinitializes stem hint structure */
-static void HintReplace()
+static void
+HintReplace(void)
{
/* Effectively retire the current stems, but keep them around for */
/* revhint use in case we are in a stem when we replace hints. */
@@ -1699,8 +1755,7 @@ static void HintReplace()
/* Make calls on the PostScript interpreter (or call equivalent C code) */
/* NOTE: The n arguments have been pushed on the fake PostScript stack */
static void
-CallOtherSubr(othersubrno)
- int othersubrno;
+CallOtherSubr(int othersubrno)
{
IfTrace1((FontDebug), "CallOtherSubr %d\n", othersubrno);
@@ -1735,8 +1790,7 @@ CallOtherSubr(othersubrno)
/* character space coordinates without per- */
/* forming a CharString MOVETO command */
static void
-SetCurrentPoint(x, y)
- double x, y;
+SetCurrentPoint(double x, double y)
{
IfTrace2((FontDebug), "SetCurrentPoint %f %f\n", &x, &y);
@@ -1746,14 +1800,11 @@ SetCurrentPoint(x, y)
/* The Type1Char routine for use by PostScript. */
/************************************************/
-struct xobject *Type1Char(env, S, charstrP, subrsP, osubrsP, bluesP, modeP)
- char *env;
- struct XYspace *S;
- psobj *charstrP;
- psobj *subrsP;
- psobj *osubrsP;
- struct blues_struct *bluesP; /* FontID's ptr to the blues struct */
- int *modeP;
+struct xobject *
+Type1Char(char *env, struct XYspace *S, psobj *charstrP, psobj *subrsP,
+ psobj *osubrsP,
+ struct blues_struct *bluesP, /* FontID's ptr to the blues struct */
+ int *modeP)
{
int Code;
@@ -1804,7 +1855,66 @@ struct xobject *Type1Char(env, S, charstrP, subrsP, osubrsP, bluesP, modeP)
path = NULL; /* Indicate that character could not be built */
}
}
-
+
return((struct xobject *) path);
}
-
+
+#ifdef BUILDCID
+struct xobject *
+CIDChar(char *env, struct XYspace *S,
+ psobj *charstrP, psobj *subrsP, psobj *osubrsP,
+ struct blues_struct *bluesP, /* FontID's ptr to the blues struct */
+ int *modeP)
+{
+ int Code;
+
+ path = NULL;
+ errflag = FALSE;
+
+ /* Make parameters available to all CID routines */
+ Environment = env;
+ CharSpace = S; /* used when creating path elements */
+ CharStringP = charstrP;
+ SubrsP = subrsP;
+ OtherSubrsP = osubrsP;
+ ModeP = modeP;
+
+ blues = bluesP;
+
+ /* compute the alignment zones */
+ ComputeAlignmentZones();
+
+ StartDecrypt();
+
+ ClearStack();
+ ClearPSFakeStack();
+ ClearCallStack();
+
+ InitStems();
+
+ currx = curry = 0;
+ escapementX = escapementY = 0;
+ sidebearingX = sidebearingY = 0;
+ accentoffsetX = accentoffsetY = 0;
+ wsoffsetX = wsoffsetY = 0; /* No shift to preserve whitspace. */
+ wsset = 0; /* wsoffsetX,Y haven't been set yet. */
+
+ for (;;) {
+ if (!DoRead(&Code)) break;
+ Decode(Code);
+ if (errflag) break;
+ }
+
+ FinitStems();
+
+ /* Clean up if an error has occurred */
+ if (errflag) {
+ if (path != NULL) {
+ Destroy(path); /* Reclaim storage */
+ path = NULL; /* Indicate that character could not be built */
+ }
+ }
+
+ return((struct xobject *) path);
+}
+#endif
diff --git a/src/Type1/util.c b/src/Type1/util.c
index aafe7c5..9bd8a83 100644
--- a/src/Type1/util.c
+++ b/src/Type1/util.c
@@ -27,11 +27,35 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/util.c,v 1.6 2001/01/17 19:43:24 dawes Exp $ */
/* Author: Katherine A. Hitchcock IBM Almaden Research Laboratory */
+#ifndef FONTMODULE
#include <stdio.h>
+#else
+#include "Xdefs.h"
+#include "Xmd.h"
+#include "xf86_ansic.h"
+#endif
#include "util.h"
-#include "fontmisc.h"
+#include "fontmisc.h" /* for xalloc/xfree */
static char *vm_base = NULL; /* Start of virtual memory area */
char *vm_next = NULL; /* Pointer to first free byte */
@@ -41,10 +65,18 @@ static char *vm_base = NULL; /* Start of virtual memory area */
/*
* Initialize memory.
*/
-boolean vm_init(cnt)
-int cnt;
+boolean
+vm_init(int cnt)
{
+#ifdef BUILDCID
+ if (vm_base == NULL || (vm_base != NULL && vm_size != cnt)) {
+ if (vm_base != NULL) xfree(vm_base);
+ vm_next = vm_base = (char *)xalloc (cnt);
+ } else
+ vm_next = vm_base;
+#else
vm_next = vm_base = (char *)xalloc (cnt);
+#endif
if (vm_base != NULL) {
vm_free = cnt;
@@ -56,8 +88,8 @@ int cnt;
}
-char *vm_alloc(bytes)
- int bytes;
+char *
+vm_alloc(int bytes)
{
char *answer;
@@ -79,9 +111,8 @@ char *vm_alloc(bytes)
/*
* Format an Integer object
*/
-void objFormatInteger(objP,value)
- psobj *objP;
- int value;
+void
+objFormatInteger(psobj *objP, int value)
{
if (objP != NULL) {
objP->type = OBJ_INTEGER;
@@ -93,9 +124,8 @@ void objFormatInteger(objP,value)
/*
* Format a Real object
*/
-void objFormatReal(objP,value)
- psobj *objP;
- float value;
+void
+objFormatReal(psobj *objP, float value)
{
if (objP != NULL) {
objP->type = OBJ_REAL;
@@ -107,9 +137,8 @@ void objFormatReal(objP,value)
/*
* Format a Boolean object
*/
-void objFormatBoolean(objP,value)
- psobj *objP;
- boolean value;
+void
+objFormatBoolean(psobj *objP, boolean value)
{
if (objP != NULL) {
objP->type = OBJ_BOOLEAN;
@@ -121,10 +150,8 @@ void objFormatBoolean(objP,value)
/*
* Format an Encoding object
*/
-void objFormatEncoding(objP,length,valueP)
- psobj *objP;
- int length;
- psobj *valueP;
+void
+objFormatEncoding(psobj *objP, int length, psobj *valueP)
{
if (objP != NULL) {
objP->type = OBJ_ENCODING;
@@ -136,10 +163,8 @@ void objFormatEncoding(objP,length,valueP)
/*
* Format an Array object
*/
-void objFormatArray(objP,length,valueP)
- psobj *objP;
- int length;
- psobj *valueP;
+void
+objFormatArray(psobj *objP, int length, psobj *valueP)
{
if (objP != NULL) {
objP->type = OBJ_ARRAY;
@@ -152,10 +177,8 @@ void objFormatArray(objP,length,valueP)
/*
* Format a String object
*/
-void objFormatString(objP,length,valueP)
- psobj *objP;
- int length;
- char *valueP;
+void
+objFormatString(psobj *objP, int length, char *valueP)
{
if (objP != NULL) {
objP->type = OBJ_STRING;
@@ -167,10 +190,8 @@ void objFormatString(objP,length,valueP)
/*
* Format a Name object
*/
-void objFormatName(objP,length,valueP)
- psobj *objP;
- int length;
- char *valueP;
+void
+objFormatName(psobj *objP, int length, char *valueP)
{
if (objP != NULL) {
objP->type = OBJ_NAME;
@@ -182,9 +203,8 @@ void objFormatName(objP,length,valueP)
/*
* Format a File object
*/
-void objFormatFile(objP,valueP)
- psobj *objP;
- FILE *valueP;
+void
+objFormatFile(psobj *objP, FILE *valueP)
{
if (objP != NULL) {
objP->type = OBJ_FILE;
diff --git a/src/Type1/util.h b/src/Type1/util.h
index 20c14c4..7abc289 100644
--- a/src/Type1/util.h
+++ b/src/Type1/util.h
@@ -27,6 +27,25 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/util.h,v 1.5 2001/01/17 19:43:24 dawes Exp $ */
+
#ifndef UTIL_H
#define UTIL_H
@@ -61,7 +80,11 @@ typedef int boolean;
/* this is the size of memory allocated for reading fonts */
+#ifdef BUILDCID
+#define VM_SIZE (100*1024)
+#else
#define VM_SIZE (50*1024)
+#endif
/***================================================================***/
#ifndef MIN
@@ -71,11 +94,13 @@ typedef int boolean;
/***================================================================***/
/* Routines for managing virtual memory */
/***================================================================***/
-extern boolean vm_init();
+
+extern boolean vm_init ( int cnt );
extern long vm_free;
extern long vm_size;
extern char *vm_next;
-extern char *vm_alloc();
+extern char *vm_alloc ( int bytes );
+
/***================================================================***/
/* Macros for managing virtual memory */
/***================================================================***/
@@ -173,10 +198,17 @@ typedef struct ps_dict {
#define objPSetString(o) ((o)->type = OBJ_STRING)
#define objPSetName(o) ((o)->type = OBJ_NAME)
#define objPSetFile(o) ((o)->type = OBJ_FILE)
-
-/***================================================================***/
-/* Entry point for Type1Char to get entry from CharStrings */
-/***================================================================***/
-extern psobj *GetType1CharString();
-
+
+/***================================================================***/
+/* Prototypes of object formatting functions */
+/***================================================================***/
+extern void objFormatInteger ( psobj *objP, int value );
+extern void objFormatReal ( psobj *objP, float value );
+extern void objFormatBoolean ( psobj *objP, boolean value );
+extern void objFormatEncoding ( psobj *objP, int length, psobj *valueP );
+extern void objFormatArray ( psobj *objP, int length, psobj *valueP );
+extern void objFormatString ( psobj *objP, int length, char *valueP );
+extern void objFormatName ( psobj *objP, int length, char *valueP );
+extern void objFormatFile ( psobj *objP, FILE *valueP );
+
#endif
diff --git a/src/bitmap/bdfread.c b/src/bitmap/bdfread.c
index d365d6f..67e4252 100644
--- a/src/bitmap/bdfread.c
+++ b/src/bitmap/bdfread.c
@@ -50,9 +50,13 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/bdfread.c,v 1.12 2002/09/10 16:14:34 tsi Exp $ */
+#ifndef FONTMODULE
#include <ctype.h>
+#endif
#include "fntfilst.h"
+#include "fontutil.h"
/* use bitmap structure */
#include "bitmap.h"
#include "bdfint.h"
@@ -61,22 +65,14 @@ from The Open Group.
#define MAXENCODING 0xFFFF
#define BDFLINELEN 1024
-extern int bitmapGetGlyphs(), bitmapGetMetrics();
-extern int bitmapGetBitmaps(), bitmapGetExtents();
-static Bool bdfPadToTerminal();
+static Bool bdfPadToTerminal(FontPtr pFont);
extern int bdfFileLineNum;
/***====================================================================***/
static Bool
-bdfReadBitmap(pCI, file, bit, byte, glyph, scan, sizes)
- CharInfoPtr pCI;
- FontFilePtr file;
- int bit,
- byte,
- glyph,
- scan;
- int sizes[GLYPHPADOPTIONS];
+bdfReadBitmap(CharInfoPtr pCI, FontFilePtr file, int bit, int byte,
+ int glyph, int scan, CARD32 *sizes)
{
int widthBits,
widthBytes,
@@ -90,7 +86,7 @@ bdfReadBitmap(pCI, file, bit, byte, glyph, scan, sizes)
unsigned char *pInBits,
*picture,
*line = NULL;
- char lineBuf[BDFLINELEN];
+ unsigned char lineBuf[BDFLINELEN];
widthBits = GLYPHWIDTHPIXELS(pCI);
height = GLYPHHEIGHTPIXELS(pCI);
@@ -99,9 +95,9 @@ bdfReadBitmap(pCI, file, bit, byte, glyph, scan, sizes)
if (widthBytes * height > 0) {
picture = (unsigned char *) xalloc(widthBytes * height);
if (!picture) {
- bdfError("Couldn't allocate picture (%d*%d)\n", widthBytes, height);
+ bdfError("Couldn't allocate picture (%d*%d)\n", widthBytes, height);
goto BAILOUT;
- }
+ }
} else
picture = NULL;
pCI->bits = (char *) picture;
@@ -198,13 +194,11 @@ BAILOUT:
/***====================================================================***/
static Bool
-bdfSkipBitmap(file, height)
- FontFilePtr file;
- int height;
+bdfSkipBitmap(FontFilePtr file, int height)
{
unsigned char *line;
int i = 0;
- char lineBuf[BDFLINELEN];
+ unsigned char lineBuf[BDFLINELEN];
do {
line = bdfGetLine(file, lineBuf, BDFLINELEN);
@@ -221,16 +215,21 @@ bdfSkipBitmap(file, height)
/***====================================================================***/
static void
-bdfFreeFontBits(pFont)
- FontPtr pFont;
+bdfFreeFontBits(FontPtr pFont)
{
BitmapFontPtr bitmapFont;
BitmapExtraPtr bitmapExtra;
- int i;
+ int i, nencoding;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
bitmapExtra = (BitmapExtraPtr) bitmapFont->bitmapExtra;
xfree(bitmapFont->ink_metrics);
+ if(bitmapFont->encoding) {
+ nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
+ (pFont->info.lastRow - pFont->info.firstRow + 1);
+ for(i=0; i<NUM_SEGMENTS(nencoding); i++)
+ xfree(bitmapFont->encoding[i]);
+ }
xfree(bitmapFont->encoding);
for (i = 0; i < bitmapFont->num_chars; i++)
xfree(bitmapFont->metrics[i].bits);
@@ -247,14 +246,8 @@ bdfFreeFontBits(pFont)
static Bool
-bdfReadCharacters(file, pFont, pState, bit, byte, glyph, scan)
- FontFilePtr file;
- FontPtr pFont;
- bdfFileState *pState;
- int bit,
- byte,
- glyph,
- scan;
+bdfReadCharacters(FontFilePtr file, FontPtr pFont, bdfFileState *pState,
+ int bit, int byte, int glyph, int scan)
{
unsigned char *line;
register CharInfoPtr ci;
@@ -268,7 +261,7 @@ bdfReadCharacters(file, pFont, pState, bit, byte, glyph, scan)
BitmapFontPtr bitmapFont;
BitmapExtraPtr bitmapExtra;
CARD32 *bitmapsSizes;
- char lineBuf[BDFLINELEN];
+ unsigned char lineBuf[BDFLINELEN];
int nencoding;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
@@ -352,7 +345,7 @@ bdfReadCharacters(file, pFont, pState, bit, byte, glyph, scan)
bdfError("bad 'ENCODING' in BDF file\n");
goto BAILOUT;
}
- if (enc < -1 || t == 2 && enc2 < -1) {
+ if (enc < -1 || (t == 2 && enc2 < -1)) {
bdfError("bad ENCODING value");
goto BAILOUT;
}
@@ -435,7 +428,7 @@ bdfReadCharacters(file, pFont, pState, bit, byte, glyph, scan)
(*p == ' ') || (*p == '\t');
p++)
/* empty for loop */ ;
- ci->metrics.attributes = bdfHexByte(p) << 8 + bdfHexByte(p + 2);
+ ci->metrics.attributes = (bdfHexByte(p) << 8) + bdfHexByte(p + 2);
line = bdfGetLine(file, lineBuf, BDFLINELEN);
} else
ci->metrics.attributes = 0;
@@ -489,11 +482,13 @@ bdfReadCharacters(file, pFont, pState, bit, byte, glyph, scan)
nencoding = (pFont->info.lastRow - pFont->info.firstRow + 1) *
(pFont->info.lastCol - pFont->info.firstCol + 1);
- bitmapFont->encoding = (CharInfoPtr *) xalloc(nencoding * sizeof(CharInfoPtr));
+ bitmapFont->encoding =
+ (CharInfoPtr **) xcalloc(NUM_SEGMENTS(nencoding),
+ sizeof(CharInfoPtr*));
if (!bitmapFont->encoding) {
bdfError("Couldn't allocate ppCI (%d,%d)\n",
- nencoding,
- sizeof(CharInfoPtr));
+ NUM_SEGMENTS(nencoding),
+ sizeof(CharInfoPtr*));
goto BAILOUT;
}
pFont->info.allExist = TRUE;
@@ -503,19 +498,26 @@ bdfReadCharacters(file, pFont, pState, bit, byte, glyph, scan)
char_row++) {
if (bdfEncoding[char_row] == (CharInfoPtr *) NULL) {
pFont->info.allExist = FALSE;
- for (char_col = pFont->info.firstCol;
- char_col <= pFont->info.lastCol;
- char_col++) {
- bitmapFont->encoding[i++] = NullCharInfo;
- }
+ i += pFont->info.lastCol - pFont->info.firstCol + 1;
} else {
for (char_col = pFont->info.firstCol;
char_col <= pFont->info.lastCol;
char_col++) {
if (!bdfEncoding[char_row][char_col])
pFont->info.allExist = FALSE;
- bitmapFont->encoding[i++] = bdfEncoding[char_row][char_col];
- }
+ else {
+ if (!bitmapFont->encoding[SEGMENT_MAJOR(i)]) {
+ bitmapFont->encoding[SEGMENT_MAJOR(i)]=
+ (CharInfoPtr*)xcalloc(BITMAP_FONT_SEGMENT_SIZE,
+ sizeof(CharInfoPtr));
+ if (!bitmapFont->encoding[SEGMENT_MAJOR(i)])
+ goto BAILOUT;
+ }
+ ACCESSENCODINGL(bitmapFont->encoding,i) =
+ bdfEncoding[char_row][char_col];
+ }
+ i++;
+ }
}
}
for (i = 0; i < 256; i++)
@@ -533,13 +535,11 @@ BAILOUT:
/***====================================================================***/
static Bool
-bdfReadHeader(file, pState)
- FontFilePtr file;
- bdfFileState *pState;
+bdfReadHeader(FontFilePtr file, bdfFileState *pState)
{
unsigned char *line;
char namebuf[BDFLINELEN];
- char lineBuf[BDFLINELEN];
+ unsigned char lineBuf[BDFLINELEN];
line = bdfGetLine(file, lineBuf, BDFLINELEN);
if (!line || sscanf((char *) line, "STARTFONT %s", namebuf) != 1 ||
@@ -578,10 +578,7 @@ bdfReadHeader(file, pState)
/***====================================================================***/
static Bool
-bdfReadProperties(file, pFont, pState)
- FontFilePtr file;
- FontPtr pFont;
- bdfFileState *pState;
+bdfReadProperties(FontFilePtr file, FontPtr pFont, bdfFileState *pState)
{
int nProps, props_left,
nextProp;
@@ -591,7 +588,7 @@ bdfReadProperties(file, pFont, pState)
secondbuf[BDFLINELEN],
thirdbuf[BDFLINELEN];
unsigned char *line;
- char lineBuf[BDFLINELEN];
+ unsigned char lineBuf[BDFLINELEN];
BitmapFontPtr bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
line = bdfGetLine(file, lineBuf, BDFLINELEN);
@@ -605,6 +602,7 @@ bdfReadProperties(file, pFont, pState)
}
pFont->info.isStringProp = NULL;
pFont->info.props = NULL;
+ pFont->info.nprops = 0;
stringProps = (char *) xalloc((nProps + BDF_GENPROPS) * sizeof(char));
pFont->info.isStringProp = stringProps;
@@ -647,7 +645,7 @@ bdfReadProperties(file, pFont, pState)
if (secondbuf[0] == '"') {
stringProps[nextProp] = TRUE;
props[nextProp].value =
- bdfGetPropertyValue(line + strlen(namebuf) + 1);
+ bdfGetPropertyValue((char *)line + strlen(namebuf) + 1);
if (!props[nextProp].value)
goto BAILOUT;
break;
@@ -668,7 +666,7 @@ bdfReadProperties(file, pFont, pState)
if (secondbuf[0] == '"') {
stringProps[nextProp] = TRUE;
props[nextProp].value =
- bdfGetPropertyValue(line + strlen(namebuf) + 1);
+ bdfGetPropertyValue((char *)line + strlen(namebuf) + 1);
if (!props[nextProp].value)
goto BAILOUT;
break;
@@ -776,22 +774,15 @@ BAILOUT:
/***====================================================================***/
static void
-bdfUnloadFont(pFont)
- FontPtr pFont;
+bdfUnloadFont(FontPtr pFont)
{
bdfFreeFontBits (pFont);
- xfree (pFont->devPrivates);
- xfree(pFont);
+ DestroyFontRec(pFont);
}
int
-bdfReadFont(pFont, file, bit, byte, glyph, scan)
- FontPtr pFont;
- FontFilePtr file;
- int bit,
- byte,
- glyph,
- scan;
+bdfReadFont(FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan)
{
bdfFileState state;
xCharInfo *min,
@@ -808,7 +799,7 @@ bdfReadFont(pFont, file, bit, byte, glyph, scan)
bitmapFont = (BitmapFontPtr) xalloc(sizeof(BitmapFontRec));
if (!bitmapFont) {
- bdfError("Couldn't allocate bitmapFontRec (%d)\n", sizeof(BitmapFontRec));
+ bdfError("Couldn't allocate bitmapFontRec (%d)\n", sizeof(BitmapFontRec));
goto BAILOUT;
}
bzero((char *)bitmapFont, sizeof(BitmapFontRec));
@@ -822,7 +813,7 @@ bdfReadFont(pFont, file, bit, byte, glyph, scan)
bitmapFont->bitmapExtra = (BitmapExtraPtr) xalloc(sizeof(BitmapExtraRec));
if (!bitmapFont->bitmapExtra) {
- bdfError("Couldn't allocate bitmapExtra (%d)\n", sizeof(BitmapExtraRec));
+ bdfError("Couldn't allocate bitmapExtra (%d)\n", sizeof(BitmapExtraRec));
goto BAILOUT;
}
bzero((char *)bitmapFont->bitmapExtra, sizeof(BitmapExtraRec));
@@ -846,7 +837,8 @@ bdfReadFont(pFont, file, bit, byte, glyph, scan)
cols = pFont->info.lastCol - pFont->info.firstCol + 1;
r = r - pFont->info.firstRow;
c = c - pFont->info.firstCol;
- bitmapFont->pDefault = bitmapFont->encoding[r * cols + c];
+ bitmapFont->pDefault = ACCESSENCODING(bitmapFont->encoding,
+ r * cols + c);
}
}
pFont->bit = bit;
@@ -864,11 +856,11 @@ bdfReadFont(pFont, file, bit, byte, glyph, scan)
if (bitmapFont->bitmapExtra)
FontComputeInfoAccelerators(&bitmapFont->bitmapExtra->info);
if (pFont->info.constantMetrics) {
- if (!bitmapAddInkMetrics(pFont)) {
- bdfError("Failed to add bitmap ink metrics\n");
- goto BAILOUT;
- }
- }
+ if (!bitmapAddInkMetrics(pFont)) {
+ bdfError("Failed to add bitmap ink metrics\n");
+ goto BAILOUT;
+ }
+ }
if (bitmapFont->bitmapExtra)
bitmapFont->bitmapExtra->info.inkMetrics = pFont->info.inkMetrics;
@@ -902,9 +894,7 @@ BAILOUT:
}
int
-bdfReadFontInfo(pFontInfo, file)
- FontInfoPtr pFontInfo;
- FontFilePtr file;
+bdfReadFontInfo(FontInfoPtr pFontInfo, FontFilePtr file)
{
FontRec font;
int ret;
@@ -923,8 +913,7 @@ bdfReadFontInfo(pFontInfo, file)
}
static Bool
-bdfPadToTerminal(pFont)
- FontPtr pFont;
+bdfPadToTerminal(FontPtr pFont)
{
BitmapFontPtr bitmapFont;
BitmapExtraPtr bitmapExtra;
@@ -947,9 +936,9 @@ bdfPadToTerminal(pFont)
for (i = 0; i < bitmapFont->num_chars; i++) {
new.bits = (char *) xalloc(new_size);
if (!new.bits) {
- bdfError("Couldn't allocate bits (%d)\n", new_size);
+ bdfError("Couldn't allocate bits (%d)\n", new_size);
return FALSE;
- }
+ }
FontCharReshape(pFont, &bitmapFont->metrics[i], &new);
new.metrics.attributes = bitmapFont->metrics[i].metrics.attributes;
xfree(bitmapFont->metrics[i].bits);
diff --git a/src/bitmap/bdfutils.c b/src/bitmap/bdfutils.c
index d7e5b4c..94a9ff6 100644
--- a/src/bitmap/bdfutils.c
+++ b/src/bitmap/bdfutils.c
@@ -49,43 +49,30 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/bdfutils.c,v 1.10 2001/12/14 19:56:45 dawes Exp $ */
+#ifndef FONTMODULE
#include <ctype.h>
-
#include <stdio.h>
+#include <stdarg.h>
+#endif
+
#include "fntfilst.h"
#include "fontstruct.h"
/* use bitmap structure */
#include "bitmap.h"
#include "bdfint.h"
-#if NeedVarargsPrototypes
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
int bdfFileLineNum;
/***====================================================================***/
-/* VARARGS1 */
void
-#if NeedVarargsPrototypes
bdfError(char* message, ...)
-#else
-bdfError (message, va_alist)
- char* message;
- va_dcl
-#endif
{
va_list args;
-#if NeedVarargsPrototypes
va_start (args, message);
-#else
- va_start (args);
-#endif
-
fprintf(stderr, "BDF Error on line %d: ", bdfFileLineNum);
vfprintf(stderr, message, args);
va_end (args);
@@ -93,19 +80,15 @@ bdfError (message, va_alist)
/***====================================================================***/
-/* VARARGS1 */
void
-bdfWarning(message, a0, a1, a2, a3, a4, a5)
- char *message;
- pointer a0,
- a1,
- a2,
- a3,
- a4,
- a5;
+bdfWarning(char *message, ...)
{
+ va_list args;
+
+ va_start (args, message);
fprintf(stderr, "BDF Warning on line %d: ", bdfFileLineNum);
- fprintf(stderr, message, a0, a1, a2, a3, a4, a5);
+ vfprintf(stderr, message, args);
+ va_end (args);
}
/*
@@ -114,10 +97,7 @@ bdfWarning(message, a0, a1, a2, a3, a4, a5)
*/
unsigned char *
-bdfGetLine(file, buf, len)
- FontFilePtr file;
- unsigned char *buf;
- int len;
+bdfGetLine(FontFilePtr file, unsigned char *buf, int len)
{
int c;
unsigned char *b;
@@ -147,19 +127,17 @@ bdfGetLine(file, buf, len)
/***====================================================================***/
Atom
-bdfForceMakeAtom(str, size)
- register char *str;
- register int *size;
+bdfForceMakeAtom(char *str, int *size)
{
register int len = strlen(str);
- extern Atom MakeAtom();
+ extern Atom MakeAtom(); /* Added this line to be consistent with X.org code */
Atom the_atom;
if (size != NULL)
*size += len + 1;
the_atom = MakeAtom(str, len, TRUE);
if (the_atom == None)
- bdfError("Atom allocation failed\n");
+ bdfError("Atom allocation failed\n");
return the_atom;
}
@@ -170,8 +148,7 @@ bdfForceMakeAtom(str, size)
*/
Atom
-bdfGetPropertyValue(s)
- char *s;
+bdfGetPropertyValue(char *s)
{
register char *p,
*pp;
@@ -198,8 +175,8 @@ bdfGetPropertyValue(s)
s++;
pp = p = (char *) xalloc((unsigned) strlen(s) + 1);
if (pp == NULL) {
- bdfError("Couldn't allocate property value string (%d)\n", strlen(s) + 1);
- return None;
+ bdfError("Couldn't allocate property value string (%d)\n", strlen(s) + 1);
+ return None;
}
while (*s) {
if (*s == '"') {
@@ -225,8 +202,7 @@ bdfGetPropertyValue(s)
* return TRUE if string is a valid integer
*/
int
-bdfIsInteger(str)
- char *str;
+bdfIsInteger(char *str)
{
char c;
@@ -234,7 +210,7 @@ bdfIsInteger(str)
if (!(isdigit(c) || c == '-' || c == '+'))
return (FALSE);
- while (c = *str++)
+ while ((c = *str++))
if (!isdigit(c))
return (FALSE);
@@ -248,8 +224,7 @@ bdfIsInteger(str)
*/
unsigned char
-bdfHexByte(s)
- char *s;
+bdfHexByte(unsigned char *s)
{
unsigned char b = 0;
register char c;
@@ -302,11 +277,8 @@ static char *SpecialAtoms[] = {
};
Bool
-bdfSpecialProperty(pFont, prop, isString, bdfState)
- FontPtr pFont;
- FontPropPtr prop;
- char isString;
- bdfFileState *bdfState;
+bdfSpecialProperty(FontPtr pFont, FontPropPtr prop,
+ char isString, bdfFileState *bdfState)
{
char **special;
char *name;
diff --git a/src/bitmap/bitmap.c b/src/bitmap/bitmap.c
index 39fd5dc..6fa7bfa 100644
--- a/src/bitmap/bitmap.c
+++ b/src/bitmap/bitmap.c
@@ -25,6 +25,7 @@ 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/bitmap/bitmap.c,v 1.7 2001/12/14 19:56:45 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -33,19 +34,11 @@ in this Software without prior written authorization from The Open Group.
#include "fntfilst.h"
#include "bitmap.h"
-int bitmapGetGlyphs(), bitmapGetMetrics();
-int bitmapGetBitmaps(), bitmapGetExtents();
-void bitmapComputeFontBounds ();
-void bitmapComputeFontInkBounds ();
-
int
-bitmapGetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
- FontPtr pFont;
- unsigned long count;
- register unsigned char *chars;
- FontEncoding charEncoding;
- unsigned long *glyphCount; /* RETURN */
- CharInfoPtr *glyphs; /* RETURN */
+bitmapGetGlyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
{
BitmapFontPtr bitmapFont;
unsigned int firstCol;
@@ -56,7 +49,7 @@ bitmapGetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
register unsigned int c;
register CharInfoPtr pci;
unsigned int r;
- CharInfoPtr *encoding;
+ CharInfoPtr **encoding;
CharInfoPtr pDefault;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
@@ -75,14 +68,14 @@ bitmapGetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
while (count--) {
c = (*chars++) - firstCol;
if (c < numCols)
- *glyphs++ = encoding[c];
+ *glyphs++ = ACCESSENCODING(encoding,c);
else
*glyphs++ = pDefault;
}
} else {
while (count--) {
c = (*chars++) - firstCol;
- if (c < numCols && (pci = encoding[c]))
+ if (c < numCols && (pci = ACCESSENCODING(encoding,c)))
*glyphs++ = pci;
else if (pDefault)
*glyphs++ = pDefault;
@@ -95,7 +88,7 @@ bitmapGetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
c = *chars++ << 8;
c = (c | *chars++) - firstCol;
if (c < numCols)
- *glyphs++ = encoding[c];
+ *glyphs++ = ACCESSENCODING(encoding,c);
else
*glyphs++ = pDefault;
}
@@ -103,7 +96,7 @@ bitmapGetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
while (count--) {
c = *chars++ << 8;
c = (c | *chars++) - firstCol;
- if (c < numCols && (pci = encoding[c]))
+ if (c < numCols && (pci = ACCESSENCODING(encoding,c)))
*glyphs++ = pci;
else if (pDefault)
*glyphs++ = pDefault;
@@ -118,7 +111,7 @@ bitmapGetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
r = (*chars++) - firstRow;
c = (*chars++) - firstCol;
if (r < numRows && c < numCols &&
- (pci = encoding[r * numCols + c]))
+ (pci = ACCESSENCODING(encoding, r * numCols + c)))
*glyphs++ = pci;
else if (pDefault)
*glyphs++ = pDefault;
@@ -132,13 +125,10 @@ bitmapGetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
static CharInfoRec nonExistantChar;
int
-bitmapGetMetrics(pFont, count, chars, charEncoding, glyphCount, glyphs)
- FontPtr pFont;
- unsigned long count;
- register unsigned char *chars;
- FontEncoding charEncoding;
- unsigned long *glyphCount; /* RETURN */
- xCharInfo **glyphs; /* RETURN */
+bitmapGetMetrics(FontPtr pFont, unsigned long count, unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ xCharInfo **glyphs) /* RETURN */
{
int ret;
xCharInfo *ink_metrics;
diff --git a/src/bitmap/bitmapfunc.c b/src/bitmap/bitmapfunc.c
index c52c7e8..da06e7d 100644
--- a/src/bitmap/bitmapfunc.c
+++ b/src/bitmap/bitmapfunc.c
@@ -26,54 +26,65 @@ in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/bitmapfunc.c,v 3.18 2002/09/24 20:48:52 tsi Exp $ */
+
/*
* Author: Keith Packard, MIT X Consortium
*/
#include "fntfilst.h"
#include "bitmap.h"
+#include "fontutil.h"
+#include "bdfint.h"
+#include "pcf.h"
+#include "snfstr.h"
typedef struct _BitmapFileFunctions {
- int (*ReadFont) ( /* pFont, file, bit, byte, glyph, scan */ );
- int (*ReadInfo) ( /* pFontInfo, file */ );
+ int (*ReadFont) (FontPtr /* pFont */, FontFilePtr /* file */,
+ int /* bit */, int /* byte */,
+ int /* glyph */, int /* scan */);
+ int (*ReadInfo) ( FontInfoPtr /* pFontInfo */,
+ FontFilePtr /* file */ );
} BitmapFileFunctionsRec, *BitmapFileFunctionsPtr;
-extern int pcfReadFont(), pcfReadFontInfo();
-extern int snfReadFont(), snfReadFontInfo();
-extern int bdfReadFont(), bdfReadFontInfo();
-extern int pmfReadFont();
-int BitmapOpenBitmap ();
-extern int BitmapOpenScalable ();
-int BitmapGetInfoBitmap ();
-extern int BitmapGetInfoScalable ();
-int BitmapGetRenderIndex ();
/*
- * these two arrays must be in the same order
+ * the readers[] and renderers[] arrays must be in the same order,
+ * and also in the same order as scale[] and find_scale[] in bitscale.c
+ *
*/
static BitmapFileFunctionsRec readers[] = {
+#ifdef PCFFORMAT
{ pcfReadFont, pcfReadFontInfo} ,
{ pcfReadFont, pcfReadFontInfo} ,
#ifdef X_GZIP_FONT_COMPRESSION
{ pcfReadFont, pcfReadFontInfo} ,
#endif
- { snfReadFont, snfReadFontInfo} ,
- { snfReadFont, snfReadFontInfo} ,
+#endif
+#ifdef SNFFORMAT
+ { snfReadFont, snfReadFontInfo},
+ { snfReadFont, snfReadFontInfo},
#ifdef X_GZIP_FONT_COMPRESSION
{ snfReadFont, snfReadFontInfo} ,
#endif
+#endif
+#ifdef BDFFORMAT
{ bdfReadFont, bdfReadFontInfo} ,
{ bdfReadFont, bdfReadFontInfo} ,
#ifdef X_GZIP_FONT_COMPRESSION
{ bdfReadFont, bdfReadFontInfo} ,
#endif
+#endif
+#ifdef PCFFORMAT
{ pmfReadFont, pcfReadFontInfo} ,
+#endif
};
#define CAPABILITIES (CAP_MATRIX | CAP_CHARSUBSETTING)
static FontRendererRec renderers[] = {
+#ifdef PCFFORMAT
{ ".pcf", 4, BitmapOpenBitmap, BitmapOpenScalable,
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
@@ -81,10 +92,13 @@ static FontRendererRec renderers[] = {
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
#ifdef X_GZIP_FONT_COMPRESSION
- { ".pcf.gz", 7, BitmapOpenBitmap, BitmapOpenScalable,
+ { ".pcf.gz", 7,
+ BitmapOpenBitmap, BitmapOpenScalable,
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
#endif
+#endif
+#ifdef SNFFORMAT
{ ".snf", 4, BitmapOpenBitmap, BitmapOpenScalable,
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
@@ -96,6 +110,8 @@ static FontRendererRec renderers[] = {
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
#endif
+#endif
+#ifdef BDFFORMAT
{ ".bdf", 4, BitmapOpenBitmap, BitmapOpenScalable,
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
@@ -107,21 +123,19 @@ static FontRendererRec renderers[] = {
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES },
#endif
+#endif
+#ifdef PCFFORMAT
{ ".pmf", 4, BitmapOpenBitmap, BitmapOpenScalable,
BitmapGetInfoBitmap, BitmapGetInfoScalable, 0,
CAPABILITIES }
+#endif
};
-int BitmapOpenBitmap (fpe, ppFont, flags, entry, fileName, format, fmask,
- non_cachable_font)
- FontPathElementPtr fpe;
- FontPtr *ppFont;
- int flags;
- FontEntryPtr entry;
- char *fileName;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- FontPtr non_cachable_font; /* We don't do licensing */
+int
+BitmapOpenBitmap (FontPathElementPtr fpe, FontPtr *ppFont, int flags,
+ FontEntryPtr entry, char *fileName,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
{
FontFilePtr file;
FontPtr pFont;
@@ -137,13 +151,12 @@ int BitmapOpenBitmap (fpe, ppFont, flags, entry, fileName, format, fmask,
file = FontFileOpen (fileName);
if (!file)
return BadFontName;
- pFont = (FontPtr) xalloc(sizeof(FontRec));
- if (!pFont) {
- fprintf(stderr, "Error: Couldn't allocate pFont (%d)\n", sizeof(FontRec));
+ if (!(pFont = CreateFontRec())) {
+ fprintf(stderr, "Error: Couldn't allocate pFont (%ld)\n",
+ (unsigned long)sizeof(FontRec));
FontFileClose (file);
return AllocError;
}
- bzero((char *)pFont, sizeof(FontRec));
/* set up default values */
FontDefaultFormat(&bit, &byte, &glyph, &scan);
/* get any changes made from above */
@@ -151,24 +164,21 @@ int BitmapOpenBitmap (fpe, ppFont, flags, entry, fileName, format, fmask,
/* Fill in font record. Data format filled in by reader. */
pFont->refcnt = 0;
- pFont->maxPrivate = -1;
- pFont->devPrivates = (pointer *) 0;
ret = (*readers[i].ReadFont) (pFont, file, bit, byte, glyph, scan);
FontFileClose (file);
- if (ret != Successful)
+ if (ret != Successful) {
xfree(pFont);
- else
+ } else {
*ppFont = pFont;
+ }
return ret;
}
-int BitmapGetInfoBitmap (fpe, pFontInfo, entry, fileName)
- FontPathElementPtr fpe;
- FontInfoPtr pFontInfo;
- FontEntryPtr entry;
- char *fileName;
+int
+BitmapGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo,
+ FontEntryPtr entry, char *fileName)
{
FontFilePtr file;
int i;
@@ -189,7 +199,8 @@ int BitmapGetInfoBitmap (fpe, pFontInfo, entry, fileName)
#define numRenderers (sizeof renderers / sizeof renderers[0])
-void BitmapRegisterFontFileFunctions ()
+void
+BitmapRegisterFontFileFunctions (void)
{
int i;
@@ -202,8 +213,8 @@ void BitmapRegisterFontFileFunctions ()
* the font info reader, and the bitmap scaling routine. All users
* of this routine must be kept in step with the renderer array.
*/
-int BitmapGetRenderIndex(renderer)
- FontRendererPtr renderer;
+int
+BitmapGetRenderIndex(FontRendererPtr renderer)
{
return renderer - renderers;
}
diff --git a/src/bitmap/bitmaputil.c b/src/bitmap/bitmaputil.c
index 337ae13..d061fcd 100644
--- a/src/bitmap/bitmaputil.c
+++ b/src/bitmap/bitmaputil.c
@@ -27,9 +27,11 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/bitmaputil.c,v 1.11 2003/02/19 01:22:34 dawes Exp $ */
#include "fntfilst.h"
#include "bitmap.h"
+#include "bdfint.h"
#ifndef MAXSHORT
#define MAXSHORT 32767
@@ -51,8 +53,8 @@ MINSHORT, MINSHORT, MINSHORT, MINSHORT, MINSHORT, 0x0000};
maxbounds->field = (ci)->field;
#define COMPUTE_MINMAX(ci) \
- if ((ci)->ascent != -(ci)->descent || \
- (ci)->leftSideBearing != (ci)->rightSideBearing || \
+ if ((ci)->ascent || (ci)->descent || \
+ (ci)->leftSideBearing || (ci)->rightSideBearing || \
(ci)->characterWidth) \
{ \
MINMAX(ascent, (ci)); \
@@ -63,15 +65,13 @@ MINSHORT, MINSHORT, MINSHORT, MINSHORT, MINSHORT, 0x0000};
}
void
-bitmapComputeFontBounds(pFont)
- FontPtr pFont;
+bitmapComputeFontBounds(FontPtr pFont)
{
BitmapFontPtr bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
int nchars;
int r,
c;
- CharInfoPtr ci,
- *pci;
+ CharInfoPtr ci;
int maxOverlap;
int overlap;
xCharInfo *minbounds,
@@ -112,11 +112,11 @@ bitmapComputeFontBounds(pFont)
maxbounds = &pFont->info.maxbounds;
*minbounds = initMinMetrics;
*maxbounds = initMaxMetrics;
- pci = bitmapFont->encoding;
+ i = 0;
maxOverlap = MINSHORT;
for (r = pFont->info.firstRow; r <= pFont->info.lastRow; r++) {
for (c = pFont->info.firstCol; c <= pFont->info.lastCol; c++) {
- ci = *pci++;
+ ci = ACCESSENCODING(bitmapFont->encoding, i);
if (ci) {
COMPUTE_MINMAX(&ci->metrics);
if (ci->metrics.characterWidth < 0)
@@ -130,6 +130,7 @@ bitmapComputeFontBounds(pFont)
if (maxOverlap < overlap)
maxOverlap = overlap;
}
+ i++;
}
}
}
@@ -141,15 +142,13 @@ bitmapComputeFontBounds(pFont)
}
void
-bitmapComputeFontInkBounds(pFont)
- FontPtr pFont;
+bitmapComputeFontInkBounds(FontPtr pFont)
{
BitmapFontPtr bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
int nchars;
int r,
c;
- CharInfoPtr *pci,
- cit;
+ CharInfoPtr cit;
xCharInfo *ci;
int offset;
xCharInfo *minbounds,
@@ -184,10 +183,10 @@ bitmapComputeFontInkBounds(pFont)
maxbounds = &pFont->info.ink_maxbounds;
*minbounds = initMinMetrics;
*maxbounds = initMaxMetrics;
- pci = bitmapFont->encoding;
+ i=0;
for (r = pFont->info.firstRow; r <= pFont->info.lastRow; r++) {
for (c = pFont->info.firstCol; c <= pFont->info.lastCol; c++) {
- cit = *pci++;
+ cit = ACCESSENCODING(bitmapFont->encoding, i);
if (cit) {
offset = cit - bitmapFont->metrics;
ci = &bitmapFont->ink_metrics[offset];
@@ -195,6 +194,7 @@ bitmapComputeFontInkBounds(pFont)
minbounds->attributes &= ci->attributes;
maxbounds->attributes |= ci->attributes;
}
+ i++;
}
}
}
@@ -202,8 +202,7 @@ bitmapComputeFontInkBounds(pFont)
}
Bool
-bitmapAddInkMetrics(pFont)
- FontPtr pFont;
+bitmapAddInkMetrics(FontPtr pFont)
{
BitmapFontPtr bitmapFont;
int i;
@@ -211,7 +210,8 @@ bitmapAddInkMetrics(pFont)
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
bitmapFont->ink_metrics = (xCharInfo *) xalloc(bitmapFont->num_chars * sizeof(xCharInfo));
if (!bitmapFont->ink_metrics) {
- fprintf(stderr, "Error: Couldn't allocate ink_metrics (%d*%d)\n", bitmapFont->num_chars, sizeof(xCharInfo));
+ fprintf(stderr, "Error: Couldn't allocate ink_metrics (%d*%ld)\n",
+ bitmapFont->num_chars, (unsigned long)sizeof(xCharInfo));
return FALSE;
}
for (i = 0; i < bitmapFont->num_chars; i++)
@@ -222,8 +222,7 @@ bitmapAddInkMetrics(pFont)
/* ARGSUSED */
int
-bitmapComputeWeight(pFont)
- FontPtr pFont;
+bitmapComputeWeight(FontPtr pFont)
{
return 10;
}
diff --git a/src/bitmap/bitscale.c b/src/bitmap/bitscale.c
index 5f8ef80..287bd5c 100644
--- a/src/bitmap/bitscale.c
+++ b/src/bitmap/bitscale.c
@@ -1,5 +1,4 @@
/* $Xorg: bitscale.c,v 1.5 2001/02/09 02:04:02 xorgcvs Exp $ */
-
/*
Copyright 1991, 1994, 1998 The Open Group
@@ -27,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/bitscale.c,v 3.29 2003/01/12 03:55:46 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -34,6 +34,8 @@ from The Open Group.
#include "fntfilst.h"
#include "bitmap.h"
+#include "fontutil.h"
+#ifndef FONTMODULE
#ifdef _XOPEN_SOURCE
#include <math.h>
#else
@@ -41,14 +43,25 @@ from The Open Group.
#include <math.h>
#undef _XOPEN_SOURCE
#endif
+#endif
#ifndef MAX
#define MAX(a,b) (((a)>(b)) ? a : b)
#endif
-extern Atom MakeAtom();
+/* Should get this from elsewhere */
+extern unsigned long serverGeneration;
-void bitmapUnloadScalable();
+static void bitmapUnloadScalable (FontPtr pFont);
+static void ScaleBitmap ( FontPtr pFont, CharInfoPtr opci,
+ CharInfoPtr pci, double *inv_xform,
+ double widthMult, double heightMult );
+static FontPtr BitmapScaleBitmaps(FontPtr pf, FontPtr opf,
+ double widthMult, double heightMult,
+ FontScalablePtr vals);
+static FontPtr PrinterScaleBitmaps(FontPtr pf, FontPtr opf,
+ double widthMult, double heightMult,
+ FontScalablePtr vals);
enum scaleType {
atom, truncate_atom, pixel_size, point_size, resolution_x,
@@ -63,38 +76,84 @@ typedef struct _fontProp {
enum scaleType type;
} fontProp;
-static FontPtr BitmapScaleBitmaps();
-static FontPtr PrinterScaleBitmaps();
+typedef FontPtr (*ScaleFunc) ( FontPtr /* pf */,
+ FontPtr /* opf */,
+ double /* widthMult */,
+ double /* heightMult */,
+ FontScalablePtr /* vals */);
-typedef FontPtr (*ScaleFunc) ();
/* These next two arrays must be kept in step with the renderer array */
ScaleFunc scale[] =
{
+#ifdef PCFFORMAT
+ BitmapScaleBitmaps,
+ BitmapScaleBitmaps,
+#ifdef X_GZIP_FONT_COMPRESSION
BitmapScaleBitmaps,
+#endif
+#endif
+#ifdef SNFFORMAT
BitmapScaleBitmaps,
BitmapScaleBitmaps,
+#ifdef X_GZIP_FONT_COMPRESSION
+ BitmapScaleBitmaps,
+#endif
+#endif
+#ifdef BDFFORMAT
BitmapScaleBitmaps,
BitmapScaleBitmaps,
+#ifdef X_GZIP_FONT_COMPRESSION
BitmapScaleBitmaps,
+#endif
+#endif
+#ifdef PCFFORMAT
PrinterScaleBitmaps,
+#endif
};
-
-static FontEntryPtr FindBestToScale();
-static FontEntryPtr FindPmfToScale();
-
-typedef FontEntryPtr (*FindToScale) ();
+
+static FontEntryPtr FindBestToScale ( FontPathElementPtr fpe,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ FontScalablePtr best,
+ double *dxp, double *dyp,
+ double *sdxp, double *sdyp,
+ FontPathElementPtr *fpep );
+static FontEntryPtr FindPmfToScale ( FontPathElementPtr fpe,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ FontScalablePtr best,
+ double *dxp, double *dyp,
+ double *sdxp, double *sdyp,
+ FontPathElementPtr *fpep );
+
+typedef FontEntryPtr (*FindToScale) (FontPathElementPtr fpe,
+ FontEntryPtr entry,
+ FontScalablePtr vals,
+ FontScalablePtr best,
+ double *dxp, double *dyp,
+ double *sdxp, double *sdyp,
+ FontPathElementPtr *fpep);
FindToScale find_scale[] =
{
FindBestToScale,
FindBestToScale,
+#ifdef X_GZIP_FONT_COMPRESSION
+ FindBestToScale,
+#endif
+ FindBestToScale,
+ FindBestToScale,
+#ifdef X_GZIP_FONT_COMPRESSION
FindBestToScale,
+#endif
FindBestToScale,
FindBestToScale,
+#ifdef X_GZIP_FONT_COMPRESSION
FindBestToScale,
+#endif
FindPmfToScale,
};
-static unsigned long fontGeneration = 0; /* initialization flag */
+static unsigned long bitscaleGeneration = 0; /* initialization flag */
static fontProp fontNamePropTable[] = {
{ "FOUNDRY", 0, atom },
@@ -194,7 +253,7 @@ static fontProp rawFontPropTable[] = {
};
static void
-initFontPropTable()
+initFontPropTable(void)
{
int i;
fontProp *t;
@@ -212,39 +271,34 @@ initFontPropTable()
t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
}
+#if 0
static FontEntryPtr
-GetScalableEntry (fpe, name)
- FontPathElementPtr fpe;
- FontNamePtr name;
+GetScalableEntry (FontPathElementPtr fpe, FontNamePtr name)
{
FontDirectoryPtr dir;
dir = (FontDirectoryPtr) fpe->private;
return FontFileFindNameInDir (&dir->scalable, name);
}
+#endif
static double
-get_matrix_horizontal_component(matrix)
- double *matrix;
+get_matrix_horizontal_component(double *matrix)
{
return hypot(matrix[0], matrix[1]);
}
static double
-get_matrix_vertical_component(matrix)
- double *matrix;
+get_matrix_vertical_component(double *matrix)
{
return hypot(matrix[2], matrix[3]);
}
static Bool
-ComputeScaleFactors(from, to, dx, dy, sdx, sdy, rescale_x)
- FontScalablePtr from,
- to;
- double *dx, *sdx,
- *dy, *sdy,
- *rescale_x;
+ComputeScaleFactors(FontScalablePtr from, FontScalablePtr to,
+ double *dx, double *dy, double *sdx, double *sdy,
+ double *rescale_x)
{
double srcpixelset, destpixelset, srcpixel, destpixel;
@@ -315,40 +369,37 @@ if (m >= 1.0) { \
else if (m == 2.0) \
score += (4 * s); \
else \
- score += (3 * s) / m; \
+ score += (int)(((double)(3 * s)) / m); \
} else { \
- score += (2 * s) * m; \
+ score += (int)(((double)(2 * s)) * m); \
}
/* don't need to favor enlargement when looking for bitmap that can
be used unscalable */
#define SCORE2(m,s) \
if (m >= 1.0) \
- score += (8 * s) / m; \
+ score += (int)(((double)(8 * s)) / m); \
else \
- score += (8 * s) * m;
+ score += (int)(((double)(8 * s)) * m);
static FontEntryPtr
-FindBestToScale(fpe, entry, vals, best, dxp, dyp, sdxp, sdyp, fpep)
- FontPathElementPtr fpe;
- FontEntryPtr entry;
- FontScalablePtr vals,
- best;
- double *dxp, *sdxp,
- *dyp, *sdyp;
- FontPathElementPtr *fpep;
+FindBestToScale(FontPathElementPtr fpe, FontEntryPtr entry,
+ FontScalablePtr vals, FontScalablePtr best,
+ double *dxp, double *dyp,
+ double *sdxp, double *sdyp,
+ FontPathElementPtr *fpep)
{
FontScalableRec temp;
int source, i;
int best_score, best_unscaled_score,
score;
- double dx, sdx, dx_amount,
- dy, sdy, dy_amount,
- best_dx, best_sdx, best_dx_amount,
- best_dy, best_sdy, best_dy_amount,
- best_unscaled_sdx, best_unscaled_sdy,
- rescale_x, best_rescale_x,
- best_unscaled_rescale_x;
+ double dx = 0.0, sdx = 0.0, dx_amount = 0.0,
+ dy = 0.0, sdy = 0.0, dy_amount = 0.0,
+ best_dx = 0.0, best_sdx = 0.0, best_dx_amount = 0.0,
+ best_dy = 0.0, best_sdy = 0.0, best_dy_amount = 0.0,
+ best_unscaled_sdx = 0.0, best_unscaled_sdy = 0.0,
+ rescale_x = 0.0, best_rescale_x = 0.0,
+ best_unscaled_rescale_x = 0.0;
FontEntryPtr zero;
FontNameRec zeroName;
char zeroChars[MAXFONTNAMELEN];
@@ -356,14 +407,15 @@ FindBestToScale(fpe, entry, vals, best, dxp, dyp, sdxp, sdyp, fpep)
FontScaledPtr scaled;
FontScalableExtraPtr extra;
FontScaledPtr best_scaled, best_unscaled;
- FontPathElementPtr best_fpe, best_unscaled_fpe;
+ FontPathElementPtr best_fpe = NULL, best_unscaled_fpe = NULL;
FontEntryPtr bitmap = NULL;
FontEntryPtr result;
int aliascount = 20;
- FontPathElementPtr bitmap_fpe;
+ FontPathElementPtr bitmap_fpe = NULL;
FontNameRec xlfdName;
/* find the best match */
+ rescale_x = 1.0;
best_scaled = 0;
best_score = 0;
best_unscaled = 0;
@@ -542,14 +594,11 @@ FindBestToScale(fpe, entry, vals, best, dxp, dyp, sdxp, sdyp, fpep)
}
static FontEntryPtr
-FindPmfToScale(fpe, entry, vals, best, dxp, dyp, sdxp, sdyp, fpep)
- FontPathElementPtr fpe;
- FontEntryPtr entry;
- FontScalablePtr vals,
- best;
- double *dxp, *sdxp,
- *dyp, *sdyp;
- FontPathElementPtr *fpep;
+FindPmfToScale(FontPathElementPtr fpe, FontEntryPtr entry,
+ FontScalablePtr vals, FontScalablePtr best,
+ double *dxp, double *dyp,
+ double *sdxp, double *sdyp,
+ FontPathElementPtr *fpep)
{
FontEntryPtr result = NULL;
FontScaledPtr scaled;
@@ -576,7 +625,7 @@ FindPmfToScale(fpe, entry, vals, best, dxp, dyp, sdxp, sdyp, fpep)
the matrix appropriately */
vals->pixel_matrix[0] *= rescale_x;
vals->pixel_matrix[1] *= rescale_x;
- #ifdef NOTDEF
+#ifdef NOTDEF
/* This would force the pointsize and pixelsize fields in the
FONT property to display as matrices to more accurately
report the font being supplied. It might also break existing
@@ -584,9 +633,9 @@ FindPmfToScale(fpe, entry, vals, best, dxp, dyp, sdxp, sdyp, fpep)
vals->values_supplied =
vals->values_supplied & ~(PIXELSIZE_MASK | POINTSIZE_MASK) |
PIXELSIZE_ARRAY;
- #else /* NOTDEF */
+#else /* NOTDEF */
vals->values_supplied = vals->values_supplied & ~POINTSIZE_MASK;
- #endif /* NOTDEF */
+#endif /* NOTDEF */
/* Recompute and reround the FontScalablePtr values after
rescaling for the new width. */
FontFileCompleteXLFD(vals, vals);
@@ -597,27 +646,21 @@ FindPmfToScale(fpe, entry, vals, best, dxp, dyp, sdxp, sdyp, fpep)
}
static long
-doround(x)
-double x;
+doround(double x)
{
return (x >= 0) ? (long)(x + .5) : (long)(x - .5);
}
static int
-computeProps(pf, wasStringProp, npf, isStringProp, nprops, xfactor, yfactor,
- sXfactor, sYfactor)
- FontPropPtr pf;
- char *wasStringProp;
- FontPropPtr npf;
- char *isStringProp;
- unsigned int nprops;
- double xfactor, sXfactor,
- yfactor, sYfactor;
+computeProps(FontPropPtr pf, char *wasStringProp,
+ FontPropPtr npf, char *isStringProp,
+ unsigned int nprops, double xfactor, double yfactor,
+ double sXfactor, double sYfactor)
{
int n;
int count;
fontProp *t;
- double rawfactor;
+ double rawfactor = 0.0;
for (count = 0; nprops > 0; nprops--, pf++, wasStringProp++) {
n = sizeof(fontPropTable) / sizeof(fontProp);
@@ -641,6 +684,8 @@ computeProps(pf, wasStringProp, npf, isStringProp, nprops, xfactor, yfactor,
count++;
*isStringProp++ = *wasStringProp;
break;
+ default:
+ break;
}
if (t->type != unscaled)
{
@@ -660,44 +705,43 @@ computeProps(pf, wasStringProp, npf, isStringProp, nprops, xfactor, yfactor,
static int
-ComputeScaledProperties(sourceFontInfo, name, vals, dx, dy, sdx, sdy,
- sWidth, pProps, pIsStringProp)
- FontInfoPtr sourceFontInfo; /* the font to be scaled */
- char *name; /* name of resulting font */
- FontScalablePtr vals;
- double dx, sdx,
- dy, sdy; /* scale factors in x and y directions */
- long sWidth; /* 1000-pixel average width */
- FontPropPtr *pProps; /* returns properties; preallocated */
- char **pIsStringProp; /* return booleans; preallocated */
+ComputeScaledProperties(FontInfoPtr sourceFontInfo, /* the font to be scaled */
+ char *name, /* name of resulting font */
+ FontScalablePtr vals,
+ double dx, double dy, /* scale factors in x and y */
+ double sdx, double sdy, /* directions */
+ long sWidth, /* 1000-pixel average width */
+ FontPropPtr *pProps, /* returns properties;
+ preallocated */
+ char **pIsStringProp) /* return booleans;
+ preallocated */
{
int n;
- char *ptr1,
- *ptr2;
+ char *ptr1 = NULL, *ptr2 = NULL;
char *ptr3;
FontPropPtr fp;
fontProp *fpt;
- extern int serverGeneration;
char *isStringProp;
int nProps;
- if (fontGeneration != serverGeneration) {
+ if (bitscaleGeneration != serverGeneration) {
initFontPropTable();
- fontGeneration = serverGeneration;
+ bitscaleGeneration = serverGeneration;
}
nProps = NPROPS + 1 + sizeof(fontPropTable) / sizeof(fontProp) +
sizeof(rawFontPropTable) / sizeof(fontProp);
fp = (FontPropPtr) xalloc(sizeof(FontPropRec) * nProps);
*pProps = fp;
if (!fp) {
- fprintf(stderr, "Error: Couldn't allocate font properties (%d*%d)\n", sizeof(FontPropRec), nProps);
+ fprintf(stderr, "Error: Couldn't allocate font properties (%ld*%d)\n",
+ (unsigned long)sizeof(FontPropRec), nProps);
return 1;
}
isStringProp = (char *) xalloc (nProps);
*pIsStringProp = isStringProp;
if (!isStringProp)
{
- fprintf(stderr, "Error: Couldn't allocate isStringProp (%d)\n", nProps);
+ fprintf(stderr, "Error: Couldn't allocate isStringProp (%d)\n", nProps);
xfree (fp);
return 1;
}
@@ -761,6 +805,8 @@ ComputeScaledProperties(sourceFontInfo, name, vals, dx, dy, sdx, sdy,
case raw_average_width:
fp->value = sWidth;
break;
+ default:
+ break;
}
fp->name = fpt->atom;
}
@@ -771,13 +817,11 @@ ComputeScaledProperties(sourceFontInfo, name, vals, dx, dy, sdx, sdy,
return n;
}
-static void ScaleBitmap();
static int
-compute_xform_matrix(vals, dx, dy, xform, inv_xform, xmult, ymult)
- FontScalablePtr vals;
- double dx, dy, *inv_xform, *xmult, *ymult;
- register double *xform;
+compute_xform_matrix(FontScalablePtr vals, double dx, double dy,
+ double *xform, double *inv_xform,
+ double *xmult, double *ymult)
{
double det;
double pixel = get_matrix_vertical_component(vals->pixel_matrix);
@@ -835,19 +879,17 @@ compute_xform_matrix(vals, dx, dy, xform, inv_xform, xmult, ymult)
* returns a pointer to the new scaled font, or NULL (due to AllocError).
*/
static FontPtr
-ScaleFont(opf, widthMult, heightMult, sWidthMult, sHeightMult, vals,
- newWidthMult, newHeightMult, sWidth)
- FontPtr opf; /* originating font */
- double widthMult; /* glyphs width scale factor */
- double heightMult; /* glyphs height scale factor */
- double sWidthMult; /* scalable glyphs width scale factor */
- double sHeightMult; /* scalable glyphs height scale factor */
- FontScalablePtr vals;
- double *newWidthMult; /* return: X component of glyphs width
- scale factor */
- double *newHeightMult; /* return: Y component of glyphs height
- scale factor */
- long *sWidth; /* return: average 1000-pixel width */
+ScaleFont(FontPtr opf, /* originating font */
+ double widthMult, /* glyphs width scale factor */
+ double heightMult, /* glyphs height scale factor */
+ double sWidthMult, /* scalable glyphs width scale factor */
+ double sHeightMult, /* scalable glyphs height scale factor */
+ FontScalablePtr vals,
+ double *newWidthMult, /* return: X component of glyphs width
+ scale factor */
+ double *newHeightMult, /* return: Y component of glyphs height
+ scale factor */
+ long *sWidth) /* return: average 1000-pixel width */
{
FontPtr pf;
FontInfoPtr pfi,
@@ -856,7 +898,7 @@ ScaleFont(opf, widthMult, heightMult, sWidthMult, sHeightMult, vals,
obitmapFont;
CharInfoPtr pci,
opci;
- int nchars; /* how many characters in the font */
+ int nchars = 0; /* how many characters in the font */
int i;
int glyph;
int firstCol, lastCol, firstRow, lastRow;
@@ -870,11 +912,6 @@ ScaleFont(opf, widthMult, heightMult, sWidthMult, sHeightMult, vals,
(i)%(lastCol - firstCol + 1) + \
firstCol - opf->info.firstCol)
- extern int bitmapGetBitmaps();
- extern int bitmapGetExtents();
- extern int bitmapGetGlyphs();
- extern int bitmapGetMetrics();
-
*sWidth = 0;
opfi = &opf->info;
@@ -882,14 +919,12 @@ ScaleFont(opf, widthMult, heightMult, sWidthMult, sHeightMult, vals,
obitmapFont = (BitmapFontPtr) opf->fontPrivate;
bitmapFont = 0;
- pf = (FontPtr) xalloc(sizeof(FontRec));
- if (!pf) {
- fprintf(stderr, "Error: Couldn't allocate FontRec (%d)\n", sizeof(FontRec));
+ if (!(pf = CreateFontRec())) {
+ fprintf(stderr, "Error: Couldn't allocate FontRec (%ld)\n",
+ (unsigned long)sizeof(FontRec));
goto bail;
}
pf->refcnt = 0;
- pf->maxPrivate = -1;
- pf->devPrivates = (pointer *) 0;
pf->bit = opf->bit;
pf->byte = opf->byte;
pf->glyph = opf->glyph;
@@ -953,7 +988,8 @@ ScaleFont(opf, widthMult, heightMult, sWidthMult, sHeightMult, vals,
bitmapFont = (BitmapFontPtr) xalloc(sizeof(BitmapFontRec));
if (!bitmapFont) {
- fprintf(stderr, "Error: Couldn't allocate bitmapFont (%d)\n", sizeof(BitmapFontRec));
+ fprintf(stderr, "Error: Couldn't allocate bitmapFont (%ld)\n",
+ (unsigned long)sizeof(BitmapFontRec));
goto bail;
}
nchars = (lastRow - firstRow + 1) * (lastCol - firstCol + 1);
@@ -973,12 +1009,16 @@ ScaleFont(opf, widthMult, heightMult, sWidthMult, sHeightMult, vals,
bitmapFont->pDefault = 0;
bitmapFont->metrics = (CharInfoPtr) xalloc(nchars * sizeof(CharInfoRec));
if (!bitmapFont->metrics) {
- fprintf(stderr, "Error: Couldn't allocate metrics (%d*%d)\n", nchars, sizeof(CharInfoRec));
+ fprintf(stderr, "Error: Couldn't allocate metrics (%d*%ld)\n",
+ nchars, (unsigned long)sizeof(CharInfoRec));
goto bail;
}
- bitmapFont->encoding = (CharInfoPtr *) xalloc(nchars * sizeof(CharInfoPtr));
+ bitmapFont->encoding =
+ (CharInfoPtr **) xcalloc(NUM_SEGMENTS(nchars),
+ sizeof(CharInfoPtr*));
if (!bitmapFont->encoding) {
- fprintf(stderr, "Error: Couldn't allocate encoding (%d*%d)\n", nchars, sizeof(CharInfoPtr));
+ fprintf(stderr, "Error: Couldn't allocate encoding (%d*%ld)\n",
+ nchars, (unsigned long)sizeof(CharInfoPtr));
goto bail;
}
@@ -1020,7 +1060,8 @@ ScaleFont(opf, widthMult, heightMult, sWidthMult, sHeightMult, vals,
pci = bitmapFont->metrics;
for (i = 0; i < nchars; i++)
{
- if ((opci = obitmapFont->encoding[inkindex2 = OLDINDEX(i)]))
+ inkindex2 = OLDINDEX(i);
+ if ((opci = ACCESSENCODING(obitmapFont->encoding,OLDINDEX(i))))
{
double newlsb, newrsb, newdesc, newasc, point[2];
@@ -1039,7 +1080,6 @@ ScaleFont(opf, widthMult, heightMult, sWidthMult, sHeightMult, vals,
break;
if (j == vals->nranges)
{
- bitmapFont->encoding[i] = 0;
continue;
}
}
@@ -1050,11 +1090,17 @@ ScaleFont(opf, widthMult, heightMult, sWidthMult, sHeightMult, vals,
opci->metrics.descent == 0 &&
opci->metrics.characterWidth == 0)
{
- bitmapFont->encoding[i] = 0;
continue;
}
- bitmapFont->encoding[i] = pci;
+ if(!bitmapFont->encoding[SEGMENT_MAJOR(i)]) {
+ bitmapFont->encoding[SEGMENT_MAJOR(i)]=
+ (CharInfoPtr*)xcalloc(BITMAP_FONT_SEGMENT_SIZE,
+ sizeof(CharInfoPtr));
+ if(!bitmapFont->encoding[SEGMENT_MAJOR(i)])
+ goto bail;
+ }
+ ACCESSENCODINGL(bitmapFont->encoding, i) = pci;
/* Compute new extents for this glyph */
TRANSFORM_POINT(xform,
@@ -1107,8 +1153,6 @@ ScaleFont(opf, widthMult, heightMult, sWidthMult, sHeightMult, vals,
pci++;
}
- else
- bitmapFont->encoding[i] = 0;
}
@@ -1120,10 +1164,9 @@ ScaleFont(opf, widthMult, heightMult, sWidthMult, sHeightMult, vals,
pci = bitmapFont->metrics;
for (i = 0; i < nchars; i++)
{
- if ((pci = bitmapFont->encoding[i]) &&
- (opci = obitmapFont->encoding[OLDINDEX(i)]))
+ if ((pci = ACCESSENCODING(bitmapFont->encoding,i)) &&
+ (opci = ACCESSENCODING(obitmapFont->encoding,OLDINDEX(i))))
{
- pci = bitmapFont->encoding[i];
totalchars++;
*sWidth += abs((int)(INT16)pci->metrics.attributes);
#define MINMAX(field) \
@@ -1185,7 +1228,8 @@ ScaleFont(opf, widthMult, heightMult, sWidthMult, sHeightMult, vals,
cols = pfi->lastCol - pfi->firstCol + 1;
r = r - pfi->firstRow;
c = c - pfi->firstCol;
- bitmapFont->pDefault = bitmapFont->encoding[r * cols + c];
+ bitmapFont->pDefault =
+ ACCESSENCODING(bitmapFont->encoding, r * cols + c);
}
}
@@ -1199,19 +1243,17 @@ bail:
xfree(bitmapFont->metrics);
xfree(bitmapFont->ink_metrics);
xfree(bitmapFont->bitmaps);
+ if(bitmapFont->encoding)
+ for(i=0; i<NUM_SEGMENTS(nchars); i++)
+ xfree(bitmapFont->encoding[i]);
xfree(bitmapFont->encoding);
}
return NULL;
}
static void
-ScaleBitmap(pFont, opci, pci, inv_xform, widthMult, heightMult)
- FontPtr pFont;
- CharInfoPtr opci;
- CharInfoPtr pci;
- double *inv_xform;
- double widthMult;
- double heightMult;
+ScaleBitmap(FontPtr pFont, CharInfoPtr opci, CharInfoPtr pci,
+ double *inv_xform, double widthMult, double heightMult)
{
register char *bitmap, /* The bits */
*newBitmap;
@@ -1229,8 +1271,9 @@ ScaleBitmap(pFont, opci, pci, inv_xform, widthMult, heightMult)
yValue;
double point[2];
unsigned char *char_grayscale = 0;
- INT32 *diffusion_workspace, *thisrow, *nextrow, pixmult;
- int box_x, box_y;
+ INT32 *diffusion_workspace = NULL, *thisrow = NULL,
+ *nextrow = NULL, pixmult = 0;
+ int box_x = 0, box_y = 0;
static unsigned char masklsb[] =
{ 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 };
@@ -1292,7 +1335,9 @@ ScaleBitmap(pFont, opci, pci, inv_xform, widthMult, heightMult)
(INT32 *)xalloc((newWidth + 2) * 2 * sizeof(int));
if (!diffusion_workspace)
{
- fprintf(stderr, "Warning: Couldn't allocate diffusion workspace (%d)\n", (newWidth + 2) * 2 * sizeof(int));
+ fprintf(stderr, "Warning: Couldn't allocate diffusion"
+ " workspace (%ld)\n",
+ (newWidth + 2) * 2 * (unsigned long)sizeof(int));
xfree(char_grayscale);
char_grayscale = (unsigned char *)0;
}
@@ -1301,8 +1346,8 @@ ScaleBitmap(pFont, opci, pci, inv_xform, widthMult, heightMult)
(newWidth + 3) * sizeof(int));
thisrow = diffusion_workspace + 1;
nextrow = diffusion_workspace + newWidth + 3;
- } else {
- fprintf(stderr, "Warning: Couldn't allocate character grayscale (%d)\n", (width + 1) * (height + 1));
+ } else {
+ fprintf(stderr, "Warning: Couldn't allocate character grayscale (%d)\n", (width + 1) * (height + 1));
}
}
}
@@ -1554,15 +1599,14 @@ ScaleBitmap(pFont, opci, pci, inv_xform, widthMult, heightMult)
}
static FontPtr
-BitmapScaleBitmaps(pf, opf, widthMult, heightMult, vals)
- FontPtr pf; /* scaled font */
- FontPtr opf; /* originating font */
- double widthMult; /* glyphs width scale factor */
- double heightMult; /* glyphs height scale factor */
- FontScalablePtr vals;
+BitmapScaleBitmaps(FontPtr pf, /* scaled font */
+ FontPtr opf, /* originating font */
+ double widthMult, /* glyphs width scale factor */
+ double heightMult, /* glyphs height scale factor */
+ FontScalablePtr vals)
{
register int i;
- int nchars;
+ int nchars = 0;
char *glyphBytes;
BitmapFontPtr bitmapFont,
obitmapFont;
@@ -1593,7 +1637,7 @@ BitmapScaleBitmaps(pf, opf, widthMult, heightMult, vals)
glyph = pf->glyph;
for (i = 0; i < nchars; i++)
{
- if ((pci = bitmapFont->encoding[i]))
+ if ((pci = ACCESSENCODING(bitmapFont->encoding, i)))
bytestoalloc += BYTES_FOR_GLYPH(pci, glyph);
}
@@ -1603,7 +1647,7 @@ BitmapScaleBitmaps(pf, opf, widthMult, heightMult, vals)
bitmapFont->bitmaps = (char *) xalloc(bytestoalloc);
if (!bitmapFont->bitmaps) {
- fprintf(stderr, "Error: Couldn't allocate bitmaps (%d)\n", bytestoalloc);
+ fprintf(stderr, "Error: Couldn't allocate bitmaps (%d)\n", bytestoalloc);
goto bail;
}
bzero(bitmapFont->bitmaps, bytestoalloc);
@@ -1611,8 +1655,8 @@ BitmapScaleBitmaps(pf, opf, widthMult, heightMult, vals)
glyphBytes = bitmapFont->bitmaps;
for (i = 0; i < nchars; i++)
{
- if ((pci = bitmapFont->encoding[i]) &&
- (opci = obitmapFont->encoding[OLDINDEX(i)]))
+ if ((pci = ACCESSENCODING(bitmapFont->encoding, i)) &&
+ (opci = ACCESSENCODING(obitmapFont->encoding, OLDINDEX(i))))
{
pci->bits = glyphBytes;
ScaleBitmap (pf, opci, pci, inv_xform,
@@ -1629,21 +1673,23 @@ bail:
xfree(bitmapFont->metrics);
xfree(bitmapFont->ink_metrics);
xfree(bitmapFont->bitmaps);
+ if(bitmapFont->encoding)
+ for(i=0; i<NUM_SEGMENTS(nchars); i++)
+ xfree(bitmapFont->encoding[i]);
xfree(bitmapFont->encoding);
}
return NULL;
}
static FontPtr
-PrinterScaleBitmaps(pf, opf, widthMult, heightMult, vals)
- FontPtr pf; /* scaled font */
- FontPtr opf; /* originating font */
- double widthMult; /* glyphs width scale factor */
- double heightMult; /* glyphs height scale factor */
- FontScalablePtr vals;
+PrinterScaleBitmaps(FontPtr pf, /* scaled font */
+ FontPtr opf, /* originating font */
+ double widthMult, /* glyphs width scale factor */
+ double heightMult, /* glyphs height scale factor */
+ FontScalablePtr vals)
{
register int i;
- int nchars;
+ int nchars = 0;
char *glyphBytes;
BitmapFontPtr bitmapFont,
obitmapFont;
@@ -1674,7 +1720,7 @@ PrinterScaleBitmaps(pf, opf, widthMult, heightMult, vals)
glyph = pf->glyph;
for (i = 0; i < nchars; i++)
{
- if ((pci = bitmapFont->encoding[i]))
+ if ((pci = ACCESSENCODING(bitmapFont->encoding, i)))
bytestoalloc = MAX(bytestoalloc,BYTES_FOR_GLYPH(pci, glyph));
}
@@ -1684,7 +1730,7 @@ PrinterScaleBitmaps(pf, opf, widthMult, heightMult, vals)
bitmapFont->bitmaps = (char *) xalloc(bytestoalloc);
if (!bitmapFont->bitmaps) {
- fprintf(stderr, "Error: Couldn't allocate bitmaps (%d)\n", bytestoalloc);
+ fprintf(stderr, "Error: Couldn't allocate bitmaps (%d)\n", bytestoalloc);
goto bail;
}
bzero(bitmapFont->bitmaps, bytestoalloc);
@@ -1692,8 +1738,8 @@ PrinterScaleBitmaps(pf, opf, widthMult, heightMult, vals)
glyphBytes = bitmapFont->bitmaps;
for (i = 0; i < nchars; i++)
{
- if ((pci = bitmapFont->encoding[i]) &&
- (opci = obitmapFont->encoding[OLDINDEX(i)]))
+ if ((pci = ACCESSENCODING(bitmapFont->encoding, i)) &&
+ (opci = ACCESSENCODING(obitmapFont->encoding, OLDINDEX(i))))
{
pci->bits = glyphBytes;
}
@@ -1707,6 +1753,9 @@ bail:
xfree(bitmapFont->metrics);
xfree(bitmapFont->ink_metrics);
xfree(bitmapFont->bitmaps);
+ if(bitmapFont->encoding)
+ for(i=0; i<NUM_SEGMENTS(nchars); i++)
+ xfree(bitmapFont->encoding[i]);
xfree(bitmapFont->encoding);
}
return NULL;
@@ -1717,13 +1766,8 @@ bail:
* exported interfaces
*/
-FontFileLoadName(dirs, ndirs, name, pfont, format, fmask)
- FontFileDirPtr *dirs;
- int ndirs;
- char *name;
- FontPtr *pfont;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
+FontFileLoadName(FontFileDirPtr *dirs, int ndirs, char *name, FontPtr *pfont,
+ fsBitmapFormat format, fsBitmapFormatMask fmask)
{
FontFileNamePtr fname;
char full_name[1024];
@@ -1758,17 +1802,15 @@ FontFileLoadName(dirs, ndirs, name, pfont, format, fmask)
/* ARGSUSED */
int
-BitmapOpenScalable (fpe, pFont, flags, entry, fileName, vals, format, fmask,
- non_cachable_font)
- FontPathElementPtr fpe;
- FontPtr *pFont;
- int flags;
- FontEntryPtr entry;
- char *fileName; /* unused */
- FontScalablePtr vals;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- FontPtr non_cachable_font; /* We don't do licensing */
+BitmapOpenScalable (FontPathElementPtr fpe,
+ FontPtr *pFont,
+ int flags,
+ FontEntryPtr entry,
+ char *fileName, /* unused */
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
{
FontScalableRec best;
FontPtr font = NullFont;
@@ -1861,13 +1903,12 @@ BitmapOpenScalable (fpe, pFont, flags, entry, fileName, vals, format, fmask,
}
int
-BitmapGetInfoScalable (fpe, pFontInfo, entry, fontName, fileName, vals)
- FontPathElementPtr fpe;
- FontInfoPtr pFontInfo;
- FontEntryPtr entry;
- FontNamePtr fontName;
- char *fileName;
- FontScalablePtr vals;
+BitmapGetInfoScalable (FontPathElementPtr fpe,
+ FontInfoPtr pFontInfo,
+ FontEntryPtr entry,
+ FontNamePtr fontName,
+ char *fileName,
+ FontScalablePtr vals)
{
FontPtr pfont;
int flags = 0;
@@ -1881,6 +1922,7 @@ BitmapGetInfoScalable (fpe, pFontInfo, entry, fontName, fileName, vals)
return ret;
*pFontInfo = pfont->info;
+ pfont->info.nprops = 0;
pfont->info.props = NULL;
pfont->info.isStringProp = NULL;
@@ -1888,22 +1930,27 @@ BitmapGetInfoScalable (fpe, pFontInfo, entry, fontName, fileName, vals)
return Successful;
}
-void
-bitmapUnloadScalable (pFont)
- FontPtr pFont;
+static void
+bitmapUnloadScalable (FontPtr pFont)
{
BitmapFontPtr bitmapFont;
FontInfoPtr pfi;
+ int i, nencoding;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
pfi = &pFont->info;
xfree (pfi->props);
xfree (pfi->isStringProp);
+ if(bitmapFont->encoding) {
+ nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
+ (pFont->info.lastRow - pFont->info.firstRow + 1);
+ for(i=0; i<NUM_SEGMENTS(nencoding); i++)
+ xfree(bitmapFont->encoding[i]);
+ }
xfree (bitmapFont->encoding);
xfree (bitmapFont->bitmaps);
xfree (bitmapFont->ink_metrics);
xfree (bitmapFont->metrics);
xfree (pFont->fontPrivate);
- xfree (pFont->devPrivates);
- xfree (pFont);
+ DestroyFontRec (pFont);
}
diff --git a/src/bitmap/fontink.c b/src/bitmap/fontink.c
index fc9bc9a..45226c5 100644
--- a/src/bitmap/fontink.c
+++ b/src/bitmap/fontink.c
@@ -27,12 +27,15 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/fontink.c,v 1.7 2001/12/14 19:56:46 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
*/
#include "fntfilst.h"
+#include "bitmap.h"
+#include "bdfint.h"
static unsigned char ink_mask_msb[8] = {
0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01,
@@ -43,23 +46,20 @@ static unsigned char ink_mask_lsb[8] = {
};
void
-FontCharInkMetrics(pFont, pCI, pInk)
- FontPtr pFont;
- CharInfoPtr pCI;
- xCharInfo *pInk;
+FontCharInkMetrics(FontPtr pFont, CharInfoPtr pCI, xCharInfo *pInk)
{
int leftBearing,
ascent,
descent;
register int vpos,
hpos,
- bpos;
+ bpos = 0;
int bitmapByteWidth,
bitmapByteWidthPadded;
int bitmapBitWidth;
int span;
register unsigned char *p;
- unsigned char *ink_mask;
+ unsigned char *ink_mask = 0;
register int bmax;
register unsigned char charbits;
@@ -157,10 +157,7 @@ found_right:
#define Max(a,b) ((a)>(b)?(a):(b))
void
-FontCharReshape(pFont, pSrc, pDst)
- FontPtr pFont;
- CharInfoPtr pSrc,
- pDst;
+FontCharReshape(FontPtr pFont, CharInfoPtr pSrc, CharInfoPtr pDst)
{
int x,
y;
diff --git a/src/bitmap/pcfread.c b/src/bitmap/pcfread.c
index 7125b1a..1e07b09 100644
--- a/src/bitmap/pcfread.c
+++ b/src/bitmap/pcfread.c
@@ -1,5 +1,4 @@
/* $Xorg: pcfread.c,v 1.5 2001/02/09 02:04:02 xorgcvs Exp $ */
-
/*
Copyright 1990, 1998 The Open Group
@@ -27,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/pcfread.c,v 1.20 2003/01/12 03:55:46 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -35,6 +35,7 @@ from The Open Group.
#include "fntfilst.h"
#include "bitmap.h"
#include "pcf.h"
+
#ifndef MAX
#define MAX(a,b) (((a)>(b)) ? a : b)
#endif
@@ -57,24 +58,28 @@ pcfError (message, va_alist)
va_list args;
#if NeedVarargsPrototypes
- va_start (args, message);
+ va_start(args, message);
#else
- va_start (args);
+ va_start(args);
#endif
fprintf(stderr, "PCF Error: ");
vfprintf(stderr, message, args);
- va_end (args);
+ va_end(args);
}
-
+
/* Read PCF font files */
-void pcfUnloadFont();
+static void pcfUnloadFont ( FontPtr pFont );
static int position;
+
+#define IS_EOF(file) ((file)->eof == BUFFILEEOF)
+
+#define FONT_FILE_GETC_ERR(f) (tmp = FontFileGetc(f), BAIL_ON_EOF)
+
static int
-pcfGetLSB32(file)
- FontFilePtr file;
+pcfGetLSB32(FontFilePtr file)
{
int c;
@@ -87,9 +92,7 @@ pcfGetLSB32(file)
}
static int
-pcfGetINT32(file, format)
- FontFilePtr file;
- CARD32 format;
+pcfGetINT32(FontFilePtr file, CARD32 format)
{
int c;
@@ -109,9 +112,7 @@ pcfGetINT32(file, format)
}
static int
-pcfGetINT16(file, format)
- FontFilePtr file;
- CARD32 format;
+pcfGetINT16(FontFilePtr file, CARD32 format)
{
int c;
@@ -129,9 +130,7 @@ pcfGetINT16(file, format)
#define pcfGetINT8(file, format) (position++, FontFileGetc(file))
static PCFTablePtr
-pcfReadTOC(file, countp)
- FontFilePtr file;
- int *countp;
+pcfReadTOC(FontFilePtr file, int *countp)
{
CARD32 version;
PCFTablePtr tables;
@@ -143,9 +142,10 @@ pcfReadTOC(file, countp)
if (version != PCF_FILE_VERSION)
return (PCFTablePtr) NULL;
count = pcfGetLSB32(file);
+ if (IS_EOF(file)) return (PCFTablePtr) NULL;
tables = (PCFTablePtr) xalloc(count * sizeof(PCFTableRec));
if (!tables) {
- pcfError("pcfReadTOC(): Couldn't allocate tables (%d*%d)\n", count, sizeof(PCFTableRec));
+ pcfError("pcfReadTOC(): Couldn't allocate tables (%d*%d)\n", count, sizeof(PCFTableRec));
return (PCFTablePtr) NULL;
}
for (i = 0; i < count; i++) {
@@ -153,9 +153,15 @@ pcfReadTOC(file, countp)
tables[i].format = pcfGetLSB32(file);
tables[i].size = pcfGetLSB32(file);
tables[i].offset = pcfGetLSB32(file);
+ if (IS_EOF(file)) goto Bail;
}
+
*countp = count;
return tables;
+
+ Bail:
+ xfree(tables);
+ return (PCFTablePtr) NULL;
}
/*
@@ -165,11 +171,8 @@ pcfReadTOC(file, countp)
* metrics
*/
-static void
-pcfGetMetric(file, format, metric)
- FontFilePtr file;
- CARD32 format;
- xCharInfo *metric;
+static Bool
+pcfGetMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
{
metric->leftSideBearing = pcfGetINT16(file, format);
metric->rightSideBearing = pcfGetINT16(file, format);
@@ -177,13 +180,13 @@ pcfGetMetric(file, format, metric)
metric->ascent = pcfGetINT16(file, format);
metric->descent = pcfGetINT16(file, format);
metric->attributes = pcfGetINT16(file, format);
+ if (IS_EOF(file)) return FALSE;
+
+ return TRUE;
}
-static void
-pcfGetCompressedMetric(file, format, metric)
- FontFilePtr file;
- CARD32 format;
- xCharInfo *metric;
+static Bool
+pcfGetCompressedMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
{
metric->leftSideBearing = pcfGetINT8(file, format) - 0x80;
metric->rightSideBearing = pcfGetINT8(file, format) - 0x80;
@@ -191,6 +194,9 @@ pcfGetCompressedMetric(file, format, metric)
metric->ascent = pcfGetINT8(file, format) - 0x80;
metric->descent = pcfGetINT8(file, format) - 0x80;
metric->attributes = 0;
+ if (IS_EOF(file)) return FALSE;
+
+ return TRUE;
}
/*
@@ -198,13 +204,8 @@ pcfGetCompressedMetric(file, format, metric)
* in the font file
*/
static Bool
-pcfSeekToType(file, tables, ntables, type, formatp, sizep)
- FontFilePtr file;
- PCFTablePtr tables;
- int ntables;
- CARD32 type;
- CARD32 *formatp;
- CARD32 *sizep;
+pcfSeekToType(FontFilePtr file, PCFTablePtr tables, int ntables,
+ CARD32 type, CARD32 *formatp, CARD32 *sizep)
{
int i;
@@ -223,10 +224,7 @@ pcfSeekToType(file, tables, ntables, type, formatp, sizep)
}
static Bool
-pcfHasType (tables, ntables, type)
- PCFTablePtr tables;
- int ntables;
- CARD32 type;
+pcfHasType (PCFTablePtr tables, int ntables, CARD32 type)
{
int i;
@@ -244,18 +242,15 @@ pcfHasType (tables, ntables, type)
*/
static Bool
-pcfGetProperties(pFontInfo, file, tables, ntables)
- FontInfoPtr pFontInfo;
- FontFilePtr file;
- PCFTablePtr tables;
- int ntables;
+pcfGetProperties(FontInfoPtr pFontInfo, FontFilePtr file,
+ PCFTablePtr tables, int ntables)
{
FontPropPtr props = 0;
int nprops;
char *isStringProp = 0;
CARD32 format;
int i;
- int size;
+ CARD32 size;
int string_size;
char *strings;
@@ -267,20 +262,22 @@ pcfGetProperties(pFontInfo, file, tables, ntables)
if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
goto Bail;
nprops = pcfGetINT32(file, format);
+ if (IS_EOF(file)) goto Bail;
props = (FontPropPtr) xalloc(nprops * sizeof(FontPropRec));
if (!props) {
- pcfError("pcfGetProperties(): Couldn't allocate props (%d*%d)\n", nprops, sizeof(FontPropRec));
+ pcfError("pcfGetProperties(): Couldn't allocate props (%d*%d)\n", nprops, sizeof(FontPropRec));
goto Bail;
}
isStringProp = (char *) xalloc(nprops * sizeof(char));
if (!isStringProp) {
- pcfError("pcfGetProperties(): Couldn't allocate isStringProp (%d*%d)\n", nprops, sizeof(char));
+ pcfError("pcfGetProperties(): Couldn't allocate isStringProp (%d*%d)\n", nprops, sizeof(char));
goto Bail;
}
for (i = 0; i < nprops; i++) {
props[i].name = pcfGetINT32(file, format);
isStringProp[i] = pcfGetINT8(file, format);
props[i].value = pcfGetINT32(file, format);
+ if (IS_EOF(file)) goto Bail;
}
/* pad the property array */
/*
@@ -290,16 +287,19 @@ pcfGetProperties(pFontInfo, file, tables, ntables)
if (nprops & 3)
{
i = 4 - (nprops & 3);
- FontFileSkip(file, i);
+ (void)FontFileSkip(file, i);
position += i;
}
+ if (IS_EOF(file)) goto Bail;
string_size = pcfGetINT32(file, format);
+ if (IS_EOF(file)) goto Bail;
strings = (char *) xalloc(string_size);
if (!strings) {
- pcfError("pcfGetProperties(): Couldn't allocate strings (%d)\n", string_size);
+ pcfError("pcfGetProperties(): Couldn't allocate strings (%d)\n", string_size);
goto Bail;
}
FontFileRead(file, strings, string_size);
+ if (IS_EOF(file)) goto Bail;
position += string_size;
for (i = 0; i < nprops; i++) {
props[i].name = MakeAtom(strings + props[i].name,
@@ -329,17 +329,14 @@ Bail:
*/
static Bool
-pcfGetAccel(pFontInfo, file, tables, ntables, type)
- FontInfoPtr pFontInfo;
- FontFilePtr file;
- PCFTablePtr tables;
- int ntables;
- CARD32 type;
+pcfGetAccel(FontInfoPtr pFontInfo, FontFilePtr file,
+ PCFTablePtr tables, int ntables, CARD32 type)
{
CARD32 format;
- int size;
+ CARD32 size;
- if (!pcfSeekToType(file, tables, ntables, type, &format, &size))
+ if (!pcfSeekToType(file, tables, ntables, type, &format, &size) ||
+ IS_EOF(file))
goto Bail;
format = pcfGetLSB32(file);
if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT) &&
@@ -360,11 +357,16 @@ pcfGetAccel(pFontInfo, file, tables, ntables, type)
pFontInfo->fontAscent = pcfGetINT32(file, format);
pFontInfo->fontDescent = pcfGetINT32(file, format);
pFontInfo->maxOverlap = pcfGetINT32(file, format);
- pcfGetMetric(file, format, &pFontInfo->minbounds);
- pcfGetMetric(file, format, &pFontInfo->maxbounds);
+ if (IS_EOF(file)) goto Bail;
+ if (!pcfGetMetric(file, format, &pFontInfo->minbounds))
+ goto Bail;
+ if (!pcfGetMetric(file, format, &pFontInfo->maxbounds))
+ goto Bail;
if (PCF_FORMAT_MATCH(format, PCF_ACCEL_W_INKBOUNDS)) {
- pcfGetMetric(file, format, &pFontInfo->ink_minbounds);
- pcfGetMetric(file, format, &pFontInfo->ink_maxbounds);
+ if (!pcfGetMetric(file, format, &pFontInfo->ink_minbounds))
+ goto Bail;
+ if (!pcfGetMetric(file, format, &pFontInfo->ink_maxbounds))
+ goto Bail;
} else {
pFontInfo->ink_minbounds = pFontInfo->minbounds;
pFontInfo->ink_maxbounds = pFontInfo->maxbounds;
@@ -375,13 +377,8 @@ Bail:
}
int
-pcfReadFont(pFont, file, bit, byte, glyph, scan)
- FontPtr pFont;
- FontFilePtr file;
- int bit,
- byte,
- glyph,
- scan;
+pcfReadFont(FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan)
{
CARD32 format;
CARD32 size;
@@ -396,13 +393,14 @@ pcfReadFont(pFont, file, bit, byte, glyph, scan)
CharInfoPtr metrics = 0;
xCharInfo *ink_metrics = 0;
char *bitmaps = 0;
- CharInfoPtr *encoding = 0;
- int nencoding;
+ CharInfoPtr **encoding = 0;
+ int nencoding = 0;
int encodingOffset;
CARD32 bitmapSizes[GLYPHPADOPTIONS];
CARD32 *offsets = 0;
Bool hasBDFAccelerators;
+ pFont->info.nprops = 0;
pFont->info.props = 0;
if (!(tables = pcfReadTOC(file, &ntables)))
goto Bail;
@@ -433,17 +431,21 @@ pcfReadFont(pFont, file, bit, byte, glyph, scan)
nmetrics = pcfGetINT32(file, format);
else
nmetrics = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
metrics = (CharInfoPtr) xalloc(nmetrics * sizeof(CharInfoRec));
if (!metrics) {
- pcfError("pcfReadFont(): Couldn't allocate metrics (%d*%d)\n", nmetrics, sizeof(CharInfoRec));
+ pcfError("pcfReadFont(): Couldn't allocate metrics (%d*%d)\n", nmetrics, sizeof(CharInfoRec));
goto Bail;
}
for (i = 0; i < nmetrics; i++)
- if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
- pcfGetMetric(file, format, &(metrics + i)->metrics);
- else
- pcfGetCompressedMetric(file, format, &(metrics + i)->metrics);
-
+ if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
+ if (!pcfGetMetric(file, format, &(metrics + i)->metrics))
+ goto Bail;
+ } else {
+ if (!pcfGetCompressedMetric(file, format, &(metrics + i)->metrics))
+ goto Bail;
+ }
+
/* bitmaps */
if (!pcfSeekToType(file, tables, ntables, PCF_BITMAPS, &format, &size))
@@ -453,41 +455,46 @@ pcfReadFont(pFont, file, bit, byte, glyph, scan)
goto Bail;
nbitmaps = pcfGetINT32(file, format);
- if (nbitmaps != nmetrics)
+ if (nbitmaps != nmetrics || IS_EOF(file))
goto Bail;
offsets = (CARD32 *) xalloc(nbitmaps * sizeof(CARD32));
if (!offsets) {
- pcfError("pcfReadFont(): Couldn't allocate offsets (%d*%d)\n", nbitmaps, sizeof(CARD32));
+ pcfError("pcfReadFont(): Couldn't allocate offsets (%d*%d)\n", nbitmaps, sizeof(CARD32));
goto Bail;
}
-
- for (i = 0; i < nbitmaps; i++)
+ for (i = 0; i < nbitmaps; i++) {
offsets[i] = pcfGetINT32(file, format);
+ if (IS_EOF(file)) goto Bail;
+ }
- for (i = 0; i < GLYPHPADOPTIONS; i++)
+ for (i = 0; i < GLYPHPADOPTIONS; i++) {
bitmapSizes[i] = pcfGetINT32(file, format);
+ if (IS_EOF(file)) goto Bail;
+ }
+
sizebitmaps = bitmapSizes[PCF_GLYPH_PAD_INDEX(format)];
/* guard against completely empty font */
- bitmaps = (char *) xalloc(sizebitmaps ? sizebitmaps : 1);
+ bitmaps = xalloc(sizebitmaps ? sizebitmaps : 1);
if (!bitmaps) {
- pcfError("pcfReadFont(): Couldn't allocate bitmaps (%d)\n", sizebitmaps ? sizebitmaps : 1);
+ pcfError("pcfReadFont(): Couldn't allocate bitmaps (%d)\n", sizebitmaps ? sizebitmaps : 1);
goto Bail;
}
FontFileRead(file, bitmaps, sizebitmaps);
+ if (IS_EOF(file)) goto Bail;
position += sizebitmaps;
if (PCF_BIT_ORDER(format) != bit)
- BitOrderInvert(bitmaps, sizebitmaps);
+ BitOrderInvert((unsigned char *)bitmaps, sizebitmaps);
if ((PCF_BYTE_ORDER(format) == PCF_BIT_ORDER(format)) != (bit == byte)) {
switch (bit == byte ? PCF_SCAN_UNIT(format) : scan) {
case 1:
break;
case 2:
- TwoByteSwap(bitmaps, sizebitmaps);
+ TwoByteSwap((unsigned char *)bitmaps, sizebitmaps);
break;
case 4:
- FourByteSwap(bitmaps, sizebitmaps);
+ FourByteSwap((unsigned char *)bitmaps, sizebitmaps);
break;
}
}
@@ -501,7 +508,7 @@ pcfReadFont(pFont, file, bit, byte, glyph, scan)
sizepadbitmaps = bitmapSizes[PCF_SIZE_TO_INDEX(glyph)];
padbitmaps = (char *) xalloc(sizepadbitmaps);
if (!padbitmaps) {
- pcfError("pcfReadFont(): Couldn't allocate padbitmaps (%d)\n", sizepadbitmaps);
+ pcfError("pcfReadFont(): Couldn't allocate padbitmaps (%d)\n", sizepadbitmaps);
goto Bail;
}
new = 0;
@@ -536,18 +543,22 @@ pcfReadFont(pFont, file, bit, byte, glyph, scan)
nink_metrics = pcfGetINT32(file, format);
else
nink_metrics = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
if (nink_metrics != nmetrics)
goto Bail;
ink_metrics = (xCharInfo *) xalloc(nink_metrics * sizeof(xCharInfo));
- if (!ink_metrics) {
- pcfError("pcfReadFont(): Couldn't allocate ink_metrics (%d*%d)\n", nink_metrics, sizeof(xCharInfo));
+ if (!ink_metrics) {
+ pcfError("pcfReadFont(): Couldn't allocate ink_metrics (%d*%d)\n", nink_metrics, sizeof(xCharInfo));
goto Bail;
- }
+ }
for (i = 0; i < nink_metrics; i++)
- if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
- pcfGetMetric(file, format, ink_metrics + i);
- else
- pcfGetCompressedMetric(file, format, ink_metrics + i);
+ if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
+ if (!pcfGetMetric(file, format, ink_metrics + i))
+ goto Bail;
+ } else {
+ if (!pcfGetCompressedMetric(file, format, ink_metrics + i))
+ goto Bail;
+ }
}
/* encoding */
@@ -563,24 +574,34 @@ pcfReadFont(pFont, file, bit, byte, glyph, scan)
pFont->info.firstRow = pcfGetINT16(file, format);
pFont->info.lastRow = pcfGetINT16(file, format);
pFont->info.defaultCh = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
(pFont->info.lastRow - pFont->info.firstRow + 1);
- encoding = (CharInfoPtr *) xalloc(nencoding * sizeof(CharInfoPtr));
+ encoding = (CharInfoPtr **) xcalloc(NUM_SEGMENTS(nencoding),
+ sizeof(CharInfoPtr*));
if (!encoding) {
- pcfError("pcfReadFont(): Couldn't allocate encoding (%d*%d)\n", nencoding, sizeof(CharInfoPtr));
+ pcfError("pcfReadFont(): Couldn't allocate encoding (%d*%d)\n", nencoding, sizeof(CharInfoPtr));
goto Bail;
}
-
+
pFont->info.allExist = TRUE;
for (i = 0; i < nencoding; i++) {
encodingOffset = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
if (encodingOffset == 0xFFFF) {
pFont->info.allExist = FALSE;
- encoding[i] = 0;
- } else
- encoding[i] = metrics + encodingOffset;
+ } else {
+ if(!encoding[SEGMENT_MAJOR(i)]) {
+ encoding[SEGMENT_MAJOR(i)]=
+ (CharInfoPtr*)xcalloc(BITMAP_FONT_SEGMENT_SIZE,
+ sizeof(CharInfoPtr));
+ if(!encoding[SEGMENT_MAJOR(i)])
+ goto Bail;
+ }
+ ACCESSENCODINGL(encoding, i) = metrics + encodingOffset;
+ }
}
/* BDF style accelerators (i.e. bounds based on encoded glyphs) */
@@ -591,7 +612,7 @@ pcfReadFont(pFont, file, bit, byte, glyph, scan)
bitmapFont = (BitmapFontPtr) xalloc(sizeof *bitmapFont);
if (!bitmapFont) {
- pcfError("pcfReadFont(): Couldn't allocate bitmapFont (%d)\n", sizeof *bitmapFont);
+ pcfError("pcfReadFont(): Couldn't allocate bitmapFont (%d)\n", sizeof *bitmapFont);
goto Bail;
}
@@ -615,7 +636,7 @@ pcfReadFont(pFont, file, bit, byte, glyph, scan)
cols = pFont->info.lastCol - pFont->info.firstCol + 1;
r = r - pFont->info.firstRow;
c = c - pFont->info.firstCol;
- bitmapFont->pDefault = encoding[r * cols + c];
+ bitmapFont->pDefault = ACCESSENCODING(encoding, r * cols + c);
}
}
bitmapFont->bitmapExtra = (BitmapExtraPtr) 0;
@@ -632,21 +653,25 @@ pcfReadFont(pFont, file, bit, byte, glyph, scan)
return Successful;
Bail:
xfree(ink_metrics);
+ if(encoding) {
+ for(i=0; i<NUM_SEGMENTS(nencoding); i++)
+ xfree(encoding[i]);
+ }
xfree(encoding);
xfree(bitmaps);
- xfree(offsets);
xfree(metrics);
xfree(pFont->info.props);
+ pFont->info.nprops = 0;
pFont->info.props = 0;
+ xfree (pFont->info.isStringProp);
xfree(bitmapFont);
xfree(tables);
+ xfree(offsets);
return AllocError;
}
int
-pcfReadFontInfo(pFontInfo, file)
- FontInfoPtr pFontInfo;
- FontFilePtr file;
+pcfReadFontInfo(FontInfoPtr pFontInfo, FontFilePtr file)
{
PCFTablePtr tables;
int ntables;
@@ -657,6 +682,7 @@ pcfReadFontInfo(pFontInfo, file)
pFontInfo->isStringProp = NULL;
pFontInfo->props = NULL;
+ pFontInfo->nprops = 0;
if (!(tables = pcfReadTOC(file, &ntables)))
goto Bail;
@@ -686,6 +712,7 @@ pcfReadFontInfo(pFontInfo, file)
pFontInfo->firstRow = pcfGetINT16(file, format);
pFontInfo->lastRow = pcfGetINT16(file, format);
pFontInfo->defaultCh = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
nencoding = (pFontInfo->lastCol - pFontInfo->firstCol + 1) *
(pFontInfo->lastRow - pFontInfo->firstRow + 1);
@@ -694,7 +721,9 @@ pcfReadFontInfo(pFontInfo, file)
while (nencoding--) {
if (pcfGetINT16(file, format) == 0xFFFF)
pFontInfo->allExist = FALSE;
+ if (IS_EOF(file)) goto Bail;
}
+ if (IS_EOF(file)) goto Bail;
/* BDF style accelerators (i.e. bounds based on encoded glyphs) */
@@ -705,38 +734,39 @@ pcfReadFontInfo(pFontInfo, file)
xfree(tables);
return Successful;
Bail:
+ pFontInfo->nprops = 0;
xfree (pFontInfo->props);
xfree (pFontInfo->isStringProp);
xfree(tables);
return AllocError;
}
-void
-pcfUnloadFont(pFont)
- FontPtr pFont;
+static void
+pcfUnloadFont(FontPtr pFont)
{
BitmapFontPtr bitmapFont;
+ int i,nencoding;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
xfree(bitmapFont->ink_metrics);
+ if(bitmapFont->encoding) {
+ nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
+ (pFont->info.lastRow - pFont->info.firstRow + 1);
+ for(i=0; i<NUM_SEGMENTS(nencoding); i++)
+ xfree(bitmapFont->encoding[i]);
+ }
xfree(bitmapFont->encoding);
xfree(bitmapFont->bitmaps);
xfree(bitmapFont->metrics);
xfree(pFont->info.isStringProp);
xfree(pFont->info.props);
xfree(bitmapFont);
- xfree(pFont->devPrivates);
- xfree(pFont);
+ DestroyFontRec(pFont);
}
int
-pmfReadFont(pFont, file, bit, byte, glyph, scan)
- FontPtr pFont;
- FontFilePtr file;
- int bit,
- byte,
- glyph,
- scan;
+pmfReadFont(FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan)
{
CARD32 format;
CARD32 size;
@@ -750,13 +780,15 @@ pmfReadFont(pFont, file, bit, byte, glyph, scan)
CharInfoPtr metrics = 0;
xCharInfo *ink_metrics = 0;
char *bitmaps = 0;
- CharInfoPtr *encoding = 0;
- int nencoding;
+ CharInfoPtr **encoding = 0;
+ int nencoding = 0;
int encodingOffset;
Bool hasBDFAccelerators;
CharInfoPtr pci;
+ pFont->info.nprops = 0;
pFont->info.props = 0;
+
if (!(tables = pcfReadTOC(file, &ntables)))
goto Bail;
@@ -786,17 +818,21 @@ pmfReadFont(pFont, file, bit, byte, glyph, scan)
nmetrics = pcfGetINT32(file, format);
else
nmetrics = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
metrics = (CharInfoPtr) xalloc(nmetrics * sizeof(CharInfoRec));
if (!metrics) {
- pcfError("pmfReadFont(): Couldn't allocate metrics (%d*%d)\n", nmetrics, sizeof(CharInfoRec));
+ pcfError("pmfReadFont(): Couldn't allocate metrics (%d*%d)\n", nmetrics, sizeof(CharInfoRec));
goto Bail;
}
for (i = 0; i < nmetrics; i++)
- if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
- pcfGetMetric(file, format, &(metrics + i)->metrics);
- else
- pcfGetCompressedMetric(file, format, &(metrics + i)->metrics);
-
+ if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
+ if (!pcfGetMetric(file, format, &(metrics + i)->metrics))
+ goto Bail;
+ } else {
+ if (!pcfGetCompressedMetric(file, format, &(metrics + i)->metrics))
+ goto Bail;
+ }
+
/* Set the bitmaps to all point to the same zero filled array
* that is the size of the largest bitmap.
*/
@@ -809,11 +845,15 @@ pmfReadFont(pFont, file, bit, byte, glyph, scan)
pci++;
}
+#ifdef FONTMODULE
+ sizebitmaps = 1024; /* Default - we xalloc the size anyway */
+#else
sizebitmaps = BUFSIZ;
+#endif
/* guard against completely empty font */
bitmaps = (char *) xalloc(sizebitmaps);
if (!bitmaps) {
- pcfError("pmfReadFont(): Couldn't allocate bitmaps (%d)\n", sizebitmaps);
+ pcfError("pmfReadFont(): Couldn't allocate bitmaps (%d)\n", sizebitmaps);
goto Bail;
}
@@ -836,16 +876,20 @@ pmfReadFont(pFont, file, bit, byte, glyph, scan)
nink_metrics = pcfGetINT16(file, format);
if (nink_metrics != nmetrics)
goto Bail;
+ if (IS_EOF(file)) goto Bail;
ink_metrics = (xCharInfo *) xalloc(nink_metrics * sizeof(xCharInfo));
- if (!ink_metrics) {
- pcfError("pmfReadFont(): Couldn't allocate ink_metrics (%d*%d)\n", nink_metrics, sizeof(xCharInfo));
+ if (!ink_metrics) {
+ pcfError("pmfReadFont(): Couldn't allocate ink_metrics (%d*%d)\n", nink_metrics, sizeof(xCharInfo));
goto Bail;
- }
+ }
for (i = 0; i < nink_metrics; i++)
- if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
- pcfGetMetric(file, format, ink_metrics + i);
- else
- pcfGetCompressedMetric(file, format, ink_metrics + i);
+ if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
+ if (!pcfGetMetric(file, format, ink_metrics + i))
+ goto Bail;
+ } else {
+ if (!pcfGetCompressedMetric(file, format, ink_metrics + i))
+ goto Bail;
+ }
}
/* encoding */
@@ -861,25 +905,36 @@ pmfReadFont(pFont, file, bit, byte, glyph, scan)
pFont->info.firstRow = pcfGetINT16(file, format);
pFont->info.lastRow = pcfGetINT16(file, format);
pFont->info.defaultCh = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
(pFont->info.lastRow - pFont->info.firstRow + 1);
- encoding = (CharInfoPtr *) xalloc(nencoding * sizeof(CharInfoPtr));
+ encoding = (CharInfoPtr **) xcalloc(NUM_SEGMENTS(nencoding),
+ sizeof(CharInfoPtr*));
if (!encoding) {
- pcfError("pmfReadFont(): Couldn't allocate encoding (%d*%d)\n", nencoding, sizeof(CharInfoPtr));
+ pcfError("pmfReadFont(): Couldn't allocate encoding (%d*%d)\n", nencoding, sizeof(CharInfoPtr));
goto Bail;
}
-
pFont->info.allExist = TRUE;
for (i = 0; i < nencoding; i++) {
encodingOffset = pcfGetINT16(file, format);
+ if (IS_EOF(file)) goto Bail;
if (encodingOffset == 0xFFFF) {
pFont->info.allExist = FALSE;
encoding[i] = 0;
- } else
- encoding[i] = metrics + encodingOffset;
+ } else {
+ if(!encoding[SEGMENT_MAJOR(i)]) {
+ encoding[SEGMENT_MAJOR(i)]=
+ (CharInfoPtr*)xcalloc(BITMAP_FONT_SEGMENT_SIZE,
+ sizeof(CharInfoPtr));
+ if(!encoding[SEGMENT_MAJOR(i)])
+ goto Bail;
+ }
+ ACCESSENCODINGL(encoding, i) = metrics + encodingOffset;
+ }
}
+ if (IS_EOF(file)) goto Bail;
/* BDF style accelerators (i.e. bounds based on encoded glyphs) */
@@ -889,10 +944,10 @@ pmfReadFont(pFont, file, bit, byte, glyph, scan)
bitmapFont = (BitmapFontPtr) xalloc(sizeof *bitmapFont);
if (!bitmapFont) {
- pcfError("pmfReadFont(): Couldn't allocate bitmapFont (%d)\n", sizeof *bitmapFont);
+ pcfError("pmfReadFont(): Couldn't allocate bitmapFont (%d)\n", sizeof *bitmapFont);
goto Bail;
}
-
+
bitmapFont->version_num = PCF_FILE_VERSION;
bitmapFont->num_chars = nmetrics;
bitmapFont->num_tables = ntables;
@@ -913,7 +968,7 @@ pmfReadFont(pFont, file, bit, byte, glyph, scan)
cols = pFont->info.lastCol - pFont->info.firstCol + 1;
r = r - pFont->info.firstRow;
c = c - pFont->info.firstCol;
- bitmapFont->pDefault = encoding[r * cols + c];
+ bitmapFont->pDefault = ACCESSENCODING(encoding, r * cols + c);
}
}
bitmapFont->bitmapExtra = (BitmapExtraPtr) 0;
@@ -930,11 +985,18 @@ pmfReadFont(pFont, file, bit, byte, glyph, scan)
return Successful;
Bail:
xfree(ink_metrics);
+ if(encoding) {
+ for(i=0; i<NUM_SEGMENTS(nencoding); i++)
+ xfree(encoding[i]);
+ }
xfree(encoding);
+ xfree(bitmaps);
xfree(metrics);
xfree(pFont->info.props);
- xfree(bitmapFont);
+ pFont->info.nprops = 0;
pFont->info.props = 0;
+ xfree (pFont->info.isStringProp);
+ xfree(bitmapFont);
xfree(tables);
return AllocError;
}
diff --git a/src/bitmap/pcfwrite.c b/src/bitmap/pcfwrite.c
index 39f79bc..74b099e 100644
--- a/src/bitmap/pcfwrite.c
+++ b/src/bitmap/pcfwrite.c
@@ -1,5 +1,4 @@
/* $Xorg: pcfwrite.c,v 1.5 2001/02/09 02:04:02 xorgcvs Exp $ */
-
/*
Copyright 1990, 1994, 1998 The Open Group
@@ -27,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/pcfwrite.c,v 1.10 2003/01/12 03:55:46 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -39,27 +39,23 @@ from The Open Group.
extern void pcfError(
#if NeedVarargsPrototypes
- char* message, ...
+ char* message, ...
#endif
-);
+ );
/* Write PCF font files */
-static int current_position;
+static CARD32 current_position;
static int
-pcfWrite(file, b, c)
- FontFilePtr file;
- char *b;
- int c;
+pcfWrite(FontFilePtr file, char *b, int c)
{
current_position += c;
return FontFileWrite(file, b, c);
}
static int
-pcfPutLSB32(file, c)
- FontFilePtr file;
+pcfPutLSB32(FontFilePtr file, int c)
{
current_position += 4;
(void) FontFilePutc(c, file);
@@ -69,9 +65,7 @@ pcfPutLSB32(file, c)
}
static int
-pcfPutINT32(file, format, c)
- FontFilePtr file;
- CARD32 format;
+pcfPutINT32(FontFilePtr file, CARD32 format, int c)
{
current_position += 4;
if (PCF_BYTE_ORDER(format) == MSBFirst) {
@@ -88,9 +82,7 @@ pcfPutINT32(file, format, c)
}
static int
-pcfPutINT16(file, format, c)
- FontFilePtr file;
- CARD32 format;
+pcfPutINT16(FontFilePtr file, CARD32 format, int c)
{
current_position += 2;
if (PCF_BYTE_ORDER(format) == MSBFirst) {
@@ -104,19 +96,14 @@ pcfPutINT16(file, format, c)
/*ARGSUSED*/
static int
-pcfPutINT8(file, format, c)
- FontFilePtr file;
- CARD32 format;
+pcfPutINT8(FontFilePtr file, CARD32 format, int c)
{
current_position += 1;
return FontFilePutc(c, file);
}
static void
-pcfWriteTOC(file, table, count)
- FontFilePtr file;
- PCFTablePtr table;
- int count;
+pcfWriteTOC(FontFilePtr file, PCFTablePtr table, int count)
{
CARD32 version;
int i;
@@ -134,10 +121,7 @@ pcfWriteTOC(file, table, count)
}
static void
-pcfPutCompressedMetric(file, format, metric)
- FontFilePtr file;
- CARD32 format;
- xCharInfo *metric;
+pcfPutCompressedMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
{
pcfPutINT8(file, format, metric->leftSideBearing + 0x80);
pcfPutINT8(file, format, metric->rightSideBearing + 0x80);
@@ -147,10 +131,7 @@ pcfPutCompressedMetric(file, format, metric)
}
static void
-pcfPutMetric(file, format, metric)
- FontFilePtr file;
- CARD32 format;
- xCharInfo *metric;
+pcfPutMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
{
pcfPutINT16(file, format, metric->leftSideBearing);
pcfPutINT16(file, format, metric->rightSideBearing);
@@ -161,10 +142,7 @@ pcfPutMetric(file, format, metric)
}
static void
-pcfPutBitmap(file, format, pCI)
- FontFilePtr file;
- CARD32 format;
- CharInfoPtr pCI;
+pcfPutBitmap(FontFilePtr file, CARD32 format, CharInfoPtr pCI)
{
int count;
unsigned char *bits;
@@ -177,10 +155,7 @@ pcfPutBitmap(file, format, pCI)
}
static void
-pcfPutAccel(file, format, pFontInfo)
- FontFilePtr file;
- CARD32 format;
- FontInfoPtr pFontInfo;
+pcfPutAccel(FontFilePtr file, CARD32 format, FontInfoPtr pFontInfo)
{
pcfPutINT8(file, format, pFontInfo->noOverlap);
pcfPutINT8(file, format, pFontInfo->constantMetrics);
@@ -220,16 +195,13 @@ pcfPutAccel(file, format, pFontInfo)
#define CanCompressMetrics(min,max) (CanCompressMetric(min) && CanCompressMetric(max))
static char *
-pcfNameForAtom(a)
- Atom a;
+pcfNameForAtom(Atom a)
{
return NameForAtom(a);
}
int
-pcfWriteFont(pFont, file)
- FontPtr pFont;
- FontFilePtr file;
+pcfWriteFont(FontPtr pFont, FontFilePtr file)
{
PCFTableRec tables[32],
*table;
@@ -247,13 +219,13 @@ pcfWriteFont(pFont, file)
xCharInfo *ink_minbounds,
*ink_maxbounds;
BitmapFontPtr bitmapFont;
- int nencodings;
+ int nencodings = 0;
int header_size;
FontPropPtr offsetProps;
- int prop_pad;
+ int prop_pad = 0;
char *atom_name;
int glyph;
- int offset;
+ CARD32 offset;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
if (bitmapFont->bitmapExtra) {
@@ -269,7 +241,7 @@ pcfWriteFont(pFont, file)
}
offsetProps = (FontPropPtr) xalloc(pFont->info.nprops * sizeof(FontPropRec));
if (!offsetProps) {
- pcfError("pcfWriteFont(): Couldn't allocate offsetProps (%d*%d)", pFont->info.nprops, sizeof(FontPropRec));
+ pcfError("pcfWriteFont(): Couldn't allocate offsetProps (%d*%d)", pFont->info.nprops, sizeof(FontPropRec));
return AllocError;
}
prop_string_size = 0;
@@ -388,7 +360,8 @@ pcfWriteFont(pFont, file)
cur_table++, table++) {
if (current_position > table->offset) {
printf("can't go backwards... %d > %d\n",
- current_position, table->offset);
+ (int)current_position, (int)table->offset);
+ xfree(offsetProps);
return BadFontName;
}
while (current_position < table->offset)
@@ -461,8 +434,10 @@ pcfWriteFont(pFont, file)
pcfPutINT16(file, format, pFont->info.lastRow);
pcfPutINT16(file, format, pFont->info.defaultCh);
for (i = 0; i < nencodings; i++) {
- if (bitmapFont->encoding[i])
- pcfPutINT16(file, format, bitmapFont->encoding[i] - bitmapFont->metrics);
+ if (ACCESSENCODING(bitmapFont->encoding,i))
+ pcfPutINT16(file, format,
+ ACCESSENCODING(bitmapFont->encoding, i) -
+ bitmapFont->metrics);
else
pcfPutINT16(file, format, 0xFFFF);
}
@@ -490,5 +465,7 @@ pcfWriteFont(pFont, file)
break;
}
}
+
+ xfree(offsetProps);
return Successful;
}
diff --git a/src/bitmap/snfread.c b/src/bitmap/snfread.c
index 04982bc..375fa5a 100644
--- a/src/bitmap/snfread.c
+++ b/src/bitmap/snfread.c
@@ -49,8 +49,12 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/snfread.c,v 1.11 2003/01/12 03:55:46 tsi Exp $ */
+#ifndef FONTMODULE
#include <ctype.h>
+#endif
+
#include "fntfilst.h"
#include "bitmap.h"
#include "snfstr.h"
@@ -73,23 +77,20 @@ snfError (message, va_alist)
va_list args;
#if NeedVarargsPrototypes
- va_start (args, message);
+ va_start(args, message);
#else
- va_start (args);
+ va_start(args);
#endif
fprintf(stderr, "SNF Error: ");
vfprintf(stderr, message, args);
- va_end (args);
+ va_end(args);
}
-
-static void snfUnloadFont();
+
+static void snfUnloadFont(FontPtr pFont);
static int
-snfReadCharInfo(file, charInfo, base)
- FontFilePtr file;
- CharInfoPtr charInfo;
- char *base;
+snfReadCharInfo(FontFilePtr file, CharInfoPtr charInfo, char *base)
{
snfCharInfoRec snfCharInfo;
@@ -109,9 +110,7 @@ snfReadCharInfo(file, charInfo, base)
}
static int
-snfReadxCharInfo(file, charInfo)
- FontFilePtr file;
- xCharInfo *charInfo;
+snfReadxCharInfo(FontFilePtr file, xCharInfo *charInfo)
{
snfCharInfoRec snfCharInfo;
@@ -124,9 +123,7 @@ snfReadxCharInfo(file, charInfo)
}
static void
-snfCopyInfo(snfInfo, pFontInfo)
- snfFontInfoPtr snfInfo;
- FontInfoPtr pFontInfo;
+snfCopyInfo(snfFontInfoPtr snfInfo, FontInfoPtr pFontInfo)
{
pFontInfo->firstCol = snfInfo->firstCol;
pFontInfo->lastCol = snfInfo->lastCol;
@@ -152,10 +149,7 @@ snfCopyInfo(snfInfo, pFontInfo)
}
static int
-snfReadProps(snfInfo, pFontInfo, file)
- snfFontInfoPtr snfInfo;
- FontInfoPtr pFontInfo;
- FontFilePtr file;
+snfReadProps(snfFontInfoPtr snfInfo, FontInfoPtr pFontInfo, FontFilePtr file)
{
char *strings;
FontPropPtr pfp;
@@ -168,7 +162,7 @@ snfReadProps(snfInfo, pFontInfo, file)
BYTESOFSTRINGINFO(snfInfo);
propspace = (char *) xalloc(bytestoalloc);
if (!propspace) {
- snfError("snfReadProps(): Couldn't allocate propspace (%d)\n", bytestoalloc);
+ snfError("snfReadProps(): Couldn't allocate propspace (%d)\n", bytestoalloc);
return AllocError;
}
@@ -195,10 +189,8 @@ snfReadProps(snfInfo, pFontInfo, file)
return Successful;
}
-int
-snfReadHeader(snfInfo, file)
- snfFontInfoPtr snfInfo;
- FontFilePtr file;
+static int
+snfReadHeader(snfFontInfoPtr snfInfo, FontFilePtr file)
{
if (FontFileRead(file, (char *) snfInfo, sizeof *snfInfo) != sizeof *snfInfo)
return BadFontName;
@@ -213,8 +205,7 @@ static int snf_set;
static int snf_bit, snf_byte, snf_glyph, snf_scan;
void
-SnfSetFormat (bit, byte, glyph, scan)
- int bit, byte, glyph, scan;
+SnfSetFormat (int bit, int byte, int glyph, int scan)
{
snf_bit = bit;
snf_byte = byte;
@@ -223,9 +214,8 @@ SnfSetFormat (bit, byte, glyph, scan)
snf_set = 1;
}
-void
-SnfGetFormat (bit, byte, glyph, scan)
- int *bit, *byte, *glyph, *scan;
+static void
+SnfGetFormat (int *bit, int *byte, int *glyph, int *scan)
{
if (!snf_set)
FontDefaultFormat (&snf_bit, &snf_byte, &snf_glyph, &snf_scan);
@@ -236,17 +226,12 @@ SnfGetFormat (bit, byte, glyph, scan)
}
int
-snfReadFont(pFont, file, bit, byte, glyph, scan)
- FontPtr pFont;
- FontFilePtr file;
- int bit,
- byte,
- glyph,
- scan;
+snfReadFont(FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan)
{
snfFontInfoRec fi;
unsigned bytestoalloc;
- int i;
+ int i, j;
char *fontspace;
BitmapFontPtr bitmapFont;
int num_chars;
@@ -283,7 +268,8 @@ snfReadFont(pFont, file, bit, byte, glyph, scan)
metrics_off = bytestoalloc;
bytestoalloc += num_chars * sizeof(CharInfoRec); /* metrics */
encoding_off = bytestoalloc;
- bytestoalloc += num_chars * sizeof(CharInfoPtr); /* encoding */
+ bytestoalloc += NUM_SEGMENTS(num_chars) * sizeof(CharInfoPtr**);
+ /* encoding */
props_off = bytestoalloc;
bytestoalloc += fi.nProps * sizeof(FontPropRec); /* props */
isStringProp_off = bytestoalloc;
@@ -295,14 +281,13 @@ snfReadFont(pFont, file, bit, byte, glyph, scan)
fontspace = (char *) xalloc(bytestoalloc);
if (!fontspace) {
- snfError("snfReadFont(): Couldn't allocate fontspace (%d)\n", bytestoalloc);
+ snfError("snfReadFont(): Couldn't allocate fontspace (%d)\n", bytestoalloc);
return AllocError;
}
-
bitmaps = (char *) xalloc (bitmapsSize);
if (!bitmaps)
{
- snfError("snfReadFont(): Couldn't allocate bitmaps (%d)\n", bitmapsSize);
+ snfError("snfReadFont(): Couldn't allocate bitmaps (%d)\n", bitmapsSize);
xfree (fontspace);
return AllocError;
}
@@ -313,7 +298,7 @@ snfReadFont(pFont, file, bit, byte, glyph, scan)
bitmapFont = (BitmapFontPtr) fontspace;
bitmapFont->num_chars = num_chars;
bitmapFont->metrics = (CharInfoPtr) (fontspace + metrics_off);
- bitmapFont->encoding = (CharInfoPtr *) (fontspace + encoding_off);
+ bitmapFont->encoding = (CharInfoPtr **) (fontspace + encoding_off);
bitmapFont->bitmaps = bitmaps;
bitmapFont->pDefault = NULL;
bitmapFont->bitmapExtra = NULL;
@@ -329,16 +314,30 @@ snfReadFont(pFont, file, bit, byte, glyph, scan)
*/
ret = Successful;
+ memset(bitmapFont->encoding, 0,
+ NUM_SEGMENTS(num_chars)*sizeof(CharInfoPtr*));
for (i = 0; ret == Successful && i < num_chars; i++) {
ret = snfReadCharInfo(file, &bitmapFont->metrics[i], bitmaps);
- if (bitmapFont->metrics[i].bits)
- bitmapFont->encoding[i] = &bitmapFont->metrics[i];
- else
- bitmapFont->encoding[i] = 0;
+ if (bitmapFont->metrics[i].bits) {
+ if (!bitmapFont->encoding[SEGMENT_MAJOR(i)]) {
+ bitmapFont->encoding[SEGMENT_MAJOR(i)]=
+ (CharInfoPtr*)xcalloc(BITMAP_FONT_SEGMENT_SIZE,
+ sizeof(CharInfoPtr));
+ if (!bitmapFont->encoding[SEGMENT_MAJOR(i)]) {
+ ret = AllocError;
+ break;
+ }
+ }
+ ACCESSENCODINGL(bitmapFont->encoding,i) = &bitmapFont->metrics[i];
+ }
}
if (ret != Successful) {
xfree(bitmaps);
+ if(bitmapFont->encoding) {
+ for(j=0; j<SEGMENT_MAJOR(i); j++)
+ xfree(bitmapFont->encoding[i]);
+ }
xfree(fontspace);
return ret;
}
@@ -346,23 +345,23 @@ snfReadFont(pFont, file, bit, byte, glyph, scan)
* read the glyphs
*/
- if (FontFileRead(file, (char *) bitmaps, bitmapsSize) != bitmapsSize) {
+ if (FontFileRead(file, bitmaps, bitmapsSize) != bitmapsSize) {
xfree(bitmaps);
xfree(fontspace);
return BadFontName;
}
if (def_bit != bit)
- BitOrderInvert(bitmaps, bitmapsSize);
+ BitOrderInvert((unsigned char *)bitmaps, bitmapsSize);
if ((def_byte == def_bit) != (bit == byte)) {
switch (bit == byte ? def_scan : scan) {
case 1:
break;
case 2:
- TwoByteSwap(bitmaps, bitmapsSize);
+ TwoByteSwap((unsigned char *)bitmaps, bitmapsSize);
break;
case 4:
- FourByteSwap(bitmaps, bitmapsSize);
+ FourByteSwap((unsigned char *)bitmaps, bitmapsSize);
break;
}
}
@@ -457,9 +456,7 @@ snfReadFont(pFont, file, bit, byte, glyph, scan)
}
int
-snfReadFontInfo(pFontInfo, file)
- FontInfoPtr pFontInfo;
- FontFilePtr file;
+snfReadFontInfo(FontInfoPtr pFontInfo, FontFilePtr file)
{
int ret;
snfFontInfoRec fi;
@@ -473,19 +470,19 @@ snfReadFontInfo(pFontInfo, file)
pFontInfo->props = (FontPropPtr) xalloc(fi.nProps * sizeof(FontPropRec));
if (!pFontInfo->props) {
- snfError("snfReadFontInfo(): Couldn't allocate props (%d*%d)\n", fi.nProps, sizeof(FontPropRec));
+ snfError("snfReadFontInfo(): Couldn't allocate props (%d*%d)\n", fi.nProps, sizeof(FontPropRec));
return AllocError;
}
pFontInfo->isStringProp = (char *) xalloc(fi.nProps * sizeof(char));
if (!pFontInfo->isStringProp) {
- snfError("snfReadFontInfo(): Couldn't allocate isStringProp (%d*%d)\n", fi.nProps, sizeof(char));
+ snfError("snfReadFontInfo(): Couldn't allocate isStringProp (%d*%d)\n", fi.nProps, sizeof(char));
xfree(pFontInfo->props);
return AllocError;
}
num_chars = n2dChars(&fi);
bytestoskip = num_chars * sizeof(snfCharInfoRec); /* charinfos */
bytestoskip += BYTESOFGLYPHINFO(&fi);
- FontFileSkip(file, bytestoskip);
+ (void)FontFileSkip(file, bytestoskip);
ret = snfReadProps(&fi, pFontInfo, file);
if (ret != Successful) {
@@ -515,15 +512,13 @@ snfReadFontInfo(pFontInfo, file)
}
static void
-snfUnloadFont(pFont)
- FontPtr pFont;
+snfUnloadFont(FontPtr pFont)
{
BitmapFontPtr bitmapFont;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
xfree (bitmapFont->bitmaps);
xfree (bitmapFont);
- xfree (pFont->devPrivates);
- xfree (pFont);
+ DestroyFontRec (pFont);
}
diff --git a/src/bitmap/snfstr.h b/src/bitmap/snfstr.h
index 1ca91fb..09ecf8a 100644
--- a/src/bitmap/snfstr.h
+++ b/src/bitmap/snfstr.h
@@ -49,10 +49,13 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/bitmap/snfstr.h,v 1.5 2001/12/14 19:56:47 dawes Exp $ */
#ifndef SNFSTR_H
#define SNFSTR_H 1
+#include "fntfilio.h"
+
/*-
* This file describes the Server Natural Font format.
* SNF fonts are both CPU-dependent and frame buffer bit order dependent.
@@ -173,4 +176,9 @@ typedef struct _snfFontInfo {
unsigned int version2; /* version stamp double-check */
} snfFontInfoRec;
+extern void SnfSetFormat ( int bit, int byte, int glyph, int scan );
+extern int snfReadFont ( FontPtr pFont, FontFilePtr file,
+ int bit, int byte, int glyph, int scan );
+extern int snfReadFontInfo ( FontInfoPtr pFontInfo, FontFilePtr file );
+
#endif /* SNFSTR_H */
diff --git a/src/fc/fsconvert.c b/src/fc/fsconvert.c
index 1c8c6d1..47239cf 100644
--- a/src/fc/fsconvert.c
+++ b/src/fc/fsconvert.c
@@ -22,31 +22,32 @@
*
* Author: Dave Lemke, Network Computing Devices, Inc
*/
+/* $XFree86: xc/lib/font/fc/fsconvert.c,v 1.11 2002/09/10 16:14:35 tsi Exp $ */
/*
* FS data conversion
*/
#include <X11/X.h>
+#include <X11/Xtrans.h>
+#include <X11/Xpoll.h>
#include "FS.h"
#include "FSproto.h"
#include "fontmisc.h"
#include "fontstruct.h"
#include "fservestr.h"
+#include "fontutil.h"
extern char _fs_glyph_undefined;
extern char _fs_glyph_requested;
extern char _fs_glyph_zero_length;
-extern int _fs_load_glyphs();
/*
* converts data from font server form to X server form
*/
void
-_fs_convert_char_info(src, dst)
- fsXCharInfo *src;
- xCharInfo *dst;
+_fs_convert_char_info(fsXCharInfo *src, xCharInfo *dst)
{
dst->ascent = src->ascent;
dst->descent = src->descent;
@@ -57,9 +58,7 @@ _fs_convert_char_info(src, dst)
}
void
-_fs_init_fontinfo(conn, pfi)
- FSFpePtr conn;
- FontInfoPtr pfi;
+_fs_init_fontinfo(FSFpePtr conn, FontInfoPtr pfi)
{
if (conn->fsMajorVersion == 1) {
unsigned short n;
@@ -69,7 +68,7 @@ _fs_init_fontinfo(conn, pfi)
n = pfi->lastCol;
pfi->lastCol = pfi->lastRow;
pfi->lastRow = n;
- pfi->defaultCh = (pfi->defaultCh >> 8) & 0xff
+ pfi->defaultCh = ((pfi->defaultCh >> 8) & 0xff)
+ ((pfi->defaultCh & 0xff) << 8);
}
@@ -87,11 +86,8 @@ _fs_init_fontinfo(conn, pfi)
}
int
-_fs_convert_props(pi, po, pd, pfi)
- fsPropInfo *pi;
- fsPropOffset *po;
- pointer pd;
- FontInfoPtr pfi;
+_fs_convert_props(fsPropInfo *pi, fsPropOffset *po, pointer pd,
+ FontInfoPtr pfi)
{
FontPropPtr dprop;
int i,
@@ -99,38 +95,39 @@ _fs_convert_props(pi, po, pd, pfi)
char *is_str;
fsPropOffset local_off;
char *off_adr;
+ char *pdc = pd;
/* stolen from server/include/resource.h */
#define BAD_RESOURCE 0xe0000000
nprops = pfi->nprops = pi->num_offsets;
- dprop = (FontPropPtr) xalloc(sizeof(FontPropRec) * nprops);
- is_str = (char *) xalloc(sizeof(char) * nprops);
- if (!dprop || !is_str) {
- xfree(is_str);
- xfree(dprop);
+ dprop = (FontPropPtr) xalloc(sizeof(FontPropRec) * nprops +
+ sizeof (char) * nprops);
+ if (!dprop)
return -1;
- }
+
+ is_str = (char *) (dprop + nprops);
pfi->props = dprop;
pfi->isStringProp = is_str;
off_adr = (char *)po;
- for (i = 0; i < nprops; i++, dprop++, is_str++) {
+ for (i = 0; i < nprops; i++, dprop++, is_str++)
+ {
memcpy(&local_off, off_adr, SIZEOF(fsPropOffset));
- dprop->name = MakeAtom(&pd[local_off.name.position],
+ dprop->name = MakeAtom(&pdc[local_off.name.position],
local_off.name.length, 1);
if (local_off.type != PropTypeString) {
*is_str = FALSE;
dprop->value = local_off.value.position;
} else {
*is_str = TRUE;
- dprop->value = (INT32) MakeAtom(&pd[local_off.value.position],
+ dprop->value = (INT32) MakeAtom(&pdc[local_off.value.position],
local_off.value.length, 1);
if (dprop->value == BAD_RESOURCE)
{
xfree (pfi->props);
- xfree (pfi->isStringProp);
+ pfi->nprops = 0;
pfi->props = 0;
pfi->isStringProp = 0;
return -1;
@@ -142,14 +139,21 @@ _fs_convert_props(pi, po, pd, pfi)
return nprops;
}
+void
+_fs_free_props (FontInfoPtr pfi)
+{
+ if (pfi->props)
+ {
+ xfree (pfi->props);
+ pfi->nprops = 0;
+ pfi->props = 0;
+ }
+}
+
int
-_fs_convert_lfwi_reply(conn, pfi, fsrep, pi, po, pd)
- FSFpePtr conn;
- FontInfoPtr pfi;
- fsListFontsWithXInfoReply *fsrep;
- fsPropInfo *pi;
- fsPropOffset *po;
- pointer pd;
+_fs_convert_lfwi_reply(FSFpePtr conn, FontInfoPtr pfi,
+ fsListFontsWithXInfoReply *fsrep,
+ fsPropInfo *pi, fsPropOffset *po, pointer pd)
{
fsUnpack_XFontInfoHeader(fsrep, pfi);
_fs_init_fontinfo(conn, pfi);
@@ -181,14 +185,9 @@ _fs_convert_lfwi_reply(conn, pfi, fsrep, pi, po, pd)
*/
/* ARGSUSED */
int
-fs_build_range(pfont, range_flag, count, item_size, data, nranges, ranges)
- FontPtr pfont;
- Bool range_flag;
- register unsigned int count;
- int item_size;
- register unsigned char *data;
- int *nranges;
- fsRange **ranges;
+fs_build_range(FontPtr pfont, Bool range_flag, unsigned int count,
+ int item_size, unsigned char *data, int *nranges,
+ fsRange **ranges)
{
FSFontDataPtr fsd = (FSFontDataPtr) (pfont->fpePrivate);
FSFontPtr fsfont = (FSFontPtr) (pfont->fontPrivate);
@@ -309,7 +308,7 @@ fs_build_range(pfont, range_flag, count, item_size, data, nranges, ranges)
if (GLYPH_UNDEFINED(loc))
{
if (row1 == row2 &&
- ((col1 & 0xf) && col1 > firstcol ||
+ (((col1 & 0xf) && col1 > firstcol) ||
(col2 & 0xf) != 0xf) && (col2 < lastcol))
{
/* If we're loading from a single row, expand
@@ -348,10 +347,8 @@ fs_build_range(pfont, range_flag, count, item_size, data, nranges, ranges)
requests needs to be cancelled. */
void
-_fs_clean_aborted_loadglyphs(pfont, num_expected_ranges, expected_ranges)
- FontPtr pfont;
- int num_expected_ranges;
- fsRange *expected_ranges;
+_fs_clean_aborted_loadglyphs(FontPtr pfont, int num_expected_ranges,
+ fsRange *expected_ranges)
{
register FSFontPtr fsfont;
register FSFontDataRec *fsd;
@@ -405,12 +402,8 @@ _fs_clean_aborted_loadglyphs(pfont, num_expected_ranges, expected_ranges)
*/
/* ARGSUSED */
int
-_fs_check_extents(pfont, flags, nranges, range, blockrec)
- FontPtr pfont;
- Mask flags;
- int nranges;
- fsRange *range;
- FSBlockDataPtr blockrec;
+_fs_check_extents(FontPtr pfont, Mask flags, int nranges, fsRange *range,
+ FSBlockDataPtr blockrec)
{
/* XXX -- either fill in the requested info if we have it somewhere
* and return AccessDone, or else return Successful
@@ -425,13 +418,9 @@ _fs_check_extents(pfont, flags, nranges, range, blockrec)
*/
/* ARGSUSED */
int
-_fs_check_bitmaps(pfont, format, flags, nranges, range, blockrec)
- FontPtr pfont;
- fsBitmapFormat format;
- Mask flags;
- int nranges;
- fsRange *range;
- FSBlockDataPtr blockrec;
+_fs_check_bitmaps(FontPtr pfont, fsBitmapFormat format,
+ Mask flags, int nranges, fsRange *range,
+ FSBlockDataPtr blockrec)
{
/* XXX -- either fill in the requested info if we have it somewhere
* and return AccessDone, or else return Successful
@@ -440,13 +429,10 @@ _fs_check_bitmaps(pfont, format, flags, nranges, range, blockrec)
}
int
-_fs_get_glyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
- FontPtr pFont;
- unsigned long count;
- register unsigned char *chars;
- FontEncoding charEncoding;
- unsigned long *glyphCount; /* RETURN */
- CharInfoPtr *glyphs; /* RETURN */
+_fs_get_glyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
{
FSFontPtr fsdata;
unsigned int firstCol;
@@ -562,13 +548,10 @@ _fs_get_glyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
static int
-_fs_get_metrics(pFont, count, chars, charEncoding, glyphCount, glyphs)
- FontPtr pFont;
- unsigned long count;
- register unsigned char *chars;
- FontEncoding charEncoding;
- unsigned long *glyphCount; /* RETURN */
- xCharInfo **glyphs; /* RETURN */
+_fs_get_metrics(FontPtr pFont, unsigned long count, unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ xCharInfo **glyphs) /* RETURN */
{
FSFontPtr fsdata;
unsigned int firstCol;
@@ -585,6 +568,9 @@ _fs_get_metrics(pFont, count, chars, charEncoding, glyphCount, glyphs)
fsdata = (FSFontPtr) pFont->fontPrivate;
encoding = fsdata->inkMetrics;
pDefault = fsdata->pDefault;
+ /* convert default bitmap metric to default ink metric */
+ if (pDefault)
+ pDefault = encoding + (pDefault - fsdata->encoding);
firstCol = pFont->info.firstCol;
numCols = pFont->info.lastCol - firstCol + 1;
glyphsBase = glyphs;
@@ -662,41 +648,120 @@ _fs_get_metrics(pFont, count, chars, charEncoding, glyphCount, glyphs)
void
-_fs_unload_font(pfont)
- FontPtr pfont;
+_fs_unload_font(FontPtr pfont)
{
- FSFontPtr fsdata = (FSFontPtr) pfont->fontPrivate;
-
- if (fsdata->encoding)
+ FSFontPtr fsdata = (FSFontPtr) pfont->fontPrivate;
+ FSFontDataPtr fsd = (FSFontDataPtr) pfont->fpePrivate;
+ CharInfoPtr encoding = fsdata->encoding;
+ FSGlyphPtr glyphs;
+
+ /*
+ * fsdata points at FSFontRec, FSFontDataRec and name
+ */
+ if (encoding)
+ xfree(encoding);
+
+ while ((glyphs = fsdata->glyphs))
{
- register int i;
- register CharInfoPtr encoding = fsdata->encoding;
- FontInfoPtr pfi = &pfont->info;
- for (i = (pfi->lastCol - pfi->firstCol + 1) *
- (pfi->lastRow - pfi->firstRow + 1);
- i > 0;
- encoding++, i--)
- {
- if (encoding->bits &&
- encoding->bits != &_fs_glyph_undefined &&
- encoding->bits != &_fs_glyph_requested &&
- encoding->bits != &_fs_glyph_zero_length)
- xfree(encoding->bits);
- }
+ fsdata->glyphs = glyphs->next;
+ xfree (glyphs);
}
- xfree(fsdata->encoding);
+
+ /* XXX we may get called after the resource DB has been cleaned out */
+ if (find_old_font(fsd->fontid))
+ DeleteFontClientID (fsd->fontid);
+
+ _fs_free_props (&pfont->info);
+
xfree(fsdata);
-
- pfont->fontPrivate = 0;
+
+ DestroyFontRec(pfont);
}
-void
-_fs_init_font(pfont)
- FontPtr pfont;
+FontPtr
+fs_create_font (FontPathElementPtr fpe,
+ char *name,
+ int namelen,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask)
{
+ FontPtr pfont;
+ FSFontPtr fsfont;
+ FSFontDataPtr fsd;
+ int bit, byte, scan, glyph;
+
+ pfont = CreateFontRec ();
+ if (!pfont)
+ return 0;
+ fsfont = (FSFontPtr) xalloc (sizeof (FSFontRec) +
+ sizeof (FSFontDataRec) +
+ namelen + 1);
+ if (!fsfont)
+ {
+ DestroyFontRec (pfont);
+ return 0;
+ }
+ fsd = (FSFontDataPtr) (fsfont + 1);
+ bzero((char *) fsfont, sizeof(FSFontRec));
+ bzero((char *) fsd, sizeof(FSFontDataRec));
+
+ pfont->fpe = fpe;
+ pfont->fontPrivate = (pointer) fsfont;
+ pfont->fpePrivate = (pointer) fsd;
+
+ /* These font components will be needed in packGlyphs */
+ CheckFSFormat(format, BitmapFormatMaskBit |
+ BitmapFormatMaskByte |
+ BitmapFormatMaskScanLineUnit |
+ BitmapFormatMaskScanLinePad,
+ &bit,
+ &byte,
+ &scan,
+ &glyph,
+ NULL);
+ pfont->format = format;
+ pfont->bit = bit;
+ pfont->byte = byte;
+ pfont->scan = scan;
+ pfont->glyph = glyph;
+
+ pfont->info.nprops = 0;
+ pfont->info.props = 0;
+ pfont->info.isStringProp = 0;
+
/* set font function pointers */
pfont->get_glyphs = _fs_get_glyphs;
pfont->get_metrics = _fs_get_metrics;
pfont->unload_font = _fs_unload_font;
- pfont->unload_glyphs = (void (*)())0;
+ pfont->unload_glyphs = NULL;
+
+ /* set the FPE private information */
+ fsd->format = format;
+ fsd->fmask = fmask;
+ fsd->name = (char *) (fsd + 1);
+ memcpy (fsd->name, name, namelen);
+ fsd->name[namelen] = '\0';
+ fsd->fontid = GetNewFontClientID ();
+
+ /* save the ID */
+ if (!StoreFontClientFont(pfont, fsd->fontid))
+ {
+ xfree (fsfont);
+ DestroyFontRec (pfont);
+ return 0;
+ }
+
+ return pfont;
+}
+
+pointer
+fs_alloc_glyphs (FontPtr pFont, int size)
+{
+ FSGlyphPtr glyphs;
+ FSFontPtr fsfont = (FSFontPtr) pFont->fontPrivate;
+
+ glyphs = xalloc (sizeof (FSGlyphRec) + size);
+ glyphs->next = fsfont->glyphs;
+ fsfont->glyphs = glyphs;
+ return (pointer) (glyphs + 1);
}
diff --git a/src/fc/fserve.c b/src/fc/fserve.c
index 95ce811..f21233c 100644
--- a/src/fc/fserve.c
+++ b/src/fc/fserve.c
@@ -24,6 +24,7 @@ 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/fc/fserve.c,v 3.22 2002/05/31 18:45:49 dawes Exp $ */
/*
* Copyright 1990 Network Computing Devices
@@ -54,36 +55,32 @@ in this Software without prior written authorization from The Open Group.
#ifdef WIN32
#define _WILLWINSOCK_
#endif
-#include <X11/X.h>
-#include <X11/Xos.h>
+#include "X11/Xtrans.h"
#include "X11/Xpoll.h"
#include "FS.h"
#include "FSproto.h"
+#include <X11/X.h>
+#include <X11/Xos.h>
#include "fontmisc.h"
#include "fontstruct.h"
#include "fservestr.h"
+#include "fontutil.h"
#include <errno.h>
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#define Time_t long
-extern Time_t time ();
-#else
+
#include <time.h>
#define Time_t time_t
-#endif
#ifdef NCD
#include <ncd/nvram.h>
#endif
-#ifndef NULL
-#define NULL 0
-#endif
+#include <stddef.h>
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
-
+#define TimeCmp(a,c,b) ((int) ((a) - (b)) c 0)
+
#define NONZEROMETRICS(pci) ((pci)->leftSideBearing || \
(pci)->rightSideBearing || \
(pci)->ascent || \
@@ -91,37 +88,71 @@ extern Time_t time ();
(pci)->characterWidth)
-extern FontPtr find_old_font();
-
-extern int _fs_build_range();
-
-static int fs_read_glyphs();
-static int fs_read_list();
-static int fs_read_list_info();
+static int fs_read_glyphs ( FontPathElementPtr fpe, FSBlockDataPtr blockrec );
+static int fs_read_list ( FontPathElementPtr fpe, FSBlockDataPtr blockrec );
+static int fs_read_list_info ( FontPathElementPtr fpe,
+ FSBlockDataPtr blockrec );
static int fs_font_type;
extern fd_set _fs_fd_mask;
-static void fs_block_handler();
-static int fs_wakeup();
-
-static FSFpePtr awaiting_reconnect;
+static void fs_block_handler ( pointer data, OSTimePtr wt,
+ pointer LastSelectMask );
+static int fs_wakeup ( FontPathElementPtr fpe, unsigned long *mask );
-void _fs_connection_died();
-static int _fs_restart_connection();
-static void _fs_try_reconnect();
-static int fs_send_query_info();
-static int fs_send_query_extents();
-static int fs_send_query_bitmaps();
-static int fs_send_close_font();
-static void fs_client_died();
-static void _fs_client_access();
-static void _fs_client_resolution();
+/*
+ * List of all FPEs
+ */
+static FSFpePtr fs_fpes;
+/*
+ * Union of all FPE blockStates
+ */
+static CARD32 fs_blockState;
+
+static int _fs_restart_connection ( FSFpePtr conn );
+static void fs_send_query_bitmaps ( FontPathElementPtr fpe,
+ FSBlockDataPtr blockrec );
+static int fs_send_close_font ( FontPathElementPtr fpe, Font id );
+static void fs_client_died ( pointer client, FontPathElementPtr fpe );
+static void _fs_client_access ( FSFpePtr conn, pointer client, Bool sync );
+static void _fs_client_resolution ( FSFpePtr conn );
+static fsGenericReply *fs_get_reply (FSFpePtr conn, int *error);
+static int fs_await_reply (FSFpePtr conn);
+static void _fs_do_blocked (FSFpePtr conn);
+static void fs_cleanup_bfont (FSBlockedFontPtr bfont);
char _fs_glyph_undefined;
char _fs_glyph_requested;
char _fs_glyph_zero_length;
+static int generationCount;
+
+int FontServerRequestTimeout = 30 * 1000;
+
+static void
+_fs_close_server (FSFpePtr conn);
+
+static FSFpePtr
+_fs_init_conn (char *servername);
+
+static int
+_fs_wait_connect (FSFpePtr conn);
+
+static int
+_fs_send_init_packets (FSFpePtr conn);
+
+static void
+_fs_check_reconnect (FSFpePtr conn);
+
+static void
+_fs_start_reconnect (FSFpePtr conn);
+
+static void
+_fs_free_conn (FSFpePtr conn);
+
+static int
+fs_free_fpe(FontPathElementPtr fpe);
+
/*
* Font server access
*
@@ -141,35 +172,58 @@ char _fs_glyph_zero_length;
*/
-/* XXX this should probably be a macro once its fully debugged */
-/* ARGSUSED */
+#ifdef DEBUG
static void
-_fs_add_req_log(conn, opcode)
- FSFpePtr conn;
- int opcode;
+_fs_add_req_log(FSFpePtr conn, int opcode)
{
-
-#ifdef DEBUG
- conn->reqbuffer[conn->reqindex++] = opcode;
+ conn->current_seq++;
+ fprintf (stderr, "\t\tRequest: %5d Opcode: %2d\n",
+ conn->current_seq, opcode);
+ conn->reqbuffer[conn->reqindex].opcode = opcode;
+ conn->reqbuffer[conn->reqindex].sequence = conn->current_seq;
+ conn->reqindex++;
if (conn->reqindex == REQUEST_LOG_SIZE)
conn->reqindex = 0;
-#endif
+}
- conn->current_seq++;
+static void
+_fs_add_rep_log (FSFpePtr conn, fsGenericReply *rep)
+{
+ int i;
+
+ for (i = 0; i < REQUEST_LOG_SIZE; i++)
+ if (conn->reqbuffer[i].sequence == rep->sequenceNumber)
+ break;
+ if (i == REQUEST_LOG_SIZE)
+ fprintf (stderr, "\t\t\t\t\tReply: %5d Opcode: unknown\n",
+ rep->sequenceNumber);
+ else
+ fprintf (stderr, "\t\t\t\t\tReply: %5d Opcode: %d\n",
+ rep->sequenceNumber,
+ conn->reqbuffer[i].opcode);
}
+#else
+#define _fs_add_req_log(conn,op) ((conn)->current_seq++)
+#define _fs_add_rep_log(conn,rep)
+#endif
static Bool
-fs_name_check(name)
- char *name;
+fs_name_check(char *name)
{
+#ifdef __UNIXOS2__
+ /* OS/2 uses D:/usr/X11R6/.... as fontfile pathnames, so check that
+ * there is not only a protocol/ prefix, but also that the first chars
+ * are not a drive letter
+ */
+ if (name && isalpha(*name) && name[1] == ':')
+ return FALSE;
+#endif
/* Just make sure there is a protocol/ prefix */
-
return (name && *name != '/' && strchr(name, '/'));
}
static void
-_fs_client_resolution(conn)
- FSFpePtr conn;
+_fs_client_resolution(FSFpePtr conn)
{
fsSetResolutionReq srreq;
int num_res;
@@ -190,158 +244,18 @@ _fs_client_resolution(conn)
}
}
-/*
- * sends the stuff that's meaningful to a newly opened or reset FS
- */
-static int
-fs_send_init_packets(conn)
- FSFpePtr conn;
-{
- fsSetResolutionReq srreq;
- fsSetCataloguesReq screq;
- fsListCataloguesReq lcreq;
- fsListCataloguesReply lcreply;
- int num_cats,
- clen,
- len;
- char *client_cat = (char *) 0,
- *cp,
- *sp,
- *end;
- int num_res;
- FontResolutionPtr res;
- int err = Successful;
-
-#define CATALOGUE_SEP '+'
-
- res = GetClientResolutions(&num_res);
- if (num_res) {
- srreq.reqType = FS_SetResolution;
- srreq.num_resolutions = num_res;
- srreq.length = (SIZEOF(fsSetResolutionReq) +
- (num_res * SIZEOF(fsResolution)) + 3) >> 2;
-
- _fs_add_req_log(conn, FS_SetResolution);
- if (_fs_write(conn, (char *) &srreq, SIZEOF(fsSetResolutionReq)) == -1)
- {
- err = BadFontPath;
- goto fail;
- }
- if (_fs_write_pad(conn, (char *) res, (num_res * SIZEOF(fsResolution))) == -1)
- {
- err = BadFontPath;
- goto fail;
- }
- }
- sp = strrchr(conn->servername, '/');
-
- /* don't get tricked by a non-existant catalogue list */
- if (sp == strchr(conn->servername, '/')) {
- /*
- * try original name -- this might be an alternate with no catalogues
- */
- sp = strrchr(conn->requestedname, '/');
- if (sp == strchr(conn->requestedname, '/'))
- sp = (char *) 0;
- }
- if (sp) { /* turn cats into counted list */
- sp++;
- /* allocate more than enough room */
- cp = client_cat = (char *) xalloc(strlen(conn->servername));
- if (!cp) {
- err = BadAlloc;
- goto fail;
- }
- num_cats = 0;
- while (*sp) {
- end = strchr(sp, CATALOGUE_SEP);
- if (!end)
- end = sp + strlen(sp);
- *cp++ = len = end - sp;
- num_cats++;
- memmove(cp, sp, len);
- sp += len;
- if (*sp == CATALOGUE_SEP)
- sp++;
- cp += len;
- }
- clen = cp - client_cat;
- /* our list checked out, so send it */
- screq.reqType = FS_SetCatalogues;
- screq.num_catalogues = num_cats;
- screq.length = (SIZEOF(fsSetCataloguesReq) + clen + 3) >> 2;
-
- _fs_add_req_log(conn, FS_SetCatalogues);
- if (_fs_write(conn, (char *) &screq, SIZEOF(fsSetCataloguesReq)) == -1)
- {
- err = BadFontPath;
- goto fail;
- }
- if (_fs_write_pad(conn, (char *) client_cat, clen) == -1)
- {
- err = BadFontPath;
- goto fail;
- }
-
- /*
- * now sync up with the font server, to see if an error was generated
- * by a bogus catalogue
- */
- lcreq.reqType = FS_ListCatalogues;
- lcreq.length = (SIZEOF(fsListCataloguesReq)) >> 2;
- lcreq.maxNames = 0;
- lcreq.nbytes = 0;
- _fs_add_req_log(conn, FS_SetCatalogues);
- if (_fs_write(conn, (char *) &lcreq, SIZEOF(fsListCataloguesReq)) == -1)
- {
- err = BadFontPath;
- goto fail;
- }
-
- /*
- * next bit will either by the ListCats reply, or an error followed by
- * the reply
- */
- if (_fs_read(conn, (char *) &lcreply, SIZEOF(fsGenericReply)) == -1) {
- err = BadFontPath;
- goto fail;
- }
- if (lcreply.type == FS_Error &&
- ((fsError *) & lcreply)->major_opcode == FS_SetCatalogues) {
- _fs_eat_rest_of_error(conn, (fsError *) & lcreply);
- /* get ListCats response */
- (void) _fs_read(conn, (char *) &lcreply,
- SIZEOF(fsListCataloguesReply));
- err = BadFontPath;
- goto fail;
- }
- /* must be reply, swallow the rest of it */
- _fs_eat_rest_of_error(conn, (fsError *) & lcreply);
- }
-fail:
- xfree(client_cat);
- return err;
-}
-
/*
* close font server and remove any state associated with
* this connection - this includes any client records.
*/
static void
-fs_close_conn(conn)
- FSFpePtr conn;
+fs_close_conn(FSFpePtr conn)
{
FSClientPtr client, nclient;
- /* XXX - hack. The right fix is to remember that the font server
- has gone away when we first discovered it. */
- if (conn->trans_conn)
- (void) _FontTransClose (conn->trans_conn);
-
- if (conn->fs_fd != -1)
- FD_CLR(conn->fs_fd, &_fs_fd_mask);
-
+ _fs_close_server (conn);
+
for (client = conn->clients; client; client = nclient)
{
nclient = client->next;
@@ -357,65 +271,76 @@ fs_close_conn(conn)
*/
/* ARGSUSED */
static int
-fs_init_fpe(fpe)
- FontPathElementPtr fpe;
+fs_init_fpe(FontPathElementPtr fpe)
{
FSFpePtr conn;
char *name;
int err;
+ int ret;
/* open font server */
/* create FS specific fpe info */
- errno = 0;
-
name = fpe->name;
/* hack for old style names */
if (*name == ':')
name++; /* skip ':' */
- conn = _fs_open_server(name);
- if (conn) {
- conn->requestedname = fpe->name; /* stash this for later init use */
- fpe->private = (pointer) conn;
- err = fs_send_init_packets(conn);
- if (err != Successful) {
- fs_close_conn(conn);
- xfree(conn->servername);
- xfree(conn->alts);
- xfree(conn);
- return err;
+ conn = _fs_init_conn (name);
+ if (!conn)
+ err = AllocError;
+ else
+ {
+ err = init_fs_handlers (fpe, fs_block_handler);
+ if (err != Successful)
+ {
+ _fs_free_conn (conn);
+ err = AllocError;
}
- if (init_fs_handlers(fpe, fs_block_handler) != Successful)
- return AllocError;
- FD_SET(conn->fs_fd, &_fs_fd_mask);
- conn->attemptReconnect = TRUE;
-
+ else
+ {
+ fpe->private = conn;
+ conn->next = fs_fpes;
+ fs_fpes = conn;
+ ret = _fs_wait_connect (conn);
+ if (ret != FSIO_READY)
+ {
+ fs_free_fpe (fpe);
+ err = BadFontPath;
+ }
+ else
+ err = Successful;
+ }
+ }
+
+ if (err == Successful)
+ {
#ifdef NCD
if (configData.ExtendedFontDiags)
printf("Connected to font server \"%s\"\n", name);
#endif
-
- return err;
+#ifdef DEBUG
+ fprintf (stderr, "connected to FS \"%s\"\n", name);
+#endif
}
-
+ else
+ {
#ifdef DEBUG
- fprintf(stderr, "failed to connect to FS \"%s\"\n", name);
+ fprintf(stderr, "failed to connect to FS \"%s\" %d\n", name, err);
#endif
-
#ifdef NCD
- if (configData.ExtendedFontDiags)
- printf("Failed to connect to font server \"%s\"\n", name);
+ if (configData.ExtendedFontDiags)
+ printf("Failed to connect to font server \"%s\"\n", name);
#endif
-
- return (errno == ENOMEM) ? AllocError : BadFontPath;
+ ;
+ }
+ return err;
}
static int
-fs_reset_fpe(fpe)
- FontPathElementPtr fpe;
+fs_reset_fpe(FontPathElementPtr fpe)
{
- (void) fs_send_init_packets((FSFpePtr) fpe->private);
+ (void) _fs_send_init_packets((FSFpePtr) fpe->private);
return Successful;
}
@@ -424,54 +349,44 @@ fs_reset_fpe(fpe)
*/
static int
-fs_free_fpe(fpe)
- FontPathElementPtr fpe;
+fs_free_fpe(FontPathElementPtr fpe)
{
- FSFpePtr conn = (FSFpePtr) fpe->private;
- FSFpePtr recon,
- *prev;
- prev = &awaiting_reconnect;
- while (*prev) {
- recon = *prev;
- if (conn == recon) {
- *prev = recon->next_reconnect;
+ FSFpePtr conn = (FSFpePtr) fpe->private, *prev;
+
+ /* unhook from chain of all font servers */
+ for (prev = &fs_fpes; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == conn)
+ {
+ *prev = conn->next;
break;
}
- prev = &recon->next_reconnect;
}
-
+ _fs_unmark_block (conn, conn->blockState);
fs_close_conn(conn);
-
- remove_fs_handlers(fpe, fs_block_handler,
- !XFD_ANYSET(&_fs_fd_mask) && !awaiting_reconnect);
-
- xfree(conn->alts);
- xfree(conn->servername);
- xfree(conn);
+ remove_fs_handlers(fpe, fs_block_handler, fs_fpes == 0);
+ _fs_free_conn (conn);
fpe->private = (pointer) 0;
#ifdef NCD
if (configData.ExtendedFontDiags)
printf("Disconnected from font server \"%s\"\n", fpe->name);
#endif
+#ifdef DEBUG
+ fprintf (stderr, "disconnect from FS \"%s\"\n", fpe->name);
+#endif
return Successful;
}
static FSBlockDataPtr
-fs_new_block_rec(fpe, client, type)
- FontPathElementPtr fpe;
- pointer client;
- int type;
+fs_new_block_rec(FontPathElementPtr fpe, pointer client, int type)
{
FSBlockDataPtr blockrec,
- br;
- FSFpePtr fsfpe = (FSFpePtr) fpe->private;
+ *prev;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
int size;
- blockrec = (FSBlockDataPtr) xalloc(sizeof(FSBlockDataRec));
- if (!blockrec)
- return (FSBlockDataPtr) 0;
switch (type) {
case FS_OPEN_FONT:
size = sizeof(FSBlockedFontRec);
@@ -486,208 +401,301 @@ fs_new_block_rec(fpe, client, type)
size = sizeof(FSBlockedListInfoRec);
break;
default:
+ size = 0;
break;
}
- blockrec->data = (pointer) xalloc(size);
- if (!blockrec->data) {
- xfree(blockrec);
+ blockrec = (FSBlockDataPtr) xalloc(sizeof(FSBlockDataRec) + size);
+ if (!blockrec)
return (FSBlockDataPtr) 0;
- }
+ blockrec->data = (pointer) (blockrec + 1);
blockrec->client = client;
- blockrec->sequence_number = fsfpe->current_seq;
+ blockrec->sequenceNumber = -1;
+ blockrec->errcode = StillWorking;
blockrec->type = type;
blockrec->depending = 0;
blockrec->next = (FSBlockDataPtr) 0;
-
+
/* stick it on the end of the list (since its expected last) */
- br = (FSBlockDataPtr) fsfpe->blocked_requests;
- if (!br) {
- fsfpe->blocked_requests = (pointer) blockrec;
- } else {
- while (br->next)
- br = br->next;
- br->next = blockrec;
- }
+ for (prev = &conn->blockedRequests; *prev; prev = &(*prev)->next)
+ ;
+ *prev = blockrec;
return blockrec;
}
static void
-_fs_remove_block_rec(conn, blockrec)
- FSFpePtr conn;
- FSBlockDataPtr blockrec;
+_fs_set_pending_reply (FSFpePtr conn)
{
- FSBlockDataPtr br,
- last;
+ FSBlockDataPtr blockrec;
+
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ if (blockrec->errcode == StillWorking)
+ break;
+ if (blockrec)
+ {
+ conn->blockedReplyTime = GetTimeInMillis () + FontServerRequestTimeout;
+ _fs_mark_block (conn, FS_PENDING_REPLY);
+ }
+ else
+ _fs_unmark_block (conn, FS_PENDING_REPLY);
+}
- last = (FSBlockDataPtr) 0;
- br = (FSBlockDataPtr) conn->blocked_requests;
- while (br) {
- if (br == blockrec) {
- if (last)
- last->next = br->next;
- else
- conn->blocked_requests = (pointer) br->next;
- if (br->type == FS_LOAD_GLYPHS)
- {
- FSBlockedGlyphPtr bglyph = (FSBlockedGlyphPtr)br->data;
- if (bglyph->num_expected_ranges)
- xfree(bglyph->expected_ranges);
- }
- xfree(br->data);
- xfree(br);
- return;
+static void
+_fs_remove_block_rec(FSFpePtr conn, FSBlockDataPtr blockrec)
+{
+ FSBlockDataPtr *prev;
+
+ for (prev = &conn->blockedRequests; *prev; prev = &(*prev)->next)
+ if (*prev == blockrec)
+ {
+ *prev = blockrec->next;
+ break;
}
- last = br;
- br = br->next;
+ if (blockrec->type == FS_LOAD_GLYPHS)
+ {
+ FSBlockedGlyphPtr bglyph = (FSBlockedGlyphPtr)blockrec->data;
+ if (bglyph->num_expected_ranges)
+ xfree(bglyph->expected_ranges);
}
+ xfree(blockrec);
+ _fs_set_pending_reply (conn);
}
static void
-signal_clients_depending(clients_depending)
-FSClientsDependingPtr *clients_depending;
+_fs_signal_clients_depending(FSClientsDependingPtr *clients_depending)
{
- FSClientsDependingPtr p = *clients_depending, p2;
- *clients_depending = (FSClientsDependingPtr)0;
-
- while (p != (FSClientsDependingPtr)0)
+ FSClientsDependingPtr p;
+
+ while ((p = *clients_depending))
{
- p2 = p;
+ *clients_depending = p->next;
ClientSignal(p->client);
- p = p->next;
- xfree(p2);
+ xfree(p);
}
}
static int
-add_clients_depending(clients_depending, client)
-FSClientsDependingPtr *clients_depending;
-pointer client;
+_fs_add_clients_depending(FSClientsDependingPtr *clients_depending, pointer client)
{
- while (*clients_depending != (FSClientsDependingPtr)0)
+ FSClientsDependingPtr new, cd;
+
+ for (; (cd = *clients_depending);
+ clients_depending = &(*clients_depending)->next)
{
- if ((*clients_depending)->client == client) return Suspended;
- clients_depending = &(*clients_depending)->next;
+ if (cd->client == client)
+ return Suspended;
}
- *clients_depending = (FSClientsDependingPtr)xalloc(
- sizeof(FSClientsDependingRec));
- if (!*clients_depending)
+
+ new = (FSClientsDependingPtr)xalloc (sizeof (FSClientsDependingRec));
+ if (!new)
return BadAlloc;
- (*clients_depending)->client = client;
- (*clients_depending)->next = 0;
+ new->client = client;
+ new->next = 0;
+ *clients_depending = new;
return Suspended;
}
+/*
+ * When a request is aborted due to a font server failure,
+ * signal any depending clients to restart their dependant
+ * requests
+ */
static void
-clean_aborted_blockrec(blockrec)
- FSBlockDataPtr blockrec;
+_fs_clean_aborted_blockrec(FSFpePtr conn, FSBlockDataPtr blockrec)
{
-
- switch(blockrec->type)
- {
- case FS_LOAD_GLYPHS:
- {
- FSBlockedGlyphPtr bglyph = (FSBlockedGlyphPtr)blockrec->data;
- FontPtr pfont = bglyph->pfont;
- int num_expected_ranges = bglyph->num_expected_ranges;
- fsRange *expected_ranges = bglyph->expected_ranges;
- _fs_clean_aborted_loadglyphs(pfont,
- num_expected_ranges,
- expected_ranges);
- signal_clients_depending(&bglyph->clients_depending);
- break;
- }
- case FS_OPEN_FONT:
- {
- FSBlockedFontPtr bfont = (FSBlockedFontPtr)blockrec->data;
- signal_clients_depending(&bfont->clients_depending);
- break;
- }
- default:
- break;
+ switch(blockrec->type) {
+ case FS_OPEN_FONT: {
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr)blockrec->data;
+
+ fs_cleanup_bfont (bfont);
+ _fs_signal_clients_depending(&bfont->clients_depending);
+ break;
+ }
+ case FS_LOAD_GLYPHS: {
+ FSBlockedGlyphPtr bglyph = (FSBlockedGlyphPtr)blockrec->data;
+
+ _fs_clean_aborted_loadglyphs(bglyph->pfont,
+ bglyph->num_expected_ranges,
+ bglyph->expected_ranges);
+ _fs_signal_clients_depending(&bglyph->clients_depending);
+ break;
+ }
+ case FS_LIST_FONTS:
+ break;
+ case FS_LIST_WITH_INFO: {
+ FSBlockedListInfoPtr binfo;
+ binfo = (FSBlockedListInfoPtr) blockrec->data;
+ if (binfo->status == FS_LFWI_REPLY)
+ FD_SET(conn->fs_fd, &_fs_fd_mask);
+ _fs_free_props (&binfo->info);
+ }
+ default:
+ break;
}
}
static void
-fs_abort_blockrec(conn, blockrec)
- FSFpePtr conn;
- FSBlockDataPtr blockrec;
+fs_abort_blockrec(FSFpePtr conn, FSBlockDataPtr blockrec)
{
- clean_aborted_blockrec(blockrec);
- _fs_remove_block_rec(conn, blockrec);
+ _fs_clean_aborted_blockrec (conn, blockrec);
+ _fs_remove_block_rec (conn, blockrec);
}
-
+/*
+ * Tell the font server we've failed to complete an open and
+ * then unload the partially created font
+ */
static void
-fs_free_font(bfont)
- FSBlockedFontPtr bfont;
+fs_cleanup_bfont (FSBlockedFontPtr bfont)
{
- FontPtr pfont;
FSFontDataRec *fsd;
- pfont = bfont->pfont;
- fsd = (FSFontDataRec *) pfont->fpePrivate;
-
- /* xfree better be able to handle NULL */
- (*pfont->unload_font)(pfont);
- DeleteFontClientID(fsd->fontid);
- xfree(fsd->name);
- xfree(pfont->info.isStringProp);
- xfree(pfont->info.props);
-
- xfree(pfont);
- xfree(fsd);
-
- bfont->pfont = (FontPtr) 0;
+ if (bfont->pfont)
+ {
+ fsd = (FSFontDataRec *) bfont->pfont->fpePrivate;
+
+ /* make sure the FS knows we choked on it */
+ fs_send_close_font(bfont->pfont->fpe, bfont->fontid);
+
+ /*
+ * Either unload the font if it's being opened for
+ * the first time, or smash the generation field to
+ * mark this font as an orphan
+ */
+ if (!(bfont->flags & FontReopen))
+ {
+ if (bfont->freeFont)
+ (*bfont->pfont->unload_font) (bfont->pfont);
+#ifdef DEBUG
+ else
+ fprintf (stderr, "Not freeing other font in cleanup_bfont\n");
+#endif
+ bfont->pfont = 0;
+ }
+ else
+ fsd->generation = -1;
+ }
}
-static void
-_fs_cleanup_font(bfont)
- FSBlockedFontPtr bfont;
+/*
+ * Check to see if a complete reply is waiting
+ */
+static fsGenericReply *
+fs_get_reply (FSFpePtr conn, int *error)
{
- FSFontDataRec *fsd;
+ char *buf;
+ fsGenericReply *rep;
+ int ret;
- if (bfont->pfont)
+ /* block if the connection is down or paused in lfwi */
+ if (conn->fs_fd == -1 || !FD_ISSET (conn->fs_fd, &_fs_fd_mask))
{
- fsd = (FSFontDataRec *) bfont->pfont->fpePrivate;
+ *error = FSIO_BLOCK;
+ return 0;
+ }
- /* make sure the FS knows we choked on it */
- fs_send_close_font(fsd->fpe, bfont->fontid);
+ ret = _fs_start_read (conn, sizeof (fsGenericReply), &buf);
+ if (ret != FSIO_READY)
+ {
+ *error = FSIO_BLOCK;
+ return 0;
+ }
- fs_free_font(bfont);
+ rep = (fsGenericReply *) buf;
+
+ ret = _fs_start_read (conn, rep->length << 2, &buf);
+ if (ret != FSIO_READY)
+ {
+ *error = FSIO_BLOCK;
+ return 0;
}
- bfont->errcode = AllocError;
+
+ *error = FSIO_READY;
+
+ return (fsGenericReply *) buf;
}
+static Bool
+fs_reply_ready (FSFpePtr conn)
+{
+ fsGenericReply *rep;
+
+ if (conn->fs_fd == -1 || !FD_ISSET (conn->fs_fd, &_fs_fd_mask))
+ return FALSE;
+ if (fs_data_read (conn) < sizeof (fsGenericReply))
+ return FALSE;
+ rep = (fsGenericReply *) (conn->inBuf.buf + conn->inBuf.remove);
+ if (fs_data_read (conn) < rep->length << 2)
+ return FALSE;
+ return TRUE;
+}
-static int
-fs_read_open_font(fpe, blockrec)
- FontPathElementPtr fpe;
- FSBlockDataPtr blockrec;
+static void
+_fs_pending_reply (FSFpePtr conn)
{
- FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- fsOpenBitmapFontReply rep;
- FSBlockDataPtr blockOrig;
- FSBlockedFontPtr origBfont;
+ if (!(conn->blockState & FS_PENDING_REPLY))
+ {
+ _fs_mark_block (conn, FS_PENDING_REPLY);
+ conn->blockedReplyTime = GetTimeInMillis () + FontServerRequestTimeout;
+ }
+}
- /* pull out the OpenFont reply */
- memcpy(&rep, &blockrec->header, SIZEOF(fsGenericReply));
+static void
+_fs_prepare_for_reply (FSFpePtr conn)
+{
+ _fs_pending_reply (conn);
+ _fs_flush (conn);
+}
- if (rep.type == FS_Error) {
- _fs_eat_rest_of_error(conn, (fsError *) & rep);
- return BadFontName;
- } else { /* get rest of reply */
- if (_fs_read(conn, (char *) &rep + SIZEOF(fsGenericReply),
- SIZEOF(fsOpenBitmapFontReply) - SIZEOF(fsGenericReply)) == -1) {
- /* If we're not reopening a font, we'll allocate the
- structures again after connection is reestablished. */
- if (!(bfont->flags & FontReopen)) fs_free_font(bfont);
- return StillWorking;
+/*
+ * Block (for a while) awaiting a complete reply
+ */
+static int
+fs_await_reply (FSFpePtr conn)
+{
+ int ret;
+
+ if (conn->blockState & FS_COMPLETE_REPLY)
+ return FSIO_READY;
+
+ while (!fs_get_reply (conn, &ret))
+ {
+ if (ret != FSIO_BLOCK)
+ return ret;
+ if (_fs_wait_for_readable (conn, FontServerRequestTimeout) != FSIO_READY)
+ {
+ _fs_connection_died (conn);
+ return FSIO_ERROR;
}
}
+ return FSIO_READY;
+}
+/*
+ * Process the reply to an OpenBitmapFont request
+ */
+static int
+fs_read_open_font(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
+ fsOpenBitmapFontReply *rep;
+ FSBlockDataPtr blockOrig;
+ FSBlockedFontPtr origBfont;
+ int ret;
+
+ rep = (fsOpenBitmapFontReply *) fs_get_reply (conn, &ret);
+ if (!rep || rep->type == FS_Error)
+ {
+ if (ret == FSIO_BLOCK)
+ return StillWorking;
+ if (rep)
+ _fs_done_read (conn, rep->length << 2);
+ fs_cleanup_bfont (bfont);
+ return BadFontName;
+ }
+
/* If we're not reopening a font and FS detected a duplicate font
open request, replace our reference to the new font with a
reference to an existing font (possibly one not finished
@@ -697,23 +705,27 @@ fs_read_open_font(fpe, blockrec)
if we we decide (in fs_read_query_info()) that we don't like what
we got. */
- if (rep.otherid && !(bfont->flags & FontReopen)) {
- (void) fs_send_close_font(fpe, bfont->fontid);
-
+ if (rep->otherid && !(bfont->flags & FontReopen))
+ {
+ fs_cleanup_bfont (bfont);
+
/* Find old font if we're completely done getting it from server. */
- fs_free_font(bfont);
- bfont->pfont = find_old_font(rep.otherid);
- bfont->fontid = rep.otherid;
+ bfont->pfont = find_old_font(rep->otherid);
+ bfont->freeFont = FALSE;
+ bfont->fontid = rep->otherid;
bfont->state = FS_DONE_REPLY;
/*
* look for a blocked request to open the same font
*/
- for (blockOrig = (FSBlockDataPtr) conn->blocked_requests;
+ for (blockOrig = conn->blockedRequests;
blockOrig;
- blockOrig = blockOrig->next) {
- if (blockOrig != blockrec && blockOrig->type == FS_OPEN_FONT) {
+ blockOrig = blockOrig->next)
+ {
+ if (blockOrig != blockrec && blockOrig->type == FS_OPEN_FONT)
+ {
origBfont = (FSBlockedFontPtr) blockOrig->data;
- if (origBfont->fontid == rep.otherid) {
+ if (origBfont->fontid == rep->otherid)
+ {
blockrec->depending = blockOrig->depending;
blockOrig->depending = blockrec;
bfont->state = FS_DEPENDING;
@@ -725,252 +737,267 @@ fs_read_open_font(fpe, blockrec)
if (bfont->pfont == NULL)
{
/* XXX - something nasty happened */
- return BadFontName;
+ ret = BadFontName;
}
- return AccessDone;
+ else
+ ret = AccessDone;
}
-
- bfont->pfont->info.cachable = rep.cachable != 0;
- bfont->state = FS_INFO_REPLY;
- /* ask for the next stage */
- (void) fs_send_query_info(fpe, blockrec);
- return StillWorking;
+ else
+ {
+ bfont->pfont->info.cachable = rep->cachable != 0;
+ bfont->state = FS_INFO_REPLY;
+ /*
+ * Reset the blockrec for the next reply
+ */
+ blockrec->sequenceNumber = bfont->queryInfoSequence;
+ conn->blockedReplyTime = GetTimeInMillis () + FontServerRequestTimeout;
+ ret = StillWorking;
+ }
+ _fs_done_read (conn, rep->length << 2);
+ return ret;
}
+static Bool
+fs_fonts_match (FontInfoPtr pInfo1, FontInfoPtr pInfo2)
+{
+ int i;
+
+ if (pInfo1->firstCol != pInfo2->firstCol ||
+ pInfo1->lastCol != pInfo2->lastCol ||
+ pInfo1->firstRow != pInfo2->firstRow ||
+ pInfo1->lastRow != pInfo2->lastRow ||
+ pInfo1->defaultCh != pInfo2->defaultCh ||
+ pInfo1->noOverlap != pInfo2->noOverlap ||
+ pInfo1->terminalFont != pInfo2->terminalFont ||
+ pInfo1->constantMetrics != pInfo2->constantMetrics ||
+ pInfo1->constantWidth != pInfo2->constantWidth ||
+ pInfo1->inkInside != pInfo2->inkInside ||
+ pInfo1->inkMetrics != pInfo2->inkMetrics ||
+ pInfo1->allExist != pInfo2->allExist ||
+ pInfo1->drawDirection != pInfo2->drawDirection ||
+ pInfo1->cachable != pInfo2->cachable ||
+ pInfo1->anamorphic != pInfo2->anamorphic ||
+ pInfo1->maxOverlap != pInfo2->maxOverlap ||
+ pInfo1->fontAscent != pInfo2->fontAscent ||
+ pInfo1->fontDescent != pInfo2->fontDescent ||
+ pInfo1->nprops != pInfo2->nprops)
+ return FALSE;
+
+#define MATCH(xci1, xci2) \
+ (((xci1).leftSideBearing == (xci2).leftSideBearing) && \
+ ((xci1).rightSideBearing == (xci2).rightSideBearing) && \
+ ((xci1).characterWidth == (xci2).characterWidth) && \
+ ((xci1).ascent == (xci2).ascent) && \
+ ((xci1).descent == (xci2).descent) && \
+ ((xci1).attributes == (xci2).attributes))
+
+ if (!MATCH(pInfo1->maxbounds, pInfo2->maxbounds) ||
+ !MATCH(pInfo1->minbounds, pInfo2->minbounds) ||
+ !MATCH(pInfo1->ink_maxbounds, pInfo2->ink_maxbounds) ||
+ !MATCH(pInfo1->ink_minbounds, pInfo2->ink_minbounds))
+ return FALSE;
+
+#undef MATCH
+
+ for (i = 0; i < pInfo1->nprops; i++)
+ if (pInfo1->isStringProp[i] !=
+ pInfo2->isStringProp[i] ||
+ pInfo1->props[i].name !=
+ pInfo2->props[i].name ||
+ pInfo1->props[i].value !=
+ pInfo2->props[i].value)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
static int
-fs_read_query_info(fpe, blockrec)
- FontPathElementPtr fpe;
- FSBlockDataPtr blockrec;
+fs_read_query_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
{
- FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- fsQueryXInfoReply rep;
- fsPropInfo pi;
- fsPropOffset *po;
- pointer pd;
- unsigned long prop_len;
- FSBlockedFontRec newbfont, *oldbfont;
- FontRec newpfont, *oldpfont;
- int err;
-
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ fsQueryXInfoReply *rep;
+ char *buf;
+ fsPropInfo *pi;
+ fsPropOffset *po;
+ pointer pd;
+ FontInfoPtr pInfo;
+ FontInfoRec tempInfo;
+ int err;
+ int ret;
+
+ rep = (fsQueryXInfoReply *) fs_get_reply (conn, &ret);
+ if (!rep || rep->type == FS_Error)
+ {
+ if (ret == FSIO_BLOCK)
+ return StillWorking;
+ if (rep)
+ _fs_done_read (conn, rep->length << 2);
+ fs_cleanup_bfont (bfont);
+ return BadFontName;
+ }
+
/* If this is a reopen, accumulate the query info into a dummy
font and compare to our original data. */
if (bfont->flags & FontReopen)
- {
- newbfont = *(oldbfont = bfont);
- bfont = &newbfont;
- newpfont = *(oldpfont = oldbfont->pfont);
- newpfont.info.isStringProp = NULL;
- newpfont.info.props = NULL;
- newbfont.pfont = &newpfont;
- err = StillWorking;
- }
-
- /* pull out the QueryXInfo reply */
- memcpy(&rep, &blockrec->header, SIZEOF(fsGenericReply));
- if (_fs_read(conn, (char *) &rep + SIZEOF(fsGenericReply),
- SIZEOF(fsQueryXInfoReply) - SIZEOF(fsGenericReply)) == -1) {
- if (bfont->flags & FontReopen) goto bail;
- fs_free_font(bfont);
- return StillWorking;
- }
+ pInfo = &tempInfo;
+ else
+ pInfo = &bfont->pfont->info;
+
+ buf = (char *) rep;
+ buf += SIZEOF(fsQueryXInfoReply);
+
/* move the data over */
- fsUnpack_XFontInfoHeader(&rep, &bfont->pfont->info);
- _fs_init_fontinfo(conn, &bfont->pfont->info);
+ fsUnpack_XFontInfoHeader(rep, pInfo);
+
+ /* compute accelerators */
+ _fs_init_fontinfo(conn, pInfo);
- if (bfont->pfont->info.terminalFont)
- {
- bfont->format =
- (bfont->format & ~ (BitmapFormatImageRectMask)) |
- BitmapFormatImageRectMax;
- }
+ /* Compute offsets into the reply */
+ pi = (fsPropInfo *) buf;
+ buf += SIZEOF (fsPropInfo);
+
+ po = (fsPropOffset *) buf;
+ buf += pi->num_offsets * SIZEOF(fsPropOffset);
- if (_fs_read(conn, (char *) &pi, SIZEOF(fsPropInfo)) == -1) {
- if (bfont->flags & FontReopen) goto bail;
- fs_free_font(bfont);
- return StillWorking;
- }
- prop_len = pi.num_offsets * SIZEOF(fsPropOffset);
- po = (fsPropOffset *) xalloc(prop_len);
- pd = (pointer) xalloc(pi.data_len);
- if (!po || !pd) {
- xfree(pd);
- xfree(po);
- /* clear the wire */
- (void) _fs_drain_bytes(conn, prop_len + pi.data_len);
- /* clean up the font */
- if (bfont->flags & FontReopen) { err = AllocError ; goto bail; }
- (void) _fs_cleanup_font(bfont);
- return AllocError;
- }
- if (_fs_read_pad(conn, (char *) po, prop_len) == -1 ||
- _fs_read_pad(conn, (char *) pd, pi.data_len) == -1) {
- xfree(pd);
- xfree(po);
- if (bfont->flags & FontReopen) goto bail;
- fs_free_font(bfont);
- return StillWorking;
- }
- if (_fs_convert_props(&pi, po, pd, &bfont->pfont->info) == -1)
+ pd = (pointer) buf;
+ buf += pi->data_len;
+
+ /* convert the properties and step over the reply */
+ ret = _fs_convert_props(pi, po, pd, pInfo);
+ _fs_done_read (conn, rep->length << 2);
+
+ if (ret == -1)
{
- xfree(po);
- xfree(pd);
- if (bfont->flags & FontReopen) { err = AllocError ; goto bail; }
- (void) _fs_cleanup_font(bfont);
+ fs_cleanup_bfont (bfont);
return AllocError;
}
- xfree(po);
- xfree(pd);
if (bfont->flags & FontReopen)
{
- int i;
-
- err = BadFontName;
-
/* We're reopening a font that we lost because of a downed
connection. In the interest of avoiding corruption from
opening a different font than the old one (we already have
its metrics, extents, and probably some of its glyphs),
verify that the metrics and properties all match. */
- if (newpfont.info.firstCol != oldpfont->info.firstCol ||
- newpfont.info.lastCol != oldpfont->info.lastCol ||
- newpfont.info.firstRow != oldpfont->info.firstRow ||
- newpfont.info.lastRow != oldpfont->info.lastRow ||
- newpfont.info.defaultCh != oldpfont->info.defaultCh ||
- newpfont.info.noOverlap != oldpfont->info.noOverlap ||
- newpfont.info.terminalFont != oldpfont->info.terminalFont ||
- newpfont.info.constantMetrics != oldpfont->info.constantMetrics ||
- newpfont.info.constantWidth != oldpfont->info.constantWidth ||
- newpfont.info.inkInside != oldpfont->info.inkInside ||
- newpfont.info.inkMetrics != oldpfont->info.inkMetrics ||
- newpfont.info.allExist != oldpfont->info.allExist ||
- newpfont.info.drawDirection != oldpfont->info.drawDirection ||
- newpfont.info.cachable != oldpfont->info.cachable ||
- newpfont.info.anamorphic != oldpfont->info.anamorphic ||
- newpfont.info.maxOverlap != oldpfont->info.maxOverlap ||
- newpfont.info.fontAscent != oldpfont->info.fontAscent ||
- newpfont.info.fontDescent != oldpfont->info.fontDescent ||
- newpfont.info.nprops != oldpfont->info.nprops)
- goto bail;
-
-#define MATCH(xci1, xci2) \
- (((xci1).leftSideBearing == (xci2).leftSideBearing) && \
- ((xci1).rightSideBearing == (xci2).rightSideBearing) && \
- ((xci1).characterWidth == (xci2).characterWidth) && \
- ((xci1).ascent == (xci2).ascent) && \
- ((xci1).descent == (xci2).descent) && \
- ((xci1).attributes == (xci2).attributes))
-
- if (!MATCH(newpfont.info.maxbounds, oldpfont->info.maxbounds) ||
- !MATCH(newpfont.info.minbounds, oldpfont->info.minbounds) ||
- !MATCH(newpfont.info.ink_maxbounds, oldpfont->info.ink_maxbounds) ||
- !MATCH(newpfont.info.ink_minbounds, oldpfont->info.ink_minbounds))
- goto bail;
-
-#undef MATCH
-
- for (i = 0; i < newpfont.info.nprops; i++)
- if (newpfont.info.isStringProp[i] !=
- oldpfont->info.isStringProp[i] ||
- newpfont.info.props[i].name !=
- oldpfont->info.props[i].name ||
- newpfont.info.props[i].value !=
- oldpfont->info.props[i].value)
- goto bail;
-
- err = Successful;
- bail:
- if (err != Successful && err != StillWorking)
+ if (fs_fonts_match (pInfo, &bfont->pfont->info))
{
- /* Failure. Close the font. */
- fs_send_close_font(((FSFontDataPtr)oldpfont->fpePrivate)->fpe,
- bfont->fontid);
- ((FSFontDataPtr)oldpfont->fpePrivate)->generation = -1;
+ err = Successful;
+ bfont->state = FS_DONE_REPLY;
}
- xfree(newpfont.info.isStringProp);
- xfree(newpfont.info.props);
-
- if (err == Successful) oldbfont->state = FS_DONE_REPLY;
+ else
+ {
+ fs_cleanup_bfont (bfont);
+ err = BadFontName;
+ }
+ _fs_free_props (pInfo);
+
return err;
}
+ /*
+ * Ask for terminal format fonts if possible
+ */
+ if (bfont->pfont->info.terminalFont)
+ bfont->format = ((bfont->format & ~ (BitmapFormatImageRectMask)) |
+ BitmapFormatImageRectMax);
+
+ /*
+ * Figure out if the whole font should get loaded right now.
+ */
if (glyphCachingMode == CACHING_OFF ||
- glyphCachingMode == CACHE_16_BIT_GLYPHS && !bfont->pfont->info.lastRow)
+ (glyphCachingMode == CACHE_16_BIT_GLYPHS
+ && !bfont->pfont->info.lastRow))
+ {
bfont->flags |= FontLoadAll;
+ }
+
+ /*
+ * Ready to send the query bitmaps; the terminal font bit has
+ * been computed and glyphCaching has been considered
+ */
+ if (bfont->flags & FontLoadBitmaps)
+ {
+ fs_send_query_bitmaps (fpe, blockrec);
+ _fs_flush (conn);
+ }
bfont->state = FS_EXTENT_REPLY;
- fs_send_query_extents(fpe, blockrec);
+ /*
+ * Reset the blockrec for the next reply
+ */
+ blockrec->sequenceNumber = bfont->queryExtentsSequence;
+ conn->blockedReplyTime = GetTimeInMillis () + FontServerRequestTimeout;
+
return StillWorking;
}
static int
-fs_read_extent_info(fpe, blockrec)
- FontPathElementPtr fpe;
- FSBlockDataPtr blockrec;
+fs_read_extent_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
{
- FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
- FSFontDataPtr fsd = (FSFontDataPtr) bfont->pfont->fpePrivate;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- fsQueryXExtents16Reply rep;
- int i;
- int numInfos;
- Bool haveInk = FALSE; /* need separate ink metrics? */
- CharInfoPtr ci,
- pCI;
- FSFontPtr fsfont = (FSFontPtr) bfont->pfont->fontPrivate;
- fsXCharInfo *fsci;
- fsXCharInfo fscilocal;
- pointer fscip;
-
- /* read the QueryXExtents reply */
- memcpy(&rep, &blockrec->header, SIZEOF(fsGenericReply));
- if (_fs_read(conn, (char *) &rep + SIZEOF(fsGenericReply),
- SIZEOF(fsQueryXExtents16Reply) - SIZEOF(fsGenericReply)) == -1) {
- fs_free_font(bfont);
- return StillWorking;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
+ FSFontDataPtr fsd = (FSFontDataPtr) bfont->pfont->fpePrivate;
+ FSFontPtr fsfont = (FSFontPtr) bfont->pfont->fontPrivate;
+ fsQueryXExtents16Reply *rep;
+ char *buf;
+ int i;
+ int numExtents;
+ int numInfos;
+ int ret;
+ Bool haveInk = FALSE; /* need separate ink metrics? */
+ CharInfoPtr ci, pCI;
+ char *fsci;
+ fsXCharInfo fscilocal;
+
+ rep = (fsQueryXExtents16Reply *) fs_get_reply (conn, &ret);
+ if (!rep || rep->type == FS_Error)
+ {
+ if (ret == FSIO_BLOCK)
+ return StillWorking;
+ if (rep)
+ _fs_done_read (conn, rep->length << 2);
+ fs_cleanup_bfont (bfont);
+ return BadFontName;
}
+
/* move the data over */
/* need separate inkMetrics for fixed font server protocol version */
- numInfos = rep.num_extents;
+ numExtents = rep->num_extents;
+ numInfos = numExtents;
if (bfont->pfont->info.terminalFont && conn->fsMajorVersion > 1)
{
numInfos *= 2;
haveInk = TRUE;
}
ci = pCI = (CharInfoPtr) xalloc(sizeof(CharInfoRec) * numInfos);
-/* XXX this could be done with an ALLOCATE_LOCAL */
- fsci = (fsXCharInfo *) xalloc(SIZEOF(fsXCharInfo) * rep.num_extents);
- if (!pCI || !fsci) {
- xfree(pCI);
- xfree(fsci);
- /* clear the unusable data */
- _fs_drain_bytes(conn, SIZEOF(fsXCharInfo) * rep.num_extents);
- _fs_cleanup_font(bfont);
+
+ if (!pCI)
+ {
+ _fs_done_read (conn, rep->length << 2);
+ fs_cleanup_bfont(bfont);
return AllocError;
}
fsfont->encoding = pCI;
if (haveInk)
- fsfont->inkMetrics = pCI + rep.num_extents;
+ fsfont->inkMetrics = pCI + numExtents;
else
fsfont->inkMetrics = pCI;
- if (_fs_read_pad(conn, (char *) fsci,
- SIZEOF(fsXCharInfo) * rep.num_extents) == -1) {
- fs_free_font(bfont);
- xfree(fsci);
- return StillWorking;
- }
+ buf = (char *) rep;
+ buf += SIZEOF (fsQueryXExtents16Reply);
+ fsci = buf;
+
fsd->glyphs_to_get = 0;
- fscip = (pointer) fsci;
ci = fsfont->inkMetrics;
- for (i = 0; i < rep.num_extents; i++) {
- memcpy(&fscilocal, fscip, SIZEOF(fsXCharInfo)); /* align it */
+ for (i = 0; i < numExtents; i++)
+ {
+ memcpy(&fscilocal, fsci, SIZEOF(fsXCharInfo)); /* align it */
_fs_convert_char_info(&fscilocal, &ci->metrics);
- fscip += SIZEOF(fsXCharInfo);
+ fsci = fsci + SIZEOF(fsXCharInfo);
/* Initialize the bits field for later glyph-caching use */
if (NONZEROMETRICS(&ci->metrics))
{
@@ -989,8 +1016,9 @@ fs_read_extent_info(fpe, blockrec)
ci++;
}
- xfree(fsci);
-
+ /* Done with reply */
+ _fs_done_read (conn, rep->length << 2);
+
/* build bitmap metrics, ImageRectMax style */
if (haveInk)
{
@@ -999,7 +1027,7 @@ fs_read_extent_info(fpe, blockrec)
ci = fsfont->encoding;
ii = fsfont->inkMetrics;
- for (i = 0; i < rep.num_extents; i++, ci++, ii++)
+ for (i = 0; i < numExtents; i++, ci++, ii++)
{
if (NONZEROMETRICS(&ii->metrics))
{
@@ -1042,164 +1070,190 @@ fs_read_extent_info(fpe, blockrec)
}
bfont->state = FS_GLYPHS_REPLY;
- if (bfont->flags & FontLoadBitmaps) {
- fs_send_query_bitmaps(fpe, blockrec);
+ if (bfont->flags & FontLoadBitmaps)
+ {
+ /*
+ * Reset the blockrec for the next reply
+ */
+ blockrec->sequenceNumber = bfont->queryBitmapsSequence;
+ conn->blockedReplyTime = GetTimeInMillis () + FontServerRequestTimeout;
return StillWorking;
}
return Successful;
}
-/*
- * XXX should probably continue to read here if we can, but must be sure
- * it's our packet waiting, rather than another interspersed
- */
+#ifdef DEBUG
+static char *fs_open_states[] = {
+ "OPEN_REPLY ",
+ "INFO_REPLY ",
+ "EXTENT_REPLY",
+ "GLYPHS_REPLY",
+ "DONE_REPLY ",
+ "DEPENDING ",
+};
+#endif
+
static int
-fs_do_open_font(fpe, blockrec, readheader)
- FontPathElementPtr fpe;
- FSBlockDataPtr blockrec;
- Bool readheader;
+fs_do_open_font(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
{
- FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- int err;
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
+ int err;
+#ifdef DEBUG
+ fprintf (stderr, "fs_do_open_font state %s %s\n",
+ fs_open_states[bfont->state],
+ ((FSFontDataPtr) (bfont->pfont->fpePrivate))->name);
+#endif
+ err = BadFontName;
switch (bfont->state) {
case FS_OPEN_REPLY:
- if (readheader) {
- /* get the next header */
- if (_fs_read(conn, (char *) &blockrec->header,
- SIZEOF(fsGenericReply)) == -1) {
- fs_free_font(bfont);
- err = StillWorking;
- break;
- }
- }
- bfont->errcode = fs_read_open_font(fpe, blockrec);
- if (bfont->errcode != StillWorking) { /* already loaded, or error */
+ err = fs_read_open_font(fpe, blockrec);
+ if (err != StillWorking) { /* already loaded, or error */
/* if font's already loaded, massage error code */
switch (bfont->state) {
case FS_DONE_REPLY:
- bfont->errcode = Successful;
+ err = Successful;
break;
case FS_DEPENDING:
- bfont->errcode = StillWorking;
- break;
- }
- err = bfont->errcode;
- break;
- }
- /* if more data to read or Sync, fall thru, else return */
- if (!(bfont->flags & FontOpenSync)) {
- err = bfont->errcode;
- break;
- } else {
- if (_fs_read(conn, (char *) &blockrec->header,
- SIZEOF(fsGenericReply)) == -1) {
- fs_free_font(bfont);
err = StillWorking;
break;
}
}
- /* fall through */
+ break;
case FS_INFO_REPLY:
- bfont->errcode = fs_read_query_info(fpe, blockrec);
- if (bfont->errcode != StillWorking) {
- err = bfont->errcode;
- break;
- }
- if (!(bfont->flags & FontOpenSync)) {
- err = bfont->errcode;
- break;
- /* if more data to read, fall thru, else return */
- } else {
- if (_fs_read(conn, (char *) &blockrec->header,
- SIZEOF(fsGenericReply))) {
- fs_free_font(bfont);
- err = StillWorking;
- break;
- }
- }
- /* fall through */
+ err = fs_read_query_info(fpe, blockrec);
+ break;
case FS_EXTENT_REPLY:
- bfont->errcode = fs_read_extent_info(fpe, blockrec);
- if (bfont->errcode != StillWorking) {
- err = bfont->errcode;
- break;
- }
- if (!(bfont->flags & FontOpenSync)) {
- err = bfont->errcode;
- break;
- } else if (bfont->flags & FontLoadBitmaps) {
- if (_fs_read(conn, (char *) &blockrec->header,
- SIZEOF(fsGenericReply))) {
- fs_free_font(bfont);
- err = StillWorking;
- break;
- }
- }
- /* fall through */
+ err = fs_read_extent_info(fpe, blockrec);
+ break;
case FS_GLYPHS_REPLY:
- if (bfont->flags & FontLoadBitmaps) {
- bfont->errcode = fs_read_glyphs(fpe, blockrec);
- }
- err = bfont->errcode;
+ if (bfont->flags & FontLoadBitmaps)
+ err = fs_read_glyphs(fpe, blockrec);
break;
case FS_DEPENDING: /* can't happen */
- err = bfont->errcode;
default:
- err = bfont->errcode;
break;
}
- if (err != StillWorking) {
+#ifdef DEBUG
+ fprintf (stderr, "fs_do_open_font err %d\n", err);
+#endif
+ if (err != StillWorking)
+ {
bfont->state = FS_DONE_REPLY; /* for _fs_load_glyphs() */
- while (blockrec = blockrec->depending) {
+ while ((blockrec = blockrec->depending))
+ {
bfont = (FSBlockedFontPtr) blockrec->data;
- bfont->errcode = err;
bfont->state = FS_DONE_REPLY; /* for _fs_load_glyphs() */
}
}
return err;
}
+void
+_fs_mark_block (FSFpePtr conn, CARD32 mask)
+{
+ conn->blockState |= mask;
+ fs_blockState |= mask;
+}
+
+void
+_fs_unmark_block (FSFpePtr conn, CARD32 mask)
+{
+ FSFpePtr c;
+
+ if (conn->blockState & mask)
+ {
+ conn->blockState &= ~mask;
+ fs_blockState = 0;
+ for (c = fs_fpes; c; c = c->next)
+ fs_blockState |= c->blockState;
+ }
+}
+
/* ARGSUSED */
static void
-fs_block_handler(data, wt, LastSelectMask)
- pointer data;
- struct timeval **wt;
- fd_set* LastSelectMask;
-{
- static struct timeval recon_timeout;
- Time_t now,
- soonest;
- FSFpePtr recon;
-
- XFD_ORSET(LastSelectMask, LastSelectMask, &_fs_fd_mask);
- if (recon = awaiting_reconnect) {
- now = time((Time_t *) 0);
- soonest = recon->time_to_try;
- while (recon = recon->next_reconnect) {
- if (recon->time_to_try < soonest)
- soonest = recon->time_to_try;
- }
- if (soonest < now)
- soonest = now;
- soonest = soonest - now;
- recon_timeout.tv_sec = soonest;
- recon_timeout.tv_usec = 0;
- if (*wt == (struct timeval *) 0) {
- *wt = &recon_timeout;
- } else if ((*wt)->tv_sec > soonest) {
- **wt = recon_timeout;
+fs_block_handler(pointer data, OSTimePtr wt, pointer LastSelectMask)
+{
+ static struct timeval block_timeout;
+ CARD32 now, earliest, wakeup;
+ int soonest;
+ FSFpePtr conn;
+
+ XFD_ORSET((fd_set *)LastSelectMask, (fd_set *)LastSelectMask,
+ &_fs_fd_mask);
+ /*
+ * Flush all pending output
+ */
+ if (fs_blockState & FS_PENDING_WRITE)
+ for (conn = fs_fpes; conn; conn = conn->next)
+ if (conn->blockState & FS_PENDING_WRITE)
+ _fs_flush (conn);
+ /*
+ * Check for any fpe with a complete reply, set sleep time to zero
+ */
+ if (fs_blockState & FS_COMPLETE_REPLY)
+ {
+ block_timeout.tv_sec = 0;
+ block_timeout.tv_usec = 0;
+ if (*wt == NULL)
+ *wt = &block_timeout;
+ else
+ **wt = block_timeout;
+ }
+ /*
+ * Walk through fpe list computing sleep time
+ */
+ else if (fs_blockState & (FS_BROKEN_WRITE|
+ FS_BROKEN_CONNECTION|
+ FS_PENDING_REPLY|
+ FS_RECONNECTING))
+ {
+ now = GetTimeInMillis ();
+ earliest = now + 10000000;
+ for (conn = fs_fpes; conn; conn = conn->next)
+ {
+ if (conn->blockState & FS_RECONNECTING)
+ {
+ wakeup = conn->blockedConnectTime;
+ if (TimeCmp (wakeup, <, earliest))
+ earliest = wakeup;
+ }
+ if (conn->blockState & FS_BROKEN_CONNECTION)
+ {
+ wakeup = conn->brokenConnectionTime;
+ if (TimeCmp (wakeup, <, earliest))
+ earliest = wakeup;
+ }
+ if (conn->blockState & FS_BROKEN_WRITE)
+ {
+ wakeup = conn->brokenWriteTime;
+ if (TimeCmp (wakeup, <, earliest))
+ earliest = wakeup;
+ }
+ if (conn->blockState & FS_PENDING_REPLY)
+ {
+ wakeup = conn->blockedReplyTime;
+ if (TimeCmp (wakeup, <, earliest))
+ earliest = wakeup;
+ }
}
+ soonest = earliest - now;
+ if (soonest < 0)
+ soonest = 0;
+ block_timeout.tv_sec = soonest / 1000;
+ block_timeout.tv_usec = (soonest % 1000) * 1000;
+ if (*wt == NULL)
+ *wt = &block_timeout;
+ else if (soonest < (*wt)->tv_sec * 1000 + (*wt)->tv_usec / 1000)
+ **wt = block_timeout;
}
}
static void
-fs_handle_unexpected(conn, rep)
- FSFpePtr conn;
- fsGenericReply *rep;
+fs_handle_unexpected(FSFpePtr conn, fsGenericReply *rep)
{
- if (rep->type == FS_Event && rep->data1 == KeepAlive) {
+ if (rep->type == FS_Event && rep->data1 == KeepAlive)
+ {
fsNoopReq req;
/* ping it back */
@@ -1209,155 +1263,223 @@ fs_handle_unexpected(conn, rep)
_fs_write(conn, (char *) &req, SIZEOF(fsNoopReq));
}
/* this should suck up unexpected replies and events */
- _fs_eat_rest_of_error(conn, (fsError *) rep);
+ _fs_done_read (conn, rep->length << 2);
}
-static int
-fs_wakeup(fpe, LastSelectMask)
- FontPathElementPtr fpe;
- fd_set* LastSelectMask;
+static void
+fs_read_reply (FontPathElementPtr fpe, pointer client)
{
- FSBlockDataPtr blockrec,
- br;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- int err;
- fsGenericReply rep;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec;
+ int ret;
+ int err;
+ fsGenericReply *rep;
+
+ if ((rep = fs_get_reply (conn, &ret)))
+ {
+ _fs_add_rep_log (conn, rep);
+ for (blockrec = conn->blockedRequests;
+ blockrec;
+ blockrec = blockrec->next)
+ {
+ if (blockrec->sequenceNumber == rep->sequenceNumber)
+ break;
+ }
+ err = Successful;
+ if (!blockrec)
+ {
+ fs_handle_unexpected(conn, rep);
+ }
+ else
+ {
+ /*
+ * go read it, and if we're done,
+ * wake up the appropriate client
+ */
+ switch (blockrec->type) {
+ case FS_OPEN_FONT:
+ blockrec->errcode = fs_do_open_font(fpe, blockrec);
+ break;
+ case FS_LOAD_GLYPHS:
+ blockrec->errcode = fs_read_glyphs(fpe, blockrec);
+ break;
+ case FS_LIST_FONTS:
+ blockrec->errcode = fs_read_list(fpe, blockrec);
+ break;
+ case FS_LIST_WITH_INFO:
+ blockrec->errcode = fs_read_list_info(fpe, blockrec);
+ break;
+ default:
+ break;
+ }
+ err = blockrec->errcode;
+ if (err != StillWorking)
+ {
+ while (blockrec)
+ {
+ blockrec->errcode = err;
+ if (client != blockrec->client)
+ ClientSignal(blockrec->client);
+ blockrec = blockrec->depending;
+ }
+ _fs_unmark_block (conn, FS_PENDING_REPLY);
+ }
+ }
+ if (fs_reply_ready (conn))
+ _fs_mark_block (conn, FS_COMPLETE_REPLY);
+ else
+ _fs_unmark_block (conn, FS_COMPLETE_REPLY);
+ }
+}
- /* see if there's any data to be read */
+static int
+fs_wakeup(FontPathElementPtr fpe, unsigned long *mask)
+{
+ fd_set *LastSelectMask = (fd_set *) mask;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
/*
* Don't continue if the fd is -1 (which will be true when the
* font server terminates
*/
- if (conn->fs_fd == -1)
- return FALSE;
-
- if (FD_ISSET(conn->fs_fd, LastSelectMask)) {
+ if ((conn->blockState & FS_RECONNECTING))
+ _fs_check_reconnect (conn);
+ else if ((conn->blockState & FS_COMPLETE_REPLY) ||
+ (conn->fs_fd != -1 && FD_ISSET(conn->fs_fd, LastSelectMask)))
+ fs_read_reply (fpe, 0);
+ if (conn->blockState & (FS_PENDING_REPLY|FS_BROKEN_CONNECTION|FS_BROKEN_WRITE))
+ _fs_do_blocked (conn);
+#ifdef DEBUG
+ {
+ FSBlockDataPtr blockrec;
+ FSBlockedFontPtr bfont;
+ FSBlockedListPtr blist;
+ static CARD32 lastState;
+ static FSBlockDataPtr lastBlock;
-#ifdef NOTDEF /* bogus - doesn't deal with EOF very well,
- * now does it ... */
- /*
- * make sure it isn't spurious - mouse events seem to trigger extra
- * problems
- */
- if (_fs_data_ready(conn) <= 0) {
- return FALSE;
+ if (conn->blockState || conn->blockedRequests || lastState || lastBlock)
+ {
+ fprintf (stderr, " Block State 0x%x\n", (int) conn->blockState);
+ lastState = conn->blockState;
+ lastBlock = conn->blockedRequests;
}
-#endif
-
- /* get the header */
- if (_fs_read(conn, (char *) &rep, SIZEOF(fsGenericReply)) == -1)
- return FALSE;
-
- /* find the matching block record */
-
- for (br = (FSBlockDataPtr) conn->blocked_requests; br; br = br->next) {
- if ((CARD16)(br->sequence_number & 0xffff) ==
- (CARD16)(rep.sequenceNumber - 1))
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ {
+ switch (blockrec->type) {
+ case FS_OPEN_FONT:
+ bfont = (FSBlockedFontPtr) blockrec->data;
+ fprintf (stderr, " Blocked font errcode %d sequence %d state %s %s\n",
+ blockrec->errcode,
+ blockrec->sequenceNumber,
+ fs_open_states[bfont->state],
+ bfont->pfont ?
+ ((FSFontDataPtr) (bfont->pfont->fpePrivate))->name :
+ "<freed>");
+ break;
+ case FS_LIST_FONTS:
+ blist = (FSBlockedListPtr) blockrec->data;
+ fprintf (stderr, " Blocked list errcode %d sequence %d\n",
+ blockrec->errcode, blockrec->sequenceNumber);
+ break;
+ default:
+ fprintf (stderr, " Blocked type %d errcode %d sequence %d\n",
+ blockrec->type,
+ blockrec->errcode,
+ blockrec->sequenceNumber);
break;
- }
- if (!br) {
- fs_handle_unexpected(conn, &rep);
- return FALSE;
- }
- blockrec = br;
-
- memcpy(&blockrec->header, &rep, SIZEOF(fsGenericReply));
-
- /* go read it, and if we're done, wake up the appropriate client */
- switch (blockrec->type) {
- case FS_OPEN_FONT:
- err = fs_do_open_font(fpe, blockrec, FALSE);
- break;
- case FS_LOAD_GLYPHS:
- err = fs_read_glyphs(fpe, blockrec);
- break;
- case FS_LIST_FONTS:
- err = fs_read_list(fpe, blockrec);
- break;
- case FS_LIST_WITH_INFO:
- err = fs_read_list_info(fpe, blockrec);
- break;
- default:
- break;
- }
-
- if (err != StillWorking) {
- while (blockrec) {
- ClientSignal(blockrec->client);
- blockrec = blockrec->depending;
}
}
- /*
- * Xx we could loop here and eat any additional replies, but it should
- * feel more responsive for other clients if we come back later
- */
- } else if (awaiting_reconnect) {
- _fs_try_reconnect();
}
+#endif
return FALSE;
}
/*
- * Reconnection code
+ * Notice a dead connection and prepare for reconnect
*/
void
-_fs_connection_died(conn)
- FSFpePtr conn;
+_fs_connection_died(FSFpePtr conn)
{
- if (!conn->attemptReconnect)
+ if (conn->blockState & FS_BROKEN_CONNECTION)
return;
- conn->attemptReconnect = FALSE;
fs_close_conn(conn);
- conn->time_to_try = time((Time_t *) 0) + FS_RECONNECT_WAIT;
- conn->reconnect_delay = FS_RECONNECT_WAIT;
- conn->fs_fd = -1;
- conn->trans_conn = NULL;
- conn->next_reconnect = awaiting_reconnect;
- awaiting_reconnect = conn;
+ conn->brokenConnectionTime = GetTimeInMillis ();
+ _fs_mark_block (conn, FS_BROKEN_CONNECTION);
+ _fs_unmark_block (conn, FS_BROKEN_WRITE|FS_PENDING_WRITE|FS_RECONNECTING);
}
+/*
+ * Signal clients that the connection has come back up
+ */
static int
-_fs_restart_connection(conn)
- FSFpePtr conn;
+_fs_restart_connection(FSFpePtr conn)
{
FSBlockDataPtr block;
- conn->current_seq = 0;
- FD_SET(conn->fs_fd, &_fs_fd_mask);
- if (!fs_send_init_packets(conn))
- return FALSE;
- while (block = (FSBlockDataPtr) conn->blocked_requests) {
- ClientSignal(block->client);
- fs_abort_blockrec(conn, block);
+ _fs_unmark_block (conn, FS_GIVE_UP);
+ while ((block = (FSBlockDataPtr) conn->blockedRequests))
+ {
+ if (block->errcode == StillWorking)
+ {
+ ClientSignal(block->client);
+ fs_abort_blockrec(conn, block);
+ }
}
return TRUE;
}
+/*
+ * Declare this font server connection useless
+ */
static void
-_fs_try_reconnect()
-{
- FSFpePtr conn,
- *prev;
- Time_t now;
-
- prev = &awaiting_reconnect;
- now = time((Time_t *) 0);
- while (conn = *prev) {
- if (now - conn->time_to_try > 0) {
- if (_fs_reopen_server(conn) && _fs_restart_connection(conn)) {
- conn->attemptReconnect = TRUE;
- *prev = conn->next_reconnect;
- if (prev == &awaiting_reconnect) continue;
- } else {
- if (conn->reconnect_delay < FS_MAX_RECONNECT_WAIT)
- conn->reconnect_delay *= 2;
- now = time((Time_t *) 0);
- conn->time_to_try = now + conn->reconnect_delay;
- }
+_fs_giveup (FSFpePtr conn)
+{
+ FSBlockDataPtr block;
+
+ if (conn->blockState & FS_GIVE_UP)
+ return;
+#ifdef DEBUG
+ fprintf (stderr, "give up on FS \"%s\"\n", conn->servername);
+#endif
+ _fs_mark_block (conn, FS_GIVE_UP);
+ while ((block = (FSBlockDataPtr) conn->blockedRequests))
+ {
+ if (block->errcode == StillWorking)
+ {
+ ClientSignal (block->client);
+ fs_abort_blockrec (conn, block);
+ }
+ }
+ if (conn->fs_fd >= 0)
+ _fs_connection_died (conn);
+}
+
+static void
+_fs_do_blocked (FSFpePtr conn)
+{
+ CARD32 now;
+
+ now = GetTimeInMillis ();
+ if ((conn->blockState & FS_PENDING_REPLY) &&
+ TimeCmp (conn->blockedReplyTime, <=, now))
+ {
+ _fs_giveup (conn);
+ }
+ else
+ {
+ if (conn->blockState & FS_BROKEN_CONNECTION)
+ {
+ /* Try to reconnect broken connections */
+ if (TimeCmp (conn->brokenConnectionTime, <=, now))
+ _fs_start_reconnect (conn);
+ }
+ else if (conn->blockState & FS_BROKEN_WRITE)
+ {
+ /* Try to flush blocked connections */
+ if (TimeCmp (conn->brokenWriteTime, <=, now))
+ _fs_flush (conn);
}
- prev = &conn->next_reconnect;
}
}
@@ -1366,50 +1488,50 @@ _fs_try_reconnect()
*/
/* ARGSUSED */
static int
-fs_send_open_font(client, fpe, flags, name, namelen, format, fmask, id, ppfont)
- pointer client;
- FontPathElementPtr fpe;
- Mask flags;
- char *name;
- int namelen;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- XID id;
- FontPtr *ppfont;
-{
- FontPtr newfont;
- FSBlockDataPtr blockrec = NULL;
- FSBlockedFontPtr blockedfont;
- FSFontDataPtr fsd;
- FSFontPtr fsfont;
- FSFpePtr conn;
- fsOpenBitmapFontReq openreq;
- int err = Suspended;
- XID newid;
- unsigned char buf[1024];
- char *fontname;
-
+fs_send_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *ppfont)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FontPtr font;
+ FSBlockDataPtr blockrec = NULL;
+ FSBlockedFontPtr bfont;
+ FSFontDataPtr fsd;
+ FSFontPtr fsfont;
+ fsOpenBitmapFontReq openreq;
+ fsQueryXInfoReq inforeq;
+ fsQueryXExtents16Req extreq;
+ int err;
+ unsigned char buf[1024];
+
+ if (conn->blockState & FS_GIVE_UP)
+ return BadFontName;
+
+ if (namelen > sizeof (buf) - 1)
+ return BadFontName;
+
+ /*
+ * Get the font structure put together, either by reusing
+ * the existing one or creating a new one
+ */
if (flags & FontReopen)
{
- Atom nameatom, fn = None;
- int i;
+ Atom nameatom, fn = None;
+ int i;
- newfont = *ppfont;
- fsd = (FSFontDataPtr)newfont->fpePrivate;
- fsfont = (FSFontPtr)newfont->fontPrivate;
- fpe = newfont->fpe;
- format = fsd->format;
- fmask = fsd->fmask;
- newid = fsd->fontid;
+ font = *ppfont;
+ fsd = (FSFontDataPtr)font->fpePrivate;
+ fsfont = (FSFontPtr)font->fontPrivate;
/* This is an attempt to reopen a font. Did the font have a
NAME property? */
if ((nameatom = MakeAtom("FONT", 4, 0)) != None)
{
- for (i = 0; i < newfont->info.nprops; i++)
- if (newfont->info.props[i].name == nameatom &&
- newfont->info.isStringProp[i])
+ for (i = 0; i < font->info.nprops; i++)
+ if (font->info.props[i].name == nameatom &&
+ font->info.isStringProp[i])
{
- fn = newfont->info.props[i].value;
+ fn = font->info.props[i].value;
break;
}
}
@@ -1421,195 +1543,127 @@ fs_send_open_font(client, fpe, flags, name, namelen, format, fmask, id, ppfont)
else
namelen = strlen(name);
}
-
- conn = (FSFpePtr) fpe->private;
- if (namelen > sizeof (buf) - 1)
- return BadFontName;
- _fs_client_access (conn, client, (flags & FontOpenSync) != 0);
- _fs_client_resolution(conn);
-
-
- if (!(flags & FontReopen))
+ else
{
-
- newid = GetNewFontClientID();
-
- /* make the font */
- newfont = (FontPtr) xalloc(sizeof(FontRec));
-
- /* and the FS data */
- fsd = (FSFontDataPtr) xalloc(sizeof(FSFontDataRec));
-
- fsfont = (FSFontPtr) xalloc(sizeof(FSFontRec));
-
- fontname = (char *)xalloc(namelen);
-
- if (!newfont || !fsd || !fsfont || !fontname) {
-lowmem:
- if (!(flags & FontReopen))
- {
- xfree((char *) newfont);
- xfree((char *) fsd);
- xfree((char *) fsfont);
- xfree((char *) fontname);
- }
- if (blockrec) fs_abort_blockrec(conn, blockrec);
+ font = fs_create_font (fpe, name, namelen, format, fmask);
+ if (!font)
return AllocError;
- }
- bzero((char *) newfont, sizeof(FontRec));
- bzero((char *) fsfont, sizeof(FSFontRec));
- bzero((char *) fsd, sizeof(FSFontDataRec));
+
+ fsd = (FSFontDataPtr)font->fpePrivate;
+ fsfont = (FSFontPtr)font->fontPrivate;
}
-
+
/* make a new block record, and add it to the end of the list */
- blockrec = fs_new_block_rec(fpe, client, FS_OPEN_FONT);
- if (!blockrec) {
- goto lowmem;
- }
-
- if (!(flags & FontReopen))
- {
- int bit, byte, scan, glyph;
-
- newfont->refcnt = 0;
- newfont->maxPrivate = -1;
- newfont->devPrivates = (pointer *) 0;
- newfont->format = format;
-
- /* These font components will be needed in packGlyphs */
- CheckFSFormat(format, BitmapFormatMaskBit |
- BitmapFormatMaskByte |
- BitmapFormatMaskScanLineUnit |
- BitmapFormatMaskScanLinePad,
- &bit,
- &byte,
- &scan,
- &glyph,
- NULL);
- newfont->bit = bit;
- newfont->byte = byte;
- newfont->scan = scan;
- newfont->glyph = glyph;
-
- newfont->fpe = fpe;
- newfont->fpePrivate = (pointer) fsd;
- newfont->fontPrivate = (pointer) fsfont;
- _fs_init_font(newfont);
-
- fsd->fpe = fpe;
- fsd->name = fontname;
- fsd->namelen = namelen;
- memcpy(fontname, name, namelen);
- fsd->format = format;
- fsd->fmask = fmask;
- }
- fsd->fontid = newid;
+ blockrec = fs_new_block_rec(font->fpe, client, FS_OPEN_FONT);
+ if (!blockrec)
+ {
+ if (!(flags & FontReopen))
+ (*font->unload_font) (font);
+ return AllocError;
+ }
+
+ /*
+ * Must check this before generating any protocol, otherwise we'll
+ * mess up a reconnect in progress
+ */
+ if (conn->blockState & (FS_BROKEN_CONNECTION | FS_RECONNECTING))
+ {
+ _fs_pending_reply (conn);
+ return Suspended;
+ }
+
fsd->generation = conn->generation;
- blockedfont = (FSBlockedFontPtr) blockrec->data;
- blockedfont->fontid = newid;
- blockedfont->pfont = newfont;
- blockedfont->state = FS_OPEN_REPLY;
- blockedfont->flags = flags;
- blockedfont->format = format;
- blockedfont->clients_depending = (FSClientsDependingPtr)0;
+ bfont = (FSBlockedFontPtr) blockrec->data;
+ bfont->fontid = fsd->fontid;
+ bfont->pfont = font;
+ bfont->state = FS_OPEN_REPLY;
+ bfont->flags = flags;
+ bfont->format = fsd->format;
+ bfont->clients_depending = (FSClientsDependingPtr)0;
+ bfont->freeFont = (flags & FontReopen) == 0;
+
+ _fs_client_access (conn, client, (flags & FontOpenSync) != 0);
+ _fs_client_resolution(conn);
- /* save the ID */
- if (!StoreFontClientFont(blockedfont->pfont, blockedfont->fontid)) {
- goto lowmem;
- }
/* do an FS_OpenFont, FS_QueryXInfo and FS_QueryXExtents */
buf[0] = (unsigned char) namelen;
memcpy(&buf[1], name, namelen);
- namelen++;
openreq.reqType = FS_OpenBitmapFont;
- openreq.fid = newid;
- openreq.format_hint = format;
- openreq.format_mask = fmask;
- openreq.length = (SIZEOF(fsOpenBitmapFontReq) + namelen + 3) >> 2;
+ openreq.fid = fsd->fontid;
+ openreq.format_hint = fsd->format;
+ openreq.format_mask = fsd->fmask;
+ openreq.length = (SIZEOF(fsOpenBitmapFontReq) + namelen + 4) >> 2;
_fs_add_req_log(conn, FS_OpenBitmapFont);
_fs_write(conn, (char *) &openreq, SIZEOF(fsOpenBitmapFontReq));
- _fs_write_pad(conn, (char *) buf, namelen);
+ _fs_write_pad(conn, (char *) buf, namelen + 1);
+
+ blockrec->sequenceNumber = conn->current_seq;
+
+ inforeq.reqType = FS_QueryXInfo;
+ inforeq.id = fsd->fontid;
+ inforeq.length = SIZEOF(fsQueryXInfoReq) >> 2;
+ bfont->queryInfoSequence = conn->current_seq + 1;
+
+ _fs_add_req_log(conn, FS_QueryXInfo);
+ _fs_write(conn, (char *) &inforeq, SIZEOF(fsQueryXInfoReq));
+
+ if (!(bfont->flags & FontReopen))
+ {
+ extreq.reqType = FS_QueryXExtents16;
+ extreq.range = fsTrue;
+ extreq.fid = fsd->fontid;
+ extreq.num_ranges = 0;
+ extreq.length = SIZEOF(fsQueryXExtents16Req) >> 2;
+
+ bfont->queryExtentsSequence = conn->current_seq + 1;
+
+ _fs_add_req_log(conn, FS_QueryXExtents16);
+ _fs_write(conn, (char *) &extreq, SIZEOF(fsQueryXExtents16Req));
+ }
+
#ifdef NCD
- if (configData.ExtendedFontDiags) {
+ if (configData.ExtendedFontDiags)
+ {
memcpy(buf, name, MIN(256, namelen));
buf[MIN(256, namelen)] = '\0';
printf("Requesting font \"%s\" from font server \"%s\"\n",
- buf, fpe->name);
+ buf, font->fpe->name);
}
#endif
-
- if (flags & FontOpenSync) {
- err = fs_do_open_font(fpe, blockrec, TRUE);
- if (blockedfont->errcode == Successful) {
- *ppfont = blockedfont->pfont;
- } else {
- _fs_cleanup_font(blockedfont);
+ _fs_prepare_for_reply (conn);
+
+ err = blockrec->errcode;
+ if (bfont->flags & FontOpenSync)
+ {
+ while (blockrec->errcode == StillWorking)
+ {
+ if (fs_await_reply (conn) != FSIO_READY)
+ {
+ blockrec->errcode = BadFontName;
+ break;
+ }
+ fs_read_reply (font->fpe, client);
}
- _fs_remove_block_rec(conn, blockrec);
+ err = blockrec->errcode;
+ if (err == Successful)
+ *ppfont = bfont->pfont;
+ else
+ fs_cleanup_bfont (bfont);
+ bfont->freeFont = FALSE;
+ _fs_remove_block_rec (conn, blockrec);
}
- return err;
-}
-
-static int
-fs_send_query_info(fpe, blockrec)
- FontPathElementPtr fpe;
- FSBlockDataPtr blockrec;
-{
- FSBlockedFontPtr bfont;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- fsQueryXInfoReq inforeq;
-
- bfont = (FSBlockedFontPtr) blockrec->data;
-
- inforeq.reqType = FS_QueryXInfo;
- inforeq.id = bfont->fontid;
- inforeq.length = SIZEOF(fsQueryXInfoReq) >> 2;
-
- blockrec->sequence_number = conn->current_seq;
- _fs_add_req_log(conn, FS_QueryXInfo);
- _fs_write(conn, (char *) &inforeq, SIZEOF(fsQueryXInfoReq));
-
- return Successful;
+ return err == StillWorking ? Suspended : err;
}
-static int
-fs_send_query_extents(fpe, blockrec)
- FontPathElementPtr fpe;
- FSBlockDataPtr blockrec;
-{
- FSBlockedFontPtr bfont;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- fsQueryXExtents16Req extreq;
-
- bfont = (FSBlockedFontPtr) blockrec->data;
-
- extreq.reqType = FS_QueryXExtents16;
- extreq.range = fsTrue;
- extreq.fid = bfont->fontid;
- extreq.num_ranges = 0;
- extreq.length = SIZEOF(fsQueryXExtents16Req) >> 2;
-
- blockrec->sequence_number = conn->current_seq;
- _fs_add_req_log(conn, FS_QueryXExtents16);
- _fs_write(conn, (char *) &extreq, SIZEOF(fsQueryXExtents16Req));
-
- return Successful;
-}
-
-static int
-fs_send_query_bitmaps(fpe, blockrec)
- FontPathElementPtr fpe;
- FSBlockDataPtr blockrec;
+static void
+fs_send_query_bitmaps(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
{
- FSBlockedFontPtr bfont;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- fsQueryXBitmaps16Req bitreq;
-
-
- bfont = (FSBlockedFontPtr) blockrec->data;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
+ fsQueryXBitmaps16Req bitreq;
/* send the request */
bitreq.reqType = FS_QueryXBitmaps16;
@@ -1619,55 +1673,45 @@ fs_send_query_bitmaps(fpe, blockrec)
bitreq.length = SIZEOF(fsQueryXBitmaps16Req) >> 2;
bitreq.num_ranges = 0;
- blockrec->sequence_number = conn->current_seq;
+ bfont->queryBitmapsSequence = conn->current_seq + 1;
+
_fs_add_req_log(conn, FS_QueryXBitmaps16);
_fs_write(conn, (char *) &bitreq, SIZEOF(fsQueryXBitmaps16Req));
-
- return Successful;
}
/* ARGSUSED */
static int
-fs_open_font(client, fpe, flags, name, namelen, format, fmask, id, ppfont,
- alias, non_cachable_font)
- pointer client;
- FontPathElementPtr fpe;
- Mask flags;
- char *name;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- int namelen;
- XID id;
- FontPtr *ppfont;
- char **alias;
- FontPtr non_cachable_font; /* Not used in this FPE */
+fs_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *ppfont,
+ char **alias, FontPtr non_cachable_font)
{
- FSFpePtr conn = (FSFpePtr) fpe->private;
- FSBlockDataPtr blockrec;
- FSBlockedFontPtr blockedfont;
- int err;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec;
+ FSBlockedFontPtr bfont;
+ int err;
/* libfont interface expects ImageRectMin glyphs */
- format = format & ~BitmapFormatImageRectMask | BitmapFormatImageRectMin;
+ format = (format & ~BitmapFormatImageRectMask) | BitmapFormatImageRectMin;
*alias = (char *) 0;
- /* XX if we find the blockrec for the font */
- blockrec = (FSBlockDataPtr) conn->blocked_requests;
- while (blockrec != (FSBlockDataPtr) 0) {
- if (blockrec->type == FS_OPEN_FONT &&
- blockrec->client == client) {
- blockedfont = (FSBlockedFontPtr) blockrec->data;
- err = blockedfont->errcode;
- if (err == Successful) {
- *ppfont = blockedfont->pfont;
- } else {
- _fs_cleanup_font(blockedfont);
- }
- /* cleanup */
- _fs_remove_block_rec(conn, blockrec);
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ {
+ if (blockrec->type == FS_OPEN_FONT && blockrec->client == client)
+ {
+ err = blockrec->errcode;
+ if (err == StillWorking)
+ return Suspended;
+
+ bfont = (FSBlockedFontPtr) blockrec->data;
+ if (err == Successful)
+ *ppfont = bfont->pfont;
+ else
+ fs_cleanup_bfont (bfont);
+ _fs_remove_block_rec (conn, blockrec);
return err;
}
- blockrec = blockrec->next;
}
return fs_send_open_font(client, fpe, flags, name, namelen, format, fmask,
id, ppfont);
@@ -1675,13 +1719,13 @@ fs_open_font(client, fpe, flags, name, namelen, format, fmask, id, ppfont,
/* ARGSUSED */
static int
-fs_send_close_font(fpe, id)
- FontPathElementPtr fpe;
- Font id;
+fs_send_close_font(FontPathElementPtr fpe, Font id)
{
FSFpePtr conn = (FSFpePtr) fpe->private;
fsCloseReq req;
+ if (conn->blockState & FS_GIVE_UP)
+ return Successful;
/* tell the font server to close the font */
req.reqType = FS_CloseFont;
req.length = SIZEOF(fsCloseReq) >> 2;
@@ -1693,110 +1737,83 @@ fs_send_close_font(fpe, id)
}
/* ARGSUSED */
-static int
-fs_close_font(fpe, pfont)
- FontPathElementPtr fpe;
- FontPtr pfont;
+static void
+fs_close_font(FontPathElementPtr fpe, FontPtr pfont)
{
- FSFontDataPtr fsd = (FSFontDataPtr) pfont->fpePrivate;
- FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSFontDataPtr fsd = (FSFontDataPtr) pfont->fpePrivate;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
- /* XXX we may get called after the resource DB has been cleaned out */
- if (find_old_font(fsd->fontid))
- DeleteFontClientID(fsd->fontid);
if (conn->generation == fsd->generation)
fs_send_close_font(fpe, fsd->fontid);
- (*pfont->unload_font) (pfont);
-
-
- xfree(fsd->name);
- xfree(fsd);
- xfree(pfont->info.isStringProp);
- xfree(pfont->info.props);
- xfree(pfont->devPrivates);
- xfree(pfont);
+#ifdef DEBUG
+ {
+ FSBlockDataPtr blockrec;
+ FSBlockedFontPtr bfont;
- return Successful;
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ {
+ if (blockrec->type == FS_OPEN_FONT)
+ {
+ bfont = (FSBlockedFontPtr) blockrec->data;
+ if (bfont->pfont == pfont)
+ fprintf (stderr, "closing font which hasn't been opened\n");
+ }
+ }
+ }
+#endif
+ (*pfont->unload_font) (pfont);
}
static int
-fs_read_glyphs(fpe, blockrec)
- FontPathElementPtr fpe;
- FSBlockDataPtr blockrec;
+fs_read_glyphs(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
{
- FSBlockedGlyphPtr bglyph = (FSBlockedGlyphPtr) blockrec->data;
- FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- FontPtr pfont = bglyph->pfont; /* works for either blocked font
+ FSBlockedGlyphPtr bglyph = (FSBlockedGlyphPtr) blockrec->data;
+ FSBlockedFontPtr bfont = (FSBlockedFontPtr) blockrec->data;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FontPtr pfont = bglyph->pfont;
+ /* works for either blocked font
or glyph rec... pfont is at
the very beginning of both
blockrec->data structures */
- FSFontDataPtr fsd = (FSFontDataPtr) (pfont->fpePrivate);
- FSFontPtr fsdata = (FSFontPtr) pfont->fontPrivate;
- FontInfoPtr pfi = &pfont->info;
- fsQueryXBitmaps16Reply rep;
- fsOffset32 *ppbits;
- fsOffset32 local_off;
- char *off_adr;
- pointer pbitmaps;
- char *bits;
- int glyph_size,
- offset_size,
- i,
- err;
- int nranges = 0;
- fsRange *ranges, *nextrange;
- unsigned long minchar, maxchar;
-
- /* get reply header */
- memcpy(&rep, &blockrec->header, SIZEOF(fsGenericReply));
- if (rep.type == FS_Error) {
-/* XXX -- translate FS error */
- _fs_eat_rest_of_error(conn, (fsError *) & rep);
- err = AllocError;
- goto bail;
- }
- if (_fs_read(conn, (char *) &rep + SIZEOF(fsGenericReply),
- SIZEOF(fsQueryXBitmaps16Reply) - SIZEOF(fsGenericReply)) == -1) {
- if (blockrec->type == FS_OPEN_FONT)
- fs_free_font(bfont);
- return StillWorking;
- }
- /* allocate space for glyphs */
- offset_size = SIZEOF(fsOffset32) * (rep.num_chars);
- glyph_size = (rep.length << 2) - SIZEOF(fsQueryXBitmaps16Reply)
- - offset_size;
- ppbits = (fsOffset32 *) xalloc(offset_size);
- pbitmaps = (pointer) xalloc(glyph_size);
- if (glyph_size && !pbitmaps || !ppbits)
+ FSFontDataPtr fsd = (FSFontDataPtr) (pfont->fpePrivate);
+ FSFontPtr fsdata = (FSFontPtr) pfont->fontPrivate;
+ FontInfoPtr pfi = &pfont->info;
+ fsQueryXBitmaps16Reply *rep;
+ char *buf;
+ fsOffset32 *ppbits;
+ fsOffset32 local_off;
+ char *off_adr;
+ pointer pbitmaps;
+ char *bits, *allbits;
+#ifdef DEBUG
+ char *origallbits;
+#endif
+ int i,
+ err;
+ int nranges = 0;
+ int ret;
+ fsRange *ranges, *nextrange = 0;
+ unsigned long minchar, maxchar;
+
+ rep = (fsQueryXBitmaps16Reply *) fs_get_reply (conn, &ret);
+ if (!rep || rep->type == FS_Error)
{
- xfree(pbitmaps);
- xfree(ppbits);
-
- /* clear wire */
- (void) _fs_drain_bytes_pad(conn, offset_size);
- (void) _fs_drain_bytes_pad(conn, glyph_size);
-
- if (blockrec->type == FS_OPEN_FONT)
- _fs_cleanup_font(bfont);
+ if (ret == FSIO_BLOCK)
+ return StillWorking;
+ if (rep)
+ _fs_done_read (conn, rep->length << 2);
err = AllocError;
goto bail;
}
- /* read offsets */
- if (_fs_read_pad(conn, (char *) ppbits, offset_size) == -1) {
- if (blockrec->type == FS_OPEN_FONT)
- fs_free_font(bfont);
- return StillWorking;
- }
+ buf = (char *) rep;
+ buf += SIZEOF (fsQueryXBitmaps16Reply);
- /* read glyphs */
- if (_fs_read_pad(conn, (char *) pbitmaps, glyph_size) == -1) {
- if (blockrec->type == FS_OPEN_FONT)
- fs_free_font(bfont);
- return StillWorking;
- }
+ ppbits = (fsOffset32 *) buf;
+ buf += SIZEOF (fsOffset32) * (rep->num_chars);
+
+ pbitmaps = (pointer ) buf;
if (blockrec->type == FS_LOAD_GLYPHS)
{
@@ -1822,31 +1839,47 @@ fs_read_glyphs(fpe, blockrec)
else
{
minchar = 0;
- maxchar = rep.num_chars;
+ maxchar = rep->num_chars;
}
off_adr = (char *)ppbits;
- for (i = 0; i < rep.num_chars; i++)
+
+ allbits = fs_alloc_glyphs (pfont, rep->nbytes);
+
+ if (!allbits)
+ {
+ err = AllocError;
+ goto bail;
+ }
+
+#ifdef DEBUG
+ origallbits = allbits;
+ fprintf (stderr, "Reading %d glyphs in %d bytes for %s\n",
+ (int) rep->num_chars, (int) rep->nbytes, fsd->name);
+#endif
+
+ for (i = 0; i < rep->num_chars; i++)
{
memcpy(&local_off, off_adr, SIZEOF(fsOffset32)); /* align it */
if (blockrec->type == FS_OPEN_FONT ||
fsdata->encoding[minchar].bits == &_fs_glyph_requested)
{
- if (local_off.length)
+ /*
+ * Broken X font server returns bits for missing characters
+ * when font is padded
+ */
+ if (NONZEROMETRICS(&fsdata->encoding[minchar].metrics))
{
- bits = (char *)xalloc(local_off.length);
- if (bits == NULL)
+ if (local_off.length)
{
- xfree(ppbits);
- xfree(pbitmaps);
- err = AllocError;
- goto bail;
+ bits = allbits;
+ allbits += local_off.length;
+ memcpy(bits, (char *)pbitmaps + local_off.position,
+ local_off.length);
}
- memcpy(bits, pbitmaps + local_off.position,
- local_off.length);
+ else
+ bits = &_fs_glyph_zero_length;
}
- else if (NONZEROMETRICS(&fsdata->encoding[minchar].metrics))
- bits = &_fs_glyph_zero_length;
else
bits = 0;
if (fsdata->encoding[minchar].bits == &_fs_glyph_requested)
@@ -1866,9 +1899,10 @@ fs_read_glyphs(fpe, blockrec)
}
off_adr += SIZEOF(fsOffset32);
}
-
- xfree(ppbits);
- xfree(pbitmaps);
+#ifdef DEBUG
+ fprintf (stderr, "Used %d bytes instead of %d\n",
+ (int) (allbits - origallbits), (int) rep->nbytes);
+#endif
if (blockrec->type == FS_OPEN_FONT)
{
@@ -1878,31 +1912,23 @@ fs_read_glyphs(fpe, blockrec)
err = Successful;
bail:
- if (blockrec->type == FS_LOAD_GLYPHS)
- {
- bglyph->done = TRUE;
- bglyph->errcode = err;
- }
-
+ _fs_done_read (conn, rep->length << 2);
return err;
}
-
-
static int
-fs_send_load_glyphs(client, pfont, nranges, ranges)
- pointer client;
- FontPtr pfont;
- int nranges;
- fsRange *ranges;
-{
- FSBlockedGlyphPtr blockedglyph;
- fsQueryXBitmaps16Req req;
- FSFontDataPtr fsd = (FSFontDataPtr) (pfont->fpePrivate);
- FontPathElementPtr fpe = fsd->fpe;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- FSBlockDataPtr blockrec;
-
+fs_send_load_glyphs(pointer client, FontPtr pfont,
+ int nranges, fsRange *ranges)
+{
+ FontPathElementPtr fpe = pfont->fpe;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockedGlyphPtr blockedglyph;
+ fsQueryXBitmaps16Req req;
+ FSBlockDataPtr blockrec;
+
+ if (conn->blockState & FS_GIVE_UP)
+ return BadCharRange;
+
/* make a new block record, and add it to the end of the list */
blockrec = fs_new_block_rec(fpe, client, FS_LOAD_GLYPHS);
if (!blockrec)
@@ -1912,17 +1938,20 @@ fs_send_load_glyphs(client, pfont, nranges, ranges)
blockedglyph->num_expected_ranges = nranges;
/* Assumption: it's our job to free ranges */
blockedglyph->expected_ranges = ranges;
- blockedglyph->done = FALSE;
blockedglyph->clients_depending = (FSClientsDependingPtr)0;
- blockrec->sequence_number = conn->current_seq;
-
+ if (conn->blockState & (FS_BROKEN_CONNECTION|FS_RECONNECTING))
+ {
+ _fs_pending_reply (conn);
+ return Suspended;
+ }
+
/* send the request */
req.reqType = FS_QueryXBitmaps16;
req.fid = ((FSFontDataPtr) pfont->fpePrivate)->fontid;
req.format = pfont->format;
if (pfont->info.terminalFont)
- req.format = req.format & ~(BitmapFormatImageRectMask) |
+ req.format = (req.format & ~(BitmapFormatImageRectMask)) |
BitmapFormatImageRectMax;
req.range = TRUE;
/* each range takes up 4 bytes */
@@ -1931,6 +1960,8 @@ fs_send_load_glyphs(client, pfont, nranges, ranges)
_fs_add_req_log(conn, FS_QueryXBitmaps16);
_fs_write(conn, (char *) &req, SIZEOF(fsQueryXBitmaps16Req));
+ blockrec->sequenceNumber = conn->current_seq;
+
/* Send ranges to the server... pack into a char array by hand
to avoid structure-packing portability problems and to
handle swapping for version1 protocol */
@@ -1970,19 +2001,20 @@ fs_send_load_glyphs(client, pfont, nranges, ranges)
_fs_write(conn, range_buffer, i * 4);
}
+ _fs_prepare_for_reply (conn);
return Suspended;
}
+extern pointer serverClient; /* This could be any number that
+ doesn't conflict with existing
+ client values. */
+
int
-fs_load_all_glyphs(pfont)
- FontPtr pfont;
+fs_load_all_glyphs(FontPtr pfont)
{
- extern pointer serverClient; /* This could be any number that
- doesn't conflict with existing
- client values. */
- int err;
- FSFpePtr conn = (FSFpePtr) pfont->fpe->private;
+ int err;
+ FSFpePtr conn = (FSFpePtr) pfont->fpe->private;
/*
* The purpose of this procedure is to load all glyphs in the event
@@ -1999,67 +2031,49 @@ fs_load_all_glyphs(pfont)
while ((err = _fs_load_glyphs(serverClient, pfont, TRUE, 0, 0, NULL)) ==
Suspended)
{
- fd_set TempSelectMask;
-
- FD_ZERO (&TempSelectMask);
-
- if (_fs_wait_for_readable(conn) == -1)
+ if (fs_await_reply (conn) != FSIO_READY)
{
- /* We lost our connection. Don't wait to reestablish it;
- just give up. */
- _fs_connection_died(conn);
-
/* Get rid of blockrec */
fs_client_died(serverClient, pfont->fpe);
-
- return BadCharRange; /* As good an error as any other */
+ err = BadCharRange;
+ break;
}
- FD_SET(conn->fs_fd, &TempSelectMask);
- fs_wakeup(pfont->fpe, &TempSelectMask);
+ fs_read_reply (pfont->fpe, serverClient);
}
-
return err;
}
int
-_fs_load_glyphs(client, pfont, range_flag, nchars, item_size, data)
- pointer client;
- FontPtr pfont;
- Bool range_flag;
- unsigned int nchars;
- int item_size;
- unsigned char *data;
-{
-
- int nranges = 0;
- fsRange *ranges = NULL;
- int res;
- FSBlockDataPtr blockrec;
- FSBlockedGlyphPtr blockedglyph;
- FSFpePtr conn = (FSFpePtr) pfont->fpe->private;
- FSClientsDependingPtr *clients_depending = NULL;
+_fs_load_glyphs(pointer client, FontPtr pfont, Bool range_flag,
+ unsigned int nchars, int item_size, unsigned char *data)
+{
+ FSFpePtr conn = (FSFpePtr) pfont->fpe->private;
+ int nranges = 0;
+ fsRange *ranges = NULL;
+ int res;
+ FSBlockDataPtr blockrec;
+ FSBlockedGlyphPtr blockedglyph;
+ FSClientsDependingPtr *clients_depending = NULL;
+ int err;
/* see if the result is already there */
-
- blockrec = (FSBlockDataPtr) conn->blocked_requests;
- while (blockrec) {
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ {
if (blockrec->type == FS_LOAD_GLYPHS)
{
blockedglyph = (FSBlockedGlyphPtr) blockrec->data;
if (blockedglyph->pfont == pfont)
{
+ /* Look for this request */
if (blockrec->client == client)
{
- if (blockedglyph->done)
- {
- int errcode = blockedglyph->errcode;
- signal_clients_depending(&blockedglyph->
- clients_depending);
- _fs_remove_block_rec(conn, blockrec);
- return errcode;
- }
- else return Suspended;
+ err = blockrec->errcode;
+ if (err == StillWorking)
+ return Suspended;
+ _fs_signal_clients_depending(&blockedglyph->clients_depending);
+ _fs_remove_block_rec(conn, blockrec);
+ return err;
}
/* We've found an existing LoadGlyphs blockrec for this
font but for another client. Rather than build a
@@ -2077,17 +2091,22 @@ _fs_load_glyphs(client, pfont, range_flag, nchars, item_size, data)
bfont = (FSBlockedFontPtr) blockrec->data;
if (bfont->pfont == pfont)
{
+ /*
+ * An OpenFont is pending for this font, this must
+ * be from a reopen attempt, so finish the open
+ * attempt and retry the LoadGlyphs
+ */
if (blockrec->client == client)
{
- if (bfont->state == FS_DONE_REPLY)
- {
- int errcode = bfont->errcode;
- signal_clients_depending(&bfont->clients_depending);
- _fs_remove_block_rec(conn, blockrec);
- if (errcode == Successful) break;
- else return errcode;
- }
- else return Suspended;
+ err = blockrec->errcode;
+ if (err == StillWorking)
+ return Suspended;
+
+ _fs_signal_clients_depending(&bfont->clients_depending);
+ _fs_remove_block_rec(conn, blockrec);
+ if (err != Successful)
+ return err;
+ break;
}
/* We've found an existing OpenFont blockrec for this
font but for another client. Rather than build a
@@ -2095,15 +2114,13 @@ _fs_load_glyphs(client, pfont, range_flag, nchars, item_size, data)
maintenance), we'll add it to a queue of clients to
be signalled when the existing OpenFont is
completed. */
- if (bfont->state != FS_DONE_REPLY)
+ if (blockrec->errcode == StillWorking)
{
clients_depending = &bfont->clients_depending;
break;
}
}
}
-
- blockrec = blockrec->next;
}
/*
@@ -2139,7 +2156,7 @@ _fs_load_glyphs(client, pfont, range_flag, nchars, item_size, data)
_fs_clean_aborted_loadglyphs(pfont, nranges, ranges);
xfree(ranges);
}
- return add_clients_depending(clients_depending, client);
+ return _fs_add_clients_depending(clients_depending, client);
}
/*
@@ -2177,87 +2194,70 @@ _fs_load_glyphs(client, pfont, range_flag, nchars, item_size, data)
return fs_send_load_glyphs(client, pfont, nranges, ranges);
}
-
-
static int
-fs_read_list(fpe, blockrec)
- FontPathElementPtr fpe;
- FSBlockDataPtr blockrec;
+fs_read_list(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
{
- FSBlockedListPtr blist = (FSBlockedListPtr) blockrec->data;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- fsListFontsReply rep;
- char *data,
- *dp;
- int length,
- i;
-
- blist->done = TRUE;
-
- /* read reply header */
- memcpy(&rep, &blockrec->header, SIZEOF(fsGenericReply));
- if (rep.type == FS_Error) {
-/* XXX -- translate FS error */
- _fs_eat_rest_of_error(conn, (fsError *) & rep);
- return AllocError;
- }
- if (_fs_read(conn, (char *) &rep + SIZEOF(fsGenericReply),
- SIZEOF(fsListFontsReply) - SIZEOF(fsGenericReply)) == -1) {
- /* nothing to free (i think) */
- return StillWorking;
- }
- length = (rep.length << 2) - SIZEOF(fsListFontsReply);
- data = (char *) xalloc(length);
- if (!data) {
- _fs_drain_bytes_pad(conn, length);
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockedListPtr blist = (FSBlockedListPtr) blockrec->data;
+ fsListFontsReply *rep;
+ char *data;
+ int length,
+ i,
+ ret;
+ int err;
+
+ rep = (fsListFontsReply *) fs_get_reply (conn, &ret);
+ if (!rep || rep->type == FS_Error)
+ {
+ if (ret == FSIO_BLOCK)
+ return StillWorking;
+ if (rep)
+ _fs_done_read (conn, rep->length << 2);
return AllocError;
}
- /* read the list */
- if (_fs_read_pad(conn, data, length) == -1) {
- /* nothing to free (i think) */
- return StillWorking;
- }
+ data = (char *) rep + SIZEOF (fsListFontsReply);
+
+ err = Successful;
/* copy data into FontPathRecord */
- dp = data;
- for (i = 0; i < rep.nFonts; i++) {
- length = *(unsigned char *)dp++;
- if (AddFontNamesName(blist->names, dp, length) != Successful) {
- blist->errcode = AllocError;
+ for (i = 0; i < rep->nFonts; i++)
+ {
+ length = *(unsigned char *)data++;
+ err = AddFontNamesName(blist->names, data, length);
+ if (err != Successful)
break;
- }
- dp += length;
+ data += length;
}
-
- xfree(data);
- return Successful;
+ _fs_done_read (conn, rep->length << 2);
+ return err;
}
static int
-fs_send_list_fonts(client, fpe, pattern, patlen, maxnames, newnames)
- pointer client;
- FontPathElementPtr fpe;
- char *pattern;
- int patlen;
- int maxnames;
- FontNamesPtr newnames;
-{
- FSBlockDataPtr blockrec;
- FSBlockedListPtr blockedlist;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- fsListFontsReq req;
-
- _fs_client_access (conn, client, FALSE);
- _fs_client_resolution(conn);
+fs_send_list_fonts(pointer client, FontPathElementPtr fpe, char *pattern,
+ int patlen, int maxnames, FontNamesPtr newnames)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec;
+ FSBlockedListPtr blockedlist;
+ fsListFontsReq req;
+ if (conn->blockState & FS_GIVE_UP)
+ return BadFontName;
+
/* make a new block record, and add it to the end of the list */
blockrec = fs_new_block_rec(fpe, client, FS_LIST_FONTS);
if (!blockrec)
return AllocError;
blockedlist = (FSBlockedListPtr) blockrec->data;
- blockedlist->patlen = patlen;
- blockedlist->errcode = Successful;
blockedlist->names = newnames;
- blockedlist->done = FALSE;
+
+ if (conn->blockState & (FS_BROKEN_CONNECTION | FS_RECONNECTING))
+ {
+ _fs_pending_reply (conn);
+ return Suspended;
+ }
+
+ _fs_client_access (conn, client, FALSE);
+ _fs_client_resolution(conn);
/* send the request */
req.reqType = FS_ListFonts;
@@ -2268,6 +2268,8 @@ fs_send_list_fonts(client, fpe, pattern, patlen, maxnames, newnames)
_fs_write(conn, (char *) &req, SIZEOF(fsListFontsReq));
_fs_write_pad(conn, (char *) pattern, patlen);
+ blockrec->sequenceNumber = conn->current_seq;
+
#ifdef NCD
if (configData.ExtendedFontDiags) {
char buf[256];
@@ -2279,198 +2281,155 @@ fs_send_list_fonts(client, fpe, pattern, patlen, maxnames, newnames)
}
#endif
+ _fs_prepare_for_reply (conn);
return Suspended;
}
static int
-fs_list_fonts(client, fpe, pattern, patlen, maxnames, newnames)
- pointer client;
- FontPathElementPtr fpe;
- char *pattern;
- int patlen;
- int maxnames;
- FontNamesPtr newnames;
-{
- FSBlockDataPtr blockrec;
- FSBlockedListPtr blockedlist;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- int err;
+fs_list_fonts(pointer client, FontPathElementPtr fpe,
+ char *pattern, int patlen, int maxnames, FontNamesPtr newnames)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec;
+ FSBlockedListPtr blockedlist;
+ int err;
/* see if the result is already there */
- blockrec = (FSBlockDataPtr) conn->blocked_requests;
- while (blockrec) {
- if (blockrec->type == FS_LIST_FONTS && blockrec->client == client) {
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ {
+ if (blockrec->type == FS_LIST_FONTS && blockrec->client == client)
+ {
+ err = blockrec->errcode;
+ if (err == StillWorking)
+ return Suspended;
blockedlist = (FSBlockedListPtr) blockrec->data;
- if (blockedlist->patlen == patlen && blockedlist->done) {
- err = blockedlist->errcode;
- _fs_remove_block_rec(conn, blockrec);
- return err;
- }
+ _fs_remove_block_rec(conn, blockrec);
+ return err;
}
- blockrec = blockrec->next;
}
/* didn't find waiting record, so send a new one */
return fs_send_list_fonts(client, fpe, pattern, patlen, maxnames, newnames);
}
-static int padlength[4] = {0, 3, 2, 1};
-
+/*
+ * Read a single list info reply and restart for the next reply
+ */
static int
-fs_read_list_info(fpe, blockrec)
- FontPathElementPtr fpe;
- FSBlockDataPtr blockrec;
+fs_read_list_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
{
- FSBlockedListInfoPtr binfo = (FSBlockedListInfoPtr) blockrec->data;
- fsListFontsWithXInfoReply rep;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- fsPropInfo pi;
- fsPropOffset *po;
- char *name;
- pointer pd;
- int err;
+ FSBlockedListInfoPtr binfo = (FSBlockedListInfoPtr) blockrec->data;
+ fsListFontsWithXInfoReply *rep;
+ char *buf;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ fsPropInfo *pi;
+ fsPropOffset *po;
+ pointer pd;
+ int ret;
+ int err;
/* clean up anything from the last trip */
- if (binfo->name)
- {
- xfree(binfo->name);
- binfo->name = NULL;
- }
- if (binfo->pfi) {
- xfree(binfo->pfi->isStringProp);
- xfree(binfo->pfi->props);
- xfree(binfo->pfi);
- binfo->pfi = NULL;
- }
- /* get reply header */
- memcpy(&rep, &blockrec->header, SIZEOF(fsGenericReply));
- if (rep.type == FS_Error) {
-/* XXX -- translate FS error */
- _fs_eat_rest_of_error(conn, (fsError *) & rep);
- binfo->errcode = AllocError;
- return AllocError;
- }
- if (conn->fsMajorVersion > 1)
- if (rep.nameLength == 0)
- goto done;
- /* old protocol sent a full-length reply even for the last one */
- if (_fs_read(conn, (char *) &rep + SIZEOF(fsGenericReply),
- SIZEOF(fsListFontsWithXInfoReply) - SIZEOF(fsGenericReply)) == -1) {
- goto done;
- }
- if (rep.nameLength == 0)
- goto done;
+ _fs_free_props (&binfo->info);
- /* read the data */
- name = (char *) xalloc(rep.nameLength);
- binfo->pfi = (FontInfoPtr) xalloc(sizeof(FontInfoRec));
- if (!name || !binfo->pfi) {
- xfree(name);
- xfree(binfo->pfi);
- binfo->pfi = NULL;
- _fs_drain_bytes(conn,
- rep.length - (SIZEOF(fsListFontsWithXInfoReply) -
- SIZEOF(fsGenericReply)));
- binfo->errcode = AllocError;
- return AllocError;
- }
- if (conn->fsMajorVersion == 1)
- if (_fs_read_pad(conn, name, rep.nameLength) == -1)
- goto done;
- if (_fs_read_pad(conn, (char *) &pi, SIZEOF(fsPropInfo)) == -1)
- goto done;
-
- po = (fsPropOffset *) xalloc(SIZEOF(fsPropOffset) * pi.num_offsets);
- pd = (pointer) xalloc(pi.data_len);
- if (!po || !pd) {
- xfree(name);
- xfree(po);
- xfree(pd);
- xfree (binfo->pfi);
- binfo->pfi = NULL;
- binfo->errcode = AllocError;
- return AllocError;
- }
- err = _fs_read_pad(conn, (char *) po,
- (pi.num_offsets * SIZEOF(fsPropOffset)));
- if (err != -1)
+ rep = (fsListFontsWithXInfoReply *) fs_get_reply (conn, &ret);
+ if (rep == 0)
{
- if (conn->fsMajorVersion > 1)
- err = _fs_read(conn, (char *) pd, pi.data_len);
- else
- err = _fs_read_pad(conn, (char *) pd, pi.data_len);
+ if (ret == FSIO_BLOCK)
+ return StillWorking;
+ binfo->status = FS_LFWI_FINISHED;
+ err = AllocError;
+ goto done;
}
- if (err != -1 && conn->fsMajorVersion != 1)
+ /*
+ * Normal termination -- the list ends with a name of length 0
+ */
+ if (rep->nameLength == 0)
{
- err = _fs_read(conn, name, rep.nameLength);
- if (err != -1)
- err = _fs_drain_bytes(conn, padlength[(pi.data_len+rep.nameLength)&3]);
+#ifdef DEBUG
+ fprintf (stderr, "fs_read_list_info done\n");
+#endif
+ binfo->status = FS_LFWI_FINISHED;
+ err = BadFontName;
+ goto done;
}
- if (err == -1) {
- xfree(name);
- xfree(po);
- xfree(pd);
- xfree (binfo->pfi);
- binfo->pfi = NULL;
- goto done;
+ buf = (char *) rep + SIZEOF (fsListFontsWithXInfoReply);
+
+ /*
+ * The original FS implementation didn't match
+ * the spec, version 1 was respecified to match the FS.
+ * Version 2 matches the original intent
+ */
+ if (conn->fsMajorVersion <= 1)
+ {
+ memcpy (binfo->name, buf, rep->nameLength);
+ buf += _fs_pad_length (rep->nameLength);
+ }
+ pi = (fsPropInfo *) buf;
+ buf += SIZEOF (fsPropInfo);
+ po = (fsPropOffset *) buf;
+ buf += pi->num_offsets * SIZEOF (fsPropOffset);
+ pd = (pointer) buf;
+ buf += pi->data_len;
+ if (conn->fsMajorVersion > 1)
+ {
+ memcpy (binfo->name, buf, rep->nameLength);
+ buf += _fs_pad_length (rep->nameLength);
}
- if (_fs_convert_lfwi_reply(conn, binfo->pfi, &rep, &pi, po, pd) != Successful)
+#ifdef DEBUG
+ binfo->name[rep->nameLength] = '\0';
+ fprintf (stderr, "fs_read_list_info %s\n", binfo->name);
+#endif
+ err = _fs_convert_lfwi_reply(conn, &binfo->info, rep, pi, po, pd);
+ if (err != Successful)
{
- xfree(name);
- xfree(po);
- xfree(pd);
- xfree (binfo->pfi);
- binfo->pfi = NULL;
+ binfo->status = FS_LFWI_FINISHED;
goto done;
}
- xfree(po);
- xfree(pd);
- binfo->name = name;
- binfo->namelen = rep.nameLength;
- binfo->remaining = rep.nReplies;
+ binfo->namelen = rep->nameLength;
+ binfo->remaining = rep->nReplies;
binfo->status = FS_LFWI_REPLY;
- binfo->errcode = Suspended;
+
/* disable this font server until we've processed this response */
+ _fs_unmark_block (conn, FS_COMPLETE_REPLY);
FD_CLR(conn->fs_fd, &_fs_fd_mask);
-
- return Successful;
-
-done:
- binfo->status = FS_LFWI_FINISHED;
- binfo->errcode = BadFontName;
- binfo->name = (char *) 0;
- return Successful;
+done:
+ _fs_done_read (conn, rep->length << 2);
+ return err;
}
/* ARGSUSED */
static int
-fs_start_list_with_info(client, fpe, pattern, len, maxnames, pdata)
- pointer client;
- FontPathElementPtr fpe;
- char *pattern;
- int len;
- int maxnames;
- pointer *pdata;
-{
- FSBlockDataPtr blockrec;
- FSBlockedListInfoPtr blockedinfo;
+fs_start_list_with_info(pointer client, FontPathElementPtr fpe,
+ char *pattern, int len, int maxnames, pointer *pdata)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec;
+ FSBlockedListInfoPtr binfo;
fsListFontsWithXInfoReq req;
- FSFpePtr conn = (FSFpePtr) fpe->private;
- _fs_client_access (conn, client, FALSE);
- _fs_client_resolution(conn);
+ if (conn->blockState & FS_GIVE_UP)
+ return BadFontName;
/* make a new block record, and add it to the end of the list */
blockrec = fs_new_block_rec(fpe, client, FS_LIST_WITH_INFO);
if (!blockrec)
return AllocError;
- blockedinfo = (FSBlockedListInfoPtr) blockrec->data;
- bzero((char *) blockedinfo, sizeof(FSBlockedListInfoRec));
- blockedinfo->status = FS_LFWI_WAITING;
- blockedinfo->errcode = Suspended;
+
+ binfo = (FSBlockedListInfoPtr) blockrec->data;
+ bzero((char *) binfo, sizeof(FSBlockedListInfoRec));
+ binfo->status = FS_LFWI_WAITING;
+
+ if (conn->blockState & (FS_BROKEN_CONNECTION | FS_RECONNECTING))
+ {
+ _fs_pending_reply (conn);
+ return Suspended;
+ }
+
+ _fs_client_access (conn, client, FALSE);
+ _fs_client_resolution(conn);
/* send the request */
req.reqType = FS_ListFontsWithXInfo;
@@ -2481,6 +2440,8 @@ fs_start_list_with_info(client, fpe, pattern, len, maxnames, pdata)
(void) _fs_write(conn, (char *) &req, SIZEOF(fsListFontsWithXInfoReq));
(void) _fs_write_pad(conn, pattern, len);
+ blockrec->sequenceNumber = conn->current_seq;
+
#ifdef NCD
if (configData.ExtendedFontDiags) {
char buf[256];
@@ -2492,35 +2453,26 @@ fs_start_list_with_info(client, fpe, pattern, len, maxnames, pdata)
}
#endif
+ _fs_prepare_for_reply (conn);
return Successful;
}
/* ARGSUSED */
static int
-fs_next_list_with_info(client, fpe, namep, namelenp, pFontInfo, numFonts,
- private)
- pointer client;
- FontPathElementPtr fpe;
- char **namep;
- int *namelenp;
- FontInfoPtr *pFontInfo;
- int *numFonts;
- pointer private;
-{
- FSBlockDataPtr blockrec;
- FSBlockedListInfoPtr blockedinfo;
- FSFpePtr conn = (FSFpePtr) fpe->private;
+fs_next_list_with_info(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo, int *numFonts,
+ pointer private)
+{
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec;
+ FSBlockedListInfoPtr binfo;
+ int err;
/* see if the result is already there */
- blockrec = (FSBlockDataPtr) conn->blocked_requests;
- while (blockrec) {
- if (blockrec->type == FS_LIST_WITH_INFO &&
- blockrec->client == client) {
- blockedinfo = (FSBlockedListInfoPtr) blockrec->data;
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
+ if (blockrec->type == FS_LIST_WITH_INFO && blockrec->client == client)
break;
- }
- blockrec = blockrec->next;
- }
if (!blockrec)
{
@@ -2533,26 +2485,35 @@ fs_next_list_with_info(client, fpe, namep, namelenp, pFontInfo, numFonts,
return BadFontName;
}
- if (blockedinfo->status == FS_LFWI_WAITING)
+ binfo = (FSBlockedListInfoPtr) blockrec->data;
+
+ if (binfo->status == FS_LFWI_WAITING)
return Suspended;
- *namep = blockedinfo->name;
- *namelenp = blockedinfo->namelen;
- *pFontInfo = blockedinfo->pfi;
- *numFonts = blockedinfo->remaining;
+ *namep = binfo->name;
+ *namelenp = binfo->namelen;
+ *pFontInfo = &binfo->info;
+ *numFonts = binfo->remaining;
+
+ /* Restart reply processing from this font server */
FD_SET(conn->fs_fd, &_fs_fd_mask);
- if (blockedinfo->status == FS_LFWI_FINISHED) {
- int err = blockedinfo->errcode;
-
+ if (fs_reply_ready (conn))
+ _fs_mark_block (conn, FS_COMPLETE_REPLY);
+
+ err = blockrec->errcode;
+ switch (binfo->status) {
+ case FS_LFWI_FINISHED:
_fs_remove_block_rec(conn, blockrec);
- return err;
- }
- if (blockedinfo->status == FS_LFWI_REPLY) {
- blockedinfo->status = FS_LFWI_WAITING;
- return Successful;
- } else {
- return blockedinfo->errcode;
+ break;
+ case FS_LFWI_REPLY:
+ binfo->status = FS_LFWI_WAITING;
+ blockrec->errcode = StillWorking;
+ conn->blockedReplyTime = GetTimeInMillis () + FontServerRequestTimeout;
+ _fs_mark_block (conn, FS_PENDING_REPLY);
+ break;
}
+
+ return err;
}
/*
@@ -2560,17 +2521,15 @@ fs_next_list_with_info(client, fpe, namep, namelenp, pFontInfo, numFonts,
*/
static void
-fs_client_died(client, fpe)
- pointer client;
- FontPathElementPtr fpe;
+fs_client_died(pointer client, FontPathElementPtr fpe)
{
- FSFpePtr conn = (FSFpePtr) fpe->private;
- FSBlockDataPtr blockrec,
- depending;
- FSClientPtr *prev, cur;
- fsFreeACReq freeac;
+ FSFpePtr conn = (FSFpePtr) fpe->private;
+ FSBlockDataPtr blockrec,
+ depending;
+ FSClientPtr *prev, cur;
+ fsFreeACReq freeac;
- for (prev = &conn->clients; cur = *prev; prev = &cur->next)
+ for (prev = &conn->clients; (cur = *prev); prev = &cur->next)
{
if (cur->client == client) {
freeac.reqType = FS_FreeAC;
@@ -2583,36 +2542,17 @@ fs_client_died(client, fpe)
break;
}
}
- /* see if the result is already there */
- blockrec = (FSBlockDataPtr) conn->blocked_requests;
- while (blockrec) {
+ /* find a pending requests */
+ for (blockrec = conn->blockedRequests; blockrec; blockrec = blockrec->next)
if (blockrec->client == client)
break;
- blockrec = blockrec->next;
- }
+
if (!blockrec)
return;
- if (blockrec->type == FS_LIST_WITH_INFO)
- {
- FSBlockedListInfoPtr binfo;
- binfo = (FSBlockedListInfoPtr) blockrec->data;
- if (binfo->status == FS_LFWI_REPLY)
- FD_SET(conn->fs_fd, &_fs_fd_mask);
- if (binfo->name)
- {
- xfree(binfo->name);
- binfo->name = NULL;
- }
- if (binfo->pfi)
- {
- xfree(binfo->pfi->isStringProp);
- xfree(binfo->pfi->props);
- xfree(binfo->pfi);
- binfo->pfi = NULL;
- }
- }
+
/* replace the client pointers in this block rec with the chained one */
- if (depending = blockrec->depending) {
+ if ((depending = blockrec->depending))
+ {
blockrec->client = depending->client;
blockrec->depending = depending->depending;
blockrec = depending;
@@ -2621,20 +2561,22 @@ fs_client_died(client, fpe)
}
static void
-_fs_client_access (conn, client, sync)
- FSFpePtr conn;
- pointer client;
- Bool sync;
+_fs_client_access (FSFpePtr conn, pointer client, Bool sync)
{
FSClientPtr *prev, cur;
fsCreateACReq crac;
fsSetAuthorizationReq setac;
- fsGenericReply rep;
char *authorizations;
int authlen;
Bool new_cur = FALSE;
- for (prev = &conn->clients; cur = *prev; prev = &cur->next)
+#ifdef DEBUG
+ if (conn->blockState & (FS_RECONNECTING|FS_BROKEN_CONNECTION))
+ {
+ fprintf (stderr, "Sending requests without a connection\n");
+ }
+#endif
+ for (prev = &conn->clients; (cur = *prev); prev = &cur->next)
{
if (cur->client == client)
{
@@ -2678,15 +2620,6 @@ _fs_client_access (conn, client, sync)
_fs_add_req_log(conn, FS_CreateAC);
_fs_write(conn, (char *) &crac, sizeof (fsCreateACReq));
_fs_write(conn, authorizations, authlen);
- /* if we're synchronous, open_font will be confused by
- * the reply; eat it and continue
- */
- if (sync)
- {
- if (_fs_read(conn, (char *) &rep, sizeof (fsGenericReply)) == -1)
- return;
- fs_handle_unexpected(conn, &rep);
- }
/* ignore reply; we don't even care about it */
conn->curacid = 0;
cur->auth_generation = client_auth_generation(client);
@@ -2703,11 +2636,512 @@ _fs_client_access (conn, client, sync)
}
/*
+ * Poll a pending connect
+ */
+
+static int
+_fs_check_connect (FSFpePtr conn)
+{
+ int ret;
+
+ ret = _fs_poll_connect (conn->trans_conn, 0);
+ switch (ret) {
+ case FSIO_READY:
+ conn->fs_fd = _FontTransGetConnectionNumber (conn->trans_conn);
+ FD_SET (conn->fs_fd, &_fs_fd_mask);
+ break;
+ case FSIO_BLOCK:
+ break;
+ }
+ return ret;
+}
+
+/*
+ * Return an FSIO status while waiting for the completed connection
+ * reply to arrive
+ */
+
+static fsConnSetup *
+_fs_get_conn_setup (FSFpePtr conn, int *error, int *setup_len)
+{
+ int ret;
+ char *data;
+ int headlen;
+ int len;
+ fsConnSetup *setup;
+ fsConnSetupAccept *accept;
+
+ ret = _fs_start_read (conn, SIZEOF (fsConnSetup), &data);
+ if (ret != FSIO_READY)
+ {
+ *error = ret;
+ return 0;
+ }
+
+ setup = (fsConnSetup *) data;
+ if (setup->major_version > FS_PROTOCOL)
+ {
+ *error = FSIO_ERROR;
+ return 0;
+ }
+
+ headlen = (SIZEOF (fsConnSetup) +
+ (setup->alternate_len << 2) +
+ (setup->auth_len << 2));
+ /* On anything but Success, no extra data is sent */
+ if (setup->status != AuthSuccess)
+ {
+ len = headlen;
+ }
+ else
+ {
+ ret = _fs_start_read (conn, headlen + SIZEOF (fsConnSetupAccept), &data);
+ if (ret != FSIO_READY)
+ {
+ *error = ret;
+ return 0;
+ }
+ setup = (fsConnSetup *) data;
+ accept = (fsConnSetupAccept *) (data + headlen);
+ len = headlen + (accept->length << 2);
+ }
+ ret = _fs_start_read (conn, len, &data);
+ if (ret != FSIO_READY)
+ {
+ *error = ret;
+ return 0;
+ }
+ *setup_len = len;
+ return (fsConnSetup *) data;
+}
+
+static int
+_fs_send_conn_client_prefix (FSFpePtr conn)
+{
+ fsConnClientPrefix req;
+ int endian;
+ int ret;
+
+ /* send setup prefix */
+ endian = 1;
+ if (*(char *) &endian)
+ req.byteOrder = 'l';
+ else
+ req.byteOrder = 'B';
+
+ req.major_version = FS_PROTOCOL;
+ req.minor_version = FS_PROTOCOL_MINOR;
+
+/* XXX add some auth info here */
+ req.num_auths = 0;
+ req.auth_len = 0;
+ ret = _fs_write (conn, (char *) &req, SIZEOF (fsConnClientPrefix));
+ if (ret != FSIO_READY)
+ return FSIO_ERROR;
+ conn->blockedConnectTime = GetTimeInMillis () + FontServerRequestTimeout;
+ return ret;
+}
+
+static int
+_fs_recv_conn_setup (FSFpePtr conn)
+{
+ int ret;
+ fsConnSetup *setup;
+ FSFpeAltPtr alts;
+ int i, alt_len;
+ int setup_len;
+ char *alt_save, *alt_names;
+
+ setup = _fs_get_conn_setup (conn, &ret, &setup_len);
+ if (!setup)
+ return ret;
+ conn->current_seq = 0;
+ conn->fsMajorVersion = setup->major_version;
+ /*
+ * Create an alternate list from the initial server, but
+ * don't chain looking for alternates.
+ */
+ if (conn->alternate == 0)
+ {
+ /*
+ * free any existing alternates list, allowing the list to
+ * be updated
+ */
+ if (conn->alts)
+ {
+ xfree (conn->alts);
+ conn->alts = 0;
+ conn->numAlts = 0;
+ }
+ if (setup->num_alternates)
+ {
+ alts = (FSFpeAltPtr) xalloc (setup->num_alternates *
+ sizeof (FSFpeAltRec) +
+ (setup->alternate_len << 2));
+ if (alts)
+ {
+ alt_names = (char *) (setup + 1);
+ alt_save = (char *) (alts + setup->num_alternates);
+ for (i = 0; i < setup->num_alternates; i++)
+ {
+ alts[i].subset = alt_names[0];
+ alt_len = alt_names[1];
+ alts[i].name = alt_save;
+ memcpy (alt_save, alt_names + 2, alt_len);
+ alt_save[alt_len] = '\0';
+ alt_save += alt_len + 1;
+ alt_names += _fs_pad_length (alt_len + 2);
+ }
+ conn->numAlts = setup->num_alternates;
+ conn->alts = alts;
+ }
+ }
+ }
+ _fs_done_read (conn, setup_len);
+ if (setup->status != AuthSuccess)
+ return FSIO_ERROR;
+ return FSIO_READY;
+}
+
+static int
+_fs_open_server (FSFpePtr conn)
+{
+ int ret;
+ char *servername;
+
+ if (conn->alternate == 0)
+ servername = conn->servername;
+ else
+ servername = conn->alts[conn->alternate-1].name;
+ conn->trans_conn = _fs_connect (servername, &ret);
+ conn->blockedConnectTime = GetTimeInMillis () + FS_RECONNECT_WAIT;
+ return ret;
+}
+
+static char *
+_fs_catalog_name (char *servername)
+{
+ char *sp;
+
+ sp = strchr (servername, '/');
+ if (!sp)
+ return 0;
+ return strrchr (sp + 1, '/');
+}
+
+static int
+_fs_send_init_packets (FSFpePtr conn)
+{
+ fsSetResolutionReq srreq;
+ fsSetCataloguesReq screq;
+ int num_cats,
+ clen;
+ char *catalogues;
+ char *cat;
+ char len;
+ char *end;
+ int num_res;
+ FontResolutionPtr res;
+
+#define CATALOGUE_SEP '+'
+
+ res = GetClientResolutions(&num_res);
+ if (num_res)
+ {
+ srreq.reqType = FS_SetResolution;
+ srreq.num_resolutions = num_res;
+ srreq.length = (SIZEOF(fsSetResolutionReq) +
+ (num_res * SIZEOF(fsResolution)) + 3) >> 2;
+
+ _fs_add_req_log(conn, FS_SetResolution);
+ if (_fs_write(conn, (char *) &srreq, SIZEOF(fsSetResolutionReq)) != FSIO_READY)
+ return FSIO_ERROR;
+ if (_fs_write_pad(conn, (char *) res, (num_res * SIZEOF(fsResolution))) != FSIO_READY)
+ return FSIO_ERROR;
+ }
+
+ catalogues = 0;
+ if (conn->alternate != 0)
+ catalogues = _fs_catalog_name (conn->alts[conn->alternate-1].name);
+ if (!catalogues)
+ catalogues = _fs_catalog_name (conn->servername);
+
+ if (!catalogues)
+ {
+ conn->has_catalogues = FALSE;
+ return FSIO_READY;
+ }
+ conn->has_catalogues = TRUE;
+
+ /* turn cats into counted list */
+ catalogues++;
+
+ cat = catalogues;
+ num_cats = 0;
+ clen = 0;
+ while (*cat)
+ {
+ num_cats++;
+ end = strchr(cat, CATALOGUE_SEP);
+ if (!end)
+ end = cat + strlen (cat);
+ clen += (end - cat) + 1; /* length byte + string */
+ cat = end;
+ }
+
+ screq.reqType = FS_SetCatalogues;
+ screq.num_catalogues = num_cats;
+ screq.length = (SIZEOF(fsSetCataloguesReq) + clen + 3) >> 2;
+
+ _fs_add_req_log(conn, FS_SetCatalogues);
+ if (_fs_write(conn, (char *) &screq, SIZEOF(fsSetCataloguesReq)) != FSIO_READY)
+ return FSIO_ERROR;
+
+ while (*cat)
+ {
+ num_cats++;
+ end = strchr(cat, CATALOGUE_SEP);
+ if (!end)
+ end = cat + strlen (cat);
+ len = end - cat;
+ if (_fs_write (conn, &len, 1) != FSIO_READY)
+ return FSIO_ERROR;
+ if (_fs_write (conn, cat, (int) len) != FSIO_READY)
+ return FSIO_ERROR;
+ cat = end;
+ }
+
+ if (_fs_write (conn, "....", _fs_pad_length (clen) - clen) != FSIO_READY)
+ return FSIO_ERROR;
+
+ return FSIO_READY;
+}
+
+static int
+_fs_send_cat_sync (FSFpePtr conn)
+{
+ fsListCataloguesReq lcreq;
+
+ /*
+ * now sync up with the font server, to see if an error was generated
+ * by a bogus catalogue
+ */
+ lcreq.reqType = FS_ListCatalogues;
+ lcreq.length = (SIZEOF(fsListCataloguesReq)) >> 2;
+ lcreq.maxNames = 0;
+ lcreq.nbytes = 0;
+ _fs_add_req_log(conn, FS_SetCatalogues);
+ if (_fs_write(conn, (char *) &lcreq, SIZEOF(fsListCataloguesReq)) != FSIO_READY)
+ return FSIO_ERROR;
+ conn->blockedConnectTime = GetTimeInMillis () + FontServerRequestTimeout;
+ return FSIO_READY;
+}
+
+static int
+_fs_recv_cat_sync (FSFpePtr conn)
+{
+ fsGenericReply *reply;
+ fsError *error;
+ int err;
+ int ret;
+
+ reply = fs_get_reply (conn, &err);
+ if (!reply)
+ return err;
+
+ ret = FSIO_READY;
+ if (reply->type == FS_Error)
+ {
+ error = (fsError *) reply;
+ if (error->major_opcode == FS_SetCatalogues)
+ ret = FSIO_ERROR;
+ }
+ _fs_done_read (conn, reply->length << 2);
+ return ret;
+}
+
+static void
+_fs_close_server (FSFpePtr conn)
+{
+ _fs_unmark_block (conn, FS_PENDING_WRITE|FS_BROKEN_WRITE|FS_COMPLETE_REPLY|FS_BROKEN_CONNECTION);
+ if (conn->trans_conn)
+ {
+ _FontTransClose (conn->trans_conn);
+ conn->trans_conn = 0;
+ _fs_io_reinit (conn);
+ }
+ if (conn->fs_fd >= 0)
+ {
+ FD_CLR (conn->fs_fd, &_fs_fd_mask);
+ conn->fs_fd = -1;
+ }
+ conn->fs_conn_state = FS_CONN_UNCONNECTED;
+}
+
+static int
+_fs_do_setup_connection (FSFpePtr conn)
+{
+ int ret;
+
+ do
+ {
+#ifdef DEBUG
+ fprintf (stderr, "fs_do_setup_connection state %d\n", conn->fs_conn_state);
+#endif
+ switch (conn->fs_conn_state) {
+ case FS_CONN_UNCONNECTED:
+ ret = _fs_open_server (conn);
+ if (ret == FSIO_BLOCK)
+ conn->fs_conn_state = FS_CONN_CONNECTING;
+ break;
+ case FS_CONN_CONNECTING:
+ ret = _fs_check_connect (conn);
+ break;
+ case FS_CONN_CONNECTED:
+ ret = _fs_send_conn_client_prefix (conn);
+ break;
+ case FS_CONN_SENT_PREFIX:
+ ret = _fs_recv_conn_setup (conn);
+ break;
+ case FS_CONN_RECV_INIT:
+ ret = _fs_send_init_packets (conn);
+ if (conn->has_catalogues)
+ ret = _fs_send_cat_sync (conn);
+ break;
+ case FS_CONN_SENT_CAT:
+ if (conn->has_catalogues)
+ ret = _fs_recv_cat_sync (conn);
+ else
+ ret = FSIO_READY;
+ break;
+ default:
+ ret = FSIO_READY;
+ break;
+ }
+ switch (ret) {
+ case FSIO_READY:
+ if (conn->fs_conn_state < FS_CONN_RUNNING)
+ conn->fs_conn_state++;
+ break;
+ case FSIO_BLOCK:
+ if (TimeCmp (GetTimeInMillis (), <, conn->blockedConnectTime))
+ break;
+ ret = FSIO_ERROR;
+ /* fall through... */
+ case FSIO_ERROR:
+ _fs_close_server (conn);
+ /*
+ * Try the next alternate
+ */
+ if (conn->alternate < conn->numAlts)
+ {
+ conn->alternate++;
+ ret = FSIO_READY;
+ }
+ else
+ conn->alternate = 0;
+ break;
+ }
+ } while (conn->fs_conn_state != FS_CONN_RUNNING && ret == FSIO_READY);
+ if (ret == FSIO_READY)
+ conn->generation = ++generationCount;
+ return ret;
+}
+
+static int
+_fs_wait_connect (FSFpePtr conn)
+{
+ int ret;
+
+ for (;;)
+ {
+ ret = _fs_do_setup_connection (conn);
+ if (ret != FSIO_BLOCK)
+ break;
+ if (conn->fs_conn_state <= FS_CONN_CONNECTING)
+ ret = _fs_poll_connect (conn->trans_conn, 1000);
+ else
+ ret = _fs_wait_for_readable (conn, 1000);
+ if (ret == FSIO_ERROR)
+ break;
+ }
+ return ret;
+}
+
+/*
+ * Poll a connection in the process of reconnecting
+ */
+static void
+_fs_check_reconnect (FSFpePtr conn)
+{
+ int ret;
+
+ ret = _fs_do_setup_connection (conn);
+ switch (ret) {
+ case FSIO_READY:
+ _fs_unmark_block (conn, FS_RECONNECTING|FS_GIVE_UP);
+ _fs_restart_connection (conn);
+ break;
+ case FSIO_BLOCK:
+ break;
+ case FSIO_ERROR:
+ conn->brokenConnectionTime = GetTimeInMillis () + FS_RECONNECT_POLL;
+ break;
+ }
+}
+
+/*
+ * Start the reconnection process
+ */
+static void
+_fs_start_reconnect (FSFpePtr conn)
+{
+ if (conn->blockState & FS_RECONNECTING)
+ return;
+ conn->alternate = 0;
+ _fs_mark_block (conn, FS_RECONNECTING);
+ _fs_unmark_block (conn, FS_BROKEN_CONNECTION);
+ _fs_check_reconnect (conn);
+}
+
+
+static FSFpePtr
+_fs_init_conn (char *servername)
+{
+ FSFpePtr conn;
+
+ conn = xalloc (sizeof (FSFpeRec) + strlen (servername) + 1);
+ if (!conn)
+ return 0;
+ memset (conn, '\0', sizeof (FSFpeRec));
+ if (!_fs_io_init (conn))
+ {
+ xfree (conn);
+ return 0;
+ }
+ conn->servername = (char *) (conn + 1);
+ conn->fs_conn_state = FS_CONN_UNCONNECTED;
+ conn->fs_fd = -1;
+ strcpy (conn->servername, servername);
+ return conn;
+}
+
+static void
+_fs_free_conn (FSFpePtr conn)
+{
+ _fs_close_server (conn);
+ _fs_io_fini (conn);
+ if (conn->alts)
+ xfree (conn->alts);
+ xfree (conn);
+}
+
+/*
* called at server init time
*/
void
-fs_register_fpe_functions()
+fs_register_fpe_functions(void)
{
fs_font_type = RegisterFPEFunctions(fs_name_check,
fs_init_fpe,
@@ -2718,28 +3152,20 @@ fs_register_fpe_functions()
fs_list_fonts,
fs_start_list_with_info,
fs_next_list_with_info,
- fs_wakeup,
+ (WakeupFpeFunc)fs_wakeup,
fs_client_died,
_fs_load_glyphs,
- (int (*))0,
- (int (*))0,
- (void (*))0);
+ NULL,
+ NULL,
+ NULL);
}
static int
-check_fs_open_font(client, fpe, flags, name, namelen, format, fmask, id, ppfont,
- alias, non_cachable_font)
- pointer client;
- FontPathElementPtr fpe;
- Mask flags;
- char *name;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- int namelen;
- XID id;
- FontPtr *ppfont;
- char **alias;
- FontPtr non_cachable_font; /* Not used in this FPE */
+check_fs_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *ppfont,
+ char **alias, FontPtr non_cachable_font)
{
if (XpClientIsBitmapClient(client))
return (fs_open_font(client, fpe, flags, name, namelen, format,
@@ -2748,13 +3174,9 @@ check_fs_open_font(client, fpe, flags, name, namelen, format, fmask, id, ppfont,
}
static int
-check_fs_list_fonts(client, fpe, pattern, patlen, maxnames, newnames)
- pointer client;
- FontPathElementPtr fpe;
- char *pattern;
- int patlen;
- int maxnames;
- FontNamesPtr newnames;
+check_fs_list_fonts(pointer client, FontPathElementPtr fpe,
+ char *pattern, int patlen, int maxnames,
+ FontNamesPtr newnames)
{
if (XpClientIsBitmapClient(client))
return (fs_list_fonts(client, fpe, pattern, patlen, maxnames,
@@ -2763,13 +3185,9 @@ check_fs_list_fonts(client, fpe, pattern, patlen, maxnames, newnames)
}
static int
-check_fs_start_list_with_info(client, fpe, pattern, len, maxnames, pdata)
- pointer client;
- FontPathElementPtr fpe;
- char *pattern;
- int len;
- int maxnames;
- pointer *pdata;
+check_fs_start_list_with_info(pointer client, FontPathElementPtr fpe,
+ char *pattern, int len, int maxnames,
+ pointer *pdata)
{
if (XpClientIsBitmapClient(client))
return (fs_start_list_with_info(client, fpe, pattern, len, maxnames,
@@ -2778,15 +3196,10 @@ check_fs_start_list_with_info(client, fpe, pattern, len, maxnames, pdata)
}
static int
-check_fs_next_list_with_info(client, fpe, namep, namelenp, pFontInfo, numFonts,
- private)
- pointer client;
- FontPathElementPtr fpe;
- char **namep;
- int *namelenp;
- FontInfoPtr *pFontInfo;
- int *numFonts;
- pointer private;
+check_fs_next_list_with_info(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo, int *numFonts,
+ pointer private)
{
if (XpClientIsBitmapClient(client))
return (fs_next_list_with_info(client, fpe, namep, namelenp, pFontInfo,
@@ -2795,7 +3208,7 @@ check_fs_next_list_with_info(client, fpe, namep, namelenp, pFontInfo, numFonts,
}
void
-check_fs_register_fpe_functions()
+check_fs_register_fpe_functions(void)
{
fs_font_type = RegisterFPEFunctions(fs_name_check,
fs_init_fpe,
@@ -2806,10 +3219,10 @@ check_fs_register_fpe_functions()
check_fs_list_fonts,
check_fs_start_list_with_info,
check_fs_next_list_with_info,
- fs_wakeup,
+ (WakeupFpeFunc)fs_wakeup,
fs_client_died,
_fs_load_glyphs,
- (int (*))0,
- (int (*))0,
- (void (*))0);
+ NULL,
+ NULL,
+ NULL);
}
diff --git a/src/fc/fserve.h b/src/fc/fserve.h
index b5370d0..9d69257 100644
--- a/src/fc/fserve.h
+++ b/src/fc/fserve.h
@@ -24,6 +24,7 @@
* Author: Dave Lemke, Network Computing Devices, Inc
*
*/
+/* $XFree86: xc/lib/font/fc/fserve.h,v 1.5 2001/04/05 17:42:28 dawes Exp $ */
#ifndef _FSERVE_H_
#define _FSERVE_H_
@@ -50,6 +51,12 @@
#define FS_LFWI_REPLY 1
#define FS_LFWI_FINISHED 2
+/* states of connection */
+#define FS_CONN_CLOSED 0
+#define FS_CONN_CONNECTING 1
+#define FS_CONN_READ_HEADER 2
+#define FS_CONN_READ_DATA 3
+
#define AccessDone 0x400
typedef struct _fs_font_data *FSFontDataPtr;
@@ -59,10 +66,31 @@ typedef struct _fs_blocked_list *FSBlockedListPtr;
typedef struct _fs_blocked_list_info *FSBlockedListInfoPtr;
typedef struct _fs_block_data *FSBlockDataPtr;
typedef struct _fs_font_table *FSFontTablePtr;
+typedef struct _fs_fpe_data *FSFpePtr;
typedef struct _fs_blocked_bitmaps *FSBlockedBitmapPtr;
typedef struct _fs_blocked_extents *FSBlockedExtentPtr;
-extern void fs_convert_char_info();
+extern void _fs_convert_char_info ( fsXCharInfo *src, xCharInfo *dst );
+extern void _fs_free_props (FontInfoPtr pfi);
+extern FontPtr fs_create_font (FontPathElementPtr fpe,
+ char *name,
+ int namelen,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask);
+
+extern int fs_load_all_glyphs ( FontPtr pfont );
+extern int _fs_load_glyphs ( pointer client, FontPtr pfont, Bool range_flag,
+ unsigned int nchars, int item_size,
+ unsigned char *data );
+
+/*
+ * These should be declared elsewhere, but I'm concerned that moving them
+ * would cause problems building other pieces
+ */
+extern FontPtr find_old_font (Font id);
+extern int set_font_authorizations (char **a, int *len, pointer client);
+extern long GetTimeInMillis (void);
+
#endif /* _FSERVE_H_ */
diff --git a/src/fc/fservestr.h b/src/fc/fservestr.h
index 891d4ae..20c85f6 100644
--- a/src/fc/fservestr.h
+++ b/src/fc/fservestr.h
@@ -23,6 +23,7 @@
*
* Author: Dave Lemke, Network Computing Devices, Inc
*/
+/* $XFree86: xc/lib/font/fc/fservestr.h,v 3.4 2001/07/25 15:04:56 dawes Exp $ */
#ifndef _FSERVESTR_H_
#define _FSERVESTR_H_
@@ -37,18 +38,21 @@
* font server private storage
*/
+typedef struct _fs_glyph {
+ struct _fs_glyph *next;
+} FSGlyphRec, *FSGlyphPtr;
typedef struct _fs_font {
CharInfoPtr pDefault;
CharInfoPtr encoding;
CharInfoPtr inkMetrics;
+ FSGlyphPtr glyphs;
} FSFontRec, *FSFontPtr;
/* FS special data for the font */
typedef struct _fs_font_data {
long fontid;
int generation; /* FS generation when opened */
- FontPathElementPtr fpe;
unsigned long glyphs_to_get; /* # glyphs remaining to be gotten */
/* Following data needed in case font needs to be reopened. */
@@ -65,22 +69,23 @@ typedef struct fs_clients_depending {
/* OpenFont specific data for blocked request */
typedef struct _fs_blocked_font {
- FontPtr pfont;
+ FontPtr pfont; /* must be first for fs_read_glyphs */
long fontid;
int state; /* how many of the replies have landed */
- int errcode;
int flags;
+ Bool freeFont; /* free this font on failure */
+ CARD16 queryInfoSequence;
+ CARD16 queryExtentsSequence;
+ CARD16 queryBitmapsSequence;
fsBitmapFormat format;
FSClientsDependingPtr clients_depending;
} FSBlockedFontRec;
/* LoadGlyphs data for blocked request */
typedef struct _fs_blocked_glyphs {
- FontPtr pfont;
+ FontPtr pfont; /* must be first for fs_read_glyphs */
int num_expected_ranges;
fsRange *expected_ranges;
- int errcode;
- Bool done;
FSClientsDependingPtr clients_depending;
} FSBlockedGlyphRec;
@@ -89,7 +94,6 @@ typedef struct _fs_blocked_extents {
FontPtr pfont;
fsRange *expected_ranges;
int nranges;
- Bool done;
unsigned long nextents;
fsXCharInfo *extents;
} FSBlockedExtentRec;
@@ -99,7 +103,6 @@ typedef struct _fs_blocked_bitmaps {
FontPtr pfont;
fsRange *expected_ranges;
int nranges;
- Bool done;
unsigned long size;
unsigned long nglyphs;
fsOffset32 *offsets;
@@ -109,29 +112,25 @@ typedef struct _fs_blocked_bitmaps {
/* state for blocked ListFonts */
typedef struct _fs_blocked_list {
FontNamesPtr names;
- int patlen;
- int errcode;
- Bool done;
} FSBlockedListRec;
/* state for blocked ListFontsWithInfo */
typedef struct _fs_blocked_list_info {
int status;
- char *name;
int namelen;
- FontInfoPtr pfi;
+ FontInfoRec info;
+ char name[256];
int remaining;
- int errcode;
} FSBlockedListInfoRec;
/* state for blocked request */
typedef struct _fs_block_data {
- int type; /* Open Font, LoadGlyphs, ListFonts,
- * ListWithInfo */
+ int type; /* Open Font, LoadGlyphs, ListFonts,
+ * ListWithInfo */
pointer client; /* who wants it */
- int sequence_number;/* expected */
- fsGenericReply header;
+ CARD16 sequenceNumber; /* expected */
pointer data; /* type specific data */
+ int errcode; /* Suspended, et al. */
struct _fs_block_data *depending; /* clients depending on this one */
struct _fs_block_data *next;
} FSBlockDataRec;
@@ -142,7 +141,7 @@ typedef struct _fs_reconnect {
} FSReconnectRec, *FSReconnectPtr;
-#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#if !defined(UNIXCPP) || defined(ANSICPP)
#define fsCat(x,y) x##_##y
#else
#define fsCat(x,y) x/**/_/**/y
@@ -184,5 +183,29 @@ typedef struct _fs_reconnect {
fsUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->maxbounds); \
fsUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->ink_maxbounds)
-
+extern void _fs_init_fontinfo ( FSFpePtr conn, FontInfoPtr pfi );
+extern int _fs_convert_props ( fsPropInfo *pi, fsPropOffset *po, pointer pd,
+ FontInfoPtr pfi );
+extern int _fs_convert_lfwi_reply ( FSFpePtr conn, FontInfoPtr pfi,
+ fsListFontsWithXInfoReply *fsrep,
+ fsPropInfo *pi, fsPropOffset *po,
+ pointer pd );
+extern int fs_build_range ( FontPtr pfont, Bool range_flag,
+ unsigned int count, int item_size,
+ unsigned char *data, int *nranges,
+ fsRange **ranges );
+extern void _fs_clean_aborted_loadglyphs ( FontPtr pfont,
+ int num_expected_ranges,
+ fsRange *expected_ranges );
+extern int _fs_check_extents ( FontPtr pfont, Mask flags, int nranges,
+ fsRange *range, FSBlockDataPtr blockrec );
+extern int _fs_check_bitmaps ( FontPtr pfont, fsBitmapFormat format,
+ Mask flags, int nranges, fsRange *range,
+ FSBlockDataPtr blockrec );
+extern int _fs_get_glyphs ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs );
+extern void _fs_unload_font ( FontPtr pfont );
+extern void _fs_init_font ( FontPtr pfont );
+extern pointer fs_alloc_glyphs (FontPtr pFont, int size);
#endif /* _FSERVESTR_H_ */
diff --git a/src/fc/fsio.c b/src/fc/fsio.c
index 578d86a..b5d9de0 100644
--- a/src/fc/fsio.c
+++ b/src/fc/fsio.c
@@ -23,6 +23,7 @@
*
* Author: Dave Lemke, Network Computing Devices, Inc
*/
+/* $XFree86: xc/lib/font/fc/fsio.c,v 3.16 2002/05/31 18:45:49 dawes Exp $ */
/*
* font server i/o routines
*/
@@ -31,113 +32,84 @@
#define _WILLWINSOCK_
#endif
-#include "FS.h"
-#include "FSproto.h"
-
#include "X11/Xtrans.h"
#include "X11/Xpoll.h"
+#include "FS.h"
+#include "FSproto.h"
#include "fontmisc.h"
-#include "fsio.h"
+#include "fontstruct.h"
+#include "fservestr.h"
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
-#ifndef WIN32
+#if !defined(WIN32)
+#ifndef Lynx
#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
#endif
#include <errno.h>
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#endif
#ifdef WIN32
#define EWOULDBLOCK WSAEWOULDBLOCK
#undef EINTR
#define EINTR WSAEINTR
#endif
-/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
- * systems are broken and return EWOULDBLOCK when they should return EAGAIN
- */
-#ifdef WIN32
-#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
-#else
-#if defined(EAGAIN) && defined(EWOULDBLOCK)
-#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
-#else
-#ifdef EAGAIN
-#define ETEST() (errno == EAGAIN)
-#else
-#define ETEST() (errno == EWOULDBLOCK)
-#endif
-#endif
-#endif
-#ifdef WIN32
-#define ECHECK(err) (WSAGetLastError() == err)
-#define ESET(val) WSASetLastError(val)
-#else
-#define ECHECK(err) (errno == err)
-#define ESET(val) errno = val
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2PseudoSelect(n,r,w,x,t)
#endif
+
static int padlength[4] = {0, 3, 2, 1};
fd_set _fs_fd_mask;
-int _fs_wait_for_readable();
+static int
+_fs_resize (FSBufPtr buf, long size);
-#ifdef SIGNALRETURNSINT
-#define SIGNAL_T int
-#else
-#define SIGNAL_T void
-#endif
-
-/* ARGSUSED */
-static SIGNAL_T
-_fs_alarm(foo)
- int foo;
+static void
+_fs_downsize (FSBufPtr buf, long size);
+
+int
+_fs_poll_connect (XtransConnInfo trans_conn, int timeout)
{
- return;
+ fd_set w_mask;
+ struct timeval tv;
+ int fs_fd = _FontTransGetConnectionNumber (trans_conn);
+ int ret;
+
+ do
+ {
+ tv.tv_usec = 0;
+ tv.tv_sec = timeout;
+ FD_ZERO (&w_mask);
+ FD_SET (fs_fd, &w_mask);
+ ret = Select (fs_fd + 1, NULL, &w_mask, NULL, &tv);
+ } while (ret < 0 && ECHECK(EINTR));
+ if (ret == 0)
+ return FSIO_BLOCK;
+ if (ret < 0)
+ return FSIO_ERROR;
+ return FSIO_READY;
}
-static XtransConnInfo
-_fs_connect(servername, timeout)
- char *servername;
- int timeout;
+XtransConnInfo
+_fs_connect(char *servername, int *err)
{
- XtransConnInfo trans_conn; /* transport connection object */
- int ret = -1;
-#ifdef SIGALRM
- unsigned oldTime;
-
- SIGNAL_T(*oldAlarm) ();
-#endif
+ XtransConnInfo trans_conn; /* transport connection object */
+ int ret;
+ int i = 0;
+ int retries = 5;
/*
* Open the network connection.
*/
if( (trans_conn=_FontTransOpenCOTSClient(servername)) == NULL )
- {
- return (NULL);
- }
-
-#ifdef SIGALRM
- oldTime = alarm((unsigned) 0);
- oldAlarm = signal(SIGALRM, _fs_alarm);
- alarm((unsigned) timeout);
-#endif
-
- ret = _FontTransConnect(trans_conn,servername);
-
-#ifdef SIGALRM
- alarm((unsigned) 0);
- signal(SIGALRM, oldAlarm);
- alarm(oldTime);
-#endif
-
- if (ret < 0)
- {
- _FontTransClose(trans_conn);
- return (NULL);
- }
+ {
+ *err = FSIO_ERROR;
+ return 0;
+ }
/*
* Set the connection non-blocking since we use select() to block.
@@ -145,330 +117,310 @@ _fs_connect(servername, timeout)
_FontTransSetOption(trans_conn, TRANS_NONBLOCKING, 1);
- return trans_conn;
-}
-
-static int generationCount;
-
-/* ARGSUSED */
-static Bool
-_fs_setup_connection(conn, servername, timeout, copy_name_p)
- FSFpePtr conn;
- char *servername;
- int timeout;
- Bool copy_name_p;
-{
- fsConnClientPrefix prefix;
- fsConnSetup rep;
- int setuplength;
- fsConnSetupAccept conn_accept;
- int endian;
- int i;
- int alt_len;
- char *auth_data = NULL,
- *vendor_string = NULL,
- *alt_data = NULL,
- *alt_dst;
- FSFpeAltPtr alts;
- int nalts;
-
- if ((conn->trans_conn = _fs_connect(servername, 5)) == NULL)
- return FALSE;
-
- conn->fs_fd = _FontTransGetConnectionNumber (conn->trans_conn);
-
- conn->generation = ++generationCount;
+ do {
+ if (i == TRANS_TRY_CONNECT_AGAIN)
+ sleep(1);
+ i = _FontTransConnect(trans_conn,servername);
+ } while ((i == TRANS_TRY_CONNECT_AGAIN) && (retries-- > 0));
- /* send setup prefix */
- endian = 1;
- if (*(char *) &endian)
- prefix.byteOrder = 'l';
+ if (i < 0)
+ {
+ if (i == TRANS_IN_PROGRESS)
+ ret = FSIO_BLOCK;
+ else
+ ret = FSIO_ERROR;
+ }
else
- prefix.byteOrder = 'B';
-
- prefix.major_version = FS_PROTOCOL;
- prefix.minor_version = FS_PROTOCOL_MINOR;
+ ret = FSIO_READY;
-/* XXX add some auth info here */
- prefix.num_auths = 0;
- prefix.auth_len = 0;
-
- if (_fs_write(conn, (char *) &prefix, SIZEOF(fsConnClientPrefix)) == -1)
- return FALSE;
-
- /* read setup info */
- if (_fs_read(conn, (char *) &rep, SIZEOF(fsConnSetup)) == -1)
- return FALSE;
+ if (ret == FSIO_ERROR)
+ {
+ _FontTransClose(trans_conn);
+ trans_conn = 0;
+ }
- conn->fsMajorVersion = rep.major_version;
- if (rep.major_version > FS_PROTOCOL)
- return FALSE;
+ *err = ret;
+ return trans_conn;
+}
- alts = 0;
- /* parse alternate list */
- if ((nalts = rep.num_alternates)) {
- setuplength = rep.alternate_len << 2;
- alts = (FSFpeAltPtr) xalloc(nalts * sizeof(FSFpeAltRec) +
- setuplength);
- if (!alts) {
- _FontTransClose(conn->trans_conn);
- errno = ENOMEM;
- return FALSE;
- }
- alt_data = (char *) (alts + nalts);
- if (_fs_read(conn, (char *) alt_data, setuplength) == -1) {
- xfree(alts);
- return FALSE;
+int
+_fs_fill (FSFpePtr conn)
+{
+ long avail, need;
+ long bytes_read;
+ Bool waited = FALSE;
+
+ if (_fs_flush (conn) < 0)
+ return FSIO_ERROR;
+ /*
+ * Don't go overboard here; stop reading when we've
+ * got enough to satisfy the pending request
+ */
+ while ((need = conn->inNeed - (conn->inBuf.insert -
+ conn->inBuf.remove)) > 0)
+ {
+ avail = conn->inBuf.size - conn->inBuf.insert;
+ /*
+ * For SVR4 with a unix-domain connection, ETEST() after selecting
+ * readable means the server has died. To do this here, we look for
+ * two consecutive reads returning ETEST().
+ */
+ ESET (0);
+ bytes_read =_FontTransRead(conn->trans_conn,
+ conn->inBuf.buf + conn->inBuf.insert,
+ avail);
+ if (bytes_read > 0) {
+ conn->inBuf.insert += bytes_read;
+ waited = FALSE;
}
- alt_dst = alt_data;
- for (i = 0; i < nalts; i++) {
- alts[i].subset = alt_data[0];
- alt_len = alt_data[1];
- alts[i].name = alt_dst;
- memmove(alt_dst, alt_data + 2, alt_len);
- alt_dst[alt_len] = '\0';
- alt_dst += (alt_len + 1);
- alt_data += (2 + alt_len + padlength[(2 + alt_len) & 3]);
+ else
+ {
+ if (bytes_read == 0 || ETEST ())
+ {
+ if (!waited)
+ {
+ waited = TRUE;
+ if (_fs_wait_for_readable (conn, 0) == FSIO_BLOCK)
+ return FSIO_BLOCK;
+ continue;
+ }
+ }
+ _fs_connection_died (conn);
+ return FSIO_ERROR;
}
}
- if (conn->alts)
- xfree(conn->alts);
- conn->alts = alts;
- conn->numAlts = nalts;
-
- setuplength = rep.auth_len << 2;
- if (setuplength &&
- !(auth_data = (char *) xalloc((unsigned int) setuplength))) {
- _FontTransClose(conn->trans_conn);
- errno = ENOMEM;
- return FALSE;
- }
- if (_fs_read(conn, (char *) auth_data, setuplength) == -1) {
- xfree(auth_data);
- return FALSE;
- }
- if (rep.status != AuthSuccess) {
- xfree(auth_data);
- _FontTransClose(conn->trans_conn);
- errno = EPERM;
- return FALSE;
- }
- /* get rest */
- if (_fs_read(conn, (char *) &conn_accept, (long) SIZEOF(fsConnSetupAccept)) == -1) {
- xfree(auth_data);
- return FALSE;
- }
- if ((vendor_string = (char *)
- xalloc((unsigned) conn_accept.vendor_len + 1)) == NULL) {
- xfree(auth_data);
- _FontTransClose(conn->trans_conn);
- errno = ENOMEM;
- return FALSE;
- }
- if (_fs_read_pad(conn, (char *) vendor_string, conn_accept.vendor_len) == -1) {
- xfree(vendor_string);
- xfree(auth_data);
- return FALSE;
+ return FSIO_READY;
+}
+
+/*
+ * Make space and return whether data have already arrived
+ */
+
+int
+_fs_start_read (FSFpePtr conn, long size, char **buf)
+{
+ int ret;
+
+ conn->inNeed = size;
+ if (fs_inqueued(conn) < size)
+ {
+ if (_fs_resize (&conn->inBuf, size) != FSIO_READY)
+ {
+ _fs_connection_died (conn);
+ return FSIO_ERROR;
+ }
+ ret = _fs_fill (conn);
+ if (ret == FSIO_ERROR)
+ return ret;
+ if (ret == FSIO_BLOCK || fs_inqueued(conn) < size)
+ return FSIO_BLOCK;
}
- xfree(auth_data);
- xfree(vendor_string);
+ if (buf)
+ *buf = conn->inBuf.buf + conn->inBuf.remove;
+ return FSIO_READY;
+}
- if (copy_name_p)
+void
+_fs_done_read (FSFpePtr conn, long size)
+{
+ if (conn->inBuf.insert - conn->inBuf.remove < size)
{
- conn->servername = (char *) xalloc(strlen(servername) + 1);
- if (conn->servername == NULL)
- return FALSE;
- strcpy(conn->servername, servername);
+#ifdef DEBUG
+ fprintf (stderr, "_fs_done_read skipping to many bytes\n");
+#endif
+ return;
}
- else
- conn->servername = servername;
+ conn->inBuf.remove += size;
+ conn->inNeed -= size;
+ _fs_downsize (&conn->inBuf, FS_BUF_MAX);
+}
- return TRUE;
+long
+_fs_pad_length (long len)
+{
+ return len + padlength[len&3];
}
-static Bool
-_fs_try_alternates(conn, timeout)
- FSFpePtr conn;
- int timeout;
+int
+_fs_flush (FSFpePtr conn)
{
- int i;
+ long bytes_written;
+ long remain;
+
+ /* XXX - hack. The right fix is to remember that the font server
+ has gone away when we first discovered it. */
+ if (conn->fs_fd < 0)
+ return FSIO_ERROR;
- for (i = 0; i < conn->numAlts; i++)
- if (_fs_setup_connection(conn, conn->alts[i].name, timeout, TRUE))
- return TRUE;
- return FALSE;
+ while ((remain = conn->outBuf.insert - conn->outBuf.remove) > 0)
+ {
+ bytes_written = _FontTransWrite(conn->trans_conn,
+ conn->outBuf.buf + conn->outBuf.remove,
+ (int) remain);
+ if (bytes_written > 0)
+ {
+ conn->outBuf.remove += bytes_written;
+ }
+ else
+ {
+ if (bytes_written == 0 || ETEST ())
+ {
+ conn->brokenWriteTime = GetTimeInMillis () + FS_FLUSH_POLL;
+ _fs_mark_block (conn, FS_BROKEN_WRITE);
+ break;
+ }
+ if (!ECHECK (EINTR))
+ {
+ _fs_connection_died (conn);
+ return FSIO_ERROR;
+ }
+ }
+ }
+ if (conn->outBuf.remove == conn->outBuf.insert)
+ {
+ _fs_unmark_block (conn, FS_BROKEN_WRITE|FS_PENDING_WRITE);
+ if (conn->outBuf.size > FS_BUF_INC)
+ conn->outBuf.buf = xrealloc (conn->outBuf.buf, FS_BUF_INC);
+ conn->outBuf.remove = conn->outBuf.insert = 0;
+ }
+ return FSIO_READY;
}
-#define FS_OPEN_TIMEOUT 30
-#define FS_REOPEN_TIMEOUT 10
-
-FSFpePtr
-_fs_open_server(servername)
- char *servername;
+static int
+_fs_resize (FSBufPtr buf, long size)
{
- FSFpePtr conn;
+ char *new;
+ long new_size;
- conn = (FSFpePtr) xalloc(sizeof(FSFpeRec));
- if (!conn) {
- errno = ENOMEM;
- return (FSFpePtr) NULL;
- }
- bzero((char *) conn, sizeof(FSFpeRec));
- if (!_fs_setup_connection(conn, servername, FS_OPEN_TIMEOUT, TRUE)) {
- if (!_fs_try_alternates(conn, FS_OPEN_TIMEOUT)) {
- xfree(conn->alts);
- xfree(conn);
- return (FSFpePtr) NULL;
+ if (buf->remove)
+ {
+ if (buf->remove != buf->insert)
+ {
+ memmove (buf->buf,
+ buf->buf + buf->remove,
+ buf->insert - buf->remove);
}
+ buf->insert -= buf->remove;
+ buf->remove = 0;
}
- return conn;
+ if (buf->size - buf->remove < size)
+ {
+ new_size = ((buf->remove + size + FS_BUF_INC) / FS_BUF_INC) * FS_BUF_INC;
+ new = xrealloc (buf->buf, new_size);
+ if (!new)
+ return FSIO_ERROR;
+ buf->buf = new;
+ buf->size = new_size;
+ }
+ return FSIO_READY;
}
-Bool
-_fs_reopen_server(conn)
- FSFpePtr conn;
+static void
+_fs_downsize (FSBufPtr buf, long size)
{
- if (_fs_setup_connection(conn, conn->servername, FS_REOPEN_TIMEOUT, FALSE))
- return TRUE;
- if (_fs_try_alternates(conn, FS_REOPEN_TIMEOUT))
- return TRUE;
- return FALSE;
+ if (buf->insert == buf->remove)
+ {
+ buf->insert = buf->remove = 0;
+ if (buf->size > size)
+ {
+ buf->buf = xrealloc (buf->buf, size);
+ buf->size = size;
+ }
+ }
}
-/*
- * expects everything to be here. *not* to be called when reading huge
- * numbers of replies, but rather to get each chunk
- */
-int
-_fs_read(conn, data, size)
- FSFpePtr conn;
- char *data;
- unsigned long size;
+void
+_fs_io_reinit (FSFpePtr conn)
{
- long bytes_read;
-
- if (size == 0) {
-
-#ifdef DEBUG
- fprintf(stderr, "tried to read 0 bytes \n");
-#endif
+ conn->outBuf.insert = conn->outBuf.remove = 0;
+ _fs_downsize (&conn->outBuf, FS_BUF_INC);
+ conn->inBuf.insert = conn->inBuf.remove = 0;
+ _fs_downsize (&conn->inBuf, FS_BUF_MAX);
+}
- return 0;
- }
- ESET(0);
- while ((bytes_read = _FontTransRead(conn->trans_conn,
- data, (int) size)) != size) {
- if (bytes_read > 0) {
- size -= bytes_read;
- data += bytes_read;
- } else if (ETEST()) {
- /* in a perfect world, this shouldn't happen */
- /* ... but then, its less than perfect... */
- if (_fs_wait_for_readable(conn) == -1) { /* check for error */
- _fs_connection_died(conn);
- ESET(EPIPE);
- return -1;
- }
- ESET(0);
- } else if (ECHECK(EINTR)) {
- continue;
- } else { /* something bad happened */
- if (conn->fs_fd > 0)
- _fs_connection_died(conn);
- ESET(EPIPE);
- return -1;
- }
+Bool
+_fs_io_init (FSFpePtr conn)
+{
+ conn->outBuf.insert = conn->outBuf.remove = 0;
+ conn->outBuf.buf = xalloc (FS_BUF_INC);
+ if (!conn->outBuf.buf)
+ return FALSE;
+ conn->outBuf.size = FS_BUF_INC;
+
+ conn->inBuf.insert = conn->inBuf.remove = 0;
+ conn->inBuf.buf = xalloc (FS_BUF_INC);
+ if (!conn->inBuf.buf)
+ {
+ xfree (conn->outBuf.buf);
+ conn->outBuf.buf = 0;
+ return FALSE;
}
- return 0;
+ conn->inBuf.size = FS_BUF_INC;
+
+ return TRUE;
}
-int
-_fs_write(conn, data, size)
- FSFpePtr conn;
- char *data;
- unsigned long size;
+void
+_fs_io_fini (FSFpePtr conn)
{
- long bytes_written;
+ if (conn->outBuf.buf)
+ xfree (conn->outBuf.buf);
+ if (conn->inBuf.buf)
+ xfree (conn->inBuf.buf);
+}
+static int
+_fs_do_write(FSFpePtr conn, char *data, long len, long size)
+{
if (size == 0) {
-
#ifdef DEBUG
fprintf(stderr, "tried to write 0 bytes \n");
#endif
-
- return 0;
+ return FSIO_READY;
}
- /* XXX - hack. The right fix is to remember that the font server
- has gone away when we first discovered it. */
- if (!conn->trans_conn)
- return -1;
-
- ESET(0);
- while ((bytes_written = _FontTransWrite(conn->trans_conn,
- data, (int) size)) != size) {
- if (bytes_written > 0) {
- size -= bytes_written;
- data += bytes_written;
- } else if (ETEST()) {
- /* XXX -- we assume this can't happen */
-
-#ifdef DEBUG
- fprintf(stderr, "fs_write blocking\n");
-#endif
- } else if (ECHECK(EINTR)) {
- continue;
- } else { /* something bad happened */
- _fs_connection_died(conn);
- ESET(EPIPE);
- return -1;
+ if (conn->fs_fd == -1)
+ return FSIO_ERROR;
+
+ while (conn->outBuf.insert + size > conn->outBuf.size)
+ {
+ if (_fs_flush (conn) < 0)
+ return FSIO_ERROR;
+ if (_fs_resize (&conn->outBuf, size) < 0)
+ {
+ _fs_connection_died (conn);
+ return FSIO_ERROR;
}
}
- return 0;
+ memcpy (conn->outBuf.buf + conn->outBuf.insert, data, len);
+ conn->outBuf.insert += size;
+ _fs_mark_block (conn, FS_PENDING_WRITE);
+ return FSIO_READY;
}
+/*
+ * Write the indicated bytes
+ */
int
-_fs_read_pad(conn, data, len)
- FSFpePtr conn;
- char *data;
- int len;
+_fs_write (FSFpePtr conn, char *data, long len)
{
- char pad[3];
-
- if (_fs_read(conn, data, len) == -1)
- return -1;
-
- /* read the junk */
- if (padlength[len & 3]) {
- return _fs_read(conn, pad, padlength[len & 3]);
- }
- return 0;
+ return _fs_do_write (conn, data, len, len);
}
-
+
+/*
+ * Write the indicated bytes adding any appropriate pad
+ */
int
-_fs_write_pad(conn, data, len)
- FSFpePtr conn;
- char *data;
- int len;
+_fs_write_pad(FSFpePtr conn, char *data, long len)
{
- static char pad[3];
-
- if (_fs_write(conn, data, len) == -1)
- return -1;
-
- /* write the pad */
- if (padlength[len & 3]) {
- return _fs_write(conn, pad, padlength[len & 3]);
- }
- return 0;
+ return _fs_do_write (conn, data, len, len + padlength[len & 3]);
}
/*
* returns the amount of data waiting to be read
*/
int
-_fs_data_ready(conn)
- FSFpePtr conn;
+_fs_data_ready(FSFpePtr conn)
{
BytesReadable_t readable;
@@ -478,73 +430,65 @@ _fs_data_ready(conn)
}
int
-_fs_wait_for_readable(conn)
- FSFpePtr conn;
+_fs_wait_for_readable(FSFpePtr conn, int ms)
{
- fd_set r_mask;
- fd_set e_mask;
+ fd_set r_mask;
+ fd_set e_mask;
int result;
+ struct timeval tv;
-#ifdef DEBUG
- fprintf(stderr, "read would block\n");
-#endif
-
- do {
+ for (;;) {
+ if (conn->fs_fd < 0)
+ return FSIO_ERROR;
FD_ZERO(&r_mask);
FD_ZERO(&e_mask);
+ tv.tv_sec = ms / 1000;
+ tv.tv_usec = (ms % 1000) * 1000;
FD_SET(conn->fs_fd, &r_mask);
FD_SET(conn->fs_fd, &e_mask);
- result = Select(conn->fs_fd + 1, &r_mask, NULL, &e_mask, NULL);
- if (result == -1) {
+ result = Select(conn->fs_fd + 1, &r_mask, NULL, &e_mask, &tv);
+ if (result < 0)
+ {
if (ECHECK(EINTR) || ECHECK(EAGAIN))
continue;
else
- return -1;
+ return FSIO_ERROR;
}
- if (result && FD_ISSET(conn->fs_fd, &e_mask))
- return -1;
- } while (result <= 0);
-
- return 0;
+ if (result == 0)
+ return FSIO_BLOCK;
+ if (FD_ISSET(conn->fs_fd, &r_mask))
+ return FSIO_READY;
+ return FSIO_ERROR;
+ }
}
int
-_fs_set_bit(mask, fd)
- fd_set* mask;
- int fd;
+_fs_set_bit(fd_set *mask, int fd)
{
FD_SET(fd, mask);
return fd;
}
int
-_fs_is_bit_set(mask, fd)
- fd_set* mask;
- int fd;
+_fs_is_bit_set(fd_set *mask, int fd)
{
return FD_ISSET(fd, mask);
}
void
-_fs_bit_clear(mask, fd)
- fd_set* mask;
- int fd;
+_fs_bit_clear(fd_set *mask, int fd)
{
FD_CLR(fd, mask);
}
int
-_fs_any_bit_set(mask)
- fd_set* mask;
+_fs_any_bit_set(fd_set *mask)
{
return XFD_ANYSET(mask);
}
void
-_fs_or_bits(dst, m1, m2)
- fd_set* dst;
- fd_set* m1;
- fd_set* m2;
+_fs_or_bits(fd_set *dst, fd_set *m1, fd_set *m2)
{
#ifdef WIN32
int i;
@@ -564,49 +508,3 @@ _fs_or_bits(dst, m1, m2)
XFD_ORSET(dst, m1, m2);
#endif
}
-
-int
-_fs_drain_bytes(conn, len)
- FSFpePtr conn;
- int len;
-{
- char buf[128];
-
-#ifdef DEBUG
- fprintf(stderr, "draining wire\n");
-#endif
-
- while (len > 0) {
- if (_fs_read(conn, buf, (len < 128) ? len : 128) < 0)
- return -1;
- len -= 128;
- }
- return 0;
-}
-
-void
-_fs_drain_bytes_pad(conn, len)
- FSFpePtr conn;
- int len;
-{
- _fs_drain_bytes(conn, len);
-
- /* read the junk */
- if (padlength[len & 3]) {
- _fs_drain_bytes(conn, padlength[len & 3]);
- }
-}
-
-void
-_fs_eat_rest_of_error(conn, err)
- FSFpePtr conn;
- fsError *err;
-{
- int len = (err->length - (SIZEOF(fsGenericReply) >> 2)) << 2;
-
-#ifdef DEBUG
- fprintf(stderr, "clearing error\n");
-#endif
-
- _fs_drain_bytes(conn, len);
-}
diff --git a/src/fc/fsio.h b/src/fc/fsio.h
index dd33cdf..974ef4a 100644
--- a/src/fc/fsio.h
+++ b/src/fc/fsio.h
@@ -23,10 +23,12 @@
*
* Author: Dave Lemke, Network Computing Devices, Inc
*/
+/* $XFree86: xc/lib/font/fc/fsio.h,v 1.6 2001/01/17 19:43:29 dawes Exp $ */
#ifndef _FSIO_H_
#define _FSIO_H_
+#undef DEBUG
#define REQUEST_LOG_SIZE 100
typedef struct _fs_fpe_alternate {
@@ -43,18 +45,52 @@ typedef struct _fs_client_data {
int auth_generation;
} FSClientRec, *FSClientPtr;
-#define FS_RECONNECT_WAIT 5
-#define FS_MAX_RECONNECT_WAIT 80
+#define FS_RECONNECT_POLL 1000
+#define FS_RECONNECT_WAIT 5000
+#define FS_GIVEUP_WAIT 20000
+#define FS_REQUEST_TIMEOUT 20000
+#define FS_OPEN_TIMEOUT 30000
+#define FS_REOPEN_TIMEOUT 10000
+#define FS_FLUSH_POLL 1000
+
+typedef struct _fs_buf {
+ char *buf; /* data */
+ long size; /* sizeof data */
+ long insert; /* where to insert new data */
+ long remove; /* where to remove old data */
+} FSBufRec, *FSBufPtr;
+
+#define FS_BUF_INC 1024
+#define FS_BUF_MAX 32768
+
+#define FS_PENDING_WRITE 0x01 /* some write data is queued */
+#define FS_BROKEN_WRITE 0x02 /* writes are broken */
+#define FS_BROKEN_CONNECTION 0x04 /* connection is broken */
+#define FS_PENDING_REPLY 0x08 /* waiting for a reply */
+#define FS_GIVE_UP 0x10 /* font server declared useless */
+#define FS_COMPLETE_REPLY 0x20 /* complete reply ready */
+#define FS_RECONNECTING 0x40
+
+#define FS_CONN_UNCONNECTED 0
+#define FS_CONN_CONNECTING 1
+#define FS_CONN_CONNECTED 2
+#define FS_CONN_SENT_PREFIX 3
+#define FS_CONN_RECV_INIT 4
+#define FS_CONN_SENT_CAT 5
+#define FS_CONN_RUNNING 6
/* FS specific font FontPathElement data */
typedef struct _fs_fpe_data {
- int fs_fd;
+ FSFpePtr next; /* list of all active fs fpes */
+ int fs_fd; /* < 0 when not running */
+ int fs_conn_state; /* connection state */
int current_seq;
char *servername;
- char *requestedname; /* client's name for this connection */
+ Bool has_catalogues;
int generation;
int numAlts;
+ int alternate; /* which alternate is in use +1 */
int fsMajorVersion; /* font server major version number */
FSFpeAltPtr alts;
@@ -62,21 +98,90 @@ typedef struct _fs_fpe_data {
XID curacid;
#ifdef DEBUG
int reqindex;
- int reqbuffer[REQUEST_LOG_SIZE];
+ struct {
+ int opcode;
+ int sequence;
+ } reqbuffer[REQUEST_LOG_SIZE];
#endif
+ FSBufRec outBuf; /* request queue */
+ FSBufRec inBuf; /* reply queue */
+ long inNeed; /* amount needed for reply */
- int attemptReconnect;
-
-/* XXX massive crock to get around stupid #include interferences */
- pointer blocked_requests;
-/* Data for reconnect - put it here to avoid allocate failure nightmare */
- long time_to_try;
- long reconnect_delay;
- struct _fs_fpe_data *next_reconnect;
+ CARD32 blockState;
+ CARD32 blockedReplyTime; /* time to abort blocked read */
+ CARD32 brokenWriteTime; /* time to retry broken write */
+ CARD32 blockedConnectTime; /* time to abort blocked connect */
+ CARD32 brokenConnectionTime; /* time to retry broken connection */
+
+ FSBlockDataPtr blockedRequests;
+
struct _XtransConnInfo *trans_conn; /* transport connection object */
-} FSFpeRec, *FSFpePtr;
+} FSFpeRec;
+
+#define fs_outspace(conn) ((conn)->outBuf.size - (conn)->outBuf.insert)
+#define fs_outqueued(conn) ((conn)->outBuf.insert - (conn)->outBuf.remove)
+#define fs_inqueued(conn) ((conn)->inBuf.insert - (conn)->inBuf.remove)
+#define fs_needsflush(conn) (fs_outqueued(conn) != 0)
+#define fs_needsfill(conn) (fs_inqueued(conn) < (conn)->inNeed)
+#define fs_needsconnect(conn) ((conn)->fs_fd < 0)
+#define fs_data_read(conn) ((conn)->inBuf.insert - (conn)->inBuf.remove)
+
+#define FSIO_READY 1
+#define FSIO_BLOCK 0
+#define FSIO_ERROR -1
+
+extern Bool _fs_reopen_server ( FSFpePtr conn );
+extern int _fs_write ( FSFpePtr conn, char *data, long size );
+extern int _fs_write_pad ( FSFpePtr conn, char *data, long len );
+extern int _fs_data_ready ( FSFpePtr conn );
+extern int _fs_wait_for_readable ( FSFpePtr conn, int ms );
+extern int _fs_set_bit ( fd_set * mask, int fd );
+extern int _fs_is_bit_set ( fd_set * mask, int fd );
+extern void _fs_bit_clear ( fd_set * mask, int fd );
+extern int _fs_any_bit_set ( fd_set * mask );
+extern void _fs_or_bits ( fd_set * dst, fd_set * m1, fd_set * m2 );
+extern long _fs_pad_length (long len);
-FSFpePtr _fs_open_server();
-void _fs_bit_clear();
+extern void _fs_connection_died ( FSFpePtr conn );
+
+extern int _fs_fill (FSFpePtr conn);
+extern int _fs_flush (FSFpePtr conn);
+extern void _fs_mark_block (FSFpePtr conn, CARD32 mask);
+extern void _fs_unmark_block (FSFpePtr conn, CARD32 mask);
+extern void _fs_done_read (FSFpePtr conn, long size);
+extern void _fs_io_reinit (FSFpePtr conn);
+extern int _fs_start_read (FSFpePtr conn, long size, char **buf);
+extern Bool _fs_io_init (FSFpePtr conn);
+extern void _fs_io_fini (FSFpePtr conn);
+extern int _fs_poll_connect (XtransConnInfo trans_conn, int timeout);
+extern XtransConnInfo _fs_connect(char *servername, int *ret);
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#ifdef WIN32
+#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
+#else
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST() (errno == EAGAIN)
+#else
+#define ETEST() (errno == EWOULDBLOCK)
+#endif
+#endif
+#endif
+#ifdef WIN32
+#define ECHECK(err) (WSAGetLastError() == err)
+#define ESET(val) WSASetLastError(val)
+#else
+#ifdef ISC
+#define ECHECK(err) ((errno == err) || ETEST())
+#else
+#define ECHECK(err) (errno == err)
+#endif
+#define ESET(val) errno = val
+#endif
#endif /* _FSIO_H_ */
diff --git a/src/fc/fslibos.h b/src/fc/fslibos.h
index d666ea4..8ca2a8a 100644
--- a/src/fc/fslibos.h
+++ b/src/fc/fslibos.h
@@ -31,6 +31,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/fc/fslibos.h,v 3.7 2002/05/31 18:45:49 dawes Exp $ */
/*
* FSlib networking & os include file
@@ -56,8 +57,12 @@ from The Open Group.
#endif
#endif
#ifndef OPEN_MAX
-#ifdef SVR4
+#if defined(SVR4) || defined(__UNIXOS2__)
+#ifdef SCO325
+#define OPEN_MAX sysconf(_SC_OPEN_MAX)
+#else
#define OPEN_MAX 256
+#endif
#else
#include <sys/param.h>
#ifndef OPEN_MAX
diff --git a/src/fontfile/bitsource.c b/src/fontfile/bitsource.c
index ac77875..0230535 100644
--- a/src/fontfile/bitsource.c
+++ b/src/fontfile/bitsource.c
@@ -25,6 +25,7 @@ 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.4 2001/12/14 19:56:49 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -35,8 +36,7 @@ in this Software without prior written authorization from The Open Group.
BitmapSourcesRec FontFileBitmapSources;
Bool
-FontFileRegisterBitmapSource (fpe)
- FontPathElementPtr fpe;
+FontFileRegisterBitmapSource (FontPathElementPtr fpe)
{
FontPathElementPtr *new;
int i;
@@ -59,8 +59,7 @@ FontFileRegisterBitmapSource (fpe)
}
void
-FontFileUnregisterBitmapSource (fpe)
- FontPathElementPtr fpe;
+FontFileUnregisterBitmapSource (FontPathElementPtr fpe)
{
int i;
@@ -90,7 +89,7 @@ FontFileUnregisterBitmapSource (fpe)
* The bitmap sources in the new path will be registered by the init_func.
*/
void
-FontFileEmptyBitmapSource()
+FontFileEmptyBitmapSource(void)
{
if (FontFileBitmapSources.count == 0)
return;
@@ -102,16 +101,15 @@ FontFileEmptyBitmapSource()
}
int
-FontFileMatchBitmapSource (fpe, pFont, flags, entry, zeroPat, vals, format, fmask, noSpecificSize)
- FontPathElementPtr fpe;
- FontPtr *pFont;
- int flags;
- FontEntryPtr entry;
- FontNamePtr zeroPat;
- FontScalablePtr vals;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- Bool noSpecificSize;
+FontFileMatchBitmapSource (FontPathElementPtr fpe,
+ FontPtr *pFont,
+ int flags,
+ FontEntryPtr entry,
+ FontNamePtr zeroPat,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ Bool noSpecificSize)
{
int source;
FontEntryPtr zero;
diff --git a/src/fontfile/bufio.c b/src/fontfile/bufio.c
index 40293c5..19d61bf 100644
--- a/src/fontfile/bufio.c
+++ b/src/fontfile/bufio.c
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/fontfile/bufio.c,v 3.10 2002/05/31 18:45:49 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -37,16 +38,13 @@ from The Open Group.
#include <fontmisc.h>
#include <bufio.h>
#include <errno.h>
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#endif
BufFilePtr
-BufFileCreate (private, io, skip, close)
- char *private;
- int (*io)();
- int (*skip)();
- int (*close)();
+BufFileCreate (char *private,
+ int (*input)(BufFilePtr),
+ int (*output)(int, BufFilePtr),
+ int (*skip)(BufFilePtr, int),
+ int (*close)(BufFilePtr, int))
{
BufFilePtr f;
@@ -56,17 +54,18 @@ BufFileCreate (private, io, skip, close)
f->private = private;
f->bufp = f->buffer;
f->left = 0;
- f->io = io;
+ f->input = input;
+ f->output = output;
f->skip = skip;
+ f->eof = 0;
f->close = close;
return f;
}
-#define FileDes(f) ((int) (f)->private)
+#define FileDes(f) ((int)(long) (f)->private)
static int
-BufFileRawFill (f)
- BufFilePtr f;
+BufFileRawFill (BufFilePtr f)
{
int left;
@@ -81,9 +80,7 @@ BufFileRawFill (f)
}
static int
-BufFileRawSkip (f, count)
- BufFilePtr f;
- int count;
+BufFileRawSkip (BufFilePtr f, int count)
{
int curoff;
int fileoff;
@@ -115,8 +112,7 @@ BufFileRawSkip (f, count)
}
static int
-BufFileRawClose (f, doClose)
- BufFilePtr f;
+BufFileRawClose (BufFilePtr f, int doClose)
{
if (doClose)
close (FileDes (f));
@@ -124,16 +120,17 @@ BufFileRawClose (f, doClose)
}
BufFilePtr
-BufFileOpenRead (fd)
- int fd;
+BufFileOpenRead (int fd)
{
- return BufFileCreate ((char *) fd, BufFileRawFill, BufFileRawSkip, BufFileRawClose);
+#ifdef __UNIXOS2__
+ /* 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 (c, f)
- int c;
- BufFilePtr f;
+BufFileRawFlush (int c, BufFilePtr f)
{
int cnt;
@@ -148,22 +145,22 @@ BufFileRawFlush (c, f)
}
BufFilePtr
-BufFileOpenWrite (fd)
- int fd;
+BufFileOpenWrite (int fd)
{
BufFilePtr f;
- f = BufFileCreate ((char *) fd, BufFileRawFlush, 0, BufFileFlush);
+#ifdef __UNIXOS2__
+ /* 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 (f, b, n)
- BufFilePtr f;
- char *b;
- int n;
+BufFileRead (BufFilePtr f, char *b, int n)
{
int c, cnt;
cnt = n;
@@ -177,10 +174,7 @@ BufFileRead (f, b, n)
}
int
-BufFileWrite (f, b, n)
- BufFilePtr f;
- char *b;
- int n;
+BufFileWrite (BufFilePtr f, char *b, int n)
{
int cnt;
cnt = n;
@@ -192,18 +186,15 @@ BufFileWrite (f, b, n)
}
int
-BufFileFlush (f)
- BufFilePtr f;
+BufFileFlush (BufFilePtr f, int doClose)
{
if (f->bufp != f->buffer)
- return (*f->io) (BUFFILEEOF, f);
+ return (*f->output) (BUFFILEEOF, f);
return 0;
}
int
-BufFileClose (f, doClose)
- BufFilePtr f;
- int doClose;
+BufFileClose (BufFilePtr f, int doClose)
{
int ret;
ret = (*f->close) (f, doClose);
@@ -212,8 +203,7 @@ BufFileClose (f, doClose)
}
void
-BufFileFree (f)
- BufFilePtr f;
+BufFileFree (BufFilePtr f)
{
xfree (f);
}
diff --git a/src/fontfile/decompress.c b/src/fontfile/decompress.c
index aef4461..187254d 100644
--- a/src/fontfile/decompress.c
+++ b/src/fontfile/decompress.c
@@ -45,6 +45,7 @@ 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.5 2001/12/14 19:56:50 dawes Exp $ */
/*
* decompress - cat a compressed file
*/
@@ -88,8 +89,6 @@ static char_type magic_header[] = { "\037\235" }; /* 1F 9D */
# define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
#endif /* COMPATIBLE */
-static code_int getcode();
-
/*
* the next two codes should not be changed lightly, as they must not
* lie within the contiguous general code space.
@@ -132,11 +131,13 @@ static int hsize_table[] = {
69001 /* 16 bits - 95% occupancy */
};
-static int BufCompressedFill(), BufCompressedSkip(), BufCompressedClose();
+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 (f)
- BufFilePtr f;
+BufFilePushCompressed (BufFilePtr f)
{
int code;
int maxbits;
@@ -150,6 +151,8 @@ BufFilePushCompressed (f)
return 0;
}
code = BufFileGet (f);
+ if (code == BUFFILEEOF) return 0;
+
maxbits = code & BIT_MASK;
if (maxbits > BITS || maxbits < 12)
return 0;
@@ -184,13 +187,13 @@ BufFilePushCompressed (f)
*file->stackp++ = file->finchar;
return BufFileCreate ((char *) file,
BufCompressedFill,
+ 0,
BufCompressedSkip,
BufCompressedClose);
}
static int
-BufCompressedClose (f, doClose)
- BufFilePtr f;
+BufCompressedClose (BufFilePtr f, int doClose)
{
CompressedFile *file;
BufFilePtr raw;
@@ -203,8 +206,7 @@ BufCompressedClose (f, doClose)
}
static int
-BufCompressedFill (f)
- BufFilePtr f;
+BufCompressedFill (BufFilePtr f)
{
CompressedFile *file;
register char_type *stackp, *de_stack;
@@ -300,8 +302,7 @@ BufCompressedFill (f)
static char_type rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
static code_int
-getcode(file)
- CompressedFile *file;
+getcode(CompressedFile *file)
{
register code_int code;
register int r_off, bits;
@@ -375,9 +376,7 @@ getcode(file)
}
static int
-BufCompressedSkip (f, bytes)
- BufFilePtr f;
- int bytes;
+BufCompressedSkip (BufFilePtr f, int bytes)
{
int c;
while (bytes--)
@@ -390,9 +389,8 @@ BufCompressedSkip (f, bytes)
}
#ifdef TEST
-main (argc, argv)
- int argc;
- char **argv;
+int
+main (int argc, char *argv[])
{
BufFilePtr inputraw, input, output;
int c;
@@ -400,9 +398,10 @@ main (argc, argv)
inputraw = BufFileOpenRead (0);
input = BufFilePushCompressed (inputraw);
output = BufFileOpenWrite (1);
- while ((c = BufFileGet (input)) != -1)
+ while ((c = BufFileGet (input)) != BUFFILEEOF)
BufFilePut (c, output);
BufFileClose (input, FALSE);
BufFileClose (output, FALSE);
+ return 0;
}
#endif
diff --git a/src/fontfile/defaults.c b/src/fontfile/defaults.c
index 2738287..6425d20 100644
--- a/src/fontfile/defaults.c
+++ b/src/fontfile/defaults.c
@@ -25,6 +25,7 @@ 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.8 2001/12/14 19:56:50 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -62,8 +63,10 @@ in this Software without prior written authorization from The Open Group.
#define DEFAULT_SCAN_UNIT 1
#endif
-FontDefaultFormat (bit, byte, glyph, scan)
- int *bit, *byte, *glyph, *scan;
+#include "fntfilst.h"
+
+void
+FontDefaultFormat (int *bit, int *byte, int *glyph, int *scan)
{
*bit = DEFAULT_BIT_ORDER;
*byte = DEFAULT_BYTE_ORDER;
diff --git a/src/fontfile/dirfile.c b/src/fontfile/dirfile.c
index 82f0d10..5f90501 100644
--- a/src/fontfile/dirfile.c
+++ b/src/fontfile/dirfile.c
@@ -25,6 +25,7 @@ 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.15 2002/05/31 18:45:50 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -41,20 +42,23 @@ in this Software without prior written authorization from The Open Group.
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#endif
-static int ReadFontAlias();
+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 (directory, pdir)
- char *directory;
- FontDirectoryPtr *pdir;
+FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
{
char file_name[MAXFONTFILENAMELEN];
char font_name[MAXFONTNAMELEN];
char dir_file[MAXFONTFILENAMELEN];
+#ifdef FONTDIRATTRIB
+ char dir_path[MAXFONTFILENAMELEN];
+ char *ptr;
+#endif
FILE *file;
int count,
i,
@@ -64,8 +68,24 @@ FontFileReadDirectory (directory, pdir)
FontDirectoryPtr dir = NullFontDirectory;
+#ifdef FONTDIRATTRIB
+ /* Check for font directory attributes */
+#ifndef __UNIXOS2__
+ if ((ptr = strchr(directory, ':'))) {
+#else
+ /* OS/2 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);
+#else
strcpy(dir_file, directory);
- if (directory[strlen(directory) - 1] != '/')
+#endif
+ if (dir_file[strlen(dir_file) - 1] != '/')
strcat(dir_file, "/");
strcat(dir_file, FontDirFile);
file = fopen(dir_file, "r");
@@ -85,8 +105,14 @@ FontFileReadDirectory (directory, pdir)
dir->dir_mtime = statb.st_mtime;
if (format[0] == '\0')
sprintf(format, "%%%ds %%%d[^\n]\n",
- MAXFONTFILENAMELEN-1, MAXFONTNAMELEN-1);
+ MAXFONTFILENAMELEN-1, MAXFONTNAMELEN-1);
while ((count = fscanf(file, format, file_name, font_name)) != EOF) {
+#ifdef __UNIXOS2__
+ /* 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);
@@ -103,7 +129,11 @@ FontFileReadDirectory (directory, pdir)
} else if (errno != ENOENT) {
return BadFontPath;
}
+#ifdef FONTDIRATTRIB
+ status = ReadFontAlias(dir_path, FALSE, &dir);
+#else
status = ReadFontAlias(directory, FALSE, &dir);
+#endif
if (status != Successful) {
if (dir)
FontFileFreeDir (dir);
@@ -119,10 +149,9 @@ FontFileReadDirectory (directory, pdir)
}
Bool
-FontFileDirectoryChanged(dir)
- FontDirectoryPtr dir;
+FontFileDirectoryChanged(FontDirectoryPtr dir)
{
- char dir_file[MAXFONTNAMELEN];
+ char dir_file[MAXFONTFILENAMELEN];
struct stat statb;
strcpy (dir_file, dir->directory);
@@ -153,11 +182,10 @@ FontFileDirectoryChanged(dir)
*/
static Bool
-AddFileNameAliases(dir)
- FontDirectoryPtr dir;
+AddFileNameAliases(FontDirectoryPtr dir)
{
int i;
- char copy[MAXFONTNAMELEN];
+ char copy[MAXFONTFILENAMELEN];
char *fileName;
FontTablePtr table;
FontRendererPtr renderer;
@@ -198,29 +226,24 @@ AddFileNameAliases(dir)
* "font name \"With Double Quotes\" \\ and \\ back-slashes"
* works just fine.
*
- * A line beginning with a # denotes a newline-terminated comment.
+ * A line beginning with a ! denotes a newline-terminated comment.
*/
/*
* token types
*/
-static int lexAlias(), lexc();
-
#define NAME 0
#define NEWLINE 1
#define DONE 2
#define EALLOC 3
static int
-ReadFontAlias(directory, isFile, pdir)
- char *directory;
- Bool isFile;
- FontDirectoryPtr *pdir;
+ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir)
{
char alias[MAXFONTNAMELEN];
char font_name[MAXFONTNAMELEN];
- char alias_file[MAXFONTNAMELEN];
+ char alias_file[MAXFONTFILENAMELEN];
FILE *file;
FontDirectoryPtr dir;
int token;
@@ -279,12 +302,8 @@ ReadFontAlias(directory, isFile, pdir)
status = AllocError;
break;
case NAME:
- CopyISOLatin1Lowered((unsigned char *) alias,
- (unsigned char *) alias,
- strlen(alias));
- CopyISOLatin1Lowered((unsigned char *) font_name,
- (unsigned char *) lexToken,
- strlen(lexToken));
+ CopyISOLatin1Lowered(alias, alias, strlen(alias));
+ CopyISOLatin1Lowered(font_name, lexToken, strlen(lexToken));
if (!FontFileAddFontAlias (dir, alias, font_name))
status = AllocError;
break;
@@ -305,9 +324,7 @@ ReadFontAlias(directory, isFile, pdir)
static int charClass;
static int
-lexAlias(file, lexToken)
- FILE *file;
- char **lexToken;
+lexAlias(FILE *file, char **lexToken)
{
int c;
char *t;
@@ -370,6 +387,8 @@ lexAlias(file, lexToken)
break;
case Comment:
continue;
+ default:
+ break;
}
*t++ = c;
++count;
@@ -405,8 +424,7 @@ lexAlias(file, lexToken)
}
static int
-lexc(file)
- FILE *file;
+lexc(FILE *file)
{
int c;
@@ -429,6 +447,7 @@ lexc(file)
case '\t':
charClass = WHITE;
break;
+ case '\r':
case '\n':
charClass = NL;
break;
diff --git a/src/fontfile/ffcheck.c b/src/fontfile/ffcheck.c
index 6f29801..4de2a4b 100644
--- a/src/fontfile/ffcheck.c
+++ b/src/fontfile/ffcheck.c
@@ -25,43 +25,34 @@ 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.15 2001/12/14 19:56:51 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
*/
-/* $NCDId: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
+/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
-#include "fntfilst.h"
+#include "fntfilst.h"
+#include "bitmap.h"
+#ifdef LOADABLEFONTS
+#include "fontmod.h"
+#endif
/*
* Map FPE functions to renderer functions
*/
-extern int FontFileNameCheck();
-extern int FontFileInitFPE();
-extern int FontFileResetFPE();
-extern int FontFileFreeFPE();
-extern void FontFileCloseFont();
-
/* Here we must check the client to see if it has a context attached to
* it that allows us to access the printer fonts
*/
-int
-FontFileCheckOpenFont (client, fpe, flags, name, namelen, format, fmask,
- id, pFont, aliasName, non_cachable_font)
- pointer client;
- FontPathElementPtr fpe;
- int flags;
- char *name;
- int namelen;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- XID id;
- FontPtr *pFont;
- char **aliasName;
- FontPtr non_cachable_font;
+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,
@@ -69,28 +60,19 @@ FontFileCheckOpenFont (client, fpe, flags, name, namelen, format, fmask,
return BadFontName;
}
-int
-FontFileCheckListFonts (client, fpe, pat, len, max, names)
- pointer client;
- FontPathElementPtr fpe;
- char *pat;
- int len;
- int max;
- FontNamesPtr names;
+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;
}
-int
-FontFileCheckStartListFontsWithInfo(client, fpe, pat, len, max, privatep)
- pointer client;
- FontPathElementPtr fpe;
- char *pat;
- int len;
- int max;
- pointer *privatep;
+static int
+FontFileCheckStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
{
if (XpClientIsBitmapClient(client))
return FontFileStartListFontsWithInfo(client, fpe, pat, len,
@@ -98,16 +80,11 @@ FontFileCheckStartListFontsWithInfo(client, fpe, pat, len, max, privatep)
return BadFontName;
}
-int
-FontFileCheckListNextFontWithInfo(client, fpe, namep, namelenp, pFontInfo,
- numFonts, private)
- pointer client;
- FontPathElementPtr fpe;
- char **namep;
- int *namelenp;
- FontInfoPtr *pFontInfo;
- int *numFonts;
- pointer private;
+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,
@@ -115,14 +92,10 @@ FontFileCheckListNextFontWithInfo(client, fpe, namep, namelenp, pFontInfo,
return BadFontName;
}
-int
-FontFileCheckStartListFontsAndAliases(client, fpe, pat, len, max, privatep)
- pointer client;
- FontPathElementPtr fpe;
- char *pat;
- int len;
- int max;
- pointer *privatep;
+static int
+FontFileCheckStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
{
if (XpClientIsBitmapClient(client))
return FontFileStartListFontsAndAliases(client, fpe, pat, len,
@@ -130,16 +103,11 @@ FontFileCheckStartListFontsAndAliases(client, fpe, pat, len, max, privatep)
return BadFontName;
}
-int
-FontFileCheckListNextFontOrAlias(client, fpe, namep, namelenp, resolvedp,
- resolvedlenp, private)
- pointer client;
- FontPathElementPtr fpe;
- char **namep;
- int *namelenp;
- char **resolvedp;
- int *resolvedlenp;
- pointer private;
+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,
@@ -147,24 +115,51 @@ FontFileCheckListNextFontOrAlias(client, fpe, namep, namelenp, resolvedp,
return BadFontName;
}
-extern void FontFileEmptyBitmapSource();
-typedef int (*IntFunc) ();
+typedef int (*IntFunc) (void);
static int font_file_check_type;
void
-FontFileCheckRegisterFpeFunctions ()
+FontFileCheckRegisterFpeFunctions (void)
{
+#ifndef LOADABLEFONTS
BitmapRegisterFontFileFunctions ();
#ifndef LOWMEMFTPT
#ifndef CRAY
+#ifdef BUILD_SPEEDO
SpeedoRegisterFontFileFunctions ();
+#endif
+#ifdef BUILD_TYPE1
Type1RegisterFontFileFunctions();
#endif
+#endif
+#ifdef BUILD_CID
+ CIDRegisterFontFileFunctions();
+#endif
+#ifdef BUILD_FREETYPE
+ FreeTypeRegisterFontFileFunctions();
+#endif
+#ifdef BUILD_XTRUETYPE
+ XTrueTypeRegisterFontFileFunctions();
+#endif
#endif /* ifndef LOWMEMFTPT */
+#else
+
+ {
+ int i;
+
+ if (FontModuleList) {
+ for (i = 0; FontModuleList[i].name; i++) {
+ if (FontModuleList[i].initFunc)
+ FontModuleList[i].initFunc();
+ }
+ }
+ }
+#endif
+
font_file_check_type = RegisterFPEFunctions(FontFileNameCheck,
FontFileInitFPE,
FontFileFreeFPE,
@@ -174,9 +169,9 @@ FontFileCheckRegisterFpeFunctions ()
FontFileCheckListFonts,
FontFileCheckStartListFontsWithInfo,
FontFileCheckListNextFontWithInfo,
- (IntFunc) 0,
- (IntFunc) 0,
- (IntFunc) 0,
+ NULL,
+ NULL,
+ NULL,
FontFileCheckStartListFontsAndAliases,
FontFileCheckListNextFontOrAlias,
FontFileEmptyBitmapSource);
diff --git a/src/fontfile/fileio.c b/src/fontfile/fileio.c
index 43c84ab..8a7cb03 100644
--- a/src/fontfile/fileio.c
+++ b/src/fontfile/fileio.c
@@ -25,6 +25,7 @@ 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.10 2002/05/31 18:45:50 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -33,12 +34,11 @@ in this Software without prior written authorization from The Open Group.
#include <fntfilio.h>
#include <X11/Xos.h>
#ifndef O_BINARY
-#define O_BINARY 0
+#define O_BINARY O_RDONLY
#endif
FontFilePtr
-FontFileOpen (name)
- char *name;
+FontFileOpen (const char *name)
{
int fd;
int len;
@@ -54,7 +54,12 @@ FontFileOpen (name)
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);
@@ -75,8 +80,7 @@ FontFileOpen (name)
}
int
-FontFileClose (f)
- FontFilePtr f;
+FontFileClose (FontFilePtr f)
{
return BufFileClose ((BufFilePtr) f, TRUE);
}
diff --git a/src/fontfile/filewr.c b/src/fontfile/filewr.c
index d8ed5b5..8de8f26 100644
--- a/src/fontfile/filewr.c
+++ b/src/fontfile/filewr.c
@@ -25,6 +25,7 @@ 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.7 2002/05/31 18:45:50 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -34,12 +35,11 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Xos.h>
FontFilePtr
-FontFileOpenWrite (name)
- char *name;
+FontFileOpenWrite (const char *name)
{
int fd;
-#ifdef WIN32
+#if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)
fd = open (name, O_CREAT|O_TRUNC|O_RDWR|O_BINARY, 0666);
#else
fd = creat (name, 0666);
@@ -50,14 +50,13 @@ FontFileOpenWrite (name)
}
FontFilePtr
-FontFileOpenWriteFd (fd)
+FontFileOpenWriteFd (int fd)
{
return (FontFilePtr) BufFileOpenWrite (fd);
}
FontFilePtr
-FontFileOpenFd (fd)
- int fd;
+FontFileOpenFd (int fd)
{
return (FontFilePtr) BufFileOpenRead (fd);
}
diff --git a/src/fontfile/fontdir.c b/src/fontfile/fontdir.c
index beca5af..a2bd411 100644
--- a/src/fontfile/fontdir.c
+++ b/src/fontfile/fontdir.c
@@ -25,6 +25,7 @@ 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.19 2002/05/31 18:45:50 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -34,9 +35,7 @@ in this Software without prior written authorization from The Open Group.
#include <X11/keysym.h>
Bool
-FontFileInitTable (table, size)
- FontTablePtr table;
- int size;
+FontFileInitTable (FontTablePtr table, int size)
{
if (size)
{
@@ -53,14 +52,14 @@ FontFileInitTable (table, size)
}
void
-FontFileFreeEntry (entry)
- FontEntryPtr entry;
+FontFileFreeEntry (FontEntryPtr entry)
{
FontScalableExtraPtr extra;
int i;
if (entry->name.name)
xfree(entry->name.name);
+ entry->name.name = NULL;
switch (entry->type)
{
@@ -75,9 +74,11 @@ FontFileFreeEntry (entry)
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:
@@ -87,8 +88,7 @@ FontFileFreeEntry (entry)
}
void
-FontFileFreeTable (table)
- FontTablePtr table;
+FontFileFreeTable (FontTablePtr table)
{
int i;
@@ -98,21 +98,44 @@ FontFileFreeTable (table)
}
FontDirectoryPtr
-FontFileMakeDir(dirName, size)
- char *dirName;
- int size;
+FontFileMakeDir(char *dirName, int size)
{
FontDirectoryPtr dir;
int dirlen;
int needslash = 0;
+#ifdef FONTDIRATTRIB
+ char *attrib;
+ int attriblen;
+#endif
+#ifdef FONTDIRATTRIB
+#ifndef __UNIXOS2__
+ 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;
+ }
+#else
dirlen = strlen(dirName);
+#endif
if (dirName[dirlen - 1] != '/')
#ifdef NCD
if (dirlen) /* leave out slash for builtins */
#endif
needslash = 1;
+#ifdef FONTDIRATTRIB
+ dir = (FontDirectoryPtr) xalloc(sizeof *dir + dirlen + needslash + 1 +
+ (attriblen ? attriblen + 1 : 0));
+#else
dir = (FontDirectoryPtr) xalloc(sizeof *dir + dirlen + needslash + 1);
+#endif
if (!dir)
return (FontDirectoryPtr)0;
if (!FontFileInitTable (&dir->scalable, 0))
@@ -129,15 +152,25 @@ FontFileMakeDir(dirName, size)
dir->directory = (char *) (dir + 1);
dir->dir_mtime = 0;
dir->alias_mtime = 0;
+#ifdef FONTDIRATTRIB
+ 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);
+#else
strcpy(dir->directory, dirName);
+#endif
if (needslash)
strcat(dir->directory, "/");
return dir;
}
void
-FontFileFreeDir (dir)
- FontDirectoryPtr dir;
+FontFileFreeDir (FontDirectoryPtr dir)
{
FontFileFreeTable (&dir->scalable);
FontFileFreeTable (&dir->nonScalable);
@@ -145,9 +178,7 @@ FontFileFreeDir (dir)
}
FontEntryPtr
-FontFileAddEntry(table, prototype)
- FontTablePtr table;
- FontEntryPtr prototype;
+FontFileAddEntry(FontTablePtr table, FontEntryPtr prototype)
{
FontEntryPtr entry;
int newsize;
@@ -175,24 +206,56 @@ FontFileAddEntry(table, prototype)
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
-#ifdef NeedFunctionPrototypes
FontFileNameCompare(const void* a, const void* b)
-#else
-FontFileNameCompare(a, b)
- char *a,
- *b;
-#endif
{
FontEntryPtr a_name = (FontEntryPtr) a,
b_name = (FontEntryPtr) b;
- return strcmp(a_name->name.name, b_name->name.name);
+ return strcmpn(a_name->name.name, b_name->name.name);
}
void
-FontFileSortTable (table)
- FontTablePtr table;
+FontFileSortTable (FontTablePtr table)
{
if (!table->sorted) {
qsort((char *) table->entries, table->used, sizeof(FontEntryRec),
@@ -202,8 +265,7 @@ FontFileSortTable (table)
}
void
-FontFileSortDir(dir)
- FontDirectoryPtr dir;
+FontFileSortDir(FontDirectoryPtr dir)
{
FontFileSortTable (&dir->scalable);
FontFileSortTable (&dir->nonScalable);
@@ -225,19 +287,17 @@ FontFileSortDir(dir)
*/
#define isWild(c) ((c) == XK_asterisk || (c) == XK_question)
+#define isDigit(c) (XK_0 <= (c) && (c) <= XK_9)
static int
-SetupWildMatch(table, pat, leftp, rightp, privatep)
- FontTablePtr table;
- FontNamePtr pat;
- int *leftp,
- *rightp;
- int *privatep;
+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,
@@ -248,12 +308,17 @@ SetupWildMatch(table, pat, leftp, rightp, privatep)
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;
@@ -266,7 +331,10 @@ SetupWildMatch(table, pat, leftp, rightp, privatep)
*rightp = right;
return -1;
} else if (firstWild) {
- first = firstWild - name;
+ 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);
@@ -283,7 +351,7 @@ SetupWildMatch(table, pat, leftp, rightp, privatep)
} else {
while (left < right) {
center = (left + right) / 2;
- result = strcmp(name, table->entries[center].name.name);
+ result = strcmpn(name, table->entries[center].name.name);
if (result == 0)
return center;
if (result < 0)
@@ -298,9 +366,7 @@ SetupWildMatch(table, pat, leftp, rightp, privatep)
}
static int
-PatternMatch(pat, patdashes, string, stringdashes)
- char *pat;
- char *string;
+PatternMatch(char *pat, int patdashes, char *string, int stringdashes)
{
char c,
t;
@@ -360,9 +426,7 @@ PatternMatch(pat, patdashes, string, stringdashes)
}
int
-FontFileCountDashes (name, namelen)
- char *name;
- int namelen;
+FontFileCountDashes (char *name, int namelen)
{
int ndashes = 0;
@@ -373,8 +437,7 @@ FontFileCountDashes (name, namelen)
}
char *
-FontFileSaveString (s)
- char *s;
+FontFileSaveString (char *s)
{
char *n;
@@ -386,10 +449,8 @@ FontFileSaveString (s)
}
FontEntryPtr
-FontFileFindNameInScalableDir(table, pat, vals)
- FontTablePtr table;
- FontNamePtr pat;
- FontScalablePtr vals;
+FontFileFindNameInScalableDir(FontTablePtr table, FontNamePtr pat,
+ FontScalablePtr vals)
{
int i,
start,
@@ -417,11 +478,11 @@ FontFileFindNameInScalableDir(table, pat, vals)
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))
+ 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];
@@ -433,23 +494,15 @@ FontFileFindNameInScalableDir(table, pat, vals)
}
FontEntryPtr
-FontFileFindNameInDir(table, pat)
- FontTablePtr table;
- FontNamePtr pat;
+FontFileFindNameInDir(FontTablePtr table, FontNamePtr pat)
{
return FontFileFindNameInScalableDir(table, pat, (FontScalablePtr)0);
}
int
-FontFileFindNamesInScalableDir(table, pat, max, names, vals,
- alias_behavior, newmax)
- FontTablePtr table;
- FontNamePtr pat;
- int max;
- FontNamesPtr names;
- FontScalablePtr vals;
- int alias_behavior;
- int *newmax;
+FontFileFindNamesInScalableDir(FontTablePtr table, FontNamePtr pat, int max,
+ FontNamesPtr names, FontScalablePtr vals,
+ int alias_behavior, int *newmax)
{
int i,
start,
@@ -487,11 +540,11 @@ FontFileFindNamesInScalableDir(table, pat, max, names, vals,
cap = ~0; /* Calling code will have to see if true */
else
cap = 0;
- if (((vs & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
+ if ((((vs & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
(vs & POINTSIZE_MASK) == POINTSIZE_ARRAY) &&
- !(cap & CAP_MATRIX) ||
- (vs & CHARSUBSET_SPECIFIED) &&
- !(cap & CAP_CHARSUBSETTING))
+ !(cap & CAP_MATRIX)) ||
+ ((vs & CHARSUBSET_SPECIFIED) &&
+ !(cap & CAP_CHARSUBSETTING)))
continue;
}
@@ -534,11 +587,8 @@ FontFileFindNamesInScalableDir(table, pat, max, names, vals,
}
int
-FontFileFindNamesInDir(table, pat, max, names)
- FontTablePtr table;
- FontNamePtr pat;
- int max;
- FontNamesPtr names;
+FontFileFindNamesInDir(FontTablePtr table, FontNamePtr pat,
+ int max, FontNamesPtr names)
{
return FontFileFindNamesInScalableDir(table, pat, max, names,
(FontScalablePtr)0,
@@ -546,10 +596,7 @@ FontFileFindNamesInDir(table, pat, max, names)
}
Bool
-FontFileMatchName(name, length, pat)
- char *name;
- int length;
- FontNamePtr pat;
+FontFileMatchName(char *name, int length, FontNamePtr pat)
{
/* Perform a fontfile-type name match on a single name */
FontTableRec table;
@@ -573,17 +620,14 @@ FontFileMatchName(name, length, pat)
*/
Bool
-FontFileAddFontFile (dir, fontName, fileName)
- FontDirectoryPtr dir;
- char *fontName;
- char *fileName;
+FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
{
FontEntryRec entry;
FontScalableRec vals, zeroVals;
FontRendererPtr renderer;
FontEntryPtr existing;
FontScalableExtraPtr extra;
- FontEntryPtr bitmap, scalable;
+ FontEntryPtr bitmap = 0, scalable;
Bool isscale;
renderer = FontFileMatchRenderer (fileName);
@@ -610,6 +654,28 @@ FontFileAddFontFile (dir, fontName, fileName)
(vals.values_supplied & PIXELSIZE_MASK) != PIXELSIZE_ARRAY &&
(vals.values_supplied & POINTSIZE_MASK) != POINTSIZE_ARRAY &&
!(vals.values_supplied & ENHANCEMENT_SPECIFY_MASK);
+#ifdef FONTDIRATTRIB
+#define UNSCALED_ATTRIB "unscaled"
+ /* For scalable fonts, check if the "unscaled" attribute is present */
+ if (isscale && 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);
+ }
+#endif
if (!isscale || (vals.values_supplied & SIZE_SPECIFY_MASK))
{
/* If the fontname says it is nonScalable, make sure that the
@@ -739,10 +805,7 @@ FontFileAddFontFile (dir, fontName, fileName)
}
Bool
-FontFileAddFontAlias (dir, aliasName, fontName)
- FontDirectoryPtr dir;
- char *aliasName;
- char *fontName;
+FontFileAddFontAlias (FontDirectoryPtr dir, char *aliasName, char *fontName)
{
FontEntryRec entry;
diff --git a/src/fontfile/fontfile.c b/src/fontfile/fontfile.c
index 5230a15..1e39413 100644
--- a/src/fontfile/fontfile.c
+++ b/src/fontfile/fontfile.c
@@ -25,11 +25,12 @@ 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.16 2002/05/31 18:45:50 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
*/
-/* $NCDId: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
+/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
#include "fntfilst.h"
@@ -37,11 +38,23 @@ in this Software without prior written authorization from The Open Group.
* 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 (name)
- char *name;
+FontFileNameCheck (char *name)
{
#ifndef NCD
+#ifdef __UNIXOS2__
+ /* 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
+ */
+ if (isalpha(*name) && name[1]==':')
+ return TRUE;
+#endif
return *name == '/';
#else
return ((strcmp(name, "built-ins") == 0) || (*name == '/'));
@@ -49,8 +62,7 @@ FontFileNameCheck (name)
}
int
-FontFileInitFPE (fpe)
- FontPathElementPtr fpe;
+FontFileInitFPE (FontPathElementPtr fpe)
{
int status;
FontDirectoryPtr dir;
@@ -71,12 +83,15 @@ FontFileInitFPE (fpe)
/* ARGSUSED */
int
-FontFileResetFPE (fpe)
- FontPathElementPtr fpe;
+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 */
@@ -94,8 +109,7 @@ FontFileResetFPE (fpe)
}
int
-FontFileFreeFPE (fpe)
- FontPathElementPtr fpe;
+FontFileFreeFPE (FontPathElementPtr fpe)
{
FontFileUnregisterBitmapSource (fpe);
FontFileFreeDir ((FontDirectoryPtr) fpe->private);
@@ -103,13 +117,9 @@ FontFileFreeFPE (fpe)
}
static int
-transfer_values_to_alias(entryname, entrynamelength, resolvedname,
- aliasName, vals)
- char *entryname;
- int entrynamelength;
- char *resolvedname;
- char **aliasName;
- FontScalablePtr vals;
+transfer_values_to_alias(char *entryname, int entrynamelength,
+ char *resolvedname,
+ char **aliasName, FontScalablePtr vals)
{
static char aliasname[MAXFONTNAMELEN];
int nameok = 1, len;
@@ -117,6 +127,7 @@ transfer_values_to_alias(entryname, entrynamelength, resolvedname,
*aliasName = resolvedname;
if ((len = strlen(*aliasName)) <= MAXFONTNAMELEN &&
+ (entrynamelength < MAXFONTNAMELEN) &&
FontFileCountDashes (*aliasName, len) == 14)
{
FontScalableRec tmpVals;
@@ -158,7 +169,6 @@ transfer_values_to_alias(entryname, entrynamelength, resolvedname,
gotchas */
if (FontFileCompleteXLFD(&tmpVals2, &tmpVals2))
{
- double hypot();
tempmatrix[0] =
matrix[0] * tmpVals2.point_matrix[0] +
matrix[1] * tmpVals2.point_matrix[2];
@@ -219,19 +229,11 @@ transfer_values_to_alias(entryname, entrynamelength, resolvedname,
/* ARGSUSED */
int
-FontFileOpenFont (client, fpe, flags, name, namelen, format, fmask,
- id, pFont, aliasName, non_cachable_font)
- pointer client;
- FontPathElementPtr fpe;
- int flags;
- char *name;
- int namelen;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- XID id;
- FontPtr *pFont;
- char **aliasName;
- FontPtr non_cachable_font;
+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];
@@ -461,9 +463,7 @@ FontFileOpenFont (client, fpe, flags, name, namelen, format, fmask,
/* ARGSUSED */
void
-FontFileCloseFont (fpe, pFont)
- FontPathElementPtr fpe;
- FontPtr pFont;
+FontFileCloseFont (FontPathElementPtr fpe, FontPtr pFont)
{
FontEntryPtr entry;
@@ -484,14 +484,11 @@ FontFileCloseFont (fpe, pFont)
(*pFont->unload_font) (pFont);
}
-int
-FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format, fmask,
- non_cachable_font)
- FontPathElementPtr fpe;
- int flags;
- FontEntryPtr entry;
- FontPtr *pFont;
- FontPtr non_cachable_font;
+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];
@@ -514,21 +511,17 @@ FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format, fmask,
}
int
-FontFileOpenBitmap (fpe, pFont, flags, entry, format, fmask)
- FontPathElementPtr fpe;
- int flags;
- FontEntryPtr entry;
- FontPtr *pFont;
+FontFileOpenBitmap (FontPathElementPtr fpe, FontPtr *pFont,
+ int flags, FontEntryPtr entry,
+ fsBitmapFormat format, fsBitmapFormatMask fmask)
{
return FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format, fmask,
(FontPtr)0);
}
-int
-FontFileGetInfoBitmap (fpe, pFontInfo, entry)
- FontPathElementPtr fpe;
- FontInfoPtr pFontInfo;
- FontEntryPtr entry;
+static int
+FontFileGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo,
+ FontEntryPtr entry)
{
FontBitmapEntryPtr bitmap;
char fileName[MAXFONTFILENAMELEN*2+1];
@@ -544,16 +537,10 @@ FontFileGetInfoBitmap (fpe, pFontInfo, entry)
}
static void
-_FontFileAddScalableNames(names, scaleNames, nameptr, zeroChars, vals, ranges,
- nranges, max)
- FontNamesPtr names;
- FontNamesPtr scaleNames;
- FontNamePtr nameptr;
- char *zeroChars;
- FontScalablePtr vals;
- fsRange *ranges;
- int nranges;
- int *max;
+_FontFileAddScalableNames(FontNamesPtr names, FontNamesPtr scaleNames,
+ FontNamePtr nameptr, char *zeroChars,
+ FontScalablePtr vals, fsRange *ranges,
+ int nranges, int *max)
{
int i;
FontScalableRec zeroVals, tmpVals;
@@ -667,14 +654,9 @@ _FontFileAddScalableNames(names, scaleNames, nameptr, zeroChars, vals, ranges,
/* ARGSUSED */
static int
-_FontFileListFonts (client, fpe, pat, len, max, names, mark_aliases)
- pointer client;
- FontPathElementPtr fpe;
- char *pat;
- int len;
- int max;
- FontNamesPtr names;
- int mark_aliases;
+_FontFileListFonts (pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max, FontNamesPtr names,
+ int mark_aliases)
{
FontDirectoryPtr dir;
char lowerChars[MAXFONTNAMELEN], zeroChars[MAXFONTNAMELEN];
@@ -779,25 +761,16 @@ typedef struct _LFWIData {
} LFWIDataRec, *LFWIDataPtr;
int
-FontFileListFonts (client, fpe, pat, len, max, names)
- pointer client;
- FontPathElementPtr fpe;
- char *pat;
- int len;
- int max;
- FontNamesPtr names;
+FontFileListFonts (pointer client, FontPathElementPtr fpe, char *pat,
+ int len, int max, FontNamesPtr names)
{
return _FontFileListFonts (client, fpe, pat, len, max, names, 0);
}
int
-FontFileStartListFontsWithInfo(client, fpe, pat, len, max, privatep)
- pointer client;
- FontPathElementPtr fpe;
- char *pat;
- int len;
- int max;
- pointer *privatep;
+FontFileStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
{
LFWIDataPtr data;
int ret;
@@ -825,12 +798,9 @@ FontFileStartListFontsWithInfo(client, fpe, pat, len, max, privatep)
/* ARGSUSED */
static int
-FontFileListOneFontWithInfo (client, fpe, namep, namelenp, pFontInfo)
- pointer client;
- FontPathElementPtr fpe;
- char **namep;
- int *namelenp;
- FontInfoPtr *pFontInfo;
+FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo)
{
FontDirectoryPtr dir;
char lowerName[MAXFONTNAMELEN];
@@ -979,15 +949,10 @@ FontFileListOneFontWithInfo (client, fpe, namep, namelenp, pFontInfo)
}
int
-FontFileListNextFontWithInfo(client, fpe, namep, namelenp, pFontInfo,
- numFonts, private)
- pointer client;
- FontPathElementPtr fpe;
- char **namep;
- int *namelenp;
- FontInfoPtr *pFontInfo;
- int *numFonts;
- pointer private;
+FontFileListNextFontWithInfo(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo,
+ int *numFonts, pointer private)
{
LFWIDataPtr data = (LFWIDataPtr) private;
int ret;
@@ -1013,13 +978,9 @@ FontFileListNextFontWithInfo(client, fpe, namep, namelenp, pFontInfo,
}
int
-FontFileStartListFontsAndAliases(client, fpe, pat, len, max, privatep)
- pointer client;
- FontPathElementPtr fpe;
- char *pat;
- int len;
- int max;
- pointer *privatep;
+FontFileStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
{
LFWIDataPtr data;
int ret;
@@ -1046,15 +1007,9 @@ FontFileStartListFontsAndAliases(client, fpe, pat, len, max, privatep)
}
int
-FontFileListNextFontOrAlias(client, fpe, namep, namelenp, resolvedp,
- resolvedlenp, private)
- pointer client;
- FontPathElementPtr fpe;
- char **namep;
- int *namelenp;
- char **resolvedp;
- int *resolvedlenp;
- pointer private;
+FontFileListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp, char **resolvedp,
+ int *resolvedlenp, pointer private)
{
LFWIDataPtr data = (LFWIDataPtr) private;
int ret;
@@ -1094,12 +1049,11 @@ FontFileListNextFontOrAlias(client, fpe, namep, namelenp, resolvedp,
}
-extern void FontFileEmptyBitmapSource();
-typedef int (*IntFunc) ();
+typedef int (*IntFunc) (void);
static int font_file_type;
void
-FontFileRegisterLocalFpeFunctions ()
+FontFileRegisterLocalFpeFunctions (void)
{
font_file_type = RegisterFPEFunctions(FontFileNameCheck,
FontFileInitFPE,
@@ -1110,9 +1064,9 @@ FontFileRegisterLocalFpeFunctions ()
FontFileListFonts,
FontFileStartListFontsWithInfo,
FontFileListNextFontWithInfo,
- (IntFunc) 0,
- (IntFunc) 0,
- (IntFunc) 0,
+ NULL,
+ NULL,
+ NULL,
FontFileStartListFontsAndAliases,
FontFileListNextFontOrAlias,
FontFileEmptyBitmapSource);
diff --git a/src/fontfile/fontscale.c b/src/fontfile/fontscale.c
index 56ed691..8fb63e4 100644
--- a/src/fontfile/fontscale.c
+++ b/src/fontfile/fontscale.c
@@ -25,6 +25,7 @@ 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.10 2001/12/14 19:56:52 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -40,11 +41,8 @@ in this Software without prior written authorization from The Open Group.
#endif
Bool
-FontFileAddScaledInstance (entry, vals, pFont, bitmapName)
- FontEntryPtr entry;
- FontScalablePtr vals;
- FontPtr pFont;
- char *bitmapName;
+FontFileAddScaledInstance (FontEntryPtr entry, FontScalablePtr vals,
+ FontPtr pFont, char *bitmapName)
{
FontScalableEntryPtr scalable;
FontScalableExtraPtr extra;
@@ -75,8 +73,7 @@ FontFileAddScaledInstance (entry, vals, pFont, bitmapName)
/* Must call this after the directory is sorted */
void
-FontFileSwitchStringsToBitmapPointers (dir)
- FontDirectoryPtr dir;
+FontFileSwitchStringsToBitmapPointers (FontDirectoryPtr dir)
{
int s;
int b;
@@ -100,9 +97,7 @@ FontFileSwitchStringsToBitmapPointers (dir)
}
void
-FontFileRemoveScaledInstance (entry, pFont)
- FontEntryPtr entry;
- FontPtr pFont;
+FontFileRemoveScaledInstance (FontEntryPtr entry, FontPtr pFont)
{
FontScalableEntryPtr scalable;
FontScalableExtraPtr extra;
@@ -124,9 +119,7 @@ FontFileRemoveScaledInstance (entry, pFont)
}
Bool
-FontFileCompleteXLFD (vals, def)
- register FontScalablePtr vals;
- FontScalablePtr def;
+FontFileCompleteXLFD (FontScalablePtr vals, FontScalablePtr def)
{
FontResolutionPtr res;
int num_res;
@@ -247,7 +240,7 @@ FontFileCompleteXLFD (vals, def)
pixel_setsize_adjustment = (double)vals->x / (double)vals->y;
vals->pixel_matrix[0] *= pixel_setsize_adjustment;
- vals->values_supplied = vals->values_supplied & ~PIXELSIZE_MASK |
+ vals->values_supplied = (vals->values_supplied & ~PIXELSIZE_MASK) |
PIXELSIZE_SCALAR_NORMALIZED;
}
@@ -349,8 +342,7 @@ FontFileCompleteXLFD (vals, def)
}
static Bool
-MatchScalable (a, b)
- FontScalablePtr a, b;
+MatchScalable (FontScalablePtr a, FontScalablePtr b)
{
int i;
@@ -370,15 +362,15 @@ MatchScalable (a, b)
if (!(a->x == b->x &&
a->y == b->y &&
- (a->width == b->width || a->width == 0 || b->width == 0) &&
+ (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)) &&
+ ((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->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;
@@ -393,9 +385,8 @@ MatchScalable (a, b)
}
FontScaledPtr
-FontFileFindScaledInstance (entry, vals, noSpecificSize)
- FontEntryPtr entry;
- FontScalablePtr vals;
+FontFileFindScaledInstance (FontEntryPtr entry, FontScalablePtr vals,
+ int noSpecificSize)
{
FontScalableEntryPtr scalable;
FontScalableExtraPtr extra;
diff --git a/src/fontfile/gunzip.c b/src/fontfile/gunzip.c
index a303f21..21894d0 100644
--- a/src/fontfile/gunzip.c
+++ b/src/fontfile/gunzip.c
@@ -2,6 +2,7 @@
/* 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.5 2001/01/17 19:43:30 dawes Exp $ */
#include "fontmisc.h"
#include <bufio.h>
@@ -15,14 +16,13 @@ typedef struct _xzip_buf {
BufFilePtr f;
} xzip_buf;
-static int BufZipFileSkip(); /* f, count */
-static int BufZipFileFill(); /* read: f; write: char, f */
-static int BufZipFileClose(); /* f, flag */
-static int BufCheckZipHeader(); /* f */
+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 (f)
- BufFilePtr f;
+BufFilePushZIP (BufFilePtr f)
{
xzip_buf *x;
@@ -58,15 +58,15 @@ BufFilePushZIP (f)
return 0;
}
- return BufFileCreate(x,
+ return BufFileCreate((char *)x,
BufZipFileFill,
+ 0,
BufZipFileSkip,
BufZipFileClose);
}
-static int BufZipFileClose(f, flag)
- BufFilePtr f;
- int flag;
+static int
+BufZipFileClose(BufFilePtr f, int flag)
{
xzip_buf *x = (xzip_buf *)f->private;
inflateEnd (&(x->z));
@@ -84,8 +84,8 @@ static int BufZipFileClose(f, flag)
Z_STREAM_END, we then have 4bytes CRC and 4bytes length...
gzio.c:gzread shows most of the mechanism.
*/
-static int BufZipFileFill (f)
- BufFilePtr f;
+static int
+BufZipFileFill (BufFilePtr f)
{
xzip_buf *x = (xzip_buf *)f->private;
@@ -102,7 +102,8 @@ static int BufZipFileFill (f)
case Z_STREAM_END:
case Z_DATA_ERROR:
case Z_ERRNO:
- return BUFFILEEOF;
+ f->left = 0;
+ return BUFFILEEOF;
default:
return BUFFILEEOF;
}
@@ -148,9 +149,8 @@ static int BufZipFileFill (f)
}
/* there should be a BufCommonSkip... */
-static int BufZipFileSkip (f, c)
- BufFilePtr f;
- int c;
+static int
+BufZipFileSkip (BufFilePtr f, int c)
{
/* BufFileRawSkip returns the count unchanged.
BufCompressedSkip returns 0.
@@ -191,8 +191,8 @@ static int BufZipFileSkip (f, c)
#define RESERVED 0xE0 /* bits 5..7: reserved */
#define GET(f) do {c = BufFileGet(f); if (c == BUFFILEEOF) return c;} while(0)
-static int BufCheckZipHeader(f)
- BufFilePtr f;
+static int
+BufCheckZipHeader(BufFilePtr f)
{
int c, flags;
GET(f); if (c != 0x1f) return 1; /* magic 1 */
diff --git a/src/fontfile/printerfont.c b/src/fontfile/printerfont.c
index 5632aa5..6759e91 100644
--- a/src/fontfile/printerfont.c
+++ b/src/fontfile/printerfont.c
@@ -25,11 +25,12 @@ 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.5 2001/12/14 19:56:52 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
*/
-/* $NCDId: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
+/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
#include "fntfilst.h"
@@ -37,10 +38,6 @@ in this Software without prior written authorization from The Open Group.
* Map FPE functions to renderer functions
*/
-extern int FontFileInitFPE();
-extern int FontFileResetFPE();
-extern int FontFileFreeFPE();
-extern void FontFileCloseFont();
#define PRINTERPATHPREFIX "PRINTER:"
/* STUB
@@ -50,9 +47,8 @@ FontPathElementPtr fpe;
{ return 1; }
*/
-int
-PrinterFontNameCheck (name)
- char *name;
+static int
+PrinterFontNameCheck (char *name)
{
if (strncmp(name,PRINTERPATHPREFIX,strlen(PRINTERPATHPREFIX)) != 0)
return 0;
@@ -64,9 +60,8 @@ PrinterFontNameCheck (name)
#endif
}
-int
-PrinterFontInitFPE (fpe)
- FontPathElementPtr fpe;
+static int
+PrinterFontInitFPE (FontPathElementPtr fpe)
{
int status;
FontDirectoryPtr dir;
@@ -91,20 +86,12 @@ PrinterFontInitFPE (fpe)
* it that allows us to access the printer fonts
*/
-int
-PrinterFontOpenFont (client, fpe, flags, name, namelen, format, fmask,
- id, pFont, aliasName, non_cachable_font)
- pointer client;
- FontPathElementPtr fpe;
- int flags;
- char *name;
- int namelen;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- XID id;
- FontPtr *pFont;
- char **aliasName;
- FontPtr non_cachable_font;
+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,
@@ -112,28 +99,19 @@ PrinterFontOpenFont (client, fpe, flags, name, namelen, format, fmask,
return BadFontName;
}
-int
-PrinterFontListFonts (client, fpe, pat, len, max, names)
- pointer client;
- FontPathElementPtr fpe;
- char *pat;
- int len;
- int max;
- FontNamesPtr names;
+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;
}
-int
-PrinterFontStartListFontsWithInfo(client, fpe, pat, len, max, privatep)
- pointer client;
- FontPathElementPtr fpe;
- char *pat;
- int len;
- int max;
- pointer *privatep;
+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,
@@ -141,16 +119,11 @@ PrinterFontStartListFontsWithInfo(client, fpe, pat, len, max, privatep)
return BadFontName;
}
-int
-PrinterFontListNextFontWithInfo(client, fpe, namep, namelenp, pFontInfo,
- numFonts, private)
- pointer client;
- FontPathElementPtr fpe;
- char **namep;
- int *namelenp;
- FontInfoPtr *pFontInfo;
- int *numFonts;
- pointer private;
+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,
@@ -158,14 +131,10 @@ PrinterFontListNextFontWithInfo(client, fpe, namep, namelenp, pFontInfo,
return BadFontName;
}
-int
-PrinterFontStartListFontsAndAliases(client, fpe, pat, len, max, privatep)
- pointer client;
- FontPathElementPtr fpe;
- char *pat;
- int len;
- int max;
- pointer *privatep;
+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,
@@ -173,16 +142,11 @@ PrinterFontStartListFontsAndAliases(client, fpe, pat, len, max, privatep)
return BadFontName;
}
-int
-PrinterFontListNextFontOrAlias(client, fpe, namep, namelenp, resolvedp,
- resolvedlenp, private)
- pointer client;
- FontPathElementPtr fpe;
- char **namep;
- int *namelenp;
- char **resolvedp;
- int *resolvedlenp;
- pointer private;
+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,
@@ -190,12 +154,11 @@ PrinterFontListNextFontOrAlias(client, fpe, namep, namelenp, resolvedp,
return BadFontName;
}
-extern void FontFileEmptyBitmapSource();
-typedef int (*IntFunc) ();
+typedef int (*IntFunc) (void);
static int printer_font_type;
void
-PrinterFontRegisterFpeFunctions ()
+PrinterFontRegisterFpeFunctions (void)
{
/* what is the use of printer font type? */
printer_font_type = RegisterFPEFunctions(PrinterFontNameCheck,
@@ -207,9 +170,9 @@ PrinterFontRegisterFpeFunctions ()
PrinterFontListFonts,
PrinterFontStartListFontsWithInfo,
PrinterFontListNextFontWithInfo,
- (IntFunc) 0,
- (IntFunc) 0,
- (IntFunc) 0,
+ NULL,
+ NULL,
+ NULL,
PrinterFontStartListFontsAndAliases,
PrinterFontListNextFontOrAlias,
FontFileEmptyBitmapSource);
diff --git a/src/fontfile/register.c b/src/fontfile/register.c
index 8379f85..385d165 100644
--- a/src/fontfile/register.c
+++ b/src/fontfile/register.c
@@ -25,6 +25,7 @@ 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.15 2001/12/14 19:56:52 dawes Exp $ */
/*
* This is in a separate source file so that small programs
@@ -32,19 +33,55 @@ in this Software without prior written authorization from The Open Group.
* end up dragging in code from all the renderers, which is not small.
*/
+#include "fontmisc.h"
+#include "fntfilst.h"
+#include "bitmap.h"
+
+#ifdef LOADABLEFONTS
+#include "fontmod.h"
+#endif
+
void
-FontFileRegisterFpeFunctions()
+FontFileRegisterFpeFunctions(void)
{
+#ifndef LOADABLEFONTS
BitmapRegisterFontFileFunctions ();
#ifndef LOWMEMFTPT
#ifndef CRAY
+#ifdef BUILD_SPEEDO
SpeedoRegisterFontFileFunctions ();
+#endif
+#ifdef BUILD_TYPE1
Type1RegisterFontFileFunctions();
#endif
+#endif
+#ifdef BUILD_CID
+ CIDRegisterFontFileFunctions();
+#endif
+#ifdef BUILD_FREETYPE
+ FreeTypeRegisterFontFileFunctions();
+#endif
+#ifdef BUILD_XTRUETYPE
+ XTrueTypeRegisterFontFileFunctions();
+#endif
#endif /* ifndef LOWMEMFTPT */
+#else
+ {
+ int i;
+
+ if (FontModuleList) {
+ for (i = 0; FontModuleList[i].name; i++) {
+ if (FontModuleList[i].initFunc)
+ FontModuleList[i].initFunc();
+ }
+ }
+ }
+#endif
+
FontFileRegisterLocalFpeFunctions ();
}
+
diff --git a/src/fontfile/renderers.c b/src/fontfile/renderers.c
index c997f27..2db871d 100644
--- a/src/fontfile/renderers.c
+++ b/src/fontfile/renderers.c
@@ -25,39 +25,76 @@ 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
*/
#include "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
-FontFileRegisterRenderer (renderer)
- FontRendererPtr renderer;
+FontFilePriorityRegisterRenderer (FontRendererPtr renderer, int priority)
{
int i;
- FontRendererPtr *new;
+ struct _FontRenderersElement *new;
- for (i = 0; i < renderers.number; i++)
- if (!strcmp (renderers.renderers[i]->fileSuffix, renderer->fileSuffix))
- return TRUE;
- i = renderers.number + 1;
- new = (FontRendererPtr *) xrealloc (renderers.renderers, sizeof *new * i);
- if (!new)
- return FALSE;
- renderer->number = i - 1;
- renderers.renderers = new;
- renderers.renderers[i - 1] = renderer;
- renderers.number = i;
+ 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 (fileName)
- char *fileName;
+FontFileMatchRenderer (char *fileName)
{
int i;
int fileLen;
@@ -66,7 +103,7 @@ FontFileMatchRenderer (fileName)
fileLen = strlen (fileName);
for (i = 0; i < renderers.number; i++)
{
- r = renderers.renderers[i];
+ r = renderers.renderers[i].renderer;
if (fileLen >= r->fileSuffixLen &&
!strcmp (fileName + fileLen - r->fileSuffixLen, r->fileSuffix))
{
diff --git a/src/util/atom.c b/src/util/atom.c
index 140d774..3863c94 100644
--- a/src/util/atom.c
+++ b/src/util/atom.c
@@ -25,6 +25,7 @@ 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/util/atom.c,v 1.10 2002/09/24 20:52:48 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -52,8 +53,7 @@ static int reverseMapSize;
static Atom lastAtom;
static int
-Hash(string, len)
- char *string;
+Hash(char *string, int len)
{
int h;
@@ -66,7 +66,7 @@ Hash(string, len)
}
static int
-ResizeHashTable ()
+ResizeHashTable (void)
{
int newHashSize;
int newHashMask;
@@ -82,7 +82,9 @@ ResizeHashTable ()
newHashSize = hashSize * 2;
newHashTable = (AtomListPtr *) xalloc (newHashSize * sizeof (AtomListPtr));
if (!newHashTable) {
- fprintf(stderr, "ResizeHashTable(): Error: Couldn't allocate newHashTable (%d)\n", newHashSize * sizeof (AtomListPtr));
+ fprintf(stderr, "ResizeHashTable(): Error: Couldn't allocate"
+ " newHashTable (%ld)\n",
+ newHashSize * (unsigned long)sizeof (AtomListPtr));
return FALSE;
}
bzero ((char *) newHashTable, newHashSize * sizeof (AtomListPtr));
@@ -114,7 +116,7 @@ ResizeHashTable ()
}
static int
-ResizeReverseMap ()
+ResizeReverseMap (void)
{
int ret = TRUE;
if (reverseMapSize == 0)
@@ -123,15 +125,16 @@ ResizeReverseMap ()
reverseMapSize *= 2;
reverseMap = (AtomListPtr *) xrealloc (reverseMap, reverseMapSize * sizeof (AtomListPtr));
if (!reverseMap) {
- fprintf(stderr, "ResizeReverseMap(): Error: Couldn't reallocate reverseMap (%d)\n", reverseMapSize * sizeof(AtomListPtr));
+ fprintf(stderr, "ResizeReverseMap(): Error: Couldn't reallocate"
+ " reverseMap (%ld)\n",
+ reverseMapSize * (unsigned long)sizeof(AtomListPtr));
ret = FALSE;
}
return ret;
}
static int
-NameEqual (a, b, l)
- char *a, *b;
+NameEqual (const char *a, const char *b, int l)
{
while (l--)
if (*a++ != *b++)
@@ -140,14 +143,11 @@ NameEqual (a, b, l)
}
Atom
-MakeAtom(string, len, makeit)
- char *string;
- unsigned len;
- int makeit;
+MakeAtom(char *string, unsigned len, int makeit)
{
AtomListPtr a;
int hash;
- int h;
+ int h = 0;
int r;
hash = Hash (string, len);
@@ -181,7 +181,8 @@ MakeAtom(string, len, makeit)
return None;
a = (AtomListPtr) xalloc (sizeof (AtomListRec) + len + 1);
if (a == NULL) {
- fprintf(stderr, "MakeAtom(): Error: Couldn't allocate AtomListRec (%d)\n", sizeof (AtomListRec) + len + 1);
+ fprintf(stderr, "MakeAtom(): Error: Couldn't allocate AtomListRec"
+ " (%ld)\n", (unsigned long)sizeof (AtomListRec) + len + 1);
return None;
}
a->name = (char *) (a + 1);
@@ -214,17 +215,16 @@ MakeAtom(string, len, makeit)
return a->atom;
}
-int ValidAtom(atom)
- Atom atom;
+int
+ValidAtom(Atom atom)
{
return (atom != None) && (atom <= lastAtom);
}
char *
-NameForAtom(atom)
- Atom atom;
+NameForAtom(Atom atom)
{
if (atom != None && atom <= lastAtom)
return reverseMap[atom]->name;
- return 0;
+ return NULL;
}
diff --git a/src/util/fontaccel.c b/src/util/fontaccel.c
index b0e8b57..f922145 100644
--- a/src/util/fontaccel.c
+++ b/src/util/fontaccel.c
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/fontaccel.c,v 1.7 2001/12/14 19:56:56 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -34,9 +35,10 @@ from The Open Group.
#include "fontmisc.h"
#include "fontstruct.h"
+#include "fontutil.h"
-void FontComputeInfoAccelerators(pFontInfo)
- FontInfoPtr pFontInfo;
+void
+FontComputeInfoAccelerators(FontInfoPtr pFontInfo)
{
pFontInfo->noOverlap = FALSE;
if (pFontInfo->maxOverlap <= pFontInfo->minbounds.leftSideBearing)
@@ -80,8 +82,8 @@ void FontComputeInfoAccelerators(pFontInfo)
pFontInfo->inkInside = FALSE;
}
-int FontCouldBeTerminal(pFontInfo)
- FontInfoPtr pFontInfo;
+int
+FontCouldBeTerminal(FontInfoPtr pFontInfo)
{
if ((pFontInfo->minbounds.leftSideBearing >= 0) &&
(pFontInfo->maxbounds.rightSideBearing <= pFontInfo->maxbounds.characterWidth) &&
diff --git a/src/util/fontnames.c b/src/util/fontnames.c
index 939d531..cbd355a 100644
--- a/src/util/fontnames.c
+++ b/src/util/fontnames.c
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/fontnames.c,v 1.5 2001/12/14 19:56:56 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -38,8 +39,7 @@ from The Open Group.
#include "fontstruct.h"
void
-FreeFontNames(pFN)
- FontNamesPtr pFN;
+FreeFontNames(FontNamesPtr pFN)
{
int i;
@@ -54,8 +54,7 @@ FreeFontNames(pFN)
}
FontNamesPtr
-MakeFontNamesRecord(size)
- unsigned size;
+MakeFontNamesRecord(unsigned int size)
{
FontNamesPtr pFN;
@@ -84,10 +83,7 @@ MakeFontNamesRecord(size)
}
int
-AddFontNamesName(names, name, length)
- FontNamesPtr names;
- char *name;
- int length;
+AddFontNamesName(FontNamesPtr names, char *name, int length)
{
int index = names->nnames;
char *nelt;
diff --git a/src/util/fontutil.c b/src/util/fontutil.c
index c67be62..3bd5e51 100644
--- a/src/util/fontutil.c
+++ b/src/util/fontutil.c
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/fontutil.c,v 3.7 2001/12/14 19:56:56 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -35,6 +36,7 @@ from The Open Group.
#include "fontmisc.h"
#include "fontstruct.h"
#include "FSproto.h"
+#include "fontutil.h"
/* Define global here... doesn't hurt the servers, and avoids
unresolved references in font clients. */
@@ -43,13 +45,12 @@ static int defaultGlyphCachingMode = DEFAULT_GLYPH_CACHING_MODE;
int glyphCachingMode = DEFAULT_GLYPH_CACHING_MODE;
void
-GetGlyphs(font, count, chars, fontEncoding, glyphcount, glyphs)
- FontPtr font;
- unsigned long count;
- unsigned char *chars;
- FontEncoding fontEncoding;
- unsigned long *glyphcount; /* RETURN */
- CharInfoPtr *glyphs; /* RETURN */
+GetGlyphs(FontPtr font,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding fontEncoding,
+ unsigned long *glyphcount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
{
(*font->get_glyphs) (font, count, chars, fontEncoding, glyphcount, glyphs);
}
@@ -58,11 +59,10 @@ GetGlyphs(font, count, chars, fontEncoding, glyphcount, glyphs)
#define MAX(a,b) ((a)>(b)?(a):(b))
void
-QueryGlyphExtents(pFont, charinfo, count, info)
- FontPtr pFont;
- CharInfoPtr *charinfo;
- unsigned long count;
- ExtentInfoRec *info;
+QueryGlyphExtents(FontPtr pFont,
+ CharInfoPtr *charinfo,
+ unsigned long count,
+ ExtentInfoRec *info)
{
register unsigned long i;
xCharInfo *pCI;
@@ -131,11 +131,10 @@ QueryGlyphExtents(pFont, charinfo, count, info)
}
Bool
-QueryTextExtents(pFont, count, chars, info)
- FontPtr pFont;
- unsigned long count;
- unsigned char *chars;
- ExtentInfoRec *info;
+QueryTextExtents(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ ExtentInfoRec *info)
{
xCharInfo **charinfo;
unsigned long n;
@@ -158,11 +157,11 @@ QueryTextExtents(pFont, count, chars, info)
/* Do default character substitution as get_metrics doesn't */
#define IsNonExistentChar(ci) (!(ci) || \
- (ci)->ascent == 0 && \
+ ((ci)->ascent == 0 && \
(ci)->descent == 0 && \
(ci)->leftSideBearing == 0 && \
(ci)->rightSideBearing == 0 && \
- (ci)->characterWidth == 0)
+ (ci)->characterWidth == 0))
firstReal = n;
defc[0] = pFont->info.defaultCh >> 8;
@@ -191,8 +190,7 @@ QueryTextExtents(pFont, count, chars, info)
}
Bool
-ParseGlyphCachingMode(str)
- char *str;
+ParseGlyphCachingMode(char *str)
{
if (!strcmp(str, "none")) defaultGlyphCachingMode = CACHING_OFF;
else if (!strcmp(str, "all")) defaultGlyphCachingMode = CACHE_ALL_GLYPHS;
@@ -202,7 +200,7 @@ ParseGlyphCachingMode(str)
}
void
-InitGlyphCaching()
+InitGlyphCaching(void)
{
/* Set glyphCachingMode to the mode the server hopes to
support. DDX drivers that do not support the requested level
@@ -217,8 +215,7 @@ InitGlyphCaching()
* caching they can support.
*/
void
-SetGlyphCachingMode(newmode)
- int newmode;
+SetGlyphCachingMode(int newmode)
{
if ( (glyphCachingMode > newmode) && (newmode >= 0) )
glyphCachingMode = newmode;
@@ -230,16 +227,15 @@ SetGlyphCachingMode(newmode)
/* add_range(): Add range to a list of ranges, with coalescence */
int
-add_range(newrange, nranges, range, charset_subset)
-fsRange *newrange;
-int *nranges;
-fsRange **range;
-Bool charset_subset;
+add_range(fsRange *newrange,
+ int *nranges,
+ fsRange **range,
+ Bool charset_subset)
{
int first, last, middle;
unsigned long keymin, keymax;
- unsigned long ptrmin, ptrmax;
- fsRange *ptr, *ptr1, *ptr2, *endptr;
+ unsigned long ptrmin = 0, ptrmax = 0;
+ fsRange *ptr = NULL, *ptr1, *ptr2, *endptr;
/* There are two different ways to treat ranges:
@@ -257,7 +253,7 @@ Bool charset_subset;
/* If newrange covers multiple rows; break up the rows */
if (!charset_subset && newrange->min_char_high != newrange->max_char_high)
{
- int i, err;
+ int i, err = 0;
fsRange temprange;
for (i = newrange->min_char_high;
i <= newrange->max_char_high;
@@ -414,3 +410,31 @@ Bool charset_subset;
return Successful;
}
+
+/* It is difficult to find a good place for this. */
+#ifdef NEED_STRCASECMP
+int
+f_strcasecmp(const char *s1, const char *s2)
+{
+ char c1, c2;
+
+ if (*s1 == 0)
+ if (*s2 == 0)
+ return 0;
+ else
+ return 1;
+
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ while (c1 == c2) {
+ if (c1 == '\0')
+ return 0;
+ s1++;
+ s2++;
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ }
+ return c1 - c2;
+}
+#endif
+
diff --git a/src/util/fontxlfd.c b/src/util/fontxlfd.c
index f1245f6..3a2c93d 100644
--- a/src/util/fontxlfd.c
+++ b/src/util/fontxlfd.c
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/fontxlfd.c,v 3.15 2002/05/31 18:45:50 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -35,12 +36,11 @@ from The Open Group.
#include "fontmisc.h"
#include "fontstruct.h"
#include "fontxlfd.h"
+#include "fontutil.h"
#include <X11/Xos.h>
#include <math.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
-#if defined(X_NOT_STDC_ENV) || (defined(sony) && !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV))
+#if defined(sony) && !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV)
#define NO_LOCALE
#endif
#ifndef NO_LOCALE
@@ -50,9 +50,7 @@ from The Open Group.
#include <stdio.h> /* for sprintf() */
static char *
-GetInt(ptr, val)
- char *ptr;
- int *val;
+GetInt(char *ptr, int *val)
{
if (*ptr == '*') {
*val = -1;
@@ -75,9 +73,7 @@ static struct lconv *locale = 0;
static char *radix = ".", *plus = "+", *minus = "-";
static char *
-readreal(ptr, result)
-char *ptr;
-double *result;
+readreal(char *ptr, double *result)
{
char buffer[80], *p1, *p2;
@@ -112,26 +108,13 @@ double *result;
*p2 = 0;
/* Now we have something that strtod() can interpret... do it. */
-#ifndef X_NOT_STDC_ENV
*result = strtod(buffer, &p1);
/* Return NULL if failure, pointer past number if success */
return (p1 == buffer) ? (char *)0 : (ptr + (p1 - buffer));
-#else
- for (p1 = buffer; isspace(*p1); p1++)
- ;
- if (sscanf(p1, "%lf", result) != 1)
- return (char *)0;
- while (!isspace(*p1))
- p1++;
- return ptr + (p1 - buffer);
-#endif
}
static char *
-xlfd_double_to_text(value, buffer, space_required)
-double value;
-char *buffer;
-int space_required;
+xlfd_double_to_text(double value, char *buffer, int space_required)
{
char formatbuf[40];
register char *p1;
@@ -204,24 +187,95 @@ int space_required;
}
double
-xlfd_round_double(x)
-double x;
+xlfd_round_double(double x)
{
- /* Utility for XLFD users to round numbers to XLFD_NDIGITS
- significant digits. How do you round to n significant digits on
- a binary machine? Let printf() do it for you. */
- char formatbuf[40], buffer[40];
-
- sprintf(formatbuf, "%%.%dlg", XLFD_NDIGITS);
- sprintf(buffer, formatbuf, x);
- return atof(buffer);
+ /* Utility for XLFD users to round numbers to XLFD_NDIGITS
+ significant digits. How do you round to n significant digits on
+ a binary machine? */
+
+#if defined(i386) || defined(__i386__) || \
+ defined(ia64) || defined(__ia64__) || \
+ defined(__alpha__) || defined(__alpha) || \
+ defined(__hppa__) || \
+ defined(__x86_64__) || defined(__x86_64)
+#if !defined(__UNIXOS2__)
+#include <float.h>
+
+/* if we have IEEE 754 fp, we can round to binary digits... */
+
+#if (FLT_RADIX == 2) && (DBL_DIG == 15) && (DBL_MANT_DIG == 53)
+
+#ifndef M_LN2
+#define M_LN2 0.69314718055994530942
+#endif
+#ifndef M_LN10
+#define M_LN10 2.30258509299404568402
+#endif
+
+/* convert # of decimal digits to # of binary digits */
+#define XLFD_NDIGITS_2 ((int)(XLFD_NDIGITS * M_LN10 / M_LN2 + 0.5))
+
+ union conv_d {
+ double d;
+ unsigned char b[8];
+ } d;
+ int i,j,k,d_exp;
+
+ if (x == 0)
+ return x;
+
+ /* do minor sanity check for IEEE 754 fp and correct byte order */
+ d.d = 1.0;
+ if (sizeof(double) == 8 && d.b[7] == 0x3f && d.b[6] == 0xf0) {
+
+ /*
+ * this code will round IEEE 754 double to XLFD_NDIGITS_2 binary digits
+ */
+
+ d.d = x;
+ d_exp = (d.b[7] << 4) | (d.b[6] >> 4);
+
+ i = (DBL_MANT_DIG-XLFD_NDIGITS_2) >> 3;
+ j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07);
+ for (; i<7; i++) {
+ k = d.b[i] + j;
+ d.b[i] = k;
+ if (k & 0x100) j = 1;
+ else break;
+ }
+ if ((i==7) && ((d.b[6] & 0xf0) != ((d_exp<<4) & 0xf0))) {
+ /* mantissa overflow: increment exponent */
+ d_exp = (d_exp & 0x800 ) | ((d_exp & 0x7ff) + 1);
+ d.b[7] = d_exp >> 4;
+ d.b[6] = (d.b[6] & 0x0f) | (d_exp << 4);
+ }
+
+ i = (DBL_MANT_DIG-XLFD_NDIGITS_2) >> 3;
+ j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07);
+ d.b[i] &= ~(j-1);
+ for (;--i>=0;) d.b[i] = 0;
+
+ return d.d;
+ }
+ else
+#endif
+#endif /* !__UNIXOS2__ */
+#endif /* i386 || __i386__ */
+ {
+ /*
+ * If not IEEE 754: Let printf() do it for you.
+ */
+
+ char formatbuf[40], buffer[40];
+
+ sprintf(formatbuf, "%%.%dlg", XLFD_NDIGITS);
+ sprintf(buffer, formatbuf, x);
+ return atof(buffer);
+ }
}
static char *
-GetMatrix(ptr, vals, which)
-char *ptr;
-FontScalablePtr vals;
-int which;
+GetMatrix(char *ptr, FontScalablePtr vals, int which)
{
double *matrix;
@@ -298,10 +352,8 @@ int which;
}
-static void append_ranges(fname, nranges, ranges)
-char *fname;
-int nranges;
-fsRange *ranges;
+static void
+append_ranges(char *fname, int nranges, fsRange *ranges)
{
if (nranges)
{
@@ -325,10 +377,7 @@ fsRange *ranges;
}
Bool
-FontParseXLFDName(fname, vals, subst)
- char *fname;
- FontScalablePtr vals;
- int subst;
+FontParseXLFDName(char *fname, FontScalablePtr vals, int subst)
{
register char *ptr;
register char *ptr1,
@@ -532,15 +581,12 @@ FontParseXLFDName(fname, vals, subst)
return TRUE;
}
-fsRange *FontParseRanges(name, nranges)
-char *name;
-int *nranges;
+fsRange *FontParseRanges(char *name, int *nranges)
{
int n;
unsigned long l;
char *p1, *p2;
fsRange *result = (fsRange *)0;
- extern int add_range();
name = strchr(name, '-');
for (n = 1; name && n < 14; n++)
diff --git a/src/util/format.c b/src/util/format.c
index 615f0ee..c406009 100644
--- a/src/util/format.c
+++ b/src/util/format.c
@@ -50,19 +50,21 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/format.c,v 1.5 2001/12/14 19:56:57 dawes Exp $ */
#include "FSproto.h"
#include "font.h"
+#include "fontstruct.h"
+#include "fontutil.h"
int
-CheckFSFormat(format, fmask, bit_order, byte_order, scan, glyph, image)
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- int *bit_order,
- *byte_order,
- *scan,
- *glyph,
- *image;
+CheckFSFormat(fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ int *bit_order,
+ int *byte_order,
+ int *scan,
+ int *glyph,
+ int *image)
{
/* convert format to what the low levels want */
if (fmask & BitmapFormatMaskBit) {
diff --git a/src/util/miscutil.c b/src/util/miscutil.c
index 5db04a1..484e387 100644
--- a/src/util/miscutil.c
+++ b/src/util/miscutil.c
@@ -27,13 +27,11 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/miscutil.c,v 1.8 2001/12/14 19:56:57 dawes Exp $ */
#include <X11/Xosdefs.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#else
-char *malloc(), *realloc();
-#endif
+#include "fontmisc.h"
#define XK_LATIN1
#include <X11/keysymdef.h>
@@ -43,32 +41,36 @@ char *malloc(), *realloc();
long serverGeneration = 1;
-unsigned long *
-Xalloc (m)
+void *
+Xalloc (unsigned long m)
{
- return (unsigned long *) malloc (m);
+ return malloc (m);
}
-unsigned long *
-Xrealloc (n,m)
- unsigned long *n;
+void *
+Xrealloc (void *n, unsigned long m)
{
if (!n)
- return (unsigned long *) malloc (m);
+ return malloc (m);
else
- return (unsigned long *) realloc ((char *) n, m);
+ return realloc (n, m);
}
-void Xfree (n)
- unsigned long *n;
+void
+Xfree (void *n)
{
if (n)
- free ((char *) n);
+ free (n);
}
-void CopyISOLatin1Lowered (dst, src, len)
- char *dst, *src;
- int len;
+void *
+Xcalloc (unsigned long n)
+{
+ return calloc (n, 1);
+}
+
+void
+CopyISOLatin1Lowered (char *dst, char *src, int len)
{
register unsigned char *dest, *source;
@@ -88,6 +90,7 @@ void CopyISOLatin1Lowered (dst, src, len)
*dest = '\0';
}
-void register_fpe_functions ()
+void
+register_fpe_functions ()
{
}
diff --git a/src/util/patcache.c b/src/util/patcache.c
index 824255c..7b31016 100644
--- a/src/util/patcache.c
+++ b/src/util/patcache.c
@@ -25,6 +25,7 @@ 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/util/patcache.c,v 3.5 2001/12/14 19:56:57 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -62,8 +63,7 @@ typedef struct _FontPatternCache {
/* Empty cache (for rehash) */
void
-EmptyFontPatternCache (cache)
- FontPatternCachePtr cache;
+EmptyFontPatternCache (FontPatternCachePtr cache)
{
int i;
@@ -84,7 +84,7 @@ EmptyFontPatternCache (cache)
/* Create and initialize cache */
FontPatternCachePtr
-MakeFontPatternCache ()
+MakeFontPatternCache (void)
{
FontPatternCachePtr cache;
int i;
@@ -102,8 +102,7 @@ MakeFontPatternCache ()
/* toss cache */
void
-FreeFontPatternCache (cache)
- FontPatternCachePtr cache;
+FreeFontPatternCache (FontPatternCachePtr cache)
{
int i;
@@ -114,9 +113,7 @@ FreeFontPatternCache (cache)
/* compute id for string */
static int
-Hash (string, len)
- char *string;
- int len;
+Hash (const char *string, int len)
{
int hash;
@@ -130,11 +127,10 @@ Hash (string, len)
/* add entry */
void
-CacheFontPattern (cache, pattern, patlen, pFont)
- FontPatternCachePtr cache;
- char *pattern;
- int patlen;
- FontPtr pFont;
+CacheFontPattern (FontPatternCachePtr cache,
+ char *pattern,
+ int patlen,
+ FontPtr pFont)
{
FontPatternCacheEntryPtr e;
char *newpat;
@@ -177,10 +173,9 @@ CacheFontPattern (cache, pattern, patlen, pFont)
/* find matching entry */
FontPtr
-FindCachedFontPattern (cache, pattern, patlen)
- FontPatternCachePtr cache;
- char *pattern;
- int patlen;
+FindCachedFontPattern (FontPatternCachePtr cache,
+ char *pattern,
+ int patlen)
{
int hash;
int i;
@@ -200,9 +195,8 @@ FindCachedFontPattern (cache, pattern, patlen)
}
void
-RemoveCachedFontPattern (cache, pFont)
- FontPatternCachePtr cache;
- FontPtr pFont;
+RemoveCachedFontPattern (FontPatternCachePtr cache,
+ FontPtr pFont)
{
FontPatternCacheEntryPtr e;
int i;
diff --git a/src/util/private.c b/src/util/private.c
index 9cb58c6..ef7d48b 100644
--- a/src/util/private.c
+++ b/src/util/private.c
@@ -25,6 +25,7 @@ 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/util/private.c,v 1.8 2001/12/14 19:56:57 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -33,33 +34,64 @@ in this Software without prior written authorization from The Open Group.
#include "fontmisc.h"
#include "fontstruct.h"
-int _FontPrivateAllocateIndex;
+static int _FontPrivateAllocateIndex = 0;
int
-AllocateFontPrivateIndex ()
+AllocateFontPrivateIndex (void)
{
return _FontPrivateAllocateIndex++;
}
+FontPtr
+CreateFontRec (void)
+{
+ FontPtr pFont;
+ int size;
+
+ size = sizeof(FontRec) + (sizeof(pointer) * _FontPrivateAllocateIndex);
+
+ pFont = (FontPtr)xalloc(size);
+ bzero((char*)pFont, size);
+
+ if(pFont) {
+ pFont->maxPrivate = _FontPrivateAllocateIndex - 1;
+ if(_FontPrivateAllocateIndex)
+ pFont->devPrivates = (pointer)(&pFont[1]);
+ }
+
+ return pFont;
+}
+
+void DestroyFontRec (FontPtr pFont)
+{
+ if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1]))
+ xfree(pFont->devPrivates);
+ xfree(pFont);
+}
+
void
-ResetFontPrivateIndex ()
+ResetFontPrivateIndex (void)
{
_FontPrivateAllocateIndex = 0;
}
Bool
-_FontSetNewPrivate (pFont, n, ptr)
- FontPtr pFont;
- int n;
- pointer ptr;
+_FontSetNewPrivate (FontPtr pFont, int n, pointer ptr)
{
pointer *new;
- if (n > pFont->maxPrivate)
- {
- new = (pointer *) xrealloc (pFont->devPrivates, (n + 1) * sizeof (pointer));
- if (!new)
- return FALSE;
+ if (n > pFont->maxPrivate) {
+ if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1])) {
+ new = (pointer *) xrealloc (pFont->devPrivates, (n + 1) * sizeof (pointer));
+ if (!new)
+ return FALSE;
+ } else {
+ new = (pointer *) xalloc ((n + 1) * sizeof (pointer));
+ if (!new)
+ return FALSE;
+ if (pFont->devPrivates)
+ memcpy (new, pFont->devPrivates, (pFont->maxPrivate + 1) * sizeof (pointer));
+ }
pFont->devPrivates = new;
/* zero out new, uninitialized privates */
while(++pFont->maxPrivate < n)
@@ -68,3 +100,4 @@ _FontSetNewPrivate (pFont, n, ptr)
pFont->devPrivates[n] = ptr;
return TRUE;
}
+
diff --git a/src/util/utilbitmap.c b/src/util/utilbitmap.c
index 9842db1..c407f29 100644
--- a/src/util/utilbitmap.c
+++ b/src/util/utilbitmap.c
@@ -25,11 +25,14 @@ 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/util/utilbitmap.c,v 1.5 2001/12/14 19:56:57 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
*/
+#include "fontmisc.h"
+
/* Utility functions for reformating font bitmaps */
static unsigned char _reverse_byte[0x100] = {
@@ -71,11 +74,9 @@ static unsigned char _reverse_byte[0x100] = {
* Invert bit order within each BYTE of an array.
*/
void
-BitOrderInvert(buf, nbytes)
- register unsigned char *buf;
- register int nbytes;
+BitOrderInvert(unsigned char *buf, int nbytes)
{
- register unsigned char *rev = _reverse_byte;
+ unsigned char *rev = _reverse_byte;
for (; --nbytes >= 0; buf++)
*buf = rev[*buf];
@@ -85,11 +86,9 @@ BitOrderInvert(buf, nbytes)
* Invert byte order within each 16-bits of an array.
*/
void
-TwoByteSwap(buf, nbytes)
- register unsigned char *buf;
- register int nbytes;
+TwoByteSwap(unsigned char *buf, int nbytes)
{
- register unsigned char c;
+ unsigned char c;
for (; nbytes > 0; nbytes -= 2, buf += 2)
{
@@ -103,11 +102,9 @@ TwoByteSwap(buf, nbytes)
* Invert byte order within each 32-bits of an array.
*/
void
-FourByteSwap(buf, nbytes)
- register unsigned char *buf;
- register int nbytes;
+FourByteSwap(unsigned char *buf, int nbytes)
{
- register unsigned char c;
+ unsigned char c;
for (; nbytes > 0; nbytes -= 4, buf += 4)
{
@@ -125,10 +122,9 @@ FourByteSwap(buf, nbytes)
*/
int
-RepadBitmap (pSrc, pDst, srcPad, dstPad, width, height)
- char *pSrc, *pDst;
- unsigned srcPad, dstPad;
- int width, height;
+RepadBitmap (char *pSrc, char *pDst,
+ unsigned int srcPad, unsigned int dstPad,
+ int width, int height)
{
int srcWidthBytes,dstWidthBytes;
int row,col;