summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-17 19:03:42 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-17 19:03:42 +0000
commit94817d4f3277d927bf96431c24033d8cd67d9a30 (patch)
tree2e4b857f2103cfbcdfcfd53b47334166e139a273
parent3795e9702b3b3a6fe0594d09cdd110adeb5e42f9 (diff)
merge XFree86 4.3.0.1 to -CURRENT
-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,
+