summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/X11/fonts/bdfint.h82
-rw-r--r--include/X11/fonts/bitmap.h72
-rw-r--r--include/X11/fonts/bufio.h122
-rw-r--r--include/X11/fonts/fntfil.h80
-rw-r--r--include/X11/fonts/fntfilio.h50
-rw-r--r--include/X11/fonts/fntfilst.h166
-rw-r--r--include/X11/fonts/fontmisc.h124
-rw-r--r--include/X11/fonts/fontshow.h37
-rw-r--r--include/X11/fonts/fontxlfd.h98
-rw-r--r--include/X11/fonts/pcf.h91
-rw-r--r--src/Speedo/adobe-iso.h200
-rw-r--r--src/Speedo/bics-iso.h223
-rw-r--r--src/Speedo/do_char.c1022
-rw-r--r--src/Speedo/do_trns.c513
-rw-r--r--src/Speedo/keys.h56
-rw-r--r--src/Speedo/out_bl2d.c776
-rw-r--r--src/Speedo/out_blk.c708
-rw-r--r--src/Speedo/out_outl.c287
-rw-r--r--src/Speedo/out_scrn.c1091
-rw-r--r--src/Speedo/out_util.c337
-rw-r--r--src/Speedo/reset.c127
-rw-r--r--src/Speedo/set_spcs.c769
-rw-r--r--src/Speedo/set_trns.c1329
-rw-r--r--src/Speedo/spdo_prv.h425
-rw-r--r--src/Speedo/speedo.h1081
-rw-r--r--src/Speedo/spencode.c62
-rw-r--r--src/Speedo/sperr.c134
-rw-r--r--src/Speedo/spfile.c349
-rw-r--r--src/Speedo/spfont.c450
-rw-r--r--src/Speedo/spfuncs.c161
-rw-r--r--src/Speedo/spglyph.c403
-rw-r--r--src/Speedo/spinfo.c441
-rw-r--r--src/Speedo/spint.h172
-rw-r--r--src/Speedo/useropt.h41
-rw-r--r--src/Type1/arith.c484
-rw-r--r--src/Type1/arith.h70
-rw-r--r--src/Type1/blues.h93
-rw-r--r--src/Type1/cluts.h35
-rw-r--r--src/Type1/curves.c217
-rw-r--r--src/Type1/curves.h40
-rw-r--r--src/Type1/digit.h64
-rw-r--r--src/Type1/fontfcn.c308
-rw-r--r--src/Type1/fontfcn.h98
-rw-r--r--src/Type1/fonts.h49
-rw-r--r--src/Type1/hdigit.h94
-rw-r--r--src/Type1/hints.c919
-rw-r--r--src/Type1/hints.h42
-rw-r--r--src/Type1/lines.c186
-rw-r--r--src/Type1/lines.h37
-rw-r--r--src/Type1/objects.c1125
-rw-r--r--src/Type1/objects.h291
-rw-r--r--src/Type1/paths.c1506
-rw-r--r--src/Type1/paths.h197
-rw-r--r--src/Type1/pictures.h48
-rw-r--r--src/Type1/regions.c1749
-rw-r--r--src/Type1/regions.h213
-rw-r--r--src/Type1/scanfont.c1519
-rw-r--r--src/Type1/spaces.c998
-rw-r--r--src/Type1/spaces.h140
-rw-r--r--src/Type1/strokes.h38
-rw-r--r--src/Type1/t1funcs.c694
-rw-r--r--src/Type1/t1hdigit.h40
-rw-r--r--src/Type1/t1imager.h148
-rw-r--r--src/Type1/t1info.c488
-rw-r--r--src/Type1/t1intf.h36
-rw-r--r--src/Type1/t1io.c294
-rw-r--r--src/Type1/t1malloc.c735
-rw-r--r--src/Type1/t1snap.c79
-rw-r--r--src/Type1/t1stdio.h68
-rw-r--r--src/Type1/t1stub.c42
-rw-r--r--src/Type1/token.c1212
-rw-r--r--src/Type1/token.h77
-rw-r--r--src/Type1/tokst.h508
-rw-r--r--src/Type1/trig.h35
-rw-r--r--src/Type1/type1.c1810
-rw-r--r--src/Type1/util.c195
-rw-r--r--src/Type1/util.h182
-rw-r--r--src/bitmap/bdfread.c967
-rw-r--r--src/bitmap/bdfutils.c365
-rw-r--r--src/bitmap/bitmap.c166
-rw-r--r--src/bitmap/bitmapfunc.c209
-rw-r--r--src/bitmap/bitmaputil.c229
-rw-r--r--src/bitmap/bitscale.c1909
-rw-r--r--src/bitmap/fontink.c218
-rw-r--r--src/bitmap/pcfread.c940
-rw-r--r--src/bitmap/pcfwrite.c494
-rw-r--r--src/bitmap/snfread.c529
-rw-r--r--src/bitmap/snfstr.h176
-rw-r--r--src/fc/fsconvert.c702
-rw-r--r--src/fc/fserve.c2815
-rw-r--r--src/fc/fserve.h68
-rw-r--r--src/fc/fservestr.h188
-rw-r--r--src/fc/fsio.c612
-rw-r--r--src/fc/fsio.h82
-rw-r--r--src/fc/fslibos.h212
-rw-r--r--src/fontfile/bitsource.c173
-rw-r--r--src/fontfile/bufio.c219
-rw-r--r--src/fontfile/decompress.c408
-rw-r--r--src/fontfile/defaults.c72
-rw-r--r--src/fontfile/dirfile.c443
-rw-r--r--src/fontfile/ffcheck.c183
-rw-r--r--src/fontfile/fileio.c83
-rw-r--r--src/fontfile/filewr.c63
-rw-r--r--src/fontfile/fontdir.c762
-rw-r--r--src/fontfile/fontfile.c1119
-rw-r--r--src/fontfile/fontscale.c453
-rw-r--r--src/fontfile/gunzip.c224
-rw-r--r--src/fontfile/printerfont.c216
-rw-r--r--src/fontfile/register.c50
-rw-r--r--src/fontfile/renderers.c77
-rw-r--r--src/util/atom.c230
-rw-r--r--src/util/fontaccel.c102
-rw-r--r--src/util/fontnames.c124
-rw-r--r--src/util/fontutil.c416
-rw-r--r--src/util/fontxlfd.c587
-rw-r--r--src/util/format.c121
-rw-r--r--src/util/miscutil.c93
-rw-r--r--src/util/patcache.c224
-rw-r--r--src/util/private.c70
-rw-r--r--src/util/utilbitmap.c187
120 files changed, 46862 insertions, 0 deletions
diff --git a/include/X11/fonts/bdfint.h b/include/X11/fonts/bdfint.h
new file mode 100644
index 0000000..04e4c41
--- /dev/null
+++ b/include/X11/fonts/bdfint.h
@@ -0,0 +1,82 @@
+/* $Xorg: bdfint.h,v 1.4 2001/02/09 02:04:01 xorgcvs Exp $ */
+
+/*
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#ifndef BDFINT_H
+#define BDFINT_H
+
+#define bdfIsPrefix(buf,str) (!strncmp((char *)buf,str,strlen(str)))
+#define bdfStrEqual(s1,s2) (!strcmp(s1,s2))
+
+#define BDF_GENPROPS 6
+#define NullProperty ((FontPropPtr)0)
+
+/*
+ * This structure holds some properties we need to generate if they aren't
+ * specified in the BDF file and some other values read from the file
+ * that we'll need to calculate them. We need to keep track of whether
+ * or not we've read them.
+ */
+typedef struct BDFSTAT {
+ int linenum;
+ char *fileName;
+ char fontName[MAXFONTNAMELEN];
+ float pointSize;
+ int resolution_x;
+ int resolution_y;
+ int digitCount;
+ int digitWidths;
+ int exHeight;
+
+ FontPropPtr fontProp;
+ FontPropPtr pointSizeProp;
+ FontPropPtr resolutionXProp;
+ FontPropPtr resolutionYProp;
+ FontPropPtr resolutionProp;
+ FontPropPtr xHeightProp;
+ FontPropPtr weightProp;
+ FontPropPtr quadWidthProp;
+ BOOL haveFontAscent;
+ BOOL haveFontDescent;
+ BOOL haveDefaultCh;
+} bdfFileState;
+
+extern unsigned char *bdfGetLine();
+
+extern void bdfError(
+#if NeedVarargsPrototypes
+ char* message, ...
+#endif
+);
+extern void bdfWarning();
+extern Atom bdfForceMakeAtom();
+extern Atom bdfGetPropertyValue();
+extern unsigned char bdfHexByte();
+
+#endif /* BDFINT_H */
diff --git a/include/X11/fonts/bitmap.h b/include/X11/fonts/bitmap.h
new file mode 100644
index 0000000..027b869
--- /dev/null
+++ b/include/X11/fonts/bitmap.h
@@ -0,0 +1,72 @@
+/* $Xorg: bitmap.h,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _BITMAP_H_
+#define _BITMAP_H_
+
+#include <fntfilio.h>
+#include <stdio.h> /* just for NULL */
+
+/*
+ * Internal format used to store bitmap fonts
+ */
+
+typedef struct _BitmapExtra {
+ Atom *glyphNames;
+ int *sWidths;
+ CARD32 bitmapsSizes[GLYPHPADOPTIONS];
+ FontInfoRec info;
+} BitmapExtraRec, *BitmapExtraPtr;
+
+typedef struct _BitmapFont {
+ unsigned version_num;
+ int num_chars;
+ int num_tables;
+ 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 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();
+
+#endif /* _BITMAP_H_ */
diff --git a/include/X11/fonts/bufio.h b/include/X11/fonts/bufio.h
new file mode 100644
index 0000000..493f3ce
--- /dev/null
+++ b/include/X11/fonts/bufio.h
@@ -0,0 +1,122 @@
+/* $Xorg: bufio.h,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#ifdef TEST
+
+#define xalloc(s) malloc(s)
+#define xfree(s) free(s)
+
+#endif
+
+#define BUFFILESIZE 8192
+#define BUFFILEEOF -1
+
+typedef unsigned char BufChar;
+
+typedef struct _buffile {
+ BufChar *bufp;
+ int left;
+ BufChar buffer[BUFFILESIZE];
+ int (*io)(/* BufFilePtr f */);
+ int (*skip)(/* BufFilePtr f, int count */);
+ int (*close)(/* BufFilePtr f */);
+ char *private;
+} BufFileRec, *BufFilePtr;
+
+extern BufFilePtr BufFileCreate (
+#if NeedFunctionPrototypes
+ 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
+);
+#ifdef X_GZIP_FONT_COMPRESSION
+extern BufFilePtr BufFilePushZIP (
+#if NeedFunctionPrototypes
+ BufFilePtr
+#endif
+);
+#endif
+extern int BufFileClose (
+#if NeedFunctionPrototypes
+ BufFilePtr,
+ int
+#endif
+);
+extern int BufFileFlush (
+#if NeedFunctionPrototypes
+ BufFilePtr
+#endif
+);
+
+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))
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
diff --git a/include/X11/fonts/fntfil.h b/include/X11/fonts/fntfil.h
new file mode 100644
index 0000000..6999e51
--- /dev/null
+++ b/include/X11/fonts/fntfil.h
@@ -0,0 +1,80 @@
+/* $Xorg: fntfil.h,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _FONTFILE_H_
+#define _FONTFILE_H_
+typedef struct _FontEntry *FontEntryPtr;
+typedef struct _FontTable *FontTablePtr;
+typedef struct _FontName *FontNamePtr;
+typedef struct _FontScaled *FontScaledPtr;
+typedef struct _FontScalableExtra *FontScalableExtraPtr;
+typedef struct _FontScalableEntry *FontScalableEntryPtr;
+typedef struct _FontScaleAliasEntry *FontScaleAliasEntryPtr;
+typedef struct _FontBitmapEntry *FontBitmapEntryPtr;
+typedef struct _FontAliasEntry *FontAliasEntryPtr;
+typedef struct _FontBCEntry *FontBCEntryPtr;
+typedef struct _FontDirectory *FontDirectoryPtr;
+typedef struct _FontRenderer *FontRendererPtr;
+
+#define NullFontEntry ((FontEntryPtr) 0)
+#define NullFontTable ((FontTablePtr) 0)
+#define NullFontName ((FontNamePtr) 0)
+#define NullFontScaled ((FontScaled) 0)
+#define NullFontScalableExtra ((FontScalableExtra) 0)
+#define NullFontscalableEntry ((FontScalableEntry) 0)
+#define NullFontScaleAliasEntry ((FontScaleAliasEntry) 0)
+#define NullFontBitmapEntry ((FontBitmapEntry) 0)
+#define NullFontAliasEntry ((FontAliasEntry) 0)
+#define NullFontBCEntry ((FontBCEntry) 0)
+#define NullFontDirectory ((FontDirectoryPtr) 0)
+#define NullFontRenderer ((FontRendererPtr) 0)
+
+#define FONT_ENTRY_SCALABLE 0
+#define FONT_ENTRY_SCALE_ALIAS 1
+#define FONT_ENTRY_BITMAP 2
+#define FONT_ENTRY_ALIAS 3
+#define FONT_ENTRY_BC 4
+
+#define MAXFONTNAMELEN 1024
+#define MAXFONTFILENAMELEN 1024
+
+#define FontDirFile "fonts.dir"
+#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 ();
+#endif /* _FONTFILE_H_ */
diff --git a/include/X11/fonts/fntfilio.h b/include/X11/fonts/fntfilio.h
new file mode 100644
index 0000000..ffb146b
--- /dev/null
+++ b/include/X11/fonts/fntfilio.h
@@ -0,0 +1,50 @@
+/* $Xorg: fntfilio.h,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#include <bufio.h>
+
+typedef BufFilePtr FontFilePtr;
+
+#define FontFileGetc(f) BufFileGet(f)
+#define FontFilePutc(c,f) BufFilePut(c,f)
+#define FontFileRead(f,b,n) BufFileRead(f,b,n)
+#define FontFileWrite(f,b,n) BufFileWrite(f,b,n)
+#define FontFileSkip(f,n) (BufFileSkip (f, n) != BUFFILEEOF)
+#define FontFileSeek(f,n) (BufFileSeek (f,n,0) != BUFFILEEOF)
+
+#define FontFileEOF BUFFILEEOF
+
+extern FontFilePtr FontFileOpen ();
+extern FontFilePtr FontFileOpenWrite ();
+extern FontFilePtr FontFileOpenFd ();
+extern FontFilePtr FontFileOpenWriteFd ();
+extern int FontFileClose ();
diff --git a/include/X11/fonts/fntfilst.h b/include/X11/fonts/fntfilst.h
new file mode 100644
index 0000000..8e90090
--- /dev/null
+++ b/include/X11/fonts/fntfilst.h
@@ -0,0 +1,166 @@
+/* $Xorg: fntfilst.h,v 1.5 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _FONTFILEST_H_
+#define _FONTFILEST_H_
+
+#include <X11/Xos.h>
+#ifndef XP_PSTEXT
+#include "fontmisc.h"
+#endif
+#include "fontstruct.h"
+#include "fntfil.h"
+#include "fontxlfd.h"
+
+typedef struct _FontName {
+ char *name;
+ short length;
+ short ndashes;
+} FontNameRec;
+
+typedef struct _FontScaled {
+ FontScalableRec vals;
+ FontEntryPtr bitmap;
+ FontPtr pFont;
+} FontScaledRec;
+
+typedef struct _FontScalableExtra {
+ FontScalableRec defaults;
+ int numScaled;
+ int sizeScaled;
+ FontScaledPtr scaled;
+ pointer private;
+} FontScalableExtraRec;
+
+typedef struct _FontScalableEntry {
+ FontRendererPtr renderer;
+ char *fileName;
+ FontScalableExtraPtr extra;
+} FontScalableEntryRec;
+
+/*
+ * This "can't" work yet - the returned alias string must be permanent,
+ * but this layer would need to generate the appropriate name from the
+ * resolved scalable + the XLFD values passed in. XXX
+ */
+
+typedef struct _FontScaleAliasEntry {
+ char *resolved;
+} FontScaleAliasEntryRec;
+
+typedef struct _FontBitmapEntry {
+ FontRendererPtr renderer;
+ char *fileName;
+ FontPtr pFont;
+} FontBitmapEntryRec;
+
+typedef struct _FontAliasEntry {
+ char *resolved;
+} FontAliasEntryRec;
+
+typedef struct _FontBCEntry {
+ FontScalableRec vals;
+ FontEntryPtr entry;
+} FontBCEntryRec;
+
+typedef struct _FontEntry {
+ FontNameRec name;
+ int type;
+ union _FontEntryParts {
+ FontScalableEntryRec scalable;
+ FontBitmapEntryRec bitmap;
+ FontAliasEntryRec alias;
+ FontBCEntryRec bc;
+ } u;
+} FontEntryRec;
+
+typedef struct _FontTable {
+ int used;
+ int size;
+ FontEntryPtr entries;
+ Bool sorted;
+} FontTableRec;
+
+typedef struct _FontDirectory {
+ char *directory;
+ unsigned long dir_mtime;
+ unsigned long alias_mtime;
+ FontTableRec scalable;
+ FontTableRec nonScalable;
+} FontDirectoryRec;
+
+/* Capability bits: for definition of capabilities bitmap in the
+ FontRendererRec to indicate support of XLFD enhancements */
+
+#define CAP_MATRIX 0x1
+#define CAP_CHARSUBSETTING 0x2
+
+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 number;
+ int capabilities; /* Bitmap components defined above */
+} FontRendererRec;
+
+typedef struct _FontRenders {
+ int number;
+ FontRendererPtr *renderers;
+} FontRenderersRec, *FontRenderersPtr;
+
+typedef struct _BitmapInstance {
+ FontScalableRec vals;
+ FontBitmapEntryPtr bitmap;
+} BitmapInstanceRec, *BitmapInstancePtr;
+
+typedef struct _BitmapScalablePrivate {
+ int numInstances;
+ BitmapInstancePtr instances;
+} BitmapScalablePrivateRec, *BitmapScalablePrivatePtr;
+
+typedef struct _BitmapSources {
+ FontPathElementPtr *fpe;
+ int size;
+ int count;
+} BitmapSourcesRec, *BitmapSourcesPtr;
+
+extern BitmapSourcesRec FontFileBitmapSources;
+
+/* Defines for FontFileFindNamesInScalableDir() behavior */
+#define NORMAL_ALIAS_BEHAVIOR 0
+#define LIST_ALIASES_AND_TARGET_NAMES (1<<0)
+#define IGNORE_SCALABLE_ALIASES (1<<1)
+
+#endif /* _FONTFILEST_H_ */
diff --git a/include/X11/fonts/fontmisc.h b/include/X11/fonts/fontmisc.h
new file mode 100644
index 0000000..22ee61e
--- /dev/null
+++ b/include/X11/fonts/fontmisc.h
@@ -0,0 +1,124 @@
+/* $Xorg: fontmisc.h,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _FONTMISC_H_
+#define _FONTMISC_H_
+
+#include <X11/Xfuncs.h>
+
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#else
+extern int rand();
+#endif
+#include <stdio.h>
+
+#ifndef X_NOT_POSIX
+#include <unistd.h>
+#else
+extern int close();
+#endif
+
+typedef unsigned char *pointer;
+typedef int Bool;
+
+#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
+#define MSBFirst 1
+#endif
+
+#ifndef None
+#define None 0l
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+extern char *NameForAtom ();
+
+#define xalloc(n) Xalloc ((unsigned) n)
+#define xfree(p) Xfree ((pointer) p)
+#define xrealloc(p,n) Xrealloc ((pointer)p,n)
+#define lowbit(x) ((x) & (~(x) + 1))
+
+#define assert(x)
+
+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
+);
+
+#endif /* _FONTMISC_H_ */
diff --git a/include/X11/fonts/fontshow.h b/include/X11/fonts/fontshow.h
new file mode 100644
index 0000000..5bb48fe
--- /dev/null
+++ b/include/X11/fonts/fontshow.h
@@ -0,0 +1,37 @@
+/* $Xorg: fontshow.h,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#define FONT_SHOW_INFO (1<<0)
+#define FONT_SHOW_PROPS (1<<1)
+#define FONT_SHOW_METRICS (1<<2)
+#define FONT_SHOW_GLYPHS (1<<3)
+#define FONT_SHOW_ALL (FONT_SHOW_INFO|FONT_SHOW_PROPS|FONT_SHOW_GLYPHS)
diff --git a/include/X11/fonts/fontxlfd.h b/include/X11/fonts/fontxlfd.h
new file mode 100644
index 0000000..759d41e
--- /dev/null
+++ b/include/X11/fonts/fontxlfd.h
@@ -0,0 +1,98 @@
+/* $Xorg: fontxlfd.h,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */
+
+/*
+
+Copyright 1990, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _FONTXLFD_H_
+#define _FONTXLFD_H_
+
+#include "FSproto.h"
+
+/* Constants for values_supplied bitmap */
+
+#define SIZE_SPECIFY_MASK 0xf
+
+#define PIXELSIZE_MASK 0x3
+#define PIXELSIZE_UNDEFINED 0
+#define PIXELSIZE_SCALAR 0x1
+#define PIXELSIZE_ARRAY 0x2
+#define PIXELSIZE_SCALAR_NORMALIZED 0x3 /* Adjusted for resolution */
+
+#define POINTSIZE_MASK 0xc
+#define POINTSIZE_UNDEFINED 0
+#define POINTSIZE_SCALAR 0x4
+#define POINTSIZE_ARRAY 0x8
+
+#define PIXELSIZE_WILDCARD 0x10
+#define POINTSIZE_WILDCARD 0x20
+
+#define ENHANCEMENT_SPECIFY_MASK 0x40
+
+#define CHARSUBSET_SPECIFIED 0x40
+
+#define EPS 1.0e-20
+#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
+ capabilities or enhancements
+ were specified in the font name */
+ double pixel_matrix[4];
+ double point_matrix[4];
+
+ /* Pixel and point fields are deprecated in favor of the
+ transformation matrices. They are provided and filled in for the
+ benefit of rasterizers that do not handle the matrices. */
+
+ int pixel,
+ point;
+
+ int x,
+ y,
+ width;
+ char *xlfdName;
+ int nranges;
+ fsRange *ranges;
+} FontScalableRec, *FontScalablePtr;
+
+extern Bool FontParseXLFDName();
+extern fsRange *FontParseRanges();
+
+#define FONT_XLFD_REPLACE_NONE 0
+#define FONT_XLFD_REPLACE_STAR 1
+#define FONT_XLFD_REPLACE_ZERO 2
+#define FONT_XLFD_REPLACE_VALUE 3
+
+#endif /* _FONTXLFD_H_ */
diff --git a/include/X11/fonts/pcf.h b/include/X11/fonts/pcf.h
new file mode 100644
index 0000000..510a8a6
--- /dev/null
+++ b/include/X11/fonts/pcf.h
@@ -0,0 +1,91 @@
+/* $Xorg: pcf.h,v 1.4 2001/02/09 02:04:02 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifndef _PCF_H_
+#define _PCF_H_
+
+/*
+ * Information used to read/write PCF fonts
+ */
+
+typedef struct _PCFTable {
+ CARD32 type;
+ CARD32 format;
+ CARD32 size;
+ CARD32 offset;
+} PCFTableRec, *PCFTablePtr;
+
+#define PCF_FILE_VERSION (('p'<<24)|('c'<<16)|('f'<<8)|1)
+#define PCF_FORMAT_MASK 0xffffff00
+
+#define PCF_DEFAULT_FORMAT 0x00000000
+#define PCF_INKBOUNDS 0x00000200
+#define PCF_ACCEL_W_INKBOUNDS 0x00000100
+#define PCF_COMPRESSED_METRICS 0x00000100
+
+#define PCF_FORMAT_MATCH(a,b) (((a)&PCF_FORMAT_MASK) == ((b)&PCF_FORMAT_MASK))
+
+#define PCF_GLYPH_PAD_MASK (3<<0)
+#define PCF_BYTE_MASK (1<<2)
+#define PCF_BIT_MASK (1<<3)
+#define PCF_SCAN_UNIT_MASK (3<<4)
+
+#define PCF_BYTE_ORDER(f) (((f) & PCF_BYTE_MASK)?MSBFirst:LSBFirst)
+#define PCF_BIT_ORDER(f) (((f) & PCF_BIT_MASK)?MSBFirst:LSBFirst)
+#define PCF_GLYPH_PAD_INDEX(f) ((f) & PCF_GLYPH_PAD_MASK)
+#define PCF_GLYPH_PAD(f) (1<<PCF_GLYPH_PAD_INDEX(f))
+#define PCF_SCAN_UNIT_INDEX(f) (((f) & PCF_SCAN_UNIT_MASK) >> 4)
+#define PCF_SCAN_UNIT(f) (1<<PCF_SCAN_UNIT_INDEX(f))
+#define PCF_FORMAT_BITS(f) ((f) & (PCF_GLYPH_PAD_MASK|PCF_BYTE_MASK|PCF_BIT_MASK|PCF_SCAN_UNIT_MASK))
+
+#define PCF_SIZE_TO_INDEX(s) ((s) == 4 ? 2 : (s) == 2 ? 1 : 0)
+#define PCF_INDEX_TO_SIZE(b) (1<<b)
+
+#define PCF_FORMAT(bit,byte,glyph,scan) (\
+ (PCF_SIZE_TO_INDEX(scan) << 4) | \
+ (((bit) == MSBFirst ? 1 : 0) << 3) | \
+ (((byte) == MSBFirst ? 1 : 0) << 2) | \
+ (PCF_SIZE_TO_INDEX(glyph) << 0))
+
+#define PCF_PROPERTIES (1<<0)
+#define PCF_ACCELERATORS (1<<1)
+#define PCF_METRICS (1<<2)
+#define PCF_BITMAPS (1<<3)
+#define PCF_INK_METRICS (1<<4)
+#define PCF_BDF_ENCODINGS (1<<5)
+#define PCF_SWIDTHS (1<<6)
+#define PCF_GLYPH_NAMES (1<<7)
+#define PCF_BDF_ACCELERATORS (1<<8)
+
+#endif /* _PCF_H_ */
diff --git a/src/Speedo/adobe-iso.h b/src/Speedo/adobe-iso.h
new file mode 100644
index 0000000..e1eeef1
--- /dev/null
+++ b/src/Speedo/adobe-iso.h
@@ -0,0 +1,200 @@
+/* $Xorg: adobe-iso.h,v 1.3 2000/08/17 19:46:24 cpqbld Exp $ */
+
+/*
+ * Latin 1 format from masterset format 11 (ps)
+ * 0 implies no valid mapping
+ */
+
+int adobe_map[] = {
+ 32, 32,
+ 33, 33,
+ 34, 34,
+ 35, 35,
+ 36, 36,
+ 37, 37,
+ 38, 38,
+ 39, 169,
+ 40, 40,
+ 41, 41,
+ 42, 42,
+ 43, 43,
+ 44, 44,
+ 45, 45,
+ 46, 46,
+ 47, 47,
+ 48, 48,
+ 49, 49,
+ 50, 50,
+ 51, 51,
+ 52, 52,
+ 53, 53,
+ 54, 54,
+ 55, 55,
+ 56, 56,
+ 57, 57,
+ 58, 58,
+ 59, 59,
+ 60, 60,
+ 61, 61,
+ 62, 62,
+ 63, 63,
+ 64, 64,
+ 65, 65,
+ 66, 66,
+ 67, 67,
+ 68, 68,
+ 69, 69,
+ 70, 70,
+ 71, 71,
+ 72, 72,
+ 73, 73,
+ 74, 74,
+ 75, 75,
+ 76, 76,
+ 77, 77,
+ 78, 78,
+ 79, 79,
+ 80, 80,
+ 81, 81,
+ 82, 82,
+ 83, 83,
+ 84, 84,
+ 85, 85,
+ 86, 86,
+ 87, 87,
+ 88, 88,
+ 89, 89,
+ 90, 90,
+ 91, 91,
+ 92, 92,
+ 93, 93,
+ 94, 195,
+ 95, 95,
+ 96, 193,
+ 97, 97,
+ 98, 98,
+ 99, 99,
+ 100, 100,
+ 101, 101,
+ 102, 102,
+ 103, 103,
+ 104, 104,
+ 105, 105,
+ 106, 106,
+ 107, 107,
+ 108, 108,
+ 109, 109,
+ 110, 110,
+ 111, 111,
+ 112, 112,
+ 113, 113,
+ 114, 114,
+ 115, 115,
+ 116, 116,
+ 117, 117,
+ 118, 118,
+ 119, 119,
+ 120, 120,
+ 121, 121,
+ 122, 122,
+ 123, 123,
+ 124, 124,
+ 125, 125,
+ 126, 196, /* lc tilde */
+ 127, 0, /* */
+ 161, 161, /* invert exclamation */
+ 162, 162, /* cent */
+ 163, 163, /* pound sterling */
+ 164, 168, /* intl currency */
+ 165, 165, /* yen */
+ 166, 320, /* split vert bar */
+ 167, 167, /* section mark */
+ 168, 200, /* dierisis */
+ 169, 0, /* superior copyright */
+ 170, 0, /* feminine ordinal */
+ 171, 171, /* dbl left guillemot */
+ 172, 314, /* math not */
+ 173, 0, /* hyphen ? */
+ 174, 0, /* superior registered */
+ 175, 0, /* overscore */
+ 176, 321, /* degree */
+ 177, 329, /* math +- */
+ 178, 333, /* superior 2 */
+ 179, 332, /* superior 3 */
+ 180, 194, /* lc acute */
+ 181, 324, /* greek lc mu */
+ 182, 182, /* Paragraph */
+ 183, 180, /* center dot */
+ 184, 203, /* cedilla lc */
+ 185, 328, /* superior 1 */
+ 186, 0, /* masculine ordinal(using superior o) */
+ 187, 187, /* right dbl guillemot */
+ 188, 327, /* 1/4 */
+ 189, 326, /* 1/2 */
+ 190, 331, /* 3/4 */
+ 191, 191, /* invert question */
+ 192, 259, /* A grave */
+ 193, 256, /* A acute */
+ 194, 257, /* A circumflex */
+ 195, 261, /* A tilde */
+ 196, 258, /* A dierisis */
+ 197, 260, /* A angstrom */
+ 198, 225, /* AE ligature */
+ 199, 262, /* C cedilla */
+ 200, 266, /* E grave */
+ 201, 263, /* E acute */
+ 202, 264, /* E circumflex */
+ 203, 265, /* E dierisis */
+ 204, 270, /* I grave */
+ 205, 267, /* I acute */
+ 206, 268, /* I circumflex */
+ 207, 269, /* I dierisis */
+ 208, 317, /* D bar */
+ 209, 271, /* N tilde */
+ 210, 275, /* O grave */
+ 211, 272, /* O acute */
+ 212, 273, /* O circumflex */
+ 213, 276, /* O tilde */
+ 214, 274, /* O dierisis */
+ 215, 325, /* math multiply */
+ 216, 233, /* O bar */
+ 217, 281, /* U grave */
+ 218, 278, /* U acute */
+ 219, 279, /* U circumflex */
+ 220, 280, /* U dierisis */
+ 221, 319, /* Y acute */
+ 222, 318, /* icelandic thorn lc */
+ 223, 251, /* German dbl s */
+ 224, 287, /* a grave */
+ 225, 284, /* a acute */
+ 226, 285, /* a circumflex */
+ 227, 289, /* a tilde */
+ 228, 286, /* a dierisis */
+ 229, 288, /* a angstrom */
+ 230, 241, /* ae ligature */
+ 231, 290, /* c cedilla */
+ 232, 294, /* e grave */
+ 233, 291, /* e acute */
+ 234, 292, /* e circumflex */
+ 235, 293, /* e dierisis */
+ 236, 298, /* i grave */
+ 237, 295, /* i acute */
+ 238, 296, /* i circumflex */
+ 239, 297, /* i dierisis */
+ 240, 323, /* icelandic eth lc */
+ 241, 299, /* n tilde */
+ 242, 303, /* o grave */
+ 243, 300, /* o acute */
+ 244, 301, /* o circumflex */
+ 245, 304, /* o tilde */
+ 246, 302, /* o dierisis */
+ 247, 322, /* math divide */
+ 248, 249, /* o bar */
+ 249, 309, /* u grave */
+ 250, 306, /* u acute */
+ 251, 307, /* u circumflex */
+ 252, 308, /* u dierisis */
+ 253, 334, /* y acute */
+ 254, 330, /* icelandic thorn uc */
+ 255, 310, /* y dierisis */
+};
diff --git a/src/Speedo/bics-iso.h b/src/Speedo/bics-iso.h
new file mode 100644
index 0000000..f520562
--- /dev/null
+++ b/src/Speedo/bics-iso.h
@@ -0,0 +1,223 @@
+/* $Xorg: bics-iso.h,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+int sp_bics_map[] = {
+ 32, 0,
+ 33, 1,
+ 34, 2,
+ 35, 3,
+ 36, 4,
+ 37, 5,
+ 38, 6,
+ 39, 264,
+ 40, 8,
+ 41, 9,
+ 42, 10,
+ 43, 11,
+ 44, 12,
+ 45, 13,
+ 46, 14,
+ 47, 15,
+ 48, 16,
+ 49, 17,
+ 50, 18,
+ 51, 19,
+ 52, 20,
+ 53, 21,
+ 54, 22,
+ 55, 23,
+ 56, 24,
+ 57, 25,
+ 58, 26,
+ 59, 27,
+ 60, 28,
+ 61, 29,
+ 62, 30,
+ 63, 31,
+ 64, 32,
+ 65, 33,
+ 66, 34,
+ 67, 35,
+ 68, 36,
+ 69, 37,
+ 70, 38,
+ 71, 39,
+ 72, 40,
+ 73, 41,
+ 74, 42,
+ 75, 43,
+ 76, 44,
+ 77, 45,
+ 78, 46,
+ 79, 47,
+ 80, 48,
+ 81, 49,
+ 82, 50,
+ 83, 51,
+ 84, 52,
+ 85, 53,
+ 86, 54,
+ 87, 55,
+ 88, 56,
+ 89, 57,
+ 90, 58,
+ 91, 59,
+ 92, 60,
+ 93, 61,
+ 94, 133,
+ 95, 63,
+ 96, 131,
+ 97, 65,
+ 98, 66,
+ 99, 67,
+ 100, 68,
+ 101, 69,
+ 102, 70,
+ 103, 71,
+ 104, 72,
+ 105, 73,
+ 106, 74,
+ 107, 75,
+ 108, 76,
+ 109, 77,
+ 110, 78,
+ 111, 79,
+ 112, 80,
+ 113, 81,
+ 114, 82,
+ 115, 83,
+ 116, 84,
+ 117, 85,
+ 118, 86,
+ 119, 87,
+ 120, 88,
+ 121, 89,
+ 122, 90,
+ 123, 91,
+ 124, 92,
+ 125, 93,
+ 126, 137,
+ 127, 358,
+ 161, 128,
+ 162, 98,
+ 163, 97,
+ 164, 278,
+ 165, 274,
+ 166, 277,
+ 167, 110,
+ 168, 135,
+ 169, 503,
+ 170, 538,
+ 171, 125,
+ 172, 309,
+ 173, 191,
+ 174, 504,
+ 175, 230,
+ 176, 339,
+ 177, 286,
+ 178, 160,
+ 179, 161,
+ 180, 129,
+ 181, 325,
+ 182, 279,
+ 183, 102,
+ 184, 141,
+ 185, 159,
+ 186, 544,
+ 187, 126,
+ 188, 151,
+ 189, 153,
+ 190, 155,
+ 191, 127,
+ 192, 259,
+ 193, 261,
+ 194, 257,
+ 195, 253,
+ 196, 255,
+ 197, 113,
+ 198, 114,
+ 199, 148,
+ 200, 249,
+ 201, 251,
+ 202, 247,
+ 203, 245,
+ 204, 239,
+ 205, 241,
+ 206, 237,
+ 207, 235,
+ 208, 169,
+ 209, 196,
+ 210, 202,
+ 211, 200,
+ 212, 204,
+ 213, 208,
+ 214, 206,
+ 215, 284,
+ 216, 115,
+ 217, 212,
+ 218, 210,
+ 219, 214,
+ 220, 216,
+ 221, 224,
+ 222, 271,
+ 223, 121,
+ 224, 260,
+ 225, 262,
+ 226, 258,
+ 227, 254,
+ 228, 256,
+ 229, 117,
+ 230, 118,
+ 231, 149,
+ 232, 250,
+ 233, 252,
+ 234, 248,
+ 235, 246,
+ 236, 240,
+ 237, 242,
+ 238, 238,
+ 239, 236,
+ 240, 273,
+ 241, 195,
+ 242, 201,
+ 243, 199,
+ 244, 203,
+ 245, 207,
+ 246, 205,
+ 247, 285,
+ 248, 119,
+ 249, 211,
+ 250, 209,
+ 251, 213,
+ 252, 215,
+ 253, 223,
+ 254, 272,
+ 255, 221,
+};
+
diff --git a/src/Speedo/do_char.c b/src/Speedo/do_char.c
new file mode 100644
index 0000000..0ae416b
--- /dev/null
+++ b/src/Speedo/do_char.c
@@ -0,0 +1,1022 @@
+/* $Xorg: do_char.c,v 1.3 2000/08/17 19:46:24 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+/***************************** D O - C H A R . C *****************************
+ * *
+ * This is the top level module for processing one simple or composite *
+ * character.
+ * *
+ ****************************************************************************/
+
+#include "spdo_prv.h" /* General definitions for Speedo */
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** 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)
+GDECL
+ufix16 char_index; /* Index to character in char directory */
+/*
+ * Returns character id for specified character index in currently
+ * selected font.
+ * Reports Error 10 and returns 0 if no font selected.
+ * Reports Error 12 and returns 0 if character data not available.
+ */
+{
+ufix8 FONTFAR *pointer; /* Pointer to character data */
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return (ufix16)0; /* Return zero character id */
+ }
+
+pointer = sp_get_char_org(char_index, TRUE); /* Get pointer to character data */
+if (pointer == NULL) /* Character data not available? */
+ {
+ report_error(12); /* Report character data not avail */
+ return (ufix16)0; /* Return zero character id */
+ }
+
+return 0xffff & NEXT_WORD(pointer); /* Return character id */
+}
+
+
+#if INCL_METRICS
+FUNCTION fix31 get_char_width(char_index)
+GDECL
+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.
+ * Reports Error 10 and returns 0 if no font selected.
+ * Reports Error 12 and returns 0 if character data not available.
+ */
+{
+ufix8 FONTFAR *pointer; /* Pointer to character data */
+fix31 set_width; /* Set width of character */
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return (fix31)0; /* Return zero character width */
+ }
+
+pointer = sp_get_char_org(char_index, TRUE); /* Get pointer to character data */
+if (pointer == NULL) /* Character data not available? */
+ {
+ report_error(12); /* Report character data not avail */
+ return (fix31)0; /* Return zero character width */
+ }
+
+pointer += 2; /* Skip over character id */
+set_width = (fix31)NEXT_WORD(pointer); /* Read set width and Convert units */
+set_width = ((set_width << 16) + (sp_globals.metric_resolution >> 1)) / sp_globals.metric_resolution;
+return set_width; /* Return in 1/65536 em units */
+}
+#endif
+
+#if INCL_METRICS
+FUNCTION fix15 get_track_kern(track, point_size)
+GDECL
+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.
+ * If the specified point size is larger than the maximum point
+ * size for the specified track, the adjustment for the maximum
+ * point size is used.
+ * If the specified point size is smaller than the minimum point
+ * size for the specified track, the adjustment for the minimum
+ * point size is used.
+ * If the specified point size is between the minimum point size
+ * and the maximum point size for the specified track, the
+ * adjustment is interpolated linearly between the minimum and
+ * maximum adjustments.
+ * Reports Error 10 and returns 0 if no font selected.
+ * Reports Error 13 and returns 0 if track kerning data not in font.
+ */
+{
+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 */
+
+if (track == 0) /* Track zero selected? */
+ {
+ return adj; /* Return zero track kerning adjustment */
+ }
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return adj; /* Return zero track kerning adjustment */
+ }
+
+no_tracks = sp_globals.kern.no_tracks; /* Number of kerning tracks */
+if (track > no_tracks) /* Required track not available? */
+ {
+ report_error(13); /* Report track kerning data not avail */
+ return adj; /* Return zero track kerning adjustment */
+ }
+
+pointer = sp_globals.kern.tkorg; /* Point to start of track kern data */
+for (i = 0; i < track; i++) /* Read until track required is read */
+ {
+ format = NEXT_BYTE(pointer); /* Read track kerning format byte */
+ min_pt_size = (format & BIT0)?
+ NEXT_WORD(pointer):
+ (fix15)NEXT_BYTE(pointer);
+ min_adj = (format & BIT1)?
+ NEXT_WORD(pointer):
+ (fix15)NEXT_BYTE(pointer);
+ max_pt_size = (format & BIT2)?
+ NEXT_WORD(pointer):
+ (fix15)NEXT_BYTE(pointer);
+ max_adj = (format & BIT3)?
+ NEXT_WORD(pointer):
+ (fix15)NEXT_BYTE(pointer);
+ }
+
+if (point_size <= min_pt_size) /* Smaller than minimum point size? */
+ {
+ return min_adj; /* Return minimum adjustment (1/256 points) */
+ }
+
+if (point_size >= max_pt_size) /* Larger than maximum point size? */
+ {
+ return max_adj; /* Return maximum adjustment (1/256 points) */
+ }
+
+delta_pt_size = (fix31)(max_pt_size - min_pt_size);
+delta_adj = (fix31)(min_adj - max_adj);
+adj = (fix15)(min_adj -
+ (((fix31)(point_size - min_pt_size) * delta_adj +
+ (delta_pt_size >> 1)) / delta_pt_size));
+return adj; /* Return interpolated adjustment (1/256 points) */
+}
+#endif
+
+#if INCL_METRICS
+FUNCTION fix31 get_pair_kern(char_index1, char_index2)
+GDECL
+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.
+ * Reports Error 10 and returns 0 if no font selected.
+ * Reports Error 14 and returns 0 if pair kerning data not in font.
+ */
+{
+ufix8 FONTFAR *origin; /* Pointer to first kerning pair record */
+ufix8 FONTFAR *pointer; /* Pointer to character data */
+ufix16 tmpufix16; /* Temporary workspace */
+fix15 no_pairs; /* Number of kerning pairs in font */
+ufix8 format; /* Track kerning format byte */
+boolean long_id; /* TRUE if 2-byte character ids */
+fix15 rec_size; /* Number of bytes in kern pair record */
+fix15 n; /* Number of remaining kern pairs */
+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 */
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return adj; /* Return zero pair kerning adjustment */
+ }
+
+no_pairs = sp_globals.kern.no_pairs; /* Number of kerning pairs */
+if (no_pairs == 0) /* Pair kerning data not available? */
+ {
+ report_error(14); /* Report pair kerning data not avail */
+ return adj; /* Return zero pair kerning adjustment */
+ }
+
+pointer = sp_globals.kern.pkorg; /* Point to start of pair kern data */
+format = NEXT_BYTE(pointer); /* Read pair kerning format byte */
+if (!(format & BIT0)) /* One-byte adjustment values? */
+ adj_base = NEXT_WORD(pointer); /* Read base adjustment */
+origin = pointer; /* First byte of kerning pair data */
+rec_size = format + 3; /* Compute kerning pair record size */
+long_id = format & BIT1; /* Set flag for 2-byte char index */
+
+n = no_pairs; /* Consider all kerning pairs */
+base = 0; /* Set base at first kern pair record */
+while (n != 0) /* While 1 or more kern pairs remain ... */
+ {
+ nn = n >> 1; /* Size of first partition */
+ i = base + nn; /* Index to record to be tested */
+ pointer = origin + (i * rec_size);
+ tmpufix16 = NEXT_CHNDX(pointer, long_id);
+ if (char_index1 < tmpufix16)
+ {
+ n = nn; /* Number remaining in first partition */
+ continue;
+ }
+ if (char_index1 > tmpufix16)
+ {
+ n -= nn + 1; /* Number remaining in second partition */
+ base = i + 1; /* Base index for second partition */
+ continue;
+ }
+ tmpufix16 = NEXT_CHNDX(pointer, long_id);
+ if (char_index2 < tmpufix16)
+ {
+ n = nn; /* Number remaining in first partition */
+ continue;
+ }
+ if (char_index2 > tmpufix16)
+ {
+ n -= nn + 1; /* Number remaining in second partition */
+ base = i + 1; /* Base index for second partition */
+ continue;
+ }
+ adj = (format & BIT0)?
+ (fix31)NEXT_WORD(pointer):
+ (fix31)(adj_base + (fix15)NEXT_BYTE(pointer));
+ adj = ((adj << 16) + (sp_globals.orus_per_em >> 1)) / sp_globals.orus_per_em; /* Convert units */
+ n = 0; /* No more to consider */
+ }
+return adj; /* Return pair kerning adjustment */
+}
+#endif
+
+
+#if INCL_METRICS
+#ifdef old
+FUNCTION boolean get_char_bbox(char_index, bbox)
+GDECL
+ufix16 char_index;
+bbox_t *bbox;
+{
+/*
+ * returns true if character exists, false if it doesn't
+ * provides transformed character bounding box in 1/65536 pixels
+ * in the provided bbox_t structure. Bounding box may be
+ * conservative in the event that the transformation is not
+ * normal or the character is compound.
+ */
+
+ufix8 FONTFAR *pointer;
+fix15 tmp;
+point_t Pmin, Pmax;
+
+#if REENTRANT_ALLOC
+plaid_t plaid;
+sp_globals.plaid = &plaid;
+#endif
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return FALSE; /* Error return */
+ }
+
+init_tcb(); /* Initialize transformation control block */
+
+pointer = sp_get_char_org(char_index, TRUE); /* Point to start of character data */
+if (pointer == NULL) /* Character data not available? */
+ {
+ report_error(12); /* Report character data not avail */
+ return FALSE; /* Error return */
+ }
+
+pointer += 2; /* Skip over character id */
+tmp = NEXT_WORD(pointer); /* Read set width */
+
+tmp = NEXT_BYTE(pointer);
+if (tmp & BIT1) /* Optional data in header? */
+ {
+ tmp = (ufix8)NEXT_BYTE(pointer); /* Read size of optional data */
+ pointer += tmp; /* Skip optional data */
+ }
+
+pointer = plaid_tcb(pointer, tmp); /* Process plaid data */
+pointer = read_bbox(pointer, &Pmin, &Pmax,(boolean)FALSE); /* Read bounding box */
+bbox->xmin = (fix31)Pmin.x << sp_globals.poshift;
+bbox->xmax = (fix31)Pmax.x << sp_globals.poshift;
+bbox->ymin = (fix31)Pmin.y << sp_globals.poshift;
+bbox->ymax = (fix31)Pmax.y << sp_globals.poshift;
+return TRUE;
+}
+
+#else /* new code, 4/25/91 */
+
+FUNCTION boolean get_char_bbox(char_index, bbox)
+GDECL
+ufix16 char_index;
+bbox_t *bbox;
+{
+/*
+ * returns true if character exists, false if it doesn't
+ * provides transformed character bounding box in 1/65536 pixels
+ * in the provided bbox_t structure. Bounding box may be
+ * conservative in the event that the transformation is not
+ * normal or the character is compound.
+ */
+
+ufix8 FONTFAR *pointer;
+fix15 tmp;
+fix15 format;
+ufix16 pix_adj;
+point_t Pmin, Pmax;
+
+#if REENTRANT_ALLOC
+plaid_t plaid;
+sp_globals.plaid = &plaid;
+#endif
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return FALSE; /* Error return */
+ }
+
+init_tcb(); /* Initialize transformation control block */
+
+pointer = sp_get_char_org(char_index, TRUE); /* Point to start of character data */
+if (pointer == NULL) /* Character data not available? */
+ {
+ report_error(12); /* Report character data not avail */
+ return FALSE; /* Error return */
+ }
+
+pointer += 2; /* Skip over character id */
+tmp = NEXT_WORD(pointer); /* Read set width */
+
+format = NEXT_BYTE(pointer);
+if (format & BIT1) /* Optional data in header? */
+ {
+ tmp = (ufix8)NEXT_BYTE(pointer); /* Read size of optional data */
+ pointer += tmp; /* Skip optional data */
+ }
+
+if (format & BIT0)
+ {
+ pix_adj = sp_globals.onepix << 1; /* Allow 2 pixel expansion ... */
+ }
+else
+ {
+ pix_adj = 0;
+ }
+
+pointer = plaid_tcb(pointer, format); /* Process plaid data */
+pointer = read_bbox(pointer, &Pmin, &Pmax,(boolean)FALSE); /* Read bounding box */
+
+Pmin.x -= pix_adj; /* ... of components of ... */
+Pmin.y -= pix_adj; /* ... compound ... */
+Pmax.x += pix_adj; /* ... character ... */
+Pmax.y += pix_adj; /* ... bounding box. */
+
+
+bbox->xmin = (fix31)Pmin.x << sp_globals.poshift;
+bbox->xmax = (fix31)Pmax.x << sp_globals.poshift;
+bbox->ymin = (fix31)Pmin.y << sp_globals.poshift;
+bbox->ymax = (fix31)Pmax.y << sp_globals.poshift;
+return TRUE;
+}
+#endif /* new code */
+
+#endif
+
+
+#if INCL_ISW
+FUNCTION boolean make_char_isw(char_index,imported_setwidth)
+GDECL
+ufix16 char_index;
+ufix32 imported_setwidth;
+{
+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 */
+ufix16 return_value;
+
+sp_globals.import_setwidth_act = TRUE;
+/* convert imported width to orus */
+sp_globals.imported_width = (sp_globals.metric_resolution *
+ imported_setwidth) >> 16;
+return_value = do_make_char(char_index);
+
+if (sp_globals.isw_modified_constants)
+ {
+ /* reset fixed point constants */
+ xmin = read_word_u(sp_globals.font_org + FH_FXMIN);
+ ymin = read_word_u(sp_globals.font_org + FH_FYMIN);
+ ymax = read_word_u(sp_globals.font_org + FH_FYMAX);
+ sp_globals.constr.data_valid = FALSE;
+ xmax = read_word_u(sp_globals.font_org + FH_FXMAX);
+ if (!setup_consts(xmin,xmax,ymin,ymax))
+ {
+ report_error(3); /* Requested specs out of range */
+ return FALSE;
+ }
+ }
+return (return_value);
+}
+
+FUNCTION boolean make_char(char_index)
+GDECL
+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)
+#else
+FUNCTION boolean make_char(char_index)
+#endif
+/*
+ * Outputs specified character using the currently selected font and
+ * scaling and output specifications.
+ * Reports Error 10 and returns FALSE if no font specifications
+ * 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;
+fix15 tmpfix15;
+ufix8 format;
+
+#if INCL_ISW
+sp_globals.isw_modified_constants = FALSE;
+#endif
+
+#if REENTRANT_ALLOC
+
+plaid_t plaid;
+
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+intercepts_t intercepts;
+sp_globals.intercepts = &intercepts;
+#endif
+
+sp_globals.plaid = &plaid;
+#endif
+
+if (!sp_globals.specs_valid) /* Font specs not defined? */
+ {
+ report_error(10); /* Report font not specified */
+ return FALSE; /* Error return */
+ }
+
+#if INCL_MULTIDEV
+#if INCL_OUTLINE
+if (sp_globals.output_mode == MODE_OUTLINE && !sp_globals.outline_device_set)
+ {
+ report_error(2);
+ return FALSE;
+ }
+else
+#endif
+ if (!sp_globals.bitmap_device_set)
+ {
+ report_error(2);
+ return FALSE;
+ }
+#endif
+
+
+init_tcb(); /* Initialize transformation control block */
+
+pointer = sp_get_char_org(char_index, TRUE); /* Point to start of character data */
+SHOW(pointer);
+if (pointer == NULL) /* Character data not available? */
+ {
+ report_error(12); /* Report character data not avail */
+ return FALSE; /* Error return */
+ }
+
+pointer += 2; /* Skip over character id */
+x_orus = NEXT_WORD(pointer); /* Read set width */
+#if INCL_SQUEEZING || INCL_ISW
+sp_globals.setwidth_orus = x_orus;
+#endif
+
+#if INCL_ISW
+if (sp_globals.import_setwidth_act)
+ x_orus = sp_globals.imported_width;
+#endif
+sp_globals.Psw.x = (fix15)((fix31)
+ (((fix31)x_orus * (sp_globals.specs.xxmult>>16) +
+ ( ((fix31)x_orus * (sp_globals.specs.xxmult&0xffffL) )>>16)
+ ) << sp_globals.pixshift) / sp_globals.metric_resolution);
+
+sp_globals.Psw.y = (fix15)(
+ (fix31)(
+ ((fix31)x_orus * (sp_globals.specs.yxmult>>16) +
+ ( ((fix31)x_orus * (sp_globals.specs.yxmult&0xffffL) )>>16)
+ ) << sp_globals.pixshift) / sp_globals.metric_resolution);
+
+format = NEXT_BYTE(pointer);
+if (format & BIT1) /* Optional data in header? */
+ {
+ tmpfix15 = (ufix8)NEXT_BYTE(pointer); /* Read size of optional data */
+ pointer += tmpfix15; /* Skip optional data */
+ }
+if (format & BIT0)
+ {
+ return sp_make_comp_char(pointer); /* Output compound character */
+ }
+else
+ {
+ return sp_make_simp_char(pointer, format); /* Output simple character */
+ }
+}
+
+FUNCTION static boolean sp_make_simp_char(pointer, format)
+GDECL
+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.
+ */
+{
+point_t Pmin, Pmax; /* Transformed corners of bounding box */
+#if INCL_SQUEEZING || INCL_ISW
+ufix8 FONTFAR *save_pointer;
+#endif
+#if INCL_ISW
+fix31 char_width;
+fix31 isw_scale;
+#endif
+
+#if INCL_SQUEEZING
+sp_globals.squeezing_compound = FALSE;
+if ((sp_globals.pspecs->flags & SQUEEZE_LEFT) ||
+ (sp_globals.pspecs->flags & SQUEEZE_RIGHT) ||
+ (sp_globals.pspecs->flags & SQUEEZE_TOP) ||
+ (sp_globals.pspecs->flags & SQUEEZE_BOTTOM) )
+ {
+ /* get the bounding box data before processing the character */
+ save_pointer = pointer;
+ preview_bounding_box (pointer, format);
+ pointer = save_pointer;
+ }
+#endif
+#if (INCL_ISW)
+if (sp_globals.import_setwidth_act)
+ {
+ save_pointer = pointer;
+ preview_bounding_box (pointer, format);
+ pointer = save_pointer;
+ /* make sure I'm not going to get fixed point overflow */
+ isw_scale = compute_isw_scale();
+ if (sp_globals.bbox_xmin_orus < 0)
+ char_width = SQUEEZE_MULT((sp_globals.bbox_xmax_orus - sp_globals.bbox_xmin_orus), isw_scale);
+ else
+ char_width = SQUEEZE_MULT(sp_globals.bbox_xmax_orus, isw_scale);
+ if (char_width >= sp_globals.isw_xmax)
+ if (!reset_xmax(char_width))
+ return FALSE;
+ }
+#endif
+pointer = plaid_tcb(pointer, format); /* Process plaid data */
+pointer = read_bbox(pointer, &Pmin, &Pmax, FALSE); /* Read bounding box */
+if (fn_begin_char(sp_globals.Psw, Pmin, Pmax)) /* Signal start of character output */
+ {
+ do
+ {
+ proc_outl_data(pointer); /* Process outline data */
+ }
+ while (!fn_end_char()); /* Repeat if not done */
+ }
+return TRUE;
+}
+
+FUNCTION static boolean sp_make_comp_char(pointer)
+GDECL
+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.
+ * Returns TRUE if output completed with no error.
+ */
+{
+point_t Pmin, Pmax; /* Transformed corners of bounding box */
+point_t Pssw; /* Transformed escapement vector */
+ufix8 FONTFAR *pointer_sav; /* Saved pointer to compound character data */
+ufix8 FONTFAR *sub_pointer; /* Pointer to sub-character data */
+ufix8 format; /* Format of DOCH instruction */
+ufix16 sub_char_index; /* Index to sub-character in character directory */
+fix15 x_posn; /* X position of sub-character (outline res units) */
+fix15 y_posn; /* Y position of sub-character (outline res units) */
+fix15 x_scale; /* X scale factor of sub-character (scale units) */
+fix15 y_scale; /* Y scale factor of sub-character (scale units) */
+fix15 tmpfix15; /* Temporary workspace */
+fix15 x_orus; /* Set width in outline resolution units */
+fix15 pix_adj; /* Pixel adjustment to compound char bounding box */
+#if INCL_SQUEEZING
+fix31 x_factor, x_offset, top_scale, bottom_scale;
+boolean squeezed_x, squeezed_y;
+#endif
+#if INCL_SQUEEZING || INCL_ISW
+fix15 x_offset_pix;
+#endif
+#if INCL_ISW
+fix31 char_width;
+fix31 isw_scale;
+#endif
+
+
+#if INCL_SQUEEZING
+sp_globals.squeezing_compound = TRUE;
+#endif
+pointer = read_bbox(pointer, &Pmin, &Pmax, TRUE); /* Read bounding box data */
+pix_adj = sp_globals.onepix << 1; /* Allow 2 pixel expansion ... */
+Pmin.x -= pix_adj; /* ... of components of ... */
+Pmin.y -= pix_adj; /* ... compound ... */
+Pmax.x += pix_adj; /* ... character ... */
+Pmax.y += pix_adj; /* ... bounding box. */
+
+#if INCL_SQUEEZING
+/* scale the bounding box if necessary before calling begin_char */
+squeezed_x = calculate_x_scale(&x_factor, &x_offset, 0);
+squeezed_y = calculate_y_scale(&top_scale, &bottom_scale,0,0);
+
+if (squeezed_x)
+ { /* scale the x coordinates of the bbox */
+ x_offset_pix = (fix15)(((x_offset >> 16) * sp_globals.tcb0.xppo)
+ >> sp_globals.mpshift);
+ if ((x_offset_pix >0) && (x_offset_pix < sp_globals.onepix))
+ x_offset_pix = sp_globals.onepix;
+ Pmin.x = SQUEEZE_MULT (x_factor, Pmin.x) + x_offset_pix - pix_adj;
+ Pmax.x = SQUEEZE_MULT (x_factor, Pmax.x) + x_offset_pix + pix_adj;
+ }
+if (squeezed_y)
+ { /* scale the y coordinates of the bbox */
+ if ((Pmin.y) < 0)
+ Pmin.y = SQUEEZE_MULT (bottom_scale, Pmin.y) - pix_adj;
+ else
+ Pmin.y = SQUEEZE_MULT (top_scale, Pmin.y) - pix_adj;
+ if ((Pmax.y) < 0)
+ Pmax.y = SQUEEZE_MULT (bottom_scale, Pmax.y) + pix_adj;
+ else
+ Pmax.y = SQUEEZE_MULT (top_scale, Pmax.y) + pix_adj;
+ }
+#endif
+#if (INCL_ISW)
+if (sp_globals.import_setwidth_act)
+ {
+ /* make sure I'm not going to get fixed point overflow */
+ isw_scale = ((fix31)sp_globals.imported_width << 16)/
+ (fix31)sp_globals.setwidth_orus;
+ char_width = SQUEEZE_MULT((sp_globals.bbox_xmax_orus -
+ sp_globals.bbox_xmin_orus),
+isw_scale);
+ if (char_width >= sp_globals.isw_xmax)
+ if (!reset_xmax(char_width))
+ return FALSE;
+ }
+#endif
+
+if (fn_begin_char(sp_globals.Psw, Pmin, Pmax)) /* Signal start of character data */
+ {
+ pointer_sav = pointer;
+ do
+ {
+ pointer = pointer_sav; /* Point to next DOCH or END instruction */
+ while ((format = NEXT_BYTE(pointer))) /* DOCH instruction? */
+ {
+ init_tcb(); /* Initialize transformation control block */
+ x_posn = sp_get_posn_arg(&pointer, format);
+ y_posn = sp_get_posn_arg(&pointer, (ufix8)(format >> 2));
+ x_scale = sp_get_scale_arg(&pointer, (ufix8)(format & BIT4));
+ y_scale = sp_get_scale_arg(&pointer, (ufix8)(format & BIT5));
+ scale_tcb(&sp_globals.tcb, x_posn, y_posn, x_scale, y_scale); /* Scale for sub-char */
+ sub_char_index = (format & BIT6)? /* Read sub-char index */
+ 0xffff & NEXT_WORD(pointer):
+ 0xffff & NEXT_BYTE(pointer);
+ sub_pointer = sp_get_char_org(sub_char_index, FALSE); /* Point to start of sub-char */
+ if (sub_pointer == NULL) /* Character data not available? */
+ {
+ return FALSE; /* Abort character output */
+ }
+ sub_pointer += 2; /* Skip over character id */
+ x_orus = NEXT_WORD(sub_pointer); /* Read set_width of sub-character */
+
+ Pssw.x = (fix15)(
+ (fix31)(
+ ((fix31)x_orus * (sp_globals.specs.xxmult>>16) +
+ ( ((fix31)x_orus * (sp_globals.specs.xxmult&0xffffL) )>>16)
+ ) << sp_globals.pixshift) / sp_globals.metric_resolution);
+ Pssw.y = (fix15)(
+ (fix31)(
+ ((fix31)x_orus * (sp_globals.specs.yxmult>>16) +
+ ( ((fix31)x_orus * (sp_globals.specs.yxmult&0xffffL) )>>16)
+ ) << sp_globals.pixshift) / sp_globals.metric_resolution);
+
+ format = NEXT_BYTE(sub_pointer); /* Read sub-character format */
+ if (format & BIT1) /* Optional data in header? */
+ {
+ tmpfix15 = (ufix8)NEXT_BYTE(sub_pointer); /* Read size of optional data */
+ sub_pointer += tmpfix15; /* Skip optional data */
+ }
+ sub_pointer = plaid_tcb(sub_pointer, format); /* Process sub-character plaid data */
+ sub_pointer = read_bbox(sub_pointer, &Pmin, &Pmax, FALSE); /* Read bounding box */
+ fn_begin_sub_char(Pssw, Pmin, Pmax); /* Signal start of sub-character data */
+ proc_outl_data(sub_pointer); /* Process sub-character data */
+ fn_end_sub_char(); /* Signal end of sub-character data */
+ }
+ }
+ while (!fn_end_char()); /* Signal end of character; repeat if required */
+ }
+return TRUE;
+}
+
+#if INCL_LCD /* Dynamic load character data supported? */
+FUNCTION static ufix8 FONTFAR *sp_get_char_org(char_index, top_level)
+GDECL
+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
+ * for the specified character index.
+ * Version for configuration supporting dynamic character data loading.
+ * Calls load_char_data() to load character data if not already loaded
+ * as part of the original font buffer.
+ * Returns NULL if character data not available
+ */
+{
+buff_t *pchar_data; /* Buffer descriptor requested */
+ufix8 FONTFAR *pointer; /* Pointer into character directory */
+ufix8 format; /* Character directory format byte */
+fix31 char_offset; /* Offset of char data from start of font file */
+fix31 next_char_offset; /* Offset of char data from start of font file */
+fix15 no_bytes; /* Number of bytes required for char data */
+
+if (top_level) /* Not element of compound char? */
+ {
+ if (char_index < sp_globals.first_char_idx) /* Before start of character set? */
+ return NULL;
+ char_index -= sp_globals.first_char_idx;
+ if (char_index >= sp_globals.no_chars_avail) /* Beyond end of character set? */
+ return NULL;
+ sp_globals.cb_offset = 0; /* Reset char buffer offset */
+ }
+
+pointer = sp_globals.pchar_dir;
+format = NEXT_BYTE(pointer); /* Read character directory format byte */
+pointer += char_index << 1; /* Point to indexed character entry */
+if (format) /* 3-byte entries in char directory? */
+ {
+ pointer += char_index; /* Adjust for 3-byte entries */
+ char_offset = read_long(pointer); /* Read file offset to char data */
+ next_char_offset = read_long(pointer + 3); /* Read offset to next char */
+ }
+else
+ {
+ char_offset = (fix31)(0xffff & NEXT_WORD(pointer)); /* Read file offset to char data */
+ next_char_offset = (fix31)(0xffff & NEXT_WORD(pointer)); /* Read offset to next char */
+ }
+
+no_bytes = next_char_offset - char_offset;
+if (no_bytes == 0) /* Character not in directory? */
+ return NULL;
+
+if (next_char_offset <= sp_globals.font_buff_size)/* Character data already in font buffer? */
+ return sp_globals.pfont->org + char_offset; /* Return pointer into font buffer */
+
+pchar_data = load_char_data(char_offset, no_bytes, sp_globals.cb_offset); /* Request char data load */
+if (pchar_data->no_bytes < no_bytes) /* Correct number of bytes loaded? */
+ return NULL;
+
+if (top_level) /* Not element of compound char? */
+ {
+ sp_globals.cb_offset = no_bytes;
+ }
+
+return pchar_data->org; /* Return pointer into character data buffer */
+}
+#endif
+
+#if INCL_LCD
+#else /* Dynamic load character data not supported? */
+FUNCTION static ufix8 FONTFAR *sp_get_char_org(char_index, top_level)
+GDECL
+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
+ * for the specified character index.
+ * Version for configuration not supporting dynamic character data loading.
+ * Returns NULL if character data not available
+ */
+{
+ufix8 FONTFAR *pointer; /* Pointer into character directory */
+ufix8 format; /* Character directory format byte */
+fix31 char_offset; /* Offset of char data from start of font file */
+fix31 next_char_offset; /* Offset of char data from start of font file */
+fix15 no_bytes; /* Number of bytes required for char data */
+
+if (top_level) /* Not element of compound char? */
+ {
+ if (char_index < sp_globals.first_char_idx) /* Before start of character set? */
+ return NULL;
+ char_index -= sp_globals.first_char_idx;
+ if (char_index >= sp_globals.no_chars_avail) /* Beyond end of character set? */
+ return NULL;
+ }
+
+pointer = sp_globals.pchar_dir;
+format = NEXT_BYTE(pointer); /* Read character directory format byte */
+pointer += char_index << 1; /* Point to indexed character entry */
+if (format) /* 3-byte entries in char directory? */
+ {
+ pointer += char_index; /* Adjust for 3-byte entries */
+ char_offset = read_long(pointer); /* Read file offset to char data */
+ next_char_offset = read_long(pointer + 3); /* Read offset to next char */
+ }
+else
+ {
+ char_offset = (fix31)(0xffff & NEXT_WORD(pointer)); /* Read file offset to char data */
+ next_char_offset = (fix31)(0xffff & NEXT_WORD(pointer)); /* Read offset to next char */
+ }
+
+no_bytes = next_char_offset - char_offset;
+if (no_bytes == 0) /* Character not in directory? */
+ return NULL;
+
+return sp_globals.pfont->org + char_offset; /* Return pointer into font buffer */
+}
+#endif
+
+
+FUNCTION static fix15 sp_get_posn_arg(ppointer, format)
+GDECL
+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.
+ * Updates pointer to byte following position argument.
+ * Returns value of position argument in outline resolution units
+ */
+{
+switch (format & 0x03)
+ {
+case 1:
+ return NEXT_WORD(*ppointer);
+
+case 2:
+ return (fix15)((fix7)NEXT_BYTE(*ppointer));
+
+default:
+ return (fix15)0;
+ }
+}
+
+FUNCTION static fix15 sp_get_scale_arg(ppointer, format)
+GDECL
+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.
+ * Updates pointer to byte following scale argument.
+ * Returns value of scale argument in scale units (normally 1/4096)
+ */
+{
+if (format)
+ return NEXT_WORD(*ppointer);
+else
+ return (fix15)ONE_SCALE;
+}
+#if INCL_ISW || INCL_SQUEEZING
+FUNCTION static void preview_bounding_box(pointer,format)
+GDECL
+ufix8 FONTFAR *pointer; /* Pointer to first byte of position argument */
+ufix8 format; /* Character format byte */
+{
+point_t Pmin, Pmax; /* Transformed corners of bounding box */
+
+ sp_globals.no_X_orus = (format & BIT2)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+ sp_globals.no_Y_orus = (format & BIT3)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+ pointer = read_oru_table(pointer);
+
+ /* Skip over control zone table */
+ pointer = skip_control_zone(pointer,format);
+
+ /* Skip over interpolation table */
+ pointer = skip_interpolation_table(pointer,format);
+ /* get_args has a pathological need for this value to be set */
+ sp_globals.Y_edge_org = sp_globals.no_X_orus;
+ pointer = read_bbox(pointer, &Pmin, &Pmax, TRUE); /* Read bounding bo
+x */
+
+}
+#endif
+#if INCL_ISW
+FUNCTION static boolean reset_xmax(xmax)
+GDECL
+fix31 xmax;
+
+{
+fix15 xmin; /* Minimum X ORU value in font */
+fix15 ymin; /* Minimum Y ORU value in font */
+fix15 ymax; /* Maximum Y ORU value in font */
+
+
+sp_globals.isw_modified_constants = TRUE;
+xmin = read_word_u(sp_globals.font_org + FH_FXMIN);
+ymin = read_word_u(sp_globals.font_org + FH_FYMIN);
+ymax = read_word_u(sp_globals.font_org + FH_FYMAX);
+
+if (!setup_consts(xmin,xmax,ymin,ymax))
+ {
+ report_error(3); /* Requested specs out of range */
+ return FALSE;
+ }
+sp_globals.constr.data_valid = FALSE;
+/* recompute setwidth */
+sp_globals.Psw.x = (fix15)((fix31)(
+ ((fix31)sp_globals.imported_width * (sp_globals.specs.xxmult>>16) +
+ ( ((fix31)sp_globals.imported_width *
+ (sp_globals.specs.xxmult&0xffffL) )>>16)
+ ) << sp_globals.pixshift) / sp_globals.metric_resolution);
+sp_globals.Psw.y = (fix15)(
+ (fix31)(
+ ((fix31)sp_globals.imported_width * (sp_globals.specs.yxmult>>16) +
+ ( ((fix31)sp_globals.imported_width * (sp_globals.specs.yxmult&0xffffL) )>>16)
+ ) << sp_globals.pixshift) / sp_globals.metric_resolution);
+
+return TRUE;
+}
+#endif
diff --git a/src/Speedo/do_trns.c b/src/Speedo/do_trns.c
new file mode 100644
index 0000000..b003284
--- /dev/null
+++ b/src/Speedo/do_trns.c
@@ -0,0 +1,513 @@
+/* $Xorg: do_trns.c,v 1.3 2000/08/17 19:46:25 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+/**************************** D O _ T R N S . C ******************************
+ * *
+ * This module is responsible for executing all intelligent transformation *
+ * for bounding box and outline data *
+ * *
+ ****************************************************************************/
+
+
+#include "spdo_prv.h" /* General definitions for Speedo */
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** 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)
+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 */
+/*
+ * Called by make_simp_char() and make_comp_char() to read the
+ * bounding box data from the font.
+ * Sets Pmin and Pmax to the bottom left and top right corners
+ * of the bounding box after transformation into device space.
+ * The units of Pmin and Pmax are sub-pixels.
+ * Updates *ppointer to point to the byte following the
+ * bounding box data.
+ */
+{
+ufix8 format1;
+ufix8 format;
+fix15 i;
+point_t P;
+
+sp_globals.x_int = 0;
+sp_globals.y_int = sp_globals.Y_int_org;
+sp_globals.x_orus = sp_globals.y_orus = 0;
+format1 = NEXT_BYTE(pointer);
+pointer = sp_get_args(pointer, format1, pPmin);
+#if INCL_SQUEEZING || INCL_ISW
+if (set_flag)
+ {
+ sp_globals.bbox_xmin_orus = sp_globals.x_orus;
+ sp_globals.bbox_ymin_orus = sp_globals.y_orus;
+ }
+#endif
+*pPmax = *pPmin;
+for (i = 1; i < 4; i++)
+ {
+ switch(i)
+ {
+ case 1:
+ if (format1 & BIT6) /* Xmax requires X int zone 1? */
+ sp_globals.x_int++;
+ format = (format1 >> 4) | 0x0c;
+ break;
+
+ case 2:
+ if (format1 & BIT7) /* Ymax requires Y int zone 1? */
+ sp_globals.y_int++;
+ format = NEXT_BYTE(pointer);
+ break;
+
+ case 3:
+ sp_globals.x_int = 0;
+ format >>= 4;
+ break;
+
+ default:
+ break;
+ }
+
+ pointer = sp_get_args(pointer, format, &P);
+#if INCL_SQUEEZING || INCL_ISW
+ if (set_flag && (i==2))
+ {
+ sp_globals.bbox_xmax_orus = sp_globals.x_orus;
+ sp_globals.bbox_ymax_orus = sp_globals.y_orus;
+ }
+#endif
+ if ((i == 2) || (!sp_globals.normal))
+ {
+ if (P.x < pPmin->x)
+ pPmin->x = P.x;
+ if (P.y < pPmin->y)
+ pPmin->y = P.y;
+ if (P.x > pPmax->x)
+ pPmax->x = P.x;
+ if (P.y > pPmax->y)
+ pPmax->y = P.y;
+ }
+ }
+
+#if DEBUG
+printf("BBOX %6.1f(Xint 0), %6.1f(Yint 0), %6.1f(Xint %d), %6.1f(Yint %d)\n",
+ (real)pPmin->x / (real)sp_globals.onepix,
+ (real)pPmin->y / (real)sp_globals.onepix,
+ (real)pPmax->x / (real)sp_globals.onepix,
+ (format1 >> 6) & 0x01,
+ (real)pPmax->y / (real)sp_globals.onepix,
+ (format1 >> 7) & 0x01);
+
+#endif
+return pointer;
+}
+
+FUNCTION void proc_outl_data(pointer)
+GDECL
+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.
+ * The outline data is parsed, transformed into device coordinates
+ * and passed to an output module for further processing.
+ * Note that pointer is not updated to facilitate repeated
+ * processing of the outline data when banding mode is in effect.
+ */
+{
+ufix8 format1, format2;
+point_t P0, P1, P2, P3;
+fix15 depth;
+fix15 curve_count;
+
+sp_globals.x_int = 0;
+sp_globals.y_int = sp_globals.Y_int_org;
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+record_xint((fix15)sp_globals.x_int); /* Record xint data */
+record_yint((fix15)(sp_globals.y_int - sp_globals.Y_int_org)); /* Record yint data */
+#endif
+
+sp_globals.x_orus = sp_globals.y_orus = 0;
+curve_count = 0;
+while(TRUE)
+ {
+ format1 = NEXT_BYTE(pointer);
+ switch(format1 >> 4)
+ {
+ case 0: /* LINE */
+ pointer = sp_get_args(pointer, format1, &P1);
+#if DEBUG
+ printf("LINE %6.1f, %6.1f\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix);
+#endif
+ fn_line(P1);
+ sp_globals.P0 = P1;
+ continue;
+
+ case 1: /* Short XINT */
+ sp_globals.x_int = format1 & 0x0f;
+#if DEBUG
+ printf("XINT %d\n", sp_globals.x_int);
+#endif
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+record_xint((fix15)sp_globals.x_int); /* Record xint data */
+#endif
+ continue;
+
+ case 2: /* Short YINT */
+ sp_globals.y_int = sp_globals.Y_int_org + (format1 & 0x0f);
+#if DEBUG
+ printf("YINT %d\n", sp_globals.y_int - sp_globals.Y_int_org);
+#endif
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+record_yint((fix15)(sp_globals.y_int - sp_globals.Y_int_org)); /* Record yint data */
+#endif
+ continue;
+
+ case 3: /* Miscellaneous */
+ switch(format1 & 0x0f)
+ {
+ case 0: /* END */
+ if (curve_count)
+ {
+ fn_end_contour();
+ }
+ return;
+
+ case 1: /* Long XINT */
+ sp_globals.x_int = NEXT_BYTE(pointer);
+#if DEBUG
+ printf("XINT %d\n", sp_globals.x_int);
+#endif
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+record_xint((fix15)sp_globals.x_int); /* Record xint data */
+#endif
+ continue;
+
+ case 2: /* Long YINT */
+ sp_globals.y_int = sp_globals.Y_int_org + NEXT_BYTE(pointer);
+#if DEBUG
+ printf("YINT %d\n", sp_globals.y_int - sp_globals.Y_int_org);
+#endif
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+record_yint((fix15)(sp_globals.y_int - sp_globals.Y_int_org)); /* Record yint data */
+#endif
+ continue;
+
+ default: /* Not used */
+ continue;
+ }
+
+ case 4: /* MOVE Inside */
+ case 5: /* MOVE Outside */
+ if (curve_count++)
+ {
+ fn_end_contour();
+ }
+
+ pointer = sp_get_args(pointer, format1, &P0);
+ sp_globals.P0 = P0;
+#if DEBUG
+ printf("MOVE %6.1f, %6.1f\n",
+ (real)sp_globals.P0.x / (real)sp_globals.onepix, (real)sp_globals.P0.y / (real)sp_globals.onepix);
+#endif
+ fn_begin_contour(sp_globals.P0, (boolean)(format1 & BIT4));
+ continue;
+
+ case 6: /* Undefined */
+#if DEBUG
+ printf("*** Undefined instruction (Hex %4x)\n", format1);
+#endif
+ continue;
+
+ case 7: /* Undefined */
+#if DEBUG
+ printf("*** Undefined instruction (Hex %4x)\n", format1);
+#endif
+ continue;
+
+ default: /* CRVE */
+ format2 = NEXT_BYTE(pointer);
+ pointer = sp_get_args(pointer, format1, &P1);
+ pointer = sp_get_args(pointer, format2, &P2);
+ pointer = sp_get_args(pointer, (ufix8)(format2 >> 4), &P3);
+ depth = (format1 >> 4) & 0x07;
+#if DEBUG
+ printf("CRVE %6.1f, %6.1f, %6.1f, %6.1f, %6.1f, %6.1f, %d\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix,
+ (real)P2.x / (real)sp_globals.onepix, (real)P2.y / (real)sp_globals.onepix,
+ (real)P3.x / (real)sp_globals.onepix, (real)P3.y / (real)sp_globals.onepix,
+ depth);
+#endif
+ depth += sp_globals.depth_adj;
+ if (sp_globals.curves_out)
+ {
+ fn_curve(P1, P2, P3, depth);
+ sp_globals.P0 = P3;
+ continue;
+ }
+ if (depth <= 0)
+ {
+ fn_line(P3);
+ sp_globals.P0 = P3;
+ continue;
+ }
+ sp_split_curve(P1, P2, P3, depth);
+ continue;
+ }
+ }
+}
+
+FUNCTION static void sp_split_curve(P1, P2, P3, depth)
+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 */
+/*
+ * Called by proc_outl_data() to subdivide Bezier curves into an
+ * appropriate number of vectors, whenever curves are not enabled
+ * for output to the currently selected output module.
+ * sp_split_curve() calls itself recursively to the depth specified
+ * at which point it calls line() to deliver each vector resulting
+ * from the spliting process.
+ */
+{
+fix31 X0 = (fix31)sp_globals.P0.x;
+fix31 Y0 = (fix31)sp_globals.P0.y;
+fix31 X1 = (fix31)P1.x;
+fix31 Y1 = (fix31)P1.y;
+fix31 X2 = (fix31)P2.x;
+fix31 Y2 = (fix31)P2.y;
+fix31 X3 = (fix31)P3.x;
+fix31 Y3 = (fix31)P3.y;
+point_t Pmid;
+point_t Pctrl1;
+point_t Pctrl2;
+
+#if DEBUG
+printf("CRVE(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix,
+ (real)P2.x / (real)sp_globals.onepix, (real)P2.y / (real)sp_globals.onepix,
+ (real)P3.x / (real)sp_globals.onepix, (real)P3.y / (real)sp_globals.onepix);
+#endif
+
+
+Pmid.x = (X0 + (X1 + X2) * 3 + X3 + 4) >> 3;
+Pmid.y = (Y0 + (Y1 + Y2) * 3 + Y3 + 4) >> 3;
+if ((--depth) <= 0)
+ {
+ fn_line(Pmid);
+ sp_globals.P0 = Pmid;
+ fn_line(P3);
+ sp_globals.P0 = P3;
+ }
+else
+ {
+ Pctrl1.x = (X0 + X1 + 1) >> 1;
+ Pctrl1.y = (Y0 + Y1 + 1) >> 1;
+ Pctrl2.x = (X0 + (X1 << 1) + X2 + 2) >> 2;
+ Pctrl2.y = (Y0 + (Y1 << 1) + Y2 + 2) >> 2;
+ sp_split_curve(Pctrl1, Pctrl2, Pmid, depth);
+ Pctrl1.x = (X1 + (X2 << 1) + X3 + 2) >> 2;
+ Pctrl1.y = (Y1 + (Y2 << 1) + Y3 + 2) >> 2;
+ Pctrl2.x = (X2 + X3 + 1) >> 1;
+ Pctrl2.y = (Y2 + Y3 + 1) >> 1;
+ sp_split_curve(Pctrl1, Pctrl2, P3, depth);
+ }
+}
+
+FUNCTION static ufix8 FONTFAR *sp_get_args(pointer, format, pP)
+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 */
+/*
+ * Called by read_bbox() and proc_outl_data() to read an X Y argument
+ * pair from the font.
+ * The format is specified as follows:
+ * Bits 0-1: Type of X argument.
+ * Bits 2-3: Type of Y argument.
+ * where the 4 possible argument types are:
+ * Type 0: Controlled coordinate represented by one byte
+ * index into the X or Y controlled coordinate table.
+ * Type 1: Interpolated coordinate represented by a two-byte
+ * signed integer.
+ * Type 2: Interpolated coordinate represented by a one-byte
+ * signed increment/decrement relative to the
+ * proceding X or Y coordinate.
+ * Type 3: Repeat of preceding X or Y argument value and type.
+ * The units of P are sub-pixels.
+ * Updates *ppointer to point to the byte following the
+ * argument pair.
+ */
+{
+ufix8 edge;
+
+/* Read X argument */
+switch(format & 0x03)
+ {
+case 0: /* Index to controlled oru */
+ edge = NEXT_BYTE(pointer);
+ sp_globals.x_orus = sp_plaid.orus[edge];
+#if INCL_RULES
+ sp_globals.x_pix = sp_plaid.pix[edge];
+#endif
+ break;
+
+case 1: /* 2 byte interpolated oru value */
+ sp_globals.x_orus = NEXT_WORD(pointer);
+ goto L1;
+
+case 2: /* 1 byte signed oru increment */
+ sp_globals.x_orus += (fix15)((fix7)NEXT_BYTE(pointer));
+L1:
+#if INCL_RULES
+ sp_globals.x_pix = TRANS(sp_globals.x_orus, sp_plaid.mult[sp_globals.x_int], sp_plaid.offset[sp_globals.x_int], sp_globals.mpshift);
+#endif
+ break;
+
+default: /* No change in X value */
+ break;
+ }
+
+/* Read Y argument */
+switch((format >> 2) & 0x03)
+ {
+case 0: /* Index to controlled oru */
+ edge = sp_globals.Y_edge_org + NEXT_BYTE(pointer);
+ sp_globals.y_orus = sp_plaid.orus[edge];
+#if INCL_RULES
+ sp_globals.y_pix = sp_plaid.pix[edge];
+#endif
+ break;
+
+case 1: /* 2 byte interpolated oru value */
+ sp_globals.y_orus = NEXT_WORD(pointer);
+ goto L2;
+
+case 2: /* 1 byte signed oru increment */
+ sp_globals.y_orus += (fix15)((fix7)NEXT_BYTE(pointer));
+L2:
+#if INCL_RULES
+ sp_globals.y_pix = TRANS(sp_globals.y_orus, sp_plaid.mult[sp_globals.y_int], sp_plaid.offset[sp_globals.y_int], sp_globals.mpshift);
+#endif
+ break;
+
+default: /* No change in X value */
+ break;
+ }
+
+#if INCL_RULES
+switch(sp_globals.tcb.xmode)
+ {
+case 0: /* X mode 0 */
+ pP->x = sp_globals.x_pix;
+ break;
+
+case 1: /* X mode 1 */
+ pP->x = -sp_globals.x_pix;
+ break;
+
+case 2: /* X mode 2 */
+ pP->x = sp_globals.y_pix;
+ break;
+
+case 3: /* X mode 3 */
+ pP->x = -sp_globals.y_pix;
+ break;
+
+default: /* X mode 4 */
+#endif
+ pP->x = (MULT16(sp_globals.x_orus, sp_globals.tcb.xxmult) +
+ MULT16(sp_globals.y_orus, sp_globals.tcb.xymult) +
+ sp_globals.tcb.xoffset) >> sp_globals.mpshift;
+#if INCL_RULES
+ break;
+ }
+
+switch(sp_globals.tcb.ymode)
+ {
+case 0: /* Y mode 0 */
+ pP->y = sp_globals.y_pix;
+ break;
+
+case 1: /* Y mode 1 */
+ pP->y = -sp_globals.y_pix;
+ break;
+
+case 2: /* Y mode 2 */
+ pP->y = sp_globals.x_pix;
+ break;
+
+case 3: /* Y mode 3 */
+ pP->y = -sp_globals.x_pix;
+ break;
+
+default: /* Y mode 4 */
+#endif
+ pP->y = (MULT16(sp_globals.x_orus, sp_globals.tcb.yxmult) +
+ MULT16(sp_globals.y_orus, sp_globals.tcb.yymult) +
+ sp_globals.tcb.yoffset) >> sp_globals.mpshift;
+#if INCL_RULES
+ break;
+ }
+#endif
+
+return pointer;
+}
+
+
+
diff --git a/src/Speedo/keys.h b/src/Speedo/keys.h
new file mode 100644
index 0000000..dd9d0bf
--- /dev/null
+++ b/src/Speedo/keys.h
@@ -0,0 +1,56 @@
+/* $Xorg: keys.h,v 1.3 2000/08/17 19:46:25 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+
+/***** DECRYPTION KEY CONSTANTS (PC Platform) *****/
+
+#define CUS0 432 /* Customer number */
+
+#define KEY0 0 /* Decryption key 0 */
+#define KEY1 72 /* Decryption key 1 */
+#define KEY2 123 /* Decryption key 2 */
+#define KEY3 1 /* Decryption key 3 */
+#define KEY4 222 /* Decryption key 4 */
+#define KEY5 194 /* Decryption key 5 */
+#define KEY6 113 /* Decryption key 6 */
+#define KEY7 119 /* Decryption key 7 */
+#define KEY8 52 /* Decryption key 8 */
+
+/***** DECRYPTION KEY CONSTANTS (Sample) *****/
+
+#define XSAMPLEFONTS
+
+#define XCUS0 0 /* Customer number */
+
+#define XKEY0 0 /* Decryption key 0 */
+#define XKEY1 0 /* Decryption key 1 */
+#define XKEY2 0 /* Decryption key 2 */
+#define XKEY3 0 /* Decryption key 3 */
+#define XKEY4 0 /* Decryption key 4 */
+#define XKEY5 0 /* Decryption key 5 */
+#define XKEY6 0 /* Decryption key 6 */
+#define XKEY7 0 /* Decryption key 7 */
+#define XKEY8 0 /* Decryption key 8 */
+
+
diff --git a/src/Speedo/out_bl2d.c b/src/Speedo/out_bl2d.c
new file mode 100644
index 0000000..d14f8c3
--- /dev/null
+++ b/src/Speedo/out_bl2d.c
@@ -0,0 +1,776 @@
+/* $Xorg: out_bl2d.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+/*************************** O U T _ B L 2 D . C *****************************
+ * *
+ * This is an output module for screen writer using two dimensional scanning *
+ ****************************************************************************/
+
+
+#include "spdo_prv.h" /* General definitions for speedo */
+
+#define CLOCKWISE 1
+#define DEBUG 0
+#define ABS(X) ( (X < 0) ? -X : X)
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** 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)
+GDECL
+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.
+ * Returns FALSE otherwise.
+ */
+{
+
+if (specsarg->flags & CURVES_OUT)
+ return FALSE; /* Curves out, clipping not supported */
+
+#if DEBUG
+printf("INIT_OUT__2d()\n");
+#endif
+return TRUE;
+}
+#endif
+
+#if INCL_2D
+FUNCTION boolean begin_char_2d(Psw, Pmin, Pmax)
+GDECL
+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
+ */
+{
+#if DEBUG
+printf("BEGIN_CHAR__2d(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
+ (real)Psw.x / (real)sp_globals.onepix, (real)Psw.y / (real)sp_globals.onepix,
+ (real)Pmin.x / (real)sp_globals.onepix, (real)Pmin.y / (real)sp_globals.onepix,
+ (real)Pmax.x / (real)sp_globals.onepix, (real)Pmax.y / (real)sp_globals.onepix);
+#endif
+/* Convert PIX.FRAC to 16.16 form */
+sp_globals.x_scan_active = TRUE; /* Assume x-scanning from the start */
+
+init_char_out(Psw,Pmin,Pmax);
+return TRUE;
+}
+#endif
+
+
+#if INCL_2D
+FUNCTION void begin_contour_2d(P1, outside)
+GDECL
+point_t P1;
+boolean outside;
+/* Called at the start of each contour
+ */
+{
+
+#if DEBUG
+printf("BEGIN_CONTOUR__2d(%3.4f, %3.4f, %s)\n",
+ (real)P1.x / (real)sp_globals.onepix,
+ (real)P1.y / (real)sp_globals.onepix,
+ outside? "outside": "inside");
+#endif
+sp_globals.x0_spxl = P1.x;
+sp_globals.y0_spxl = P1.y;
+}
+#endif
+
+#if INCL_2D
+FUNCTION void line_2d(P1)
+GDECL
+point_t P1;
+/*
+ * Called for each vector in the transformed character
+ * "draws" vector into intercept table
+ */
+{
+
+#if DEBUG
+printf("LINE_0(%3.4f, %3.4f)\n",
+ (real)P1.x / (real)sp_globals.onepix,
+ (real)P1.y / (real)sp_globals.onepix);
+#endif
+
+if (sp_globals.extents_running)
+ {
+ if (sp_globals.x0_spxl > sp_globals.bmap_xmax)
+ sp_globals.bmap_xmax = sp_globals.x0_spxl;
+ if (sp_globals.x0_spxl < sp_globals.bmap_xmin)
+ sp_globals.bmap_xmin = sp_globals.x0_spxl;
+ if (sp_globals.y0_spxl > sp_globals.bmap_ymax)
+ sp_globals.bmap_ymax = sp_globals.y0_spxl;
+ if (sp_globals.y0_spxl < sp_globals.bmap_ymin)
+ sp_globals.bmap_ymin = sp_globals.y0_spxl;
+ }
+
+if (!sp_globals.intercept_oflo)
+ {
+ sp_draw_vector_to_2d(sp_globals.x0_spxl,
+ sp_globals.y0_spxl,
+ P1.x,
+ P1.y,
+ &sp_globals.y_band); /* y-scan */
+
+ if (sp_globals.x_scan_active)
+ sp_draw_vector_to_2d(sp_globals.y0_spxl,
+ sp_globals.x0_spxl,
+ P1.y,
+ P1.x,
+ &sp_globals.x_band); /* x-scan if selected */
+ }
+
+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)
+GDECL
+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 */
+ fix15 temp1; /* various uses */
+ fix15 temp2; /* various uses */
+register fix31 dx_dy; /* slope of line in 16.16 form */
+register fix31 xc; /* high-precision (16.16) x coordinate */
+ fix15 y_pxl;
+
+yc = (y0 + sp_globals.pixrnd) >> sp_globals.pixshift; /* current scan line = end of last line */
+y_pxl = (y1 + sp_globals.pixrnd) >> sp_globals.pixshift; /* calculate new end-scan line */
+
+if ((how_many_y = y_pxl - yc) == 0) return; /* Don't draw a null line */
+
+if (how_many_y < 0) yc--; /* Predecrment downward lines */
+
+if (yc > band->band_max) /* Is start point above band? */
+ {
+ if (y_pxl > band->band_max) return; /* line has to go down! */
+ how_many_y = y_pxl - (yc = band->band_max) - 1; /* Yes, limit it */
+ }
+
+if (yc < band->band_min) /* Is start point below band? */
+ {
+ if (y_pxl < band->band_min) return; /* line has to go up! */
+ how_many_y = y_pxl - (yc = band->band_min); /* Yes, limit it */
+ }
+
+xc = (fix31)(x0 + sp_globals.pixrnd) << 16; /* Original x coordinate with built in */
+ /* rounding. int.16 + pixshift form */
+
+if ( (temp1 = (x1 - x0)) == 0) /* check for vertical line */
+ {
+ dx_dy = 0L; /* Zero slope, leave xc alone */
+ goto skip_calc;
+ }
+
+/* calculate dx_dy at 16.16 fixed point */
+
+dx_dy = ( (fix31)temp1 << 16 )/(fix31)(y1 - y0);
+
+/* We have to check for a @#$%@# possible multiply overflow */
+/* by doing another @#$*& multiply. In assembly language, */
+/* the program could just check the OVerflow flag or whatever*/
+/* works on the particular processor. This C code is meant */
+/* to be processor independent. */
+
+temp1 = (yc << sp_globals.pixshift) - y0 + sp_globals.pixrnd;
+/* This sees if the sign bits start at bit 15 */
+/* if they do, no overflow has occurred */
+
+temp2 = (fix15)(MULT16(temp1,(fix15)(dx_dy >> 16)) >> 15);
+
+if ( (temp2 != (fix15)0xFFFF) &&
+ (temp2 != 0x0000) )
+ { /* Overflow. Pick point closest to yc + .5 */
+ if (ABS(temp1) < ABS((yc << sp_globals.pixshift) - y1 + sp_globals.pixrnd))
+ { /* use x1 instead of x0 */
+ xc = (fix31)(x1 + sp_globals.pixrnd) << (16 - sp_globals.pixshift);
+ }
+ goto skip_calc;
+ }
+/* calculate new xc at the center of the *current* scan line */
+/* due to banding, yc may be several lines away from y0 */
+/* xc += (yc + .5 - y0) * dx_dy */
+/* This multiply generates a subpixel delta. */
+/* So we leave it as an int.pixshift + 16 delta */
+
+xc += (fix31)temp1 * dx_dy;
+dx_dy <<= sp_globals.pixshift;
+skip_calc:
+
+yc -= band->band_array_offset; /* yc is now an offset relative to the band */
+
+if (how_many_y < 0)
+ { /* Vector down */
+ if ((how_many_y += yc + 1) < band->band_floor)
+ how_many_y = band->band_floor; /* can't go below floor */
+ while(yc >= how_many_y)
+ {
+ temp1 = (fix15)(xc >> 16);
+ sp_add_intercept_2d(yc--,temp1);
+ xc -= dx_dy;
+ }
+ }
+ else
+ { /* Vector up */
+ /* check to see that line doesn't extend beyond top of band */
+ if ((how_many_y += yc) > band->band_ceiling)
+ how_many_y = band->band_ceiling;
+ while(yc < how_many_y)
+ {
+ temp1 = (fix15)(xc >> 16);
+ sp_add_intercept_2d(yc++,temp1);
+ xc += dx_dy;
+ }
+ }
+}
+
+#endif
+
+#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
+ * with the first contour
+ */
+{
+
+fix31 xorg;
+fix31 yorg;
+#if INCL_CLIPPING
+fix31 em_max, em_min, bmap_max, bmap_min;
+#endif
+
+#if DEBUG
+printf("END_CHAR__2d()\n");
+#endif
+
+if (sp_globals.first_pass)
+ {
+ if (sp_globals.bmap_xmax >= sp_globals.bmap_xmin)
+ {
+ sp_globals.xmin = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ sp_globals.xmax = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ }
+ else
+ {
+ sp_globals.xmin = sp_globals.xmax = 0;
+ }
+ if (sp_globals.bmap_ymax >= sp_globals.bmap_ymin)
+ {
+
+#if INCL_CLIPPING
+ switch(sp_globals.tcb0.xtype)
+ {
+ case 1: /* 180 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ sp_globals.clip_ymin = -1 * sp_globals.clip_ymin;
+ if (bmap_min < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ else
+ sp_globals.ymin = bmap_min;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max < sp_globals.clip_ymax)
+ sp_globals.ymax = bmap_max;
+ else
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ sp_globals.clip_xmax = -sp_globals.xmin;
+ sp_globals.clip_xmin = ((sp_globals.set_width.x+32768L) >> 16) -
+ sp_globals.xmin;
+ break;
+ case 2: /* 90 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_xmin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;
+ sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;
+ bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ if (bmap_min > sp_globals.clip_xmin)
+ sp_globals.clip_xmin = bmap_min;
+
+ /* normalize to x origin */
+ sp_globals.clip_xmin -= sp_globals.xmin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_xmax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max < sp_globals.clip_xmax)
+ sp_globals.xmax = bmap_max;
+ else
+ sp_globals.xmax = sp_globals.clip_xmax;
+ sp_globals.clip_ymax = 0;
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ /* normalize to x origin */
+ sp_globals.clip_xmax -= sp_globals.xmin;
+ }
+ break;
+ case 3: /* 270 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_xmin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;
+ sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;
+ bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+
+ /* let the minimum be the larger of these two values */
+ if (bmap_min > sp_globals.clip_xmin)
+ sp_globals.clip_xmin = bmap_min;
+
+ /* normalize the x value to new xorgin */
+ sp_globals.clip_xmin -= sp_globals.xmin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_xmax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+ /* let the max be the lesser of these two values */
+ if (bmap_max < sp_globals.clip_xmax)
+ {
+ sp_globals.xmax = bmap_max;
+ sp_globals.clip_xmax = bmap_max;
+ }
+ else
+ sp_globals.xmax = sp_globals.clip_xmax;
+
+ /* normalize the x value to new x origin */
+ sp_globals.clip_xmax -= sp_globals.xmin;
+ }
+ /* compute y clip values */
+ sp_globals.clip_ymax = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = 0;
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ break;
+ default: /* this is for zero degree rotation and arbitrary rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max > sp_globals.clip_ymax)
+ sp_globals.ymax = bmap_max;
+ else
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ sp_globals.clip_ymin = - sp_globals.clip_ymin;
+ bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ if (bmap_min < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ else
+ sp_globals.ymin = bmap_min;
+ }
+ sp_globals.clip_xmin = -sp_globals.xmin;
+ sp_globals.clip_xmax = ((sp_globals.set_width.x+32768L) >> 16) -
+ sp_globals.xmin;
+ break;
+ }
+if ( !(sp_globals.specs.flags & CLIP_TOP))
+#endif
+ sp_globals.ymax = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+#if INCL_CLIPPING
+if ( !(sp_globals.specs.flags & CLIP_BOTTOM))
+#endif
+ sp_globals.ymin = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ }
+ else
+ {
+ sp_globals.ymin = sp_globals.ymax = 0;
+ }
+
+ /* add in the rounded out part (from xform.) of the left edge */
+ if (sp_globals.tcb.xmode == 0) /* for X pix is function of X orus only add the round */
+ xorg = (((fix31)sp_globals.xmin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift));
+ else
+ if (sp_globals.tcb.xmode == 1) /* for X pix is function of -X orus only, subtr. round */
+ xorg = (((fix31)sp_globals.xmin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift)) ;
+ else
+ xorg = (fix31)sp_globals.xmin << 16; /* for other cases don't use round on x */
+
+ if (sp_globals.tcb.ymode == 2) /* for Y pix is function of X orus only, add round error */
+ yorg = (((fix31)sp_globals.ymin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift));
+ else
+ if (sp_globals.tcb.ymode == 3) /* for Y pix is function of -X orus only, sub round */
+ yorg = (((fix31)sp_globals.ymin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift));
+ else /* all other cases have no round error on yorg */
+ yorg = (fix31)sp_globals.ymin << 16;
+
+ open_bitmap(sp_globals.set_width.x, sp_globals.set_width.y, xorg, yorg,
+ sp_globals.xmax - sp_globals.xmin, sp_globals.ymax - sp_globals.ymin);
+ if (sp_globals.intercept_oflo)
+ {
+ sp_globals.y_band.band_min = sp_globals.ymin;
+ sp_globals.y_band.band_max = sp_globals.ymax;
+ sp_globals.x_scan_active = FALSE;
+ sp_globals.no_x_lists = 0;
+ init_intercepts_out();
+ sp_globals.first_pass = FALSE;
+ sp_globals.extents_running = FALSE;
+ return FALSE;
+ }
+ else
+ {
+ sp_proc_intercepts_2d();
+ close_bitmap();
+ return TRUE;
+ }
+ }
+else
+ {
+ if (sp_globals.intercept_oflo)
+ {
+ reduce_band_size_out();
+ init_intercepts_out();
+ return FALSE;
+ }
+ else
+ {
+ sp_proc_intercepts_2d();
+ if (next_band_out())
+ {
+ init_intercepts_out();
+ return FALSE;
+ }
+ close_bitmap();
+ return TRUE;
+ }
+ }
+}
+#endif
+
+#if INCL_2D
+FUNCTION static void sp_add_intercept_2d(y, x)
+GDECL
+fix15 y; /* Y coordinate in relative pixel units */
+ /* (0 is lowest sample in band) */
+fix15 x; /* X coordinate of intercept in subpixel units */
+
+/* Called by line() to add an intercept to the intercept list structure
+ */
+
+{
+register fix15 from; /* Insertion pointers for the linked list sort */
+register fix15 to;
+
+#if DEBUG
+/* Bounds checking IS done in debug mode */
+if ((y >= MAX_INTERCEPTS) || (y < 0))
+ {
+ printf("Intercept out of table!!!!! (%d)\n",y);
+ return;
+ }
+
+if (y >= sp_globals.no_y_lists)
+ {
+ printf(" Add x intercept(%2d, %f)\n",
+ y + sp_globals.x_band.band_min - sp_globals.no_y_lists,
+ (real)x/(real)sp_globals.onepix);
+ if (y > (sp_globals.no_x_lists + sp_globals.no_y_lists))
+ {
+ printf(" Intercept too big for band!!!!!\007\n");
+ return;
+ }
+ }
+ else
+ {
+ printf(" Add y intercept(%2d, %f)\n", y + sp_globals.y_band.band_min,(real)x/(real)sp_globals.onepix);
+ }
+
+if (y < 0) /* Y value below bottom of current band? */
+ {
+ printf(" Intecerpt less than 0!!!\007\n");
+ return;
+ }
+#endif
+
+/* Store new values */
+
+sp_intercepts.car[sp_globals.next_offset] = x;
+
+/* Find slot to insert new element (between from and to) */
+
+from = y; /* Start at list head */
+
+while( (to = sp_intercepts.cdr[from]) >= sp_globals.first_offset) /* Until to == end of list */
+ {
+ if (x <= sp_intercepts.car[to]) /* If next item is larger than or same as this one... */
+ goto insert_element; /* ... drop out and insert here */
+ from = to; /* move forward in list */
+ }
+
+insert_element: /* insert element "next_offset" between elements "from" */
+ /* and "to" */
+
+sp_intercepts.cdr[from] = sp_globals.next_offset;
+sp_intercepts.cdr[sp_globals.next_offset] = to;
+
+if (++sp_globals.next_offset >= MAX_INTERCEPTS) /* Intercept buffer full? */
+ {
+ sp_globals.intercept_oflo = TRUE;
+/* There may be a few more calls to "add_intercept" from the current line */
+/* To avoid problems, we set next_offset to a safe value. We don't care */
+/* if the intercept table gets trashed at this point */
+ sp_globals.next_offset = sp_globals.first_offset;
+ }
+}
+
+#endif
+
+#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
+ */
+{
+register fix15 i;
+register fix15 from, to; /* Start and end of run in pixel units
+ relative to left extent of character */
+register fix15 y;
+register fix15 scan_line;
+ fix15 local_bmap_xmin;
+ fix15 local_bmap_xmax;
+ fix15 first_y, last_y;
+ fix15 j,k;
+
+#if INCL_CLIPPING
+if ((sp_globals.specs.flags & CLIP_LEFT) != 0)
+ clipleft = TRUE;
+else
+ clipleft = FALSE;
+if ((sp_globals.specs.flags & CLIP_RIGHT) != 0)
+ clipright = TRUE;
+else
+ clipright = FALSE;
+if (clipleft || clipright)
+ {
+ xmax = sp_globals.clip_xmax << sp_globals.pixshift;
+ xmin = sp_globals.clip_xmin << sp_globals.pixshift;
+ }
+if (!clipright)
+ xmax = ((sp_globals.set_width.x+32768L) >> 16);
+#endif
+
+if (sp_globals.x_scan_active) /* If xscanning, we need to make sure we don't miss any important pixels */
+ {
+ first_y = sp_globals.x_band.band_floor; /* start of x lists */
+ last_y = sp_globals.x_band.band_ceiling; /* end of x lists */
+ for (y = first_y; y != last_y; y++) /* scan all xlists */
+ {
+ i = sp_intercepts.cdr[y]; /* Index head of intercept list */
+ while (i != 0) /* Link to next intercept if present */
+ {
+ from = sp_intercepts.car[i];
+ j = i;
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ if (i == 0) /* End of list? */
+ {
+#if DEBUG
+ printf("****** proc_intercepts: odd number of intercepts in x list\n");
+#endif
+ break;
+ }
+ to = sp_intercepts.car[i];
+ k = sp_intercepts.cdr[i];
+ if (((to >> sp_globals.pixshift) >= (from >> sp_globals.pixshift)) &&
+ ((to - from) < (sp_globals.onepix + 1)))
+ {
+ from = ((fix31)to + (fix31)from - (fix31)sp_globals.onepix) >> (sp_globals.pixshift + 1);
+ if (from > sp_globals.y_band.band_max)
+ from = sp_globals.y_band.band_max;
+ if ((from -= sp_globals.y_band.band_min) < 0)
+ from = 0;
+ to = ((y - sp_globals.x_band.band_floor + sp_globals.x_band.band_min)
+ << sp_globals.pixshift)
+ + sp_globals.pixrnd;
+ sp_intercepts.car[j] = to;
+ sp_intercepts.car[i] = to + sp_globals.onepix;
+ sp_intercepts.cdr[i] = sp_intercepts.cdr[from];
+ sp_intercepts.cdr[from] = j;
+ }
+ i = k;
+ }
+ }
+ }
+#if DEBUG
+printf("\nIntercept lists:\n");
+#endif
+
+if ((first_y = sp_globals.y_band.band_max) >= sp_globals.ymax)
+ first_y = sp_globals.ymax - 1; /* Clip to ymax boundary */
+
+if ((last_y = sp_globals.y_band.band_min) < sp_globals.ymin)
+ last_y = sp_globals.ymin; /* Clip to sp_globals.ymin boundary */
+
+last_y -= sp_globals.y_band.band_array_offset;
+
+local_bmap_xmin = sp_globals.xmin << sp_globals.pixshift;
+local_bmap_xmax = (sp_globals.xmax << sp_globals.pixshift) + sp_globals.pixrnd;
+
+#if DEBUG
+/* Print out all of the intercept info */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = y; /* Index head of intercept list */
+ while ((i = sp_intercepts.cdr[i]) != 0) /* Link to next intercept if present */
+ {
+ if ((from = sp_intercepts.car[i] - local_bmap_xmin) < 0)
+ from = 0; /* Clip to xmin boundary */
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ if (i == 0) /* End of list? */
+ {
+ printf("****** proc_intercepts: odd number of intercepts\n");
+ break;
+ }
+ if ((to = sp_intercepts.car[i]) > sp_globals.bmap_xmax)
+ to = sp_globals.bmap_xmax - local_bmap_xmin; /* Clip to xmax boundary */
+ else
+ to -= local_bmap_xmin;
+ printf(" Y = %2d (scanline %2d): %3.4f %3.4f:\n",
+ y + sp_globals.y_band.band_min,
+ scan_line,
+ (real)from / (real)sp_globals.onepix,
+ (real)to / (real)sp_globals.onepix);
+ }
+ }
+#endif
+
+/* Draw the image */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = y; /* Index head of intercept list */
+ while ((i = sp_intercepts.cdr[i]) != 0) /* Link to next intercept if present */
+ {
+ if ((from = sp_intercepts.car[i] - local_bmap_xmin) < 0)
+ from = 0; /* Clip to xmin boundary */
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+
+ if ((to = sp_intercepts.car[i]) > local_bmap_xmax)
+ to = sp_globals.bmap_xmax - local_bmap_xmin; /* Clip to xmax boundary */
+ else
+ to -= local_bmap_xmin;
+#if INCL_CLIPPING
+ if (clipleft)
+ {
+ if (to <= xmin)
+ continue;
+ if (from < xmin)
+ from = xmin;
+ }
+ if (clipright)
+ {
+ if (from >= xmax)
+ continue;
+ if (to > xmax)
+ to = xmax;
+ }
+#endif
+ if ( (to - from) <= sp_globals.onepix)
+ {
+ from = (to + from - sp_globals.onepix) >> (sp_globals.pixshift + 1);
+ set_bitmap_bits(scan_line, from, from + 1);
+ }
+ else
+ {
+ set_bitmap_bits(scan_line, from >> sp_globals.pixshift, to >> sp_globals.pixshift);
+ }
+ }
+ }
+}
+
+#endif
diff --git a/src/Speedo/out_blk.c b/src/Speedo/out_blk.c
new file mode 100644
index 0000000..71e39af
--- /dev/null
+++ b/src/Speedo/out_blk.c
@@ -0,0 +1,708 @@
+/* $Xorg: out_blk.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+
+
+/*************************** O U T _ B L K . C *********************************
+ * *
+ * This is an output module for black-writer mode. *
+ * *
+ *****************************************************************************/
+
+
+#include "spdo_prv.h" /* General definitions for Speedo */
+
+#define DEBUG 0
+#define LOCAL static
+#define ABS(X) ( (X < 0) ? -X : X)
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** 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)
+GDECL
+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.
+ * Returns FALSE otherwise.
+ */
+{
+#if DEBUG
+printf("INIT_BLK()\n");
+#endif
+if (specsarg->flags & CURVES_OUT)
+ return FALSE; /* Curves out not supported */
+return (TRUE);
+}
+#endif
+
+
+#if INCL_BLACK
+FUNCTION boolean begin_char_black(Psw, Pmin, Pmax)
+GDECL
+point_t Psw;
+point_t Pmin;
+point_t Pmax;
+/* Called once at the start of the character generation process
+ */
+{
+#if DEBUG
+printf("BEGIN_CHAR_BLACK(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
+ (real)Psw.x / (real)sp_globals.onepix, (real)Psw.y / (real)sp_globals.onepix,
+ (real)Pmin.x / (real)sp_globals.onepix, (real)Pmin.y / (real)sp_globals.onepix,
+ (real)Pmax.x / (real)sp_globals.onepix, (real)Pmax.y / (real)sp_globals.onepix);
+#endif
+init_char_out(Psw,Pmin,Pmax);
+return TRUE;
+}
+#endif
+
+
+#if INCL_BLACK
+FUNCTION void begin_contour_black(P1, outside)
+GDECL
+point_t P1;
+boolean outside;
+/* Called at the start of each contour
+ */
+{
+
+#if DEBUG
+printf("BEGIN_CONTOUR_BLACK(%3.1f, %3.1f, %s)\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix, outside? "outside": "inside");
+#endif
+sp_globals.x0_spxl = P1.x;
+sp_globals.y0_spxl = P1.y;
+sp_globals.y_pxl = (sp_globals.y0_spxl + sp_globals.pixrnd) >> sp_globals.pixshift;
+}
+#endif
+
+#if INCL_BLACK
+FUNCTION void line_black(P1)
+GDECL
+point_t P1;
+/* Called for each vector in the transformed character
+ */
+{
+register fix15 how_many_y; /* # of intercepts at y = n + 1/2 */
+register fix15 yc, i; /* Current scan-line */
+ fix15 temp1; /* various uses */
+ fix15 temp2; /* various uses */
+register fix31 dx_dy; /* slope of line in 16.16 form */
+register fix31 xc; /* high-precision (16.16) x coordinate */
+ fix15 x0,y0,x1,y1; /* PIX.FRAC start and endpoints */
+
+x0 = sp_globals.x0_spxl; /* get start of line (== current point) */
+y0 = sp_globals.y0_spxl;
+sp_globals.x0_spxl = x1 = P1.x; /* end of line */
+sp_globals.y0_spxl = y1 = P1.y; /* (also update current point to end of line) */
+
+yc = sp_globals.y_pxl; /* current scan line = end of last line */
+sp_globals.y_pxl = (y1 + sp_globals.pixrnd) >> sp_globals.pixshift; /* calculate new end-scan sp_globals.line */
+
+
+#if DEBUG
+printf("LINE_BLACK(%3.4f, %3.4f)\n",
+ (real)P1.x/(real)sp_globals.onepix,
+ (real)P1.y/(real)sp_globals.onepix);
+#endif
+
+if (sp_globals.extents_running)
+ {
+ if (sp_globals.x0_spxl > sp_globals.bmap_xmax)
+ sp_globals.bmap_xmax = sp_globals.x0_spxl;
+ if (sp_globals.x0_spxl < sp_globals.bmap_xmin)
+ sp_globals.bmap_xmin = sp_globals.x0_spxl;
+ if (sp_globals.y0_spxl > sp_globals.bmap_ymax)
+ sp_globals.bmap_ymax = sp_globals.y0_spxl;
+ if (sp_globals.y0_spxl < sp_globals.bmap_ymin)
+ sp_globals.bmap_ymin = sp_globals.y0_spxl;
+ }
+
+if (sp_globals.intercept_oflo) return;
+
+if ((how_many_y = sp_globals.y_pxl - yc) == 0) return; /* Don't draw a null line */
+
+if (how_many_y < 0) yc--; /* Predecrment downward lines */
+
+if (yc > sp_globals.y_band.band_max) /* Is start point above band? */
+ {
+ if (sp_globals.y_pxl > sp_globals.y_band.band_max) return; /* line has to go down! */
+ how_many_y = sp_globals.y_pxl - (yc = sp_globals.y_band.band_max) - 1; /* Yes, limit it */
+ }
+
+if (yc < sp_globals.y_band.band_min) /* Is start point below band? */
+ {
+ if (sp_globals.y_pxl < sp_globals.y_band.band_min) return; /* line has to go up! */
+ how_many_y = sp_globals.y_pxl - (yc = sp_globals.y_band.band_min); /* Yes, limit it */
+ }
+
+xc = (fix31)(x0 + sp_globals.pixrnd) << (16 - sp_globals.pixshift); /* Original x coordinate with built in */
+ /* rounding. 16.16 form */
+
+
+if ( (temp1 = (x1 - x0)) == 0) /* check for vertical line */
+ {
+ yc -= sp_globals.y_band.band_min; /* yc is now an offset relative to the band */
+ temp1 = (fix15)(xc >> 16);
+ if (how_many_y < 0)
+ { /* Vector down */
+ if ((how_many_y += yc + 1) < 0) how_many_y = 0; /* can't go below 0 */
+ for (i = yc; i >= how_many_y; i--)
+ sp_add_intercept_black(i,temp1);
+ }
+ else
+ { /* Vector up */
+ /* check to see that line doesn't extend beyond top of band */
+ if ((how_many_y += yc) > sp_globals.no_y_lists) how_many_y = sp_globals.no_y_lists;
+ for (i = yc; i != how_many_y; i++)
+ sp_add_intercept_black(i,temp1);
+ }
+ return;
+ }
+
+/* calculate dx_dy at 16.16 fixed point */
+
+dx_dy = ( (fix31)temp1 << 16 )/(fix31)(y1 - y0);
+
+/* We have to check for a @#$%@# possible multiply overflow */
+/* by doing another @#$*& multiply. In assembly language, */
+/* the program could just check the OVerflow flag or whatever*/
+/* works on the particular processor. This C code is meant */
+/* to be processor independant. */
+
+temp1 = (yc << sp_globals.pixshift) - y0 + sp_globals.pixrnd;
+/* This sees if the sign bits start at bit 15 */
+/* if they do, no overflow has occurred */
+
+temp2 = (fix15)(MULT16(temp1,(fix15)(dx_dy >> 16)) >> 15);
+
+if ( (temp2 != (fix15)0xFFFF) &&
+ (temp2 != 0x0000) &&
+ /* Overflow. Pick point closest to yc + .5 */
+ (ABS(temp1) < ABS((yc << sp_globals.pixshift) - y1 + sp_globals.pixrnd)) )
+ { /* use x1 instead of x0 */
+ xc = (fix31)(x1 + sp_globals.pixrnd) << (16 - sp_globals.pixshift);
+ }
+else
+ {
+/* calculate new xc at the center of the *current* scan line */
+/* due to banding, yc may be several lines away from y0 */
+/* xc += (yc + .5 - y0) * dx_dy */
+/* This multiply generates a subpixel delta. */
+/* So we shift it to be a 16.16 delta */
+
+ xc += ((fix31)temp1 * dx_dy) >> sp_globals.pixshift;
+ }
+
+yc -= sp_globals.y_band.band_min; /* yc is now an offset relative to the band */
+
+if (how_many_y < 0)
+ { /* Vector down */
+ if (how_many_y == -1)
+ sp_add_intercept_black(yc, (fix15) (xc >> 16));
+ else
+ {
+ if ((how_many_y += yc + 1) < 0) how_many_y = 0; /* can't go below 0 */
+ for (i = yc; i >= how_many_y; i--)
+ {
+ temp1 = (fix15)(xc >> 16);
+ sp_add_intercept_black(i,temp1);
+ xc -= dx_dy;
+ }
+ }
+ }
+ else
+ { /* Vector up */
+ /* check to see that line doesn't extend beyond top of band */
+ if (how_many_y == 1)
+ sp_add_intercept_black(yc, (fix15) (xc >> 16));
+ else
+ {
+ if ((how_many_y += yc) > sp_globals.no_y_lists) how_many_y = sp_globals.no_y_lists;
+ for (i = yc; i != how_many_y; i++)
+ {
+ temp1 = (fix15)(xc >> 16);
+ sp_add_intercept_black(i,temp1);
+ xc += dx_dy;
+ }
+ }
+ }
+}
+#endif
+#if INCL_BLACK
+FUNCTION boolean end_char_black()
+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
+ * with the first contour
+ */
+{
+
+fix31 xorg;
+fix31 yorg;
+#if INCL_CLIPPING
+fix31 bmap_max, bmap_min;
+#endif
+
+#if DEBUG
+printf("END_CHAR_BLACK()\n");
+#endif
+
+if (sp_globals.first_pass)
+ {
+ if (sp_globals.bmap_xmax >= sp_globals.bmap_xmin)
+ {
+ sp_globals.xmin = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ sp_globals.xmax = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ }
+ else
+ {
+ sp_globals.xmin = sp_globals.xmax = 0;
+ }
+ if (sp_globals.bmap_ymax >= sp_globals.bmap_ymin)
+ {
+
+#if INCL_CLIPPING
+ switch(sp_globals.tcb0.xtype)
+ {
+ case 1: /* 180 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ sp_globals.clip_ymin = -1 * sp_globals.clip_ymin;
+ if (bmap_min < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ else
+ sp_globals.ymin = bmap_min;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max < sp_globals.clip_ymax)
+ sp_globals.ymax = bmap_max;
+ else
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ sp_globals.clip_xmax = -sp_globals.xmin;
+ sp_globals.clip_xmin = ((sp_globals.set_width.x+32768L) >> 16) -
+ sp_globals.xmin;
+ break;
+ case 2: /* 90 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_xmin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;
+ sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;
+ bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ if (bmap_min > sp_globals.clip_xmin)
+ sp_globals.clip_xmin = bmap_min;
+
+ /* normalize to x origin */
+ sp_globals.clip_xmin -= sp_globals.xmin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_xmax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max < sp_globals.clip_xmax)
+ sp_globals.xmax = bmap_max;
+ else
+ sp_globals.xmax = sp_globals.clip_xmax;
+ sp_globals.clip_ymax = 0;
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ /* normalize to x origin */
+ sp_globals.clip_xmax -= sp_globals.xmin;
+ }
+ break;
+ case 3: /* 270 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_xmin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;
+ sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;
+ bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+
+ /* let the minimum be the larger of these two values */
+ if (bmap_min > sp_globals.clip_xmin)
+ sp_globals.clip_xmin = bmap_min;
+
+ /* normalize the x value to new xorgin */
+ sp_globals.clip_xmin -= sp_globals.xmin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_xmax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+ /* let the max be the lesser of these two values */
+ if (bmap_max < sp_globals.clip_xmax)
+ {
+ sp_globals.xmax = bmap_max;
+ sp_globals.clip_xmax = bmap_max;
+ }
+ else
+ sp_globals.xmax = sp_globals.clip_xmax;
+
+ /* normalize the x value to new x origin */
+ sp_globals.clip_xmax -= sp_globals.xmin;
+ }
+ /* compute y clip values */
+ sp_globals.clip_ymax = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = 0;
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ break;
+ default: /* this is for zero degree rotation and arbitrary rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max > sp_globals.clip_ymax)
+ sp_globals.ymax = bmap_max;
+ else
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ sp_globals.clip_ymin = - sp_globals.clip_ymin;
+ bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ if (bmap_min < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ else
+ sp_globals.ymin = bmap_min;
+ }
+ sp_globals.clip_xmin = -sp_globals.xmin;
+ sp_globals.clip_xmax = ((sp_globals.set_width.x+32768L) >> 16) -
+ sp_globals.xmin;
+ break;
+ }
+if ( !(sp_globals.specs.flags & CLIP_TOP))
+#endif
+ sp_globals.ymax = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+#if INCL_CLIPPING
+if ( !(sp_globals.specs.flags & CLIP_BOTTOM))
+#endif
+
+ sp_globals.ymin = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ }
+ else
+ {
+ sp_globals.ymin = sp_globals.ymax = 0;
+ }
+
+ /* add in the rounded out part (from xform.) of the left edge */
+ if (sp_globals.tcb.xmode == 0) /* for X pix is function of X orus only add the round */
+ xorg = (((fix31)sp_globals.xmin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift));
+ else
+ if (sp_globals.tcb.xmode == 1) /* for X pix is function of -X orus only, subtr. round */
+ xorg = (((fix31)sp_globals.xmin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift)) ;
+ else
+ xorg = (fix31)sp_globals.xmin << 16; /* for other cases don't use round on x */
+
+ if (sp_globals.tcb.ymode == 2) /* for Y pix is function of X orus only, add round error */
+ yorg = (((fix31)sp_globals.ymin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift));
+ else
+ if (sp_globals.tcb.ymode == 3) /* for Y pix is function of -X orus only, sub round */
+ yorg = (((fix31)sp_globals.ymin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift));
+ else /* all other cases have no round error on yorg */
+ yorg = (fix31)sp_globals.ymin << 16;
+
+ open_bitmap(sp_globals.set_width.x, sp_globals.set_width.y, xorg, yorg,
+ sp_globals.xmax - sp_globals.xmin, sp_globals.ymax - sp_globals.ymin);
+ if (sp_globals.intercept_oflo)
+ {
+ sp_globals.y_band.band_min = sp_globals.ymin;
+ sp_globals.y_band.band_max = sp_globals.ymax;
+ init_intercepts_out();
+ sp_globals.first_pass = FALSE;
+ sp_globals.extents_running = FALSE;
+ return FALSE;
+ }
+ else
+ {
+ sp_proc_intercepts_black();
+ close_bitmap();
+ return TRUE;
+ }
+ }
+else
+ {
+ if (sp_globals.intercept_oflo)
+ {
+ reduce_band_size_out();
+ init_intercepts_out();
+ return FALSE;
+ }
+ else
+ {
+ sp_proc_intercepts_black();
+ if (next_band_out())
+ {
+ init_intercepts_out();
+ return FALSE;
+ }
+ close_bitmap();
+ return TRUE;
+ }
+ }
+}
+#endif
+
+#if INCL_BLACK
+FUNCTION LOCAL void sp_add_intercept_black(y, x)
+GDECL
+fix15 y; /* Y coordinate in relative pixel units */
+ /* (0 is lowest sample in band) */
+fix15 x; /* X coordinate of intercept in subpixel units */
+
+/* Called by line() to add an intercept to the intercept list structure
+ */
+
+{
+register fix15 from; /* Insertion pointers for the linked list sort */
+register fix15 to;
+
+#if DEBUG
+printf(" Add intercept(%2d, %d)\n", y + sp_globals.y_band.band_min,x);
+
+/* Bounds checking IS done in debug mode */
+if (y < 0) /* Y value below bottom of current band? */
+ {
+ printf(" Intecerpt less than 0!!!\007\n");
+ return;
+ }
+
+if (y > (sp_globals.no_y_lists - 1)) /* Y value above top of current band? */
+ {
+ printf(" Intercept too big for band!!!!!\007\n");
+ return;
+ }
+#endif
+
+/* Store new values */
+
+sp_intercepts.car[sp_globals.next_offset] = x;
+
+/* Find slot to insert new element (between from and to) */
+
+from = y; /* Start at list head */
+
+while( (to = sp_intercepts.cdr[from]) >= sp_globals.first_offset) /* Until to == end of list */
+ {
+ if (x <= sp_intercepts.car[to]) /* If next item is larger than or same as this one... */
+ goto insert_element; /* ... drop out and insert here */
+ from = to; /* move forward in list */
+ }
+
+insert_element: /* insert element "sp_globals.next_offset" between elements "from" */
+ /* and "to" */
+
+sp_intercepts.cdr[from] = sp_globals.next_offset;
+sp_intercepts.cdr[sp_globals.next_offset] = to;
+
+if (++sp_globals.next_offset >= MAX_INTERCEPTS) /* Intercept buffer full? */
+ {
+ sp_globals.intercept_oflo = TRUE;
+/* There may be a few more calls to "add_intercept" from the current line */
+/* To avoid problems, we set next_offset to a safe value. We don't care */
+/* if the intercept table gets trashed at this point */
+ sp_globals.next_offset = sp_globals.first_offset;
+ }
+}
+
+#endif
+
+#if INCL_BLACK
+FUNCTION LOCAL void sp_proc_intercepts_black()
+GDECL
+
+/* Called by sp_make_char to output accumulated intercept lists
+ * Clips output to sp_globals.xmin, sp_globals.xmax, sp_globals.ymin, sp_globals.ymax boundaries
+ */
+{
+register fix15 i;
+register fix15 from, to; /* Start and end of run in pixel units
+ relative to left extent of character */
+register fix15 y;
+register fix15 scan_line;
+ fix15 first_y, last_y;
+
+#if DEBUG
+printf("\nIntercept lists:\n");
+#endif
+
+#if INCL_CLIPPING
+if ((sp_globals.specs.flags & CLIP_LEFT) != 0)
+ clipleft = TRUE;
+else
+ clipleft = FALSE;
+if ((sp_globals.specs.flags & CLIP_RIGHT) != 0)
+ clipright = TRUE;
+else
+ clipright = FALSE;
+if (clipleft || clipright)
+ {
+ xmax = sp_globals.clip_xmax;
+ xmin = sp_globals.clip_xmin;
+ }
+if (!clipright)
+ xmax = ((sp_globals.set_width.x+32768L) >> 16);
+#endif
+
+if ((first_y = sp_globals.y_band.band_max) >= sp_globals.ymax)
+ first_y = sp_globals.ymax - 1; /* Clip to sp_globals.ymax boundary */
+
+if ((last_y = sp_globals.y_band.band_min) < sp_globals.ymin)
+ last_y = sp_globals.ymin; /* Clip to sp_globals.ymin boundary */
+
+last_y -= sp_globals.y_band.band_min;
+#if DEBUG
+/* Print out all of the intercept info */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = y; /* Index head of intercept list */
+ while ((i = sp_intercepts.cdr[i]) != 0) /* Link to next intercept if present */
+ {
+ if ((from = sp_intercepts.car[i] - sp_globals.xmin) < 0)
+ from = 0; /* Clip to sp_globals.xmin boundary */
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ if (i == 0) /* End of list? */
+ {
+ printf("****** proc_intercepts: odd number of intercepts\n");
+ break;
+ }
+ if ((to = sp_intercepts.car[i]) > sp_globals.xmax)
+ to = sp_globals.xmax - sp_globals.xmin; /* Clip to sp_globals.xmax boundary */
+ else
+ to -= sp_globals.xmin;
+ printf(" Y = %2d (scanline %2d): %d %d:\n",
+ y + sp_globals.y_band.band_min, scan_line, from, to);
+ }
+ }
+#endif
+
+/* Draw the image */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = y; /* Index head of intercept list */
+ while ((i = sp_intercepts.cdr[i]) != 0) /* Link to next intercept if present */
+ {
+ if ((from = sp_intercepts.car[i] - sp_globals.xmin) < 0)
+ from = 0; /* Clip to sp_globals.xmin boundary */
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+
+ if ((to = sp_intercepts.car[i]) > sp_globals.xmax)
+ to = sp_globals.xmax - sp_globals.xmin; /* Clip to sp_globals.xmax boundary */
+ else
+ to -= sp_globals.xmin;
+ if (from >= to)
+ {
+ if (from >= sp_globals.xmax - sp_globals.xmin)
+ {
+ --from ;
+ }
+ to = from+1;
+ }
+#if INCL_CLIPPING
+ if (clipleft)
+ {
+ if (to <= xmin)
+ continue;
+ if (from < xmin)
+ from = xmin;
+ }
+ if (clipright)
+ {
+ if (from >= xmax)
+ continue;
+ if (to > xmax)
+ to = xmax;
+ }
+#endif
+ set_bitmap_bits(scan_line, from, to);
+ }
+ }
+}
+
+#endif
+
+
+
+
diff --git a/src/Speedo/out_outl.c b/src/Speedo/out_outl.c
new file mode 100644
index 0000000..bebc684
--- /dev/null
+++ b/src/Speedo/out_outl.c
@@ -0,0 +1,287 @@
+/* $Xorg: out_outl.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+
+/**************************** O U T _ 2 _ 1 . C ******************************
+ * *
+ * This is the standard output module for vector output mode. *
+ * *
+ ****************************************************************************/
+
+
+#include "spdo_prv.h" /* General definitions for Speedo */
+
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+/* the following macro is used to limit points on the outline to the bounding box */
+
+#define RANGECHECK(value,min,max) (((value) >= (min) ? (value) : (min)) < (max) ? (value) : (max))
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** STATIC FUNCTIONS *****/
+
+
+#if INCL_OUTLINE
+FUNCTION boolean init_outline(specsarg)
+GDECL
+specs_t GLOBALFAR *specsarg;
+/*
+ * init_out2() is called by sp_set_specs() to initialize the output module.
+ * Returns TRUE if output module can accept requested specifications.
+ * Returns FALSE otherwise.
+ */
+{
+#if DEBUG
+printf("INIT_OUT_2()\n");
+#endif
+if (specsarg->flags & (CLIP_LEFT + CLIP_RIGHT + CLIP_TOP + CLIP_BOTTOM))
+ return FALSE; /* Clipping not supported */
+return (TRUE);
+}
+#endif
+
+#if INCL_OUTLINE
+FUNCTION boolean begin_char_outline(Psw, Pmin, Pmax)
+GDECL
+point_t Psw; /* End of escapement vector (sub-pixels) */
+point_t Pmin; /* Bottom left corner of bounding box */
+point_t Pmax; /* Top right corner of bounding box */
+/*
+ * If two or more output modules are included in the configuration, begin_char2()
+ * is called by begin_char() to signal the start of character output data.
+ * If only one output module is included in the configuration, begin_char() is
+ * called by make_simp_char() and make_comp_char().
+ */
+{
+fix31 set_width_x;
+fix31 set_width_y;
+fix31 xmin;
+fix31 xmax;
+fix31 ymin;
+fix31 ymax;
+
+#if DEBUG
+printf("BEGIN_CHAR_2(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
+ (real)Psw.x / (real)onepix, (real)Psw.y / (real)onepix,
+ (real)Pmin.x / (real)onepix, (real)Pmin.y / (real)onepix,
+ (real)Pmax.x / (real)onepix, (real)Pmax.y / (real)onepix);
+#endif
+sp_globals.poshift = 16 - sp_globals.pixshift;
+set_width_x = (fix31)Psw.x << sp_globals.poshift;
+set_width_y = (fix31)Psw.y << sp_globals.poshift;
+xmin = (fix31)Pmin.x << sp_globals.poshift;
+xmax = (fix31)Pmax.x << sp_globals.poshift;
+ymin = (fix31)Pmin.y << sp_globals.poshift;
+ymax = (fix31)Pmax.y << sp_globals.poshift;
+sp_globals.xmin = Pmin.x;
+sp_globals.xmax = Pmax.x;
+sp_globals.ymin = Pmin.y;
+sp_globals.ymax = Pmax.y;
+open_outline(set_width_x, set_width_y, xmin, xmax, ymin, ymax);
+return TRUE;
+}
+#endif
+
+#if INCL_OUTLINE
+FUNCTION void begin_sub_char_outline(Psw, Pmin, Pmax)
+GDECL
+point_t Psw; /* End of sub-char escapement vector */
+point_t Pmin; /* Bottom left corner of sub-char bounding box */
+point_t Pmax; /* Top right corner of sub-char bounding box */
+/*
+ * If two or more output modules are included in the configuration, begin_sub_char2()
+ * is called by begin_sub_char() to signal the start of sub-character output data.
+ * If only one output module is included in the configuration, begin_sub_char() is
+ * called by make_comp_char().
+ */
+{
+#if DEBUG
+printf("BEGIN_SUB_CHAR_2(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
+ (real)Psw.x / (real)onepix, (real)Psw.y / (real)onepix,
+ (real)Pmin.x / (real)onepix, (real)Pmin.y / (real)onepix,
+ (real)Pmax.x / (real)onepix, (real)Pmax.y / (real)onepix);
+#endif
+start_new_char();
+}
+#endif
+
+
+#if INCL_OUTLINE
+FUNCTION void begin_contour_outline(P1, outside)
+GDECL
+point_t P1; /* Start point of contour */
+boolean outside; /* TRUE if outside (counter-clockwise) contour */
+/*
+ * If two or more output modules are included in the configuration, begin_contour2()
+ * is called by begin_contour() to define the start point of a new contour
+ * and to indicate whether it is an outside (counter-clockwise) contour
+ * or an inside (clockwise) contour.
+ * If only one output module is included in the configuration, begin_sub_char() is
+ * called by proc_outl_data().
+ */
+{
+fix15 x,y;
+#if DEBUG
+printf("BEGIN_CONTOUR_2(%3.1f, %3.1f, %s)\n",
+ (real)P1.x / (real)onepix, (real)P1.y / (real)onepix, outside? "outside": "inside");
+#endif
+x = RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
+y = RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);
+
+start_contour((fix31)x << sp_globals.poshift, (fix31)y << sp_globals.poshift, outside);
+}
+#endif
+
+#if INCL_OUTLINE
+FUNCTION void curve_outline(P1, P2, P3,depth)
+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;
+/*
+ * If two or more output modules are included in the configuration, curve2()
+ * is called by curve() to output one curve segment.
+ * If only one output module is included in the configuration, curve() is
+ * called by proc_outl_data().
+ * This function is only called when curve output is enabled.
+ */
+{
+fix15 x1,y1,x2,y2,x3,y3;
+#if DEBUG
+printf("CURVE_2(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n",
+ (real)P1.x / (real)onepix, (real)P1.y / (real)onepix,
+ (real)P2.x / (real)onepix, (real)P2.y / (real)onepix,
+ (real)P3.x / (real)onepix, (real)P3.y / (real)onepix);
+#endif
+x1= RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
+y1= RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);
+
+x2= RANGECHECK(P2.x,sp_globals.xmin,sp_globals.xmax);
+y2= RANGECHECK(P2.y,sp_globals.ymin,sp_globals.ymax);
+
+x3= RANGECHECK(P3.x,sp_globals.xmin,sp_globals.xmax);
+y3= RANGECHECK(P3.y,sp_globals.ymin,sp_globals.ymax);
+
+curve_to((fix31)x1 << sp_globals.poshift, (fix31)y1 << sp_globals.poshift,
+ (fix31)x2<< sp_globals.poshift, (fix31)y2 << sp_globals.poshift,
+ (fix31)x3 << sp_globals.poshift, (fix31)y3 << sp_globals.poshift);
+}
+#endif
+
+#if INCL_OUTLINE
+FUNCTION void line_outline(P1)
+GDECL
+point_t P1; /* End point of vector */
+/*
+ * If two or more output modules are included in the configuration, line2()
+ * is called by line() to output one vector.
+ * If only one output module is included in the configuration, line() is
+ * called by proc_outl_data(). If curve output is enabled, line() is also
+ * called by split_curve().
+ */
+{
+fix15 x1,y1;
+#if DEBUG
+printf("LINE_2(%3.1f, %3.1f)\n", (real)P1.x / (real)onepix, (real)P1.y / (real)onepix);
+#endif
+x1= RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
+y1= RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);
+
+line_to((fix31)x1 << sp_globals.poshift, (fix31)y1 << sp_globals.poshift);
+}
+#endif
+
+#if INCL_OUTLINE
+FUNCTION void end_contour_outline()
+GDECL
+/*
+ * If two or more output modules are included in the configuration, end_contour2()
+ * is called by end_contour() to signal the end of a contour.
+ * If only one output module is included in the configuration, end_contour() is
+ * called by proc_outl_data().
+ */
+{
+#if DEBUG
+printf("END_CONTOUR_2()\n");
+#endif
+close_contour();
+}
+#endif
+
+
+#if INCL_OUTLINE
+FUNCTION void end_sub_char_outline()
+GDECL
+/*
+ * If two or more output modules are included in the configuration, end_sub_char2()
+ * is called by end_sub_char() to signal the end of sub-character data.
+ * If only one output module is included in the configuration, end_sub_char() is
+ * called by make_comp_char().
+ */
+{
+#if DEBUG
+printf("END_SUB_CHAR_2()\n");
+#endif
+}
+#endif
+
+
+#if INCL_OUTLINE
+FUNCTION boolean end_char_outline()
+GDECL
+/*
+ * If two or more output modules are included in the configuration, end_char2()
+ * is called by end_char() to signal the end of the character data.
+ * If only one output module is included in the configuration, end_char() is
+ * called by make_simp_char() and make_comp_char().
+ * Returns TRUE if output process is complete
+ * Returns FALSE to repeat output of the transformed data beginning
+ * with the first contour (of the first sub-char if compound).
+ */
+{
+#if DEBUG
+printf("END_CHAR_2()\n");
+#endif
+close_outline();
+return TRUE;
+}
+#endif
+
diff --git a/src/Speedo/out_scrn.c b/src/Speedo/out_scrn.c
new file mode 100644
index 0000000..3d04db6
--- /dev/null
+++ b/src/Speedo/out_scrn.c
@@ -0,0 +1,1091 @@
+/* $Xorg: out_scrn.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+
+/*************************** O U T _ S C R N . C *****************************
+ * *
+ * This is an output module for screen-writer mode. *
+ * *
+ *****************************************************************************/
+
+
+#include "spdo_prv.h" /* General definitions for Speedo */
+
+#define DEBUG 0
+#define LOCAL static
+#define ABS(X) ( (X < 0) ? -X : X)
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** 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)
+GDECL
+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.
+ * Returns FALSE otherwise.
+ */
+{
+#if DEBUG
+printf("INIT_SCREEN()\n");
+#endif
+return (TRUE);
+}
+#endif
+
+
+#if INCL_SCREEN
+FUNCTION boolean begin_char_screen(Psw, Pmin, Pmax)
+GDECL
+point_t Psw;
+point_t Pmin;
+point_t Pmax;
+/* Called once at the start of the character generation process
+ */
+{
+#if DEBUG
+printf("BEGIN_CHAR_SCREEN(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
+ (real)Psw.x / (real)sp_globals.onepix, (real)Psw.y / (real)sp_globals.onepix,
+ (real)Pmin.x / (real)sp_globals.onepix, (real)Pmin.y / (real)sp_globals.onepix,
+ (real)Pmax.x / (real)sp_globals.onepix, (real)Pmax.y / (real)sp_globals.onepix);
+#endif
+if (sp_globals.pixshift > 8)
+ sp_intercepts.fracpix = sp_globals.onepix << (8 - sp_globals.pixshift);
+else
+ sp_intercepts.fracpix = sp_globals.onepix >> (sp_globals.pixshift - 8);
+
+init_char_out(Psw,Pmin,Pmax);
+
+return TRUE;
+}
+#endif
+
+
+#if INCL_SCREEN
+FUNCTION void begin_contour_screen(P1, outside)
+GDECL
+point_t P1;
+boolean outside;
+/* Called at the start of each contour
+ */
+{
+
+#if DEBUG
+printf("BEGIN_CONTOUR_SCREEN(%3.1f, %3.1f, %s)\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix, outside? "outside": "inside");
+#endif
+sp_globals.x0_spxl = P1.x;
+sp_globals.y0_spxl = P1.y;
+sp_globals.y_pxl = (sp_globals.y0_spxl + sp_globals.pixrnd) >> sp_globals.pixshift;
+}
+#endif
+
+#if INCL_SCREEN
+FUNCTION void curve_screen(P1, P2, P3, depth)
+GDECL
+point_t P1, P2, P3;
+fix15 depth;
+{
+fix31 X0;
+fix31 Y0;
+fix31 X1;
+fix31 Y1;
+fix31 X2;
+fix31 Y2;
+fix31 X3;
+fix31 Y3;
+#if DEBUG
+printf("CURVE_SCREEN(%6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f)\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix,
+ (real)P2.x / (real)sp_globals.onepix, (real)P2.y / (real)sp_globals.onepix,
+ (real)P3.x / (real)sp_globals.onepix, (real)P3.y / (real)sp_globals.onepix);
+#endif
+
+
+if (sp_globals.extents_running) /* Accumulate actual character extents if required */
+ {
+ if (P3.x > sp_globals.bmap_xmax)
+ sp_globals.bmap_xmax = P3.x;
+ if (P3.x < sp_globals.bmap_xmin)
+ sp_globals.bmap_xmin = P3.x;
+ if (P3.y > sp_globals.bmap_ymax)
+ sp_globals.bmap_ymax = P3.y;
+ if (P3.y < sp_globals.bmap_ymin)
+ sp_globals.bmap_ymin = P3.y;
+ }
+
+X0 = ((fix31)sp_globals.x0_spxl << sp_globals.poshift) + (fix31)32768;
+Y0 = ((fix31)sp_globals.y0_spxl << sp_globals.poshift) + (fix31)32768;
+X1 = ((fix31)P1.x << sp_globals.poshift) + (fix31)32768;
+Y1 = ((fix31)P1.y << sp_globals.poshift) + (fix31)32768;
+X2 = ((fix31)P2.x << sp_globals.poshift) + (fix31)32768;
+Y2 = ((fix31)P2.y << sp_globals.poshift) + (fix31)32768;
+X3 = ((fix31)P3.x << sp_globals.poshift) + (fix31)32768;
+Y3 = ((fix31)P3.y << sp_globals.poshift) + (fix31)32768;
+
+if (((Y0 - Y3) * sp_globals.tcb.mirror) > 0)
+ {
+ sp_intercepts.leftedge = LEFT_INT;
+ }
+else
+ {
+ sp_intercepts.leftedge = 0;
+ }
+
+scan_curve_screen(X0,Y0,X1,Y1,X2,Y2,X3,Y3);
+sp_globals.x0_spxl = P3.x;
+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)
+GDECL
+fix31 X0,Y0,X1,Y1,X2,Y2,X3,Y3;
+/* Called for each curve in the transformed character if curves out enabled
+ */
+{
+fix31 Pmidx;
+fix31 Pmidy;
+fix31 Pctrl1x;
+fix31 Pctrl1y;
+fix31 Pctrl2x;
+fix31 Pctrl2y;
+
+#if 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,
+ (real)(X2-32768) / 65536.0, (real)(Y2-32768) / 65536.0,
+ (real)(X3-32768) / 65536.0, (real)(Y3-32768) / 65536.0);
+#endif
+
+if (((Y3 >> 16)) == (Y0 >> 16) || (Y3+1) == Y0 || Y3 == (Y0+1))
+ {
+ return;
+ }
+if ((X3 >> 16) == (X0 >> 16))
+ {
+ vert_line_screen(X3,(Y0>>16),(Y3>>16));
+ return;
+ }
+Pmidx = (X0 + (X1 + X2) * 3 + X3 + 4 ) >> 3;
+Pmidy = (Y0 + (Y1 + Y2) * 3 + Y3 + 4 ) >> 3;
+
+Pctrl1x = (X0 + X1 + 1 ) >> 1;
+Pctrl1y = (Y0 + Y1 + 1) >> 1;
+Pctrl2x = (X0 + (X1 << 1) + X2 + 2 ) >> 2;
+Pctrl2y = (Y0 + (Y1 << 1) + Y2 + 2 ) >> 2;
+scan_curve_screen(X0,Y0, Pctrl1x, Pctrl1y, Pctrl2x,Pctrl2y, Pmidx,Pmidy);
+
+Pctrl1x = (X1 + (X2 << 1) + X3 + 2 ) >> 2;
+Pctrl1y = (Y1 + (Y2 << 1) + Y3 + 2 ) >> 2;
+Pctrl2x = (X2 + X3 + 1 ) >> 1;
+Pctrl2y = (Y2 + Y3 + 1 ) >> 1;
+scan_curve_screen(Pmidx,Pmidy, Pctrl1x,Pctrl1y, Pctrl2x,Pctrl2y, X3,Y3);
+}
+
+FUNCTION void vert_line_screen(x,y1,y2)
+GDECL
+fix31 x;
+fix15 y1, y2;
+{
+
+#if DBGCRV
+printf("VERT_LINE_SCREEN(%6.4f, %6.4f, %6.4f)\n",
+ (real)(x - 32768) / 65536.0,
+ (real)(y1 - 32768) / 65536.0,
+ (real)(y2 - 32768) / 65536.0);
+#endif
+
+if (sp_globals.intercept_oflo)
+ return;
+
+if (y1 > y2) /* Line goes downwards ? */
+ {
+ if (y1 > (sp_globals.y_band.band_max + 1)) /* Start point above top of band? */
+ y1 = sp_globals.y_band.band_max + 1; /* Adjust start point to top of band */
+ if (y2 < sp_globals.y_band.band_min) /* End point below bottom of band? */
+ y2 = sp_globals.y_band.band_min; /* Adjust end point bottom of band */
+
+ y1 -= sp_globals.y_band.band_min; /* Translate start point to band origin */
+ y2 -= sp_globals.y_band.band_min; /* Translate end point to band origin */
+
+ while (y2 < y1) /* At least one intercept left? */
+ {
+ sp_add_intercept_screen(--y1, x); /* Add intercept */
+ }
+ }
+else if (y2 > y1) /* Line goes upwards ? */
+ {
+ if (y1 < sp_globals.y_band.band_min) /* Start point below bottom of band? */
+ y1 = sp_globals.y_band.band_min; /* Adjust start point to bottom of band */
+ if (y2 > (sp_globals.y_band.band_max + 1)) /* End point above top of band? */
+ y2 = sp_globals.y_band.band_max + 1; /* Adjust end point to top of band */
+
+ y1 -= sp_globals.y_band.band_min; /* Translate start point to band origin */
+ y2 -= sp_globals.y_band.band_min; /* Translate end point to band origin */
+
+ while (y1 < y2) /* At least one intercept left? */
+ {
+ sp_add_intercept_screen(y1++, x); /* Add intercept */
+ }
+ }
+
+
+}
+
+#endif
+
+
+#if INCL_SCREEN
+FUNCTION void line_screen(P1)
+GDECL
+point_t P1;
+/* Called for each vector in the transformed character
+ */
+{
+register fix15 how_many_y; /* # of intercepts at y = n + 1/2 */
+register fix15 yc; /* Current scan-line */
+ fix15 temp1; /* various uses */
+ fix15 temp2; /* various uses */
+register fix31 dx_dy; /* slope of line in 16.16 form */
+register fix31 xc; /* high-precision (16.16) x coordinate */
+ fix15 x0,y0,x1,y1; /* PIX.FRAC start and endpoints */
+
+x0 = sp_globals.x0_spxl; /* get start of line (== current point) */
+y0 = sp_globals.y0_spxl;
+sp_globals.x0_spxl = x1 = P1.x; /* end of line */
+sp_globals.y0_spxl = y1 = P1.y; /* (also update current point to end of line) */
+
+yc = sp_globals.y_pxl; /* current scan line = end of last line */
+sp_globals.y_pxl = (y1 + sp_globals.pixrnd) >> sp_globals.pixshift; /* calculate new end-scan sp_globals.line */
+
+
+#if DEBUG
+printf("LINE_SCREEN(%3.4f, %3.4f)\n",
+ (real)P1.x/(real)sp_globals.onepix,
+ (real)P1.y/(real)sp_globals.onepix);
+#endif
+
+if (sp_globals.extents_running)
+ {
+ if (sp_globals.x0_spxl > sp_globals.bmap_xmax)
+ sp_globals.bmap_xmax = sp_globals.x0_spxl;
+ if (sp_globals.x0_spxl < sp_globals.bmap_xmin)
+ sp_globals.bmap_xmin = sp_globals.x0_spxl;
+ if (sp_globals.y0_spxl > sp_globals.bmap_ymax)
+ sp_globals.bmap_ymax = sp_globals.y0_spxl;
+ if (sp_globals.y0_spxl < sp_globals.bmap_ymin)
+ sp_globals.bmap_ymin = sp_globals.y0_spxl;
+ }
+
+if (sp_globals.intercept_oflo) return;
+
+if ((how_many_y = sp_globals.y_pxl - yc) == 0) return; /* Don't draw a null line */
+
+xc = (fix31)(x0 + sp_globals.pixrnd) << (16 - sp_globals.pixshift); /* Original x coordinate with built in */
+ /* rounding. 16.16 form */
+
+if (how_many_y < 0)
+ {
+ yc--; /* Predecrment downward lines */
+ }
+
+if ((how_many_y * sp_globals.tcb.mirror) < 0)
+ {
+ sp_intercepts.leftedge = LEFT_INT;
+ }
+else
+ {
+ sp_intercepts.leftedge = 0;
+ }
+
+if (yc > sp_globals.y_band.band_max) /* Is start point above band? */
+ {
+ if (sp_globals.y_pxl > sp_globals.y_band.band_max) return; /* line has to go down! */
+ how_many_y = sp_globals.y_pxl - (yc = sp_globals.y_band.band_max) - 1; /* Yes, limit it */
+ }
+
+if (yc < sp_globals.y_band.band_min) /* Is start point below band? */
+ {
+ if (sp_globals.y_pxl < sp_globals.y_band.band_min) return; /* line has to go up! */
+ how_many_y = sp_globals.y_pxl - (yc = sp_globals.y_band.band_min); /* Yes, limit it */
+ }
+
+if ( (temp1 = (x1 - x0)) == 0) /* check for vertical line */
+ {
+ dx_dy = 0L; /* Zero slope, leave xc alone */
+ goto skip_calc;
+ }
+
+/* calculate dx_dy at 16.16 fixed point */
+
+dx_dy = ( (fix31)temp1 << 16 )/(fix31)(y1 - y0);
+
+/* We have to check for a @#$%@# possible multiply overflow */
+/* by doing another @#$*& multiply. In assembly language, */
+/* the program could just check the OVerflow flag or whatever*/
+/* works on the particular processor. This C code is meant */
+/* to be processor independant. */
+
+temp1 = (yc << sp_globals.pixshift) - y0 + sp_globals.pixrnd;
+/* This sees if the sign bits start at bit 15 */
+/* if they do, no overflow has occurred */
+
+temp2 = (fix15)(MULT16(temp1,(fix15)(dx_dy >> 16)) >> 15);
+
+if ( (temp2 != (fix15)-1) &&
+ (temp2 != 0x0000) )
+ { /* Overflow. Pick point closest to yc + .5 */
+ if (ABS(temp1) < ABS((yc << sp_globals.pixshift) - y1 + sp_globals.pixrnd))
+ { /* use x1 instead of x0 */
+ xc = (fix31)(x1 + sp_globals.pixrnd) << (16 - sp_globals.pixshift);
+ }
+ goto skip_calc;
+ }
+/* calculate new xc at the center of the *current* scan line */
+/* due to banding, yc may be several lines away from y0 */
+/* xc += (yc + .5 - y0) * dx_dy */
+/* This multiply generates a subpixel delta. */
+/* So we shift it to be a 16.16 delta */
+
+xc += ((fix31)temp1 * dx_dy) >> sp_globals.pixshift;
+
+skip_calc:
+
+yc -= sp_globals.y_band.band_min; /* yc is now an offset relative to the band */
+
+if (how_many_y < 0)
+ { /* Vector down */
+ if ((how_many_y += yc + 1) < 0) how_many_y = 0; /* can't go below 0 */
+ while(yc >= how_many_y)
+ {
+ sp_add_intercept_screen(yc--,xc);
+ xc -= dx_dy;
+ }
+ }
+ else
+ { /* Vector up */
+ /* check to see that line doesn't extend beyond top of band */
+ if ((how_many_y += yc) > sp_globals.no_y_lists) how_many_y = sp_globals.no_y_lists;
+ while(yc != how_many_y)
+ {
+ sp_add_intercept_screen(yc++,xc);
+ xc += dx_dy;
+ }
+ }
+}
+#endif
+
+#if INCL_SCREEN
+FUNCTION void end_contour_screen()
+GDECL
+/* Called after the last vector in each contour
+ */
+{
+#if DEBUG
+printf("END_CONTOUR_SCREEN()\n");
+#endif
+sp_intercepts.inttype[sp_globals.next_offset-1] |= END_INT;
+}
+#endif
+
+
+
+#if INCL_SCREEN
+FUNCTION boolean end_char_screen()
+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
+ * with the first contour
+ */
+{
+
+fix31 xorg;
+fix31 yorg;
+
+#if INCL_CLIPPING
+fix31 em_max, em_min, bmap_max, bmap_min;
+#endif
+
+#if DEBUG
+printf("END_CHAR_SCREEN()\n");
+#endif
+
+if (sp_globals.first_pass)
+ {
+ if (sp_globals.bmap_xmax >= sp_globals.bmap_xmin)
+ {
+ sp_globals.xmin = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ sp_globals.xmax = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ }
+ else
+ {
+ sp_globals.xmin = sp_globals.xmax = 0;
+ }
+ if (sp_globals.bmap_ymax >= sp_globals.bmap_ymin)
+ {
+
+#if INCL_CLIPPING
+ switch(sp_globals.tcb0.xtype)
+ {
+ case 1: /* 180 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ sp_globals.clip_ymin = -1 * sp_globals.clip_ymin;
+ if (bmap_min < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ else
+ sp_globals.ymin = bmap_min;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max < sp_globals.clip_ymax)
+ sp_globals.ymax = bmap_max;
+ else
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ sp_globals.clip_xmax = -sp_globals.xmin;
+ sp_globals.clip_xmin = ((sp_globals.set_width.x+32768L) >> 16) -
+ sp_globals.xmin;
+ break;
+ case 2: /* 90 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_xmin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;
+ sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;
+ bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ if (bmap_min > sp_globals.clip_xmin)
+ sp_globals.clip_xmin = bmap_min;
+
+ /* normalize to x origin */
+ sp_globals.clip_xmin -= sp_globals.xmin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_xmax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max < sp_globals.clip_xmax)
+ sp_globals.xmax = bmap_max;
+ else
+ sp_globals.xmax = sp_globals.clip_xmax;
+ sp_globals.clip_ymax = 0;
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ /* normalize to x origin */
+ sp_globals.clip_xmax -= sp_globals.xmin;
+ }
+ break;
+ case 3: /* 270 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_xmin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmin = sp_globals.clip_xmin >> sp_globals.multshift;
+ sp_globals.clip_xmin = -1 * sp_globals.clip_xmin;
+ bmap_min = (sp_globals.bmap_xmin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+
+ /* let the minimum be the larger of these two values */
+ if (bmap_min > sp_globals.clip_xmin)
+ sp_globals.clip_xmin = bmap_min;
+
+ /* normalize the x value to new xorgin */
+ sp_globals.clip_xmin -= sp_globals.xmin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_xmax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_xmax = sp_globals.clip_xmax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_xmax + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+ /* let the max be the lesser of these two values */
+ if (bmap_max < sp_globals.clip_xmax)
+ {
+ sp_globals.xmax = bmap_max;
+ sp_globals.clip_xmax = bmap_max;
+ }
+ else
+ sp_globals.xmax = sp_globals.clip_xmax;
+
+ /* normalize the x value to new x origin */
+ sp_globals.clip_xmax -= sp_globals.xmin;
+ }
+ /* compute y clip values */
+ sp_globals.clip_ymax = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = 0;
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ break;
+ default: /* this is for zero degree rotation and arbitrary rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ bmap_max = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+ if (bmap_max > sp_globals.clip_ymax)
+ sp_globals.ymax = bmap_max;
+ else
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ sp_globals.clip_ymin = - sp_globals.clip_ymin;
+ bmap_min = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ if (bmap_min < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ else
+ sp_globals.ymin = bmap_min;
+ }
+ sp_globals.clip_xmin = -sp_globals.xmin;
+ sp_globals.clip_xmax = ((sp_globals.set_width.x+32768L) >> 16) -
+ sp_globals.xmin;
+ break;
+ }
+if ( !(sp_globals.specs.flags & CLIP_TOP))
+#endif
+ sp_globals.ymax = (sp_globals.bmap_ymax + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+#if INCL_CLIPPING
+if ( !(sp_globals.specs.flags & CLIP_BOTTOM))
+#endif
+
+ sp_globals.ymin = (sp_globals.bmap_ymin + sp_globals.pixrnd + 1) >> sp_globals.pixshift;
+ }
+ else
+ {
+ sp_globals.ymin = sp_globals.ymax = 0;
+ }
+
+ /* add in the rounded out part (from xform.) of the left edge */
+ if (sp_globals.tcb.xmode == 0) /* for X pix is function of X orus only add the round */
+ xorg = (((fix31)sp_globals.xmin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift));
+ else
+ if (sp_globals.tcb.xmode == 1) /* for X pix is function of -X orus only, subtr. round */
+ xorg = (((fix31)sp_globals.xmin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift)) ;
+ else
+ xorg = (fix31)sp_globals.xmin << 16; /* for other cases don't use round on x */
+
+ if (sp_globals.tcb.ymode == 2) /* for Y pix is function of X orus only, add round error */
+ yorg = (((fix31)sp_globals.ymin << 16) + (sp_globals.rnd_xmin << sp_globals.poshift));
+ else
+ if (sp_globals.tcb.ymode == 3) /* for Y pix is function of -X orus only, sub round */
+ yorg = (((fix31)sp_globals.ymin << 16) - (sp_globals.rnd_xmin << sp_globals.poshift));
+ else /* all other cases have no round error on yorg */
+ yorg = (fix31)sp_globals.ymin << 16;
+
+ open_bitmap(sp_globals.set_width.x, sp_globals.set_width.y, xorg, yorg,
+ sp_globals.xmax - sp_globals.xmin, sp_globals.ymax - sp_globals.ymin);
+ if (sp_globals.intercept_oflo)
+ {
+ sp_globals.y_band.band_min = sp_globals.ymin;
+ sp_globals.y_band.band_max = sp_globals.ymax;
+ init_intercepts_out();
+ sp_globals.first_pass = FALSE;
+ sp_globals.extents_running = FALSE;
+ return FALSE;
+ }
+ else
+ {
+ sp_proc_intercepts_screen();
+ close_bitmap();
+ return TRUE;
+ }
+ }
+else
+ {
+ if (sp_globals.intercept_oflo)
+ {
+ reduce_band_size_out();
+ init_intercepts_out();
+ return FALSE;
+ }
+ else
+ {
+ sp_proc_intercepts_screen();
+ if (next_band_out())
+ {
+ init_intercepts_out();
+ return FALSE;
+ }
+ close_bitmap();
+ return TRUE;
+ }
+ }
+}
+#endif
+
+#if INCL_SCREEN
+FUNCTION LOCAL void sp_add_intercept_screen(y, x)
+GDECL
+fix15 y; /* Y coordinate in relative pixel units */
+ /* (0 is lowest sample in band) */
+fix31 x; /* X coordinate of intercept in subpixel units */
+
+/* Called by line() to add an intercept to the intercept list structure
+ */
+
+{
+register fix15 from; /* Insertion pointers for the linked list sort */
+register fix15 to;
+register fix15 xloc;
+register fix15 xfrac;
+
+#if DEBUG
+printf(" Add intercept(%2d, %x)\n", y + sp_globals.y_band.band_min, x);
+
+/* Bounds checking IS done in debug mode */
+if (y < 0) /* Y value below bottom of current band? */
+ {
+ printf(" Intecerpt less than 0!!!\007\n");
+ return;
+ }
+
+if (y > (sp_globals.no_y_lists - 1)) /* Y value above top of current band? */
+ {
+ printf(" Intercept too big for band!!!!!\007\n");
+ return;
+ }
+#endif
+
+/* Store new values */
+
+sp_intercepts.car[sp_globals.next_offset] = xloc = (fix15)(x >> 16);
+sp_intercepts.inttype[sp_globals.next_offset] = sp_intercepts.leftedge | (xfrac = ((x >> 8) & FRACTION));
+
+/* Find slot to insert new element (between from and to) */
+
+from = y; /* Start at list head */
+
+while( (to = sp_intercepts.cdr[from]) != 0) /* Until to == end of list */
+ {
+ if (xloc < sp_intercepts.car[to]) /* If next item is larger than or same as this one... */
+ goto insert_element; /* ... drop out and insert here */
+ else if (xloc == sp_intercepts.car[to] && xfrac < (sp_intercepts.inttype[to] & FRACTION))
+ goto insert_element; /* ... drop out and insert here */
+ from = to; /* move forward in list */
+ }
+
+insert_element: /* insert element "sp_globals.next_offset" between elements "from" */
+ /* and "to" */
+
+sp_intercepts.cdr[from] = sp_globals.next_offset;
+sp_intercepts.cdr[sp_globals.next_offset] = to;
+
+if (++sp_globals.next_offset >= MAX_INTERCEPTS) /* Intercept buffer full? */
+ {
+ sp_globals.intercept_oflo = TRUE;
+/* There may be a few more calls to "add_intercept" from the current line */
+/* To avoid problems, we set next_offset to a safe value. We don't care */
+/* if the intercept table gets trashed at this point */
+ sp_globals.next_offset = sp_globals.first_offset;
+ }
+}
+
+#endif
+
+#if INCL_SCREEN
+FUNCTION LOCAL void sp_proc_intercepts_screen()
+GDECL
+
+/* Called by sp_make_char to output accumulated intercept lists
+ * Clips output to sp_globals.xmin, sp_globals.xmax, sp_globals.ymin, sp_globals.ymax boundaries
+ */
+{
+register fix15 i,j, jplus1, iminus1;
+fix15 k,nextk, previ;
+register fix15 from, to; /* Start and end of run in pixel units
+ relative to left extent of character */
+register fix15 y;
+register fix15 scan_line;
+ fix15 first_y, last_y;
+ fix15 xsave;
+
+
+fix15 diff;
+
+#if DEBUG
+printf("\nPROC_INTERCEPTS_SCREEN: Intercept lists before:\n");
+#endif
+
+#if INCL_CLIPPING
+if ((sp_globals.specs.flags & CLIP_LEFT) != 0)
+ clipleft = TRUE;
+else
+ clipleft = FALSE;
+if ((sp_globals.specs.flags & CLIP_RIGHT) != 0)
+ clipright = TRUE;
+else
+ clipright = FALSE;
+if (clipleft || clipright)
+ {
+ xmax = sp_globals.clip_xmax + sp_globals.xmin;
+ xmin = sp_globals.clip_xmin + sp_globals.xmin;
+ }
+if (!clipright)
+ xmax = ((sp_globals.set_width.x+32768L) >> 16);
+#endif
+
+if ((first_y = sp_globals.y_band.band_max) >= sp_globals.ymax)
+ first_y = sp_globals.ymax - 1; /* Clip to sp_globals.ymax boundary */
+
+if ((last_y = sp_globals.y_band.band_min) < sp_globals.ymin)
+ last_y = sp_globals.ymin; /* Clip to sp_globals.ymin boundary */
+
+last_y -= sp_globals.y_band.band_min;
+
+#if DEBUG
+/* Print out all of the intercept info */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = y; /* Index head of intercept list */
+ while ((i = sp_intercepts.cdr[i]) != 0) /* Link to next intercept if present */
+ {
+ if ((from = sp_intercepts.car[i] - sp_globals.xmin) < 0)
+ from = 0; /* Clip to sp_globals.xmin boundary */
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ if (i == 0) /* End of list? */
+ {
+ printf("****** proc_intercepts: odd number of intercepts\n");
+ break;
+ }
+ if ((to = sp_intercepts.car[i]) > sp_globals.xmax)
+ to = sp_globals.xmax - sp_globals.xmin; /* Clip to sp_globals.xmax boundary */
+ else
+ to -= sp_globals.xmin;
+ printf(" Y = %2d (scanline %2d): %d %d:\n",
+ y + sp_globals.y_band.band_min, scan_line, from, to);
+ }
+ }
+#endif
+
+/* CHECK INTERCEPT LIST FOR DROPOUT AND WINDING, FIX IF NECESSARY */
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--)
+ {
+ previ = y;
+ i = sp_intercepts.cdr[y]; /* Index head of intercept list */
+ while (i != 0) /* Link to next intercept if present */
+ {
+ j = i;
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ if (sp_intercepts.inttype[i] & LEFT_INT)
+ {
+ if (sp_intercepts.inttype[j] & LEFT_INT)
+ {
+ do { i = sp_intercepts.cdr[i]; } while (sp_intercepts.inttype[i] & LEFT_INT);
+ do { i = sp_intercepts.cdr[i]; } while (sp_intercepts.cdr[i] && !(sp_intercepts.inttype[sp_intercepts.cdr[i]] & LEFT_INT));
+ sp_intercepts.cdr[j] = i;
+ }
+ else
+ {
+ xsave = sp_intercepts.car[j];
+ sp_intercepts.car[j] = sp_intercepts.car[i];
+ sp_intercepts.car[i] = xsave;
+
+ xsave = sp_intercepts.inttype[j];
+ sp_intercepts.inttype[j] = sp_intercepts.inttype[i] & FRACTION;
+ sp_intercepts.inttype[i] = xsave | LEFT_INT;
+
+ sp_intercepts.cdr[previ] = i;
+ sp_intercepts.cdr[j] = sp_intercepts.cdr[i];
+ sp_intercepts.cdr[i] = j;
+ i = j;
+ j = sp_intercepts.cdr[previ];
+ }
+ }
+
+ if (sp_intercepts.car[j] < sp_globals.xmin)
+ sp_intercepts.car[j] = sp_globals.xmin; /* Clip to sp_globals.xmin boundary */
+
+ if (sp_intercepts.car[i] > sp_globals.xmax)
+ sp_intercepts.car[i] = sp_globals.xmax;
+
+ if (sp_intercepts.car[j] >= sp_intercepts.car[i])
+ {
+ if ((ufix16)(sp_intercepts.inttype[j] & FRACTION) + (ufix16)(sp_intercepts.inttype[i] & FRACTION) > sp_intercepts.fracpix)
+ ++sp_intercepts.car[i];
+ else
+ --sp_intercepts.car[j];
+ }
+ if (sp_globals.first_pass)
+ {
+ if (sp_intercepts.inttype[i-1] & END_INT)
+ {
+ for (iminus1 = i+1; !(sp_intercepts.inttype[iminus1] & END_INT); iminus1++)
+ ;
+ }
+ else
+ iminus1 = i-1;
+
+ if (sp_intercepts.inttype[j] & END_INT)
+ {
+ for (jplus1 = j-1; !(sp_intercepts.inttype[jplus1] & END_INT); jplus1--)
+ ;
+ jplus1++;
+ }
+ else
+ jplus1 = j+1;
+
+ if ((sp_intercepts.inttype[iminus1] & LEFT_INT))
+ {
+ if ( sp_intercepts.car[jplus1] > sp_intercepts.car[i])
+ {
+ diff = sp_intercepts.car[jplus1] - sp_intercepts.car[i];
+ sp_intercepts.car[i] += diff/2;
+ sp_intercepts.car[jplus1] -= diff/2;
+ if (diff & 1)
+ {
+ if ((ufix16)(sp_intercepts.inttype[i] & FRACTION) + (ufix16)(sp_intercepts.inttype[jplus1] & FRACTION) > sp_intercepts.fracpix)
+ sp_intercepts.car[i] ++;
+ else
+ sp_intercepts.car[jplus1]--;
+ }
+ }
+ }
+ else if (!(sp_intercepts.inttype[jplus1] & LEFT_INT))
+ {
+ if (sp_intercepts.car[iminus1] < sp_intercepts.car[j])
+ {
+ diff = sp_intercepts.car[j] - sp_intercepts.car[iminus1];
+ sp_intercepts.car[j] -= diff/2;
+ sp_intercepts.car[iminus1] += diff/2;
+ if (diff & 1)
+ {
+ if ((ufix16)(sp_intercepts.inttype[j] & FRACTION) +
+ (ufix16)(sp_intercepts.inttype[iminus1] & FRACTION) > sp_intercepts.fracpix)
+ sp_intercepts.car[iminus1]++;
+ else
+ sp_intercepts.car[j]--;
+ }
+ }
+ }
+ if (sp_globals.tcb.mirror == -1)
+ {
+ if (sp_intercepts.inttype[j-1] & END_INT)
+ {
+ for (jplus1 = j+1; !(sp_intercepts.inttype[jplus1] & END_INT); jplus1++)
+ ;
+ }
+ else
+ {
+ jplus1 = j-1;
+ }
+ }
+
+ if (!(sp_intercepts.inttype[jplus1] & LEFT_INT) &&
+ sp_intercepts.car[j] > sp_intercepts.car[jplus1])
+ {
+ k = sp_intercepts.cdr[y - 1];
+ while (k > 0)
+ {
+ nextk = sp_intercepts.cdr[k];
+ if (!(sp_intercepts.inttype[k] & LEFT_INT) &&
+ (sp_intercepts.inttype[nextk] & LEFT_INT) &&
+ sp_intercepts.car[nextk] > sp_intercepts.car[jplus1])
+ {
+ if ((diff=sp_intercepts.car[j] - sp_intercepts.car[k]) > 0)
+ {
+ if (diff <= (sp_intercepts.car[nextk] - sp_intercepts.car[jplus1]))
+ {
+ sp_intercepts.car[j] -= diff/2;
+ sp_intercepts.car[k] += diff/2;
+ if (diff & 1)
+ {
+ if ((ufix16)(sp_intercepts.inttype[j] & FRACTION) +
+ (ufix16)(sp_intercepts.inttype[k] & FRACTION) > sp_intercepts.fracpix)
+ sp_intercepts.car[j]--;
+ else
+ sp_intercepts.car[k]++;
+ }
+ }
+ else
+ {
+ diff = sp_intercepts.car[nextk] - sp_intercepts.car[jplus1];
+ sp_intercepts.car[nextk] -= diff/2;
+ sp_intercepts.car[jplus1] += diff/2;
+ if (diff & 1)
+ {
+ if ((ufix16)(sp_intercepts.inttype[jplus1] & FRACTION) +
+ (ufix16)(sp_intercepts.inttype[nextk] & FRACTION) > sp_intercepts.fracpix)
+ sp_intercepts.car[nextk]--;
+ else
+ sp_intercepts.car[jplus1]++;
+ }
+ }
+ }
+ break;
+ }
+ k = nextk;
+ }
+ }
+ if (j > 0 && sp_intercepts.car[j-1] > sp_intercepts.car[i] && !(sp_intercepts.inttype[j-1] & END_INT))
+ {
+ diff = sp_intercepts.car[j-1] - sp_intercepts.car[i];
+ sp_intercepts.car[i] += diff/2;
+ sp_intercepts.car[j-1] -= diff/2;
+ if (diff & 1)
+ {
+ if ((ufix16)(sp_intercepts.inttype[i] & FRACTION) + (ufix16)(sp_intercepts.inttype[j-1] & FRACTION) > sp_intercepts.fracpix)
+ sp_intercepts.car[i]++;
+ else
+ sp_intercepts.car[j-1]--;
+ }
+ }
+ if (sp_intercepts.car[i+1] < sp_intercepts.car[j] && !(sp_intercepts.inttype[i] & END_INT))
+ {
+ diff = sp_intercepts.car[j] - sp_intercepts.car[i+1];
+ sp_intercepts.car[j] -= diff/2;
+ sp_intercepts.car[i+1] += diff/2;
+ if (diff & 1)
+ {
+ if ((ufix16)(sp_intercepts.inttype[j] & FRACTION) + (ufix16)(sp_intercepts.inttype[i+1] & FRACTION) > sp_intercepts.fracpix)
+ sp_intercepts.car[i+1]++;
+ else
+ sp_intercepts.car[j]--;
+ }
+
+ }
+ previ = i;
+ }
+ i = sp_intercepts.cdr[i];
+ }
+ }
+
+#if DEBUG
+printf("\nPROC_INTERCEPTS_SCREEN: Intercept lists after:\n");
+/* Print out all of the intercept info */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = y; /* Index head of intercept list */
+ while ((i = sp_intercepts.cdr[i]) != 0) /* Link to next intercept if present */
+ {
+ if ((from = sp_intercepts.car[i] - sp_globals.xmin) < 0)
+ from = 0; /* Clip to sp_globals.xmin boundary */
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ if (i == 0) /* End of list? */
+ {
+ printf("****** proc_intercepts: odd number of intercepts\n");
+ break;
+ }
+ if ((to = sp_intercepts.car[i]) > sp_globals.xmax)
+ to = sp_globals.xmax - sp_globals.xmin; /* Clip to sp_globals.xmax boundary */
+ else
+ to -= sp_globals.xmin;
+ printf(" Y = %2d (scanline %2d): %d %d:\n",
+ y + sp_globals.y_band.band_min, scan_line, from, to);
+ }
+ }
+#endif
+
+/* INTERCEPTS ALL PATCHED, NOW DRAW THE IMAGE */
+scan_line = sp_globals.ymax - first_y - 1;
+
+for (y = first_y - sp_globals.y_band.band_min; y >= last_y; y--, scan_line++)
+ {
+ i = sp_intercepts.cdr[y]; /* Index head of intercept list */
+ while (i != 0) /* Link to next intercept if present */
+ {
+ from = sp_intercepts.car[i];
+ i = sp_intercepts.cdr[i]; /* Link to next intercept */
+ to = sp_intercepts.car[i];
+#if INCL_CLIPPING
+ if (clipleft)
+ {
+ if (to <= xmin)
+ {
+ i = sp_intercepts.cdr[i];
+ continue;
+ }
+ if (from < xmin)
+ from = xmin;
+ }
+ if (clipright)
+ {
+ if (from >= xmax)
+ {
+ i = sp_intercepts.cdr[i];
+ continue;
+ }
+ if (to > xmax)
+ to = xmax;
+ }
+#endif
+ set_bitmap_bits(scan_line, from-sp_globals.xmin, to-sp_globals.xmin);
+ i = sp_intercepts.cdr[i];
+ }
+ }
+}
+
+#endif
diff --git a/src/Speedo/out_util.c b/src/Speedo/out_util.c
new file mode 100644
index 0000000..b3316a5
--- /dev/null
+++ b/src/Speedo/out_util.c
@@ -0,0 +1,337 @@
+/* $Xorg: out_util.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+
+#define DEBUG 0
+
+/*************************** O U T _ U T I L . C *****************************
+ * *
+ * This is a utility module share by all bitmap output modules *
+ * *
+ *****************************************************************************/
+
+
+#include "spdo_prv.h" /* General definitions for Speedo */
+/* absolute value function */
+#define ABS(X) ( (X < 0) ? -X : X)
+#if INCL_BLACK || INCL_2D || INCL_SCREEN
+
+FUNCTION void init_char_out(Psw,Pmin,Pmax)
+GDECL
+point_t Psw, Pmin, Pmax;
+{
+sp_globals.set_width.x = (fix31)Psw.x << sp_globals.poshift;
+sp_globals.set_width.y = (fix31)Psw.y << sp_globals.poshift;
+set_first_band_out(Pmin, Pmax);
+init_intercepts_out();
+if (sp_globals.normal)
+ {
+ sp_globals.bmap_xmin = Pmin.x;
+ sp_globals.bmap_xmax = Pmax.x;
+ sp_globals.bmap_ymin = Pmin.y;
+ sp_globals.bmap_ymax = Pmax.y;
+ sp_globals.extents_running = FALSE;
+ }
+else
+ {
+ sp_globals.bmap_xmin = 32000;
+ sp_globals.bmap_xmax = -32000;
+ sp_globals.bmap_ymin = 32000;
+ sp_globals.bmap_ymax = -32000;
+ sp_globals.extents_running = TRUE;
+ }
+sp_globals.first_pass = TRUE;
+}
+
+FUNCTION void begin_sub_char_out(Psw, Pmin, Pmax)
+GDECL
+point_t Psw;
+point_t Pmin;
+point_t Pmax;
+/* Called at the start of each sub-character in a composite character
+ */
+{
+#if DEBUG
+printf("BEGIN_SUB_CHAR_out(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
+ (real)Psw.x / (real)sp_globals.onepix, (real)Psw.y / (real)sp_globals.onepix,
+ (real)Pmin.x / (real)sp_globals.onepix, (real)Pmin.y / (real)sp_globals.onepix,
+ (real)Pmax.x / (real)sp_globals.onepix, (real)Pmax.y / (real)sp_globals.onepix);
+#endif
+restart_intercepts_out();
+if (!sp_globals.extents_running)
+ {
+ sp_globals.bmap_xmin = 32000;
+ sp_globals.bmap_xmax = -32000;
+ sp_globals.bmap_ymin = 32000;
+ sp_globals.bmap_ymax = -32000;
+ sp_globals.extents_running = TRUE;
+ }
+}
+
+FUNCTION void curve_out(P1, P2, P3,depth)
+GDECL
+point_t P1, P2, P3;
+fix15 depth;
+/* Called for each curve in the transformed character if curves out enabled
+ */
+{
+#if DEBUG
+printf("CURVE_OUT(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n",
+ (real)P1.x / (real)sp_globals.onepix, (real)P1.y / (real)sp_globals.onepix,
+ (real)P2.x / (real)sp_globals.onepix, (real)P2.y / (real)sp_globals.onepix,
+ (real)P3.x / (real)sp_globals.onepix, (real)P3.y / (real)sp_globals.onepix);
+#endif
+}
+
+
+
+FUNCTION void end_contour_out()
+GDECL
+/* Called after the last vector in each contour
+ */
+{
+#if DEBUG
+printf("END_CONTOUR_OUT()\n");
+#endif
+}
+
+
+FUNCTION void end_sub_char_out()
+GDECL
+/* Called after the last contour in each sub-character in a compound character
+ */
+{
+#if DEBUG
+printf("END_SUB_CHAR_OUT()\n");
+#endif
+}
+
+
+FUNCTION void init_intercepts_out()
+GDECL
+/* Called to initialize intercept storage data structure
+ */
+
+{
+fix15 i;
+fix15 no_lists;
+
+#if DEBUG
+printf(" Init intercepts (Y band from %d to %d)\n", sp_globals.y_band.band_min, sp_globals.y_band.band_max);
+if (sp_globals.x_scan_active)
+ printf(" (X band from %d to %d)\n", sp_globals.x_band.band_min, sp_globals.x_band.band_max);
+#endif
+
+sp_globals.intercept_oflo = FALSE;
+
+sp_globals.no_y_lists = sp_globals.y_band.band_max - sp_globals.y_band.band_min + 1;
+#if INCL_2D
+if (sp_globals.output_mode == MODE_2D)
+ {
+ sp_globals.no_x_lists = sp_globals.x_scan_active ?
+ sp_globals.x_band.band_max - sp_globals.x_band.band_min + 1 : 0;
+ no_lists = sp_globals.no_y_lists + sp_globals.no_x_lists;
+ }
+else
+#endif
+ no_lists = sp_globals.no_y_lists;
+
+#if INCL_2D
+sp_globals.y_band.band_floor = 0;
+sp_globals.y_band.band_ceiling = sp_globals.no_y_lists;
+#endif
+
+if (no_lists >= MAX_INTERCEPTS) /* Not enough room for list table? */
+ {
+ no_lists = sp_globals.no_y_lists = MAX_INTERCEPTS;
+ sp_globals.intercept_oflo = TRUE;
+ sp_globals.y_band.band_min = sp_globals.y_band.band_max - sp_globals.no_y_lists + 1;
+#if INCL_2D
+ sp_globals.y_band.band_array_offset = sp_globals.y_band.band_min;
+ sp_globals.y_band.band_ceiling = sp_globals.no_y_lists;
+ sp_globals.no_x_lists = 0;
+ sp_globals.x_scan_active = FALSE;
+#endif
+ }
+
+for (i = 0; i < no_lists; i++) /* For each active value... */
+ {
+#if INCL_SCREEN
+ if (sp_globals.output_mode == MODE_SCREEN)
+ sp_intercepts.inttype[i]=0;
+#endif
+ sp_intercepts.cdr[i] = 0; /* Mark each intercept list empty */
+ }
+
+sp_globals.first_offset = sp_globals.next_offset = no_lists;
+
+#if INCL_2D
+sp_globals.y_band.band_array_offset = sp_globals.y_band.band_min;
+sp_globals.x_band.band_array_offset = sp_globals.x_band.band_min - sp_globals.no_y_lists;
+sp_globals.x_band.band_floor = sp_globals.no_y_lists;
+sp_globals.x_band.band_ceiling = no_lists;
+#endif
+#if INCL_SCREEN
+sp_intercepts.inttype[sp_globals.no_y_lists-1] = END_INT;
+#endif
+
+}
+
+
+FUNCTION void restart_intercepts_out()
+GDECL
+
+/* Called by sp_make_char when a new sub character is started
+ * Freezes current sorted lists
+ */
+
+{
+
+#if DEBUG
+printf(" Restart intercepts:\n");
+#endif
+sp_globals.first_offset = sp_globals.next_offset;
+}
+
+
+
+FUNCTION void set_first_band_out(Pmin, Pmax)
+GDECL
+point_t Pmin;
+point_t Pmax;
+{
+
+sp_globals.ymin = Pmin.y;
+sp_globals.ymax = Pmax.y;
+
+sp_globals.ymin = (sp_globals.ymin - sp_globals.onepix + 1) >> sp_globals.pixshift;
+sp_globals.ymax = (sp_globals.ymax + sp_globals.onepix - 1) >> sp_globals.pixshift;
+
+#if INCL_CLIPPING
+ switch(sp_globals.tcb0.xtype)
+ {
+ case 1: /* 180 degree rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ sp_globals.clip_ymin = -1* sp_globals.clip_ymin;
+ if (sp_globals.ymin < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ if (sp_globals.ymax > sp_globals.clip_ymax)
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ break;
+ case 2: /* 90 degree rotation */
+ sp_globals.clip_ymax = 0;
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ break;
+ case 3: /* 270 degree rotation */
+ sp_globals.clip_ymax = ((sp_globals.set_width.y+32768L) >> 16);
+ if ((sp_globals.specs.flags & CLIP_TOP) &&
+ (sp_globals.ymax > sp_globals.clip_ymax))
+ sp_globals.ymax = sp_globals.clip_ymax;
+ sp_globals.clip_ymin = 0;
+ if ((sp_globals.specs.flags & CLIP_BOTTOM) &&
+ (sp_globals.ymin < sp_globals.clip_ymin))
+ sp_globals.ymin = sp_globals.clip_ymin;
+ break;
+ default: /* this is for zero degree rotation and arbitrary rotation */
+ if (sp_globals.specs.flags & CLIP_TOP)
+ {
+ sp_globals.clip_ymax = (fix31)((fix31)EM_TOP * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymax = sp_globals.clip_ymax >> sp_globals.multshift;
+ if (sp_globals.ymax > sp_globals.clip_ymax)
+ sp_globals.ymax = sp_globals.clip_ymax;
+ }
+ if (sp_globals.specs.flags & CLIP_BOTTOM)
+ {
+ sp_globals.clip_ymin = (fix31)((fix31)(-1 * EM_BOT) * sp_globals.tcb0.yppo + ((1<<sp_globals.multshift)/2));
+ sp_globals.clip_ymin = sp_globals.clip_ymin >> sp_globals.multshift;
+ sp_globals.clip_ymin = - sp_globals.clip_ymin;
+ if (sp_globals.ymin < sp_globals.clip_ymin)
+ sp_globals.ymin = sp_globals.clip_ymin;
+ }
+ break;
+ }
+#endif
+sp_globals.y_band.band_min = sp_globals.ymin;
+sp_globals.y_band.band_max = sp_globals.ymax - 1;
+
+sp_globals.xmin = (Pmin.x + sp_globals.pixrnd) >> sp_globals.pixshift;
+sp_globals.xmax = (Pmax.x + sp_globals.pixrnd) >> sp_globals.pixshift;
+
+
+#if INCL_2D
+sp_globals.x_band.band_min = sp_globals.xmin - 1; /* subtract one pixel of "safety margin" */
+sp_globals.x_band.band_max = sp_globals.xmax /* - 1 + 1 */; /* Add one pixel of "safety margin" */
+#endif
+}
+
+
+
+
+
+
+
+FUNCTION void reduce_band_size_out()
+GDECL
+{
+sp_globals.y_band.band_min = sp_globals.y_band.band_max - ((sp_globals.y_band.band_max - sp_globals.y_band.band_min) >> 1);
+#if INCL_2D
+sp_globals.y_band.band_array_offset = sp_globals.y_band.band_min;
+#endif
+}
+
+
+FUNCTION boolean next_band_out()
+GDECL
+{
+fix15 tmpfix15;
+
+if (sp_globals.y_band.band_min <= sp_globals.ymin)
+ return FALSE;
+tmpfix15 = sp_globals.y_band.band_max - sp_globals.y_band.band_min;
+sp_globals.y_band.band_max = sp_globals.y_band.band_min - 1;
+sp_globals.y_band.band_min = sp_globals.y_band.band_max - tmpfix15;
+if (sp_globals.y_band.band_min < sp_globals.ymin)
+ sp_globals.y_band.band_min = sp_globals.ymin;
+#if INCL_2D
+sp_globals.y_band.band_array_offset = sp_globals.y_band.band_min;
+#endif
+return TRUE;
+}
+#endif
+
diff --git a/src/Speedo/reset.c b/src/Speedo/reset.c
new file mode 100644
index 0000000..786ec43
--- /dev/null
+++ b/src/Speedo/reset.c
@@ -0,0 +1,127 @@
+/* $Xorg: reset.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+
+
+/******************************* R E S E T . C *******************************
+ * *
+ * This module provides initialization functions. *
+ * *
+ ****************************************************************************/
+
+#include "spdo_prv.h" /* General definitions for Speedo */
+#include "keys.h" /* Font decryption keys */
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** STATIC FUNCTIONS *****/
+
+
+FUNCTION void reset()
+GDECL
+/*
+ * Called by the host software to intialize the Speedo mechanism
+ */
+{
+sp_globals.specs_valid = FALSE; /* Flag specs not valid */
+
+/* Reset decryption key */
+sp_globals.key32 = (KEY3 << 8) | KEY2;
+sp_globals.key4 = KEY4;
+sp_globals.key6 = KEY6;
+sp_globals.key7 = KEY7;
+sp_globals.key8 = KEY8;
+
+#if INCL_RULES
+sp_globals.constr.font_id_valid = FALSE;
+#endif
+
+#if INCL_MULTIDEV
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+sp_globals.bitmap_device_set = FALSE;
+#endif
+#if INCL_OUTLINE
+sp_globals.outline_device_set = FALSE;
+#endif
+#endif
+}
+
+#if INCL_KEYS
+FUNCTION void set_key(key)
+GDECL
+ufix8 key[]; /* Specified decryption key */
+/*
+ * Dynamically sets font decryption key.
+ */
+{
+sp_globals.key32 = ((ufix16)key[3] << 8) | key[2];
+sp_globals.key4 = key[4];
+sp_globals.key6 = key[6];
+sp_globals.key7 = key[7];
+sp_globals.key8 = key[8];
+}
+#endif
+
+
+
+FUNCTION ufix16 get_cust_no(font_buff)
+GDECL
+buff_t font_buff;
+/*
+ returns customer number from font
+*/
+{
+ufix8 FONTFAR *hdr2_org;
+ufix16 private_off;
+
+private_off = read_word_u(font_buff.org + FH_HEDSZ);
+if (private_off + FH_CUSNR > font_buff.no_bytes)
+ {
+ report_error(1); /* Insufficient font data loaded */
+ return FALSE;
+ }
+
+hdr2_org = font_buff.org + private_off;
+
+return (read_word_u(hdr2_org + FH_CUSNR));
+}
+
+
diff --git a/src/Speedo/set_spcs.c b/src/Speedo/set_spcs.c
new file mode 100644
index 0000000..d060a4b
--- /dev/null
+++ b/src/Speedo/set_spcs.c
@@ -0,0 +1,769 @@
+/* $Xorg: set_spcs.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+
+/*************************** S E T _ S P C S . C *****************************
+ * *
+ * This module implements all sp_set_specs() functionality. *
+ * *
+ ****************************************************************************/
+#define SET_SPCS
+#include "spdo_prv.h" /* General definitions for Speedo */
+#include "keys.h"
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/****** EXTERNAL VARIABLES *****/
+
+/***** STATIC VARIABLES *****/
+
+
+/****** 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)
+GDECL
+specs_t STACKFAR *specsarg; /* Bundle of conversion specifications */
+/*
+ * Called by host software to set character generation specifications
+ */
+{
+fix31 offcd; /* Offset to start of character directory */
+fix31 ofcns; /* Offset to start of constraint data */
+fix31 cd_size; /* Size of character directory */
+fix31 no_bytes_min; /* Min number of bytes in font buffer */
+ufix16 font_id; /* Font ID */
+ufix16 private_off; /* offset to private header */
+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 */
+
+sp_globals.specs_valid = FALSE; /* Flag specs not valid */
+
+sp_globals.specs = *specsarg; /* copy specs structure into sp_globals */
+sp_globals.pspecs = &sp_globals.specs;
+sp_globals.font = *sp_globals.pspecs->pfont;
+sp_globals.pfont = &sp_globals.font;
+sp_globals.font_org = sp_globals.font.org;
+
+if (read_word_u(sp_globals.font_org + FH_FMVER + 4) != 0x0d0a)
+ {
+ report_error(4); /* Font format error */
+ return FALSE;
+ }
+if (read_word_u(sp_globals.font_org + FH_FMVER + 6) != 0x0000)
+ {
+ report_error(4); /* Font format error */
+ return FALSE;
+ }
+
+if (get_cust_no(*specsarg->pfont) == 0)
+ {
+ sp_globals.key32 = 0;
+ sp_globals.key4 = 0;
+ sp_globals.key6 = 0;
+ sp_globals.key7 = 0;
+ sp_globals.key8 = 0;
+ }
+else
+ {
+ sp_globals.key32 = (KEY3 << 8) | KEY2;
+ sp_globals.key4 = KEY4;
+ sp_globals.key6 = KEY6;
+ sp_globals.key7 = KEY7;
+ sp_globals.key8 = KEY8;
+ }
+
+
+sp_globals.no_chars_avail = read_word_u(sp_globals.font_org + FH_NCHRF);
+
+/* Read sp_globals.orus per em from font header */
+sp_globals.orus_per_em = read_word_u(sp_globals.font_org + FH_ORUPM);
+
+/* compute address of private header */
+private_off = read_word_u(sp_globals.font_org + FH_HEDSZ);
+sp_globals.hdr2_org = sp_globals.font_org + private_off;
+
+/* set metric resolution if specified, default to outline res otherwise */
+if (private_off > EXP_FH_METRES)
+ {
+ sp_globals.metric_resolution = read_word_u(sp_globals.font_org + EXP_FH_METRES);
+ }
+else
+ {
+ sp_globals.metric_resolution = sp_globals.orus_per_em;
+ }
+
+#if INCL_METRICS
+sp_globals.kern.tkorg = sp_globals.font_org + read_long(sp_globals.hdr2_org + FH_OFFTK);
+sp_globals.kern.pkorg = sp_globals.font_org + read_long(sp_globals.hdr2_org + FH_OFFPK);
+sp_globals.kern.no_tracks = read_word_u(sp_globals.font_org + FH_NKTKS);
+sp_globals.kern.no_pairs = read_word_u(sp_globals.font_org + FH_NKPRS);
+#endif
+
+offcd = read_long(sp_globals.hdr2_org + FH_OFFCD); /* Read offset to character directory */
+ofcns = read_long(sp_globals.hdr2_org + FH_OFCNS); /* Read offset to constraint data */
+cd_size = ofcns - offcd;
+if ((((sp_globals.no_chars_avail << 1) + 3) != cd_size) &&
+ (((sp_globals.no_chars_avail * 3) + 4) != cd_size))
+ {
+ report_error(4); /* Font format error */
+ return FALSE;
+ }
+
+#if INCL_LCD /* Dynamic character data load suppoorted? */
+#if INCL_METRICS
+no_bytes_min = read_long(sp_globals.hdr2_org + FH_OCHRD); /* Offset to character data */
+#else /* Dynamic character data load not supported? */
+no_bytes_min = read_long(sp_globals.hdr2_org + FH_OFFTK); /* Offset to track kerning data */
+#endif
+#else /* Dynamic character data load not supported? */
+no_bytes_min = read_long(sp_globals.hdr2_org + FH_NBYTE); /* Offset to EOF + 1 */
+#endif
+
+sp_globals.font_buff_size = sp_globals.pfont->no_bytes;
+if (sp_globals.font_buff_size < no_bytes_min) /* Minimum data not loaded? */
+ {
+ report_error(1); /* Insufficient font data loaded */
+ return FALSE;
+ }
+
+sp_globals.pchar_dir = sp_globals.font_org + offcd;
+sp_globals.first_char_idx = read_word_u(sp_globals.font_org + FH_FCHRF);
+
+/* Register font name with sp_globals.constraint mechanism */
+#if INCL_RULES
+font_id = read_word_u(sp_globals.font_org + FH_FNTID);
+if (!(sp_globals.constr.font_id_valid) || (sp_globals.constr.font_id != font_id))
+ {
+ sp_globals.constr.font_id = font_id;
+ sp_globals.constr.font_id_valid = TRUE;
+ sp_globals.constr.data_valid = FALSE;
+ }
+sp_globals.constr.org = sp_globals.font_org + ofcns;
+sp_globals.constr.active = ((sp_globals.pspecs->flags & CONSTR_OFF) == 0);
+#endif
+
+/* Set up sliding point constants */
+/* Set pixel shift to accomodate largest transformed pixel value */
+xmin = read_word_u(sp_globals.font_org + FH_FXMIN);
+xmax = read_word_u(sp_globals.font_org + FH_FXMAX);
+ymin = read_word_u(sp_globals.font_org + FH_FYMIN);
+ymax = read_word_u(sp_globals.font_org + FH_FYMAX);
+
+if (!sp_setup_consts(xmin,xmax,ymin,ymax))
+ {
+ report_error(3); /* Requested specs out of range */
+ return FALSE;
+ }
+#if INCL_ISW
+/* save the value of the max x oru that the fixed point constants are based on*/
+sp_globals.isw_xmax = xmax;
+#endif
+
+/* Setup transformation control block */
+sp_setup_tcb(&sp_globals.tcb0);
+
+
+/* Select output module */
+sp_globals.output_mode = sp_globals.pspecs->flags & 0x0007;
+
+#if INCL_USEROUT
+if (!init_userout(sp_globals.pspecs))
+#endif
+
+switch (sp_globals.output_mode)
+ {
+#if INCL_BLACK
+case MODE_BLACK: /* Output mode 0 (Black writer) */
+ sp_globals.init_out = sp_init_black;
+ sp_globals.begin_char = sp_begin_char_black;
+ sp_globals.begin_sub_char = sp_begin_sub_char_out;
+ sp_globals.begin_contour = sp_begin_contour_black;
+ sp_globals.curve = sp_curve_out;
+ sp_globals.line = sp_line_black;
+ sp_globals.end_contour = sp_end_contour_out;
+ sp_globals.end_sub_char = sp_end_sub_char_out;
+ sp_globals.end_char = sp_end_char_black;
+ break;
+#endif
+
+#if INCL_SCREEN
+case MODE_SCREEN: /* Output mode 1 (Screen writer) */
+ sp_globals.init_out = sp_init_screen;
+ sp_globals.begin_char = sp_begin_char_screen;
+ sp_globals.begin_sub_char = sp_begin_sub_char_out;
+ sp_globals.begin_contour = sp_begin_contour_screen;
+ sp_globals.curve = sp_curve_screen;
+ sp_globals.line = sp_line_screen;
+ sp_globals.end_contour = sp_end_contour_screen;
+ sp_globals.end_sub_char = sp_end_sub_char_out;
+ sp_globals.end_char = sp_end_char_screen;
+ break;
+#endif
+
+#if INCL_OUTLINE
+case MODE_OUTLINE: /* Output mode 2 (Vector) */
+ sp_globals.init_out = sp_init_outline;
+ sp_globals.begin_char = sp_begin_char_outline;
+ sp_globals.begin_sub_char = sp_begin_sub_char_outline;
+ sp_globals.begin_contour = sp_begin_contour_outline;
+ sp_globals.curve = sp_curve_outline;
+ sp_globals.line = sp_line_outline;
+ sp_globals.end_contour = sp_end_contour_outline;
+ sp_globals.end_sub_char = sp_end_sub_char_outline;
+ sp_globals.end_char = sp_end_char_outline;
+ break;
+#endif
+
+#if INCL_2D
+case MODE_2D: /* Output mode 3 */
+ sp_globals.init_out = sp_init_2d;
+ sp_globals.begin_char = sp_begin_char_2d;
+ sp_globals.begin_sub_char = sp_begin_sub_char_out;
+ sp_globals.begin_contour = sp_begin_contour_2d;
+ sp_globals.curve = sp_curve_out;
+ sp_globals.line = sp_line_2d;
+ sp_globals.end_contour = sp_end_contour_out;
+ sp_globals.end_sub_char = sp_end_sub_char_out;
+ sp_globals.end_char = sp_end_char_2d;
+ break;
+#endif
+
+default:
+ report_error(8); /* Unsupported mode requested */
+ return FALSE;
+ }
+
+ if (!fn_init_out(sp_globals.pspecs))
+ {
+ report_error(5);
+ return FALSE;
+ }
+
+
+sp_globals.curves_out = sp_globals.pspecs->flags & CURVES_OUT;
+
+if (sp_globals.pspecs->flags & BOGUS_MODE) /* Linear transformation requested? */
+ {
+ sp_globals.tcb0.xtype = sp_globals.tcb0.ytype = 4;
+ }
+else /* Intelligent transformation requested? */
+ {
+#if INCL_RULES
+#else
+ report_error(7); /* Rules requested; not supported */
+ return FALSE;
+#endif
+ }
+
+if ((sp_globals.pspecs->flags & SQUEEZE_LEFT) ||
+ (sp_globals.pspecs->flags & SQUEEZE_RIGHT) ||
+ (sp_globals.pspecs->flags & SQUEEZE_TOP) ||
+ (sp_globals.pspecs->flags & SQUEEZE_BOTTOM) )
+ {
+#if (INCL_SQUEEZING)
+#else
+ report_error(11);
+ return FALSE;
+#endif
+ }
+
+if ((sp_globals.pspecs->flags & CLIP_LEFT) ||
+ (sp_globals.pspecs->flags & CLIP_RIGHT) ||
+ (sp_globals.pspecs->flags & CLIP_TOP) ||
+ (sp_globals.pspecs->flags & CLIP_BOTTOM) )
+ {
+#if (INCL_CLIPPING)
+#else
+ report_error(11);
+ return FALSE;
+#endif
+ }
+
+sp_globals.specs_valid = TRUE;
+return TRUE;
+}
+
+
+
+#if INCL_MULTIDEV
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+FUNCTION boolean set_bitmap_device(bfuncs,size)
+GDECL
+bitmap_t *bfuncs;
+ufix16 size;
+{
+
+if (size != sizeof(sp_globals.bitmap_device))
+ return FALSE;
+
+sp_globals.bitmap_device = *bfuncs;
+sp_globals.bitmap_device_set = TRUE;
+}
+#endif
+
+#if INCL_OUTLINE
+FUNCTION boolean set_outline_device(ofuncs,size)
+GDECL
+outline_t *ofuncs;
+ufix16 size;
+{
+
+if (size != sizeof(sp_globals.outline_device))
+ return FALSE;
+
+sp_globals.outline_device = *ofuncs;
+sp_globals.outline_device_set = TRUE;
+}
+#endif
+#endif
+
+
+#ifdef old
+FUNCTION boolean sp_setup_consts(xmin, xmax, ymin, ymax)
+#else
+static FUNCTION boolean sp_setup_consts(xmin, xmax, ymin, ymax)
+#endif
+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 */
+/*
+ * Sets the following constants used for fixed point arithmetic:
+ * sp_globals.multshift multipliers and products; range is 14 to 8
+ * sp_globals.pixshift pixels: range is 0 to 8
+ * sp_globals.mpshift shift from product to sub-pixels (sp_globals.multshift - sp_globals.pixshift)
+ * sp_globals.multrnd rounding for products
+ * sp_globals.pixrnd rounding for pixels
+ * sp_globals.mprnd rounding for sub-pixels
+ * sp_globals.onepix 1 pixel in shifted pixel units
+ * sp_globals.pixfix mask to eliminate fractional bits of shifted pixels
+ * sp_globals.depth_adj curve splitting depth adjustment
+ * Returns FALSE if specs are out of range
+ */
+{
+fix31 mult; /* Successive multiplier values */
+ufix32 num; /* Numerator of largest multiplier value */
+ufix32 numcopy; /* Copy of numerator */
+ufix32 denom; /* Denominator of largest multiplier value */
+ufix32 denomcopy; /* Copy of denominator */
+ufix32 pix_max; /* Maximum pixel rounding error */
+fix31 xmult; /* Coefficient of X oru value in transformation */
+fix31 ymult; /* Coefficient of Y oru value in transformation */
+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 */
+
+/* Determine numerator and denominator of largest multiplier value */
+mult = sp_globals.pspecs->xxmult >> 16;
+if (mult < 0)
+ mult = -mult;
+num = mult;
+
+mult = sp_globals.pspecs->xymult >> 16;
+if (mult < 0)
+ mult = -mult;
+if (mult > num)
+ num = mult;
+
+mult = sp_globals.pspecs->yxmult >> 16;
+if (mult < 0)
+ mult = -mult;
+if (mult > num)
+ num = mult;
+
+mult = sp_globals.pspecs->yymult >> 16;
+if (mult < 0)
+ mult = -mult;
+if (mult > num)
+ num = mult;
+num++; /* Max absolute pixels per em (rounded up) */
+denom = (ufix32)sp_globals.orus_per_em;
+
+/* Set curve splitting depth adjustment to accomodate largest multiplier value */
+sp_globals.depth_adj = 0; /* 0 = 0.5 pel, 1 = 0.13 pel, 2 = 0.04 pel accuracy */
+denomcopy = denom;
+/* The following two occurances of a strange method of shifting twice by 1
+ are intentional and should not be changed to a single shift by 2.
+ It prevents MicroSoft C 5.1 from generating functions calls to do the shift.
+ Worse, using the REENTRANT_ALLOC option in conjunction with the /AC compiler
+ option, the function appears to be called incorrectly, causing depth_adj to always
+ be set to -7, causing very angular characters. */
+
+while ((num > denomcopy) && (sp_globals.depth_adj < 5)) /* > 1, 4, 16, ... pixels per oru? */
+ {
+ denomcopy <<= 1;
+ denomcopy <<= 1;
+ sp_globals.depth_adj++; /* Add 1, 2, 3, ... to depth adjustment */
+ }
+numcopy = num << 2;
+while ((numcopy <= denom) && (sp_globals.depth_adj > -4)) /* <= 1/4, 1/16, 1/64 pix per oru? */
+ {
+ numcopy <<= 1;
+ numcopy <<= 1;
+ sp_globals.depth_adj--; /* Subtract 1, 2, 3, ... from depth adjustment */
+ }
+SHOW(sp_globals.depth_adj);
+
+/* Set multiplier shift to accomodate largest multiplier value */
+sp_globals.multshift = 14;
+numcopy = num;
+while (numcopy >= denom) /* More than 1, 2, 4, ... pix per oru? */
+ {
+ numcopy >>= 1;
+ sp_globals.multshift--; /* sp_globals.multshift is 13, 12, 11, ... */
+ }
+
+sp_globals.multrnd = ((fix31)1 << sp_globals.multshift) >> 1;
+SHOW(sp_globals.multshift);
+
+
+pix_max = (ufix32)( 0xffff & read_word_u(sp_globals.hdr2_org + FH_PIXMX));
+
+num = 0;
+xmult = ((sp_globals.pspecs->xxmult >> 16) + 1) >> 1;
+ymult = ((sp_globals.pspecs->xymult >> 16) + 1) >> 1;
+offset = ((sp_globals.pspecs->xoffset >> 16) + 1) >> 1;
+for (i = 0; i < 8; i++)
+ {
+ if (i == 4)
+ {
+ xmult = ((sp_globals.pspecs->yxmult >> 16) + 1) >> 1;
+ ymult = ((sp_globals.pspecs->yymult >> 16) + 1) >> 1;
+ offset = ((sp_globals.pspecs->yoffset >> 16) + 1) >> 1;
+ }
+ x = (i & BIT1)? xmin: xmax;
+ y = (i & BIT0)? ymin: ymax;
+ pixval = (fix31)x * xmult + (fix31)y * ymult + offset * denom;
+ if (pixval < 0)
+ pixval = -pixval;
+ if (pixval > num)
+ {
+ num = pixval;
+ xx = x;
+ yy = y;
+ }
+ }
+if (xx < 0)
+ xx = -xx;
+if (yy < 0)
+ yy = -yy;
+num += xx + yy + ((pix_max + 2) * denom);
+ /* Allow (with 2:1 safety margin) for 1 pixel rounding errors in */
+ /* xmult, ymult and offset values, pix_max pixel expansion */
+ /* due to intelligent scaling, and */
+ /* 1 pixel rounding of overall character position */
+denom = denom << 14; /* Note num is in units of half pixels times orus per em */
+
+sp_globals.pixshift = -1;
+while ((num <= denom) && (sp_globals.pixshift < 8)) /* Max pixels <= 32768, 16384, 8192, ... pixels? */
+ {
+ num <<= 1;
+ sp_globals.pixshift++; /* sp_globals.pixshift = 0, 1, 2, ... */
+ }
+if (sp_globals.pixshift < 0)
+ return FALSE;
+
+SHOW(sp_globals.pixshift);
+sp_globals.poshift = 16 - sp_globals.pixshift;
+
+sp_globals.onepix = (fix15)1 << sp_globals.pixshift;
+sp_globals.pixrnd = sp_globals.onepix >> 1;
+sp_globals.pixfix = ~0 << sp_globals.pixshift;
+
+sp_globals.mpshift = sp_globals.multshift - sp_globals.pixshift;
+if (sp_globals.mpshift < 0)
+ return FALSE;
+sp_globals.mprnd = ((fix31)1 << sp_globals.mpshift) >> 1;
+
+return TRUE;
+}
+
+#ifdef old
+FUNCTION void sp_setup_tcb(ptcb)
+#else
+static FUNCTION void sp_setup_tcb(ptcb)
+#endif
+GDECL
+tcb_t GLOBALFAR *ptcb; /* Pointer to transformation control bloxk */
+/*
+ * Convert transformation coeffs to internal form
+ */
+{
+
+ptcb->xxmult = sp_setup_mult(sp_globals.pspecs->xxmult);
+ptcb->xymult = sp_setup_mult(sp_globals.pspecs->xymult);
+ptcb->xoffset = sp_setup_offset(sp_globals.pspecs->xoffset);
+ptcb->yxmult = sp_setup_mult(sp_globals.pspecs->yxmult);
+ptcb->yymult = sp_setup_mult(sp_globals.pspecs->yymult);
+ptcb->yoffset = sp_setup_offset(sp_globals.pspecs->yoffset);
+
+SHOW(ptcb->xxmult);
+SHOW(ptcb->xymult);
+SHOW(ptcb->xoffset);
+SHOW(ptcb->yxmult);
+SHOW(ptcb->yymult);
+SHOW(ptcb->yoffset);
+
+type_tcb(ptcb); /* Classify transformation type */
+}
+
+FUNCTION static fix15 sp_setup_mult(input_mult)
+GDECL
+fix31 input_mult; /* Multiplier in input format */
+/*
+ * Called by sp_setup_tcb() to convert multiplier in transformation
+ * matrix from external to internal form.
+ */
+{
+fix15 imshift; /* Right shift to internal format */
+fix31 imdenom; /* Divisor to internal format */
+fix31 imrnd; /* Rounding for division operation */
+
+imshift = 15 - sp_globals.multshift;
+imdenom = (fix31)sp_globals.orus_per_em << imshift;
+imrnd = imdenom >> 1;
+
+input_mult >>= 1;
+if (input_mult >= 0)
+ return (fix15)((input_mult + imrnd) / imdenom);
+else
+ return -(fix15)((-input_mult + imrnd) / imdenom);
+}
+
+FUNCTION static fix31 sp_setup_offset(input_offset)
+GDECL
+fix31 input_offset; /* Multiplier in input format */
+/*
+ * Called by sp_setup_tcb() to convert offset in transformation
+ * matrix from external to internal form.
+ */
+{
+fix15 imshift; /* Right shift to internal format */
+fix31 imrnd; /* Rounding for right shift operation */
+
+imshift = 15 - sp_globals.multshift;
+imrnd = ((fix31)1 << imshift) >> 1;
+
+return (((input_offset >> 1) + imrnd) >> imshift) + sp_globals.mprnd;
+}
+
+FUNCTION void type_tcb(ptcb)
+GDECL
+tcb_t GLOBALFAR *ptcb; /* Pointer to transformation control bloxk */
+{
+fix15 x_trans_type;
+fix15 y_trans_type;
+fix15 xx_mult;
+fix15 xy_mult;
+fix15 yx_mult;
+fix15 yy_mult;
+fix15 h_pos;
+fix15 v_pos;
+fix15 x_ppo;
+fix15 y_ppo;
+fix15 x_pos;
+fix15 y_pos;
+
+/* check for mirror image transformations */
+xx_mult = ptcb->xxmult;
+xy_mult = ptcb->xymult;
+yx_mult = ptcb->yxmult;
+yy_mult = ptcb->yymult;
+
+ptcb->mirror = ((((fix31)xx_mult*(fix31)yy_mult)-
+ ((fix31)xy_mult*(fix31)yx_mult)) < 0) ? -1 : 1;
+
+if (sp_globals.pspecs->flags & BOGUS_MODE) /* Linear transformation requested? */
+ {
+ ptcb->xtype = 4;
+ ptcb->ytype = 4;
+
+ ptcb->xppo = 0;
+ ptcb->yppo = 0;
+ ptcb->xpos = 0;
+ ptcb->ypos = 0;
+ }
+else /* Intelligent tranformation requested? */
+ {
+ h_pos = ((ptcb->xoffset >> sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+ v_pos = ((ptcb->yoffset >> sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+
+ x_trans_type = 4;
+ x_ppo = 0;
+ x_pos = 0;
+
+ y_trans_type = 4;
+ y_ppo = 0;
+ y_pos = 0;
+
+ if (xy_mult == 0)
+ {
+ if (xx_mult >= 0)
+ {
+ x_trans_type = 0; /* X pix is function of X orus only */
+ x_ppo = xx_mult;
+ x_pos = h_pos;
+ }
+ else
+ {
+ x_trans_type = 1; /* X pix is function of -X orus only */
+ x_ppo = -xx_mult;
+ x_pos = -h_pos;
+ }
+ }
+
+ else if (xx_mult == 0)
+ {
+ if (xy_mult >= 0)
+ {
+ x_trans_type = 2; /* X pix is function of Y orus only */
+ y_ppo = xy_mult;
+ y_pos = h_pos;
+ }
+ else
+ {
+ x_trans_type = 3; /* X pix is function of -Y orus only */
+ y_ppo = -xy_mult;
+ y_pos = -h_pos;
+ }
+ }
+
+ if (yx_mult == 0)
+ {
+ if (yy_mult >= 0)
+ {
+ y_trans_type = 0; /* Y pix is function of Y orus only */
+ y_ppo = yy_mult;
+ y_pos = v_pos;
+ }
+ else
+ {
+ y_trans_type = 1; /* Y pix is function of -Y orus only */
+ y_ppo = -yy_mult;
+ y_pos = -v_pos;
+ }
+ }
+ else if (yy_mult == 0)
+ {
+ if (yx_mult >= 0)
+ {
+ y_trans_type = 2; /* Y pix is function of X orus only */
+ x_ppo = yx_mult;
+ x_pos = v_pos;
+ }
+ else
+ {
+ y_trans_type = 3; /* Y pix is function of -X orus only */
+ x_ppo = -yx_mult;
+ x_pos = -v_pos;
+ }
+ }
+
+ ptcb->xtype = x_trans_type;
+ ptcb->ytype = y_trans_type;
+
+ ptcb->xppo = x_ppo;
+ ptcb->yppo = y_ppo;
+ ptcb->xpos = x_pos;
+ ptcb->ypos = y_pos;
+ }
+
+sp_globals.normal = (ptcb->xtype != 4) && (ptcb->ytype != 4);
+
+ptcb->xmode = 4;
+ptcb->ymode = 4;
+
+SHOW(ptcb->xtype);
+SHOW(ptcb->ytype);
+SHOW(ptcb->xppo);
+SHOW(ptcb->yppo);
+SHOW(ptcb->xpos);
+SHOW(ptcb->ypos);
+}
+
+FUNCTION fix31 read_long(pointer)
+GDECL
+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.
+ * Returns the decrypted value read as a signed integer.
+ */
+{
+fix31 tmpfix31;
+
+tmpfix31 = (fix31)((*pointer++) ^ sp_globals.key4) << 8; /* Read middle byte */
+tmpfix31 += (fix31)(*pointer++) << 16; /* Read most significant byte */
+tmpfix31 += (fix31)((*pointer) ^ sp_globals.key6); /* Read least significant byte */
+return tmpfix31;
+}
+
+FUNCTION fix15 read_word_u(pointer)
+GDECL
+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.
+ * Returns the decrypted value read as a signed integer.
+ */
+{
+fix15 tmpfix15;
+
+tmpfix15 = (fix15)(*pointer++) << 8; /* Read most significant byte */
+tmpfix15 += (fix15)(*pointer); /* Add least significant byte */
+return tmpfix15;
+}
+
+
diff --git a/src/Speedo/set_trns.c b/src/Speedo/set_trns.c
new file mode 100644
index 0000000..8ef34ac
--- /dev/null
+++ b/src/Speedo/set_trns.c
@@ -0,0 +1,1329 @@
+/* $Xorg: set_trns.c,v 1.3 2000/08/17 19:46:27 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+
+
+/*************************** S E T _ T R N S . C *****************************
+ * *
+ * This module is called from do_char.c to set up the intelligent *
+ * transformation for one character (or sub-character of a composite *
+ * character.
+ * *
+ ****************************************************************************/
+
+
+#include "spdo_prv.h" /* General definitions for Speedo */
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#define SHOW(X) printf("X = %d\n", X)
+#else
+#define SHOW(X)
+#endif
+/***** LOCAL MACROS *****/
+
+#define SQUEEZE_X_ORU(A,B,C) ((((fix31)A * (fix31)B) + C) >> 16)
+#define ABS(A) ((A < 0)? -A:A) /* absolute value */
+#define IMPORT_FACTOR \
+ shift = 16;\
+ while (*x_factor > (0x7fffffffL / (isw_scale >> (16 - shift))))\
+ shift--;\
+ *x_factor = (*x_factor * (isw_scale>>(16-shift))) >> shift;
+
+/***** GLOBAL VARIABLES *****/
+
+/***** GLOBAL FUNCTIONS *****/
+
+/***** EXTERNAL VARIABLES *****/
+
+/***** EXTERNAL FUNCTIONS *****/
+
+/***** STATIC VARIABLES *****/
+
+/***** 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()
+GDECL
+/*
+ * Called by sp_make_char() and make_comp_char() to initialize the current
+ * transformation control block to the top level transformation.
+ */
+{
+sp_globals.tcb = sp_globals.tcb0;
+}
+
+FUNCTION void scale_tcb(ptcb, x_pos, y_pos, x_scale, y_scale)
+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 */
+/*
+ * Called by make_comp_char() to apply position and scale for each of the
+ * components of a compound character.
+ */
+{
+fix15 xx_mult = ptcb->xxmult;
+fix15 xy_mult = ptcb->xymult;
+fix31 x_offset = ptcb->xoffset;
+fix15 yx_mult = ptcb->yxmult;
+fix15 yy_mult = ptcb->yymult;
+fix31 y_offset = ptcb->yoffset;
+
+ptcb->xxmult = TRANS(xx_mult, x_scale, (fix31)SCALE_RND, SCALE_SHIFT);
+ptcb->xymult = TRANS(xy_mult, y_scale, (fix31)SCALE_RND, SCALE_SHIFT);
+ptcb->xoffset = MULT16(xx_mult, x_pos) + MULT16(xy_mult, y_pos) + x_offset;
+ptcb->yxmult = TRANS(yx_mult, x_scale, (fix31)SCALE_RND, SCALE_SHIFT);
+ptcb->yymult = TRANS(yy_mult, y_scale, (fix31)SCALE_RND, SCALE_SHIFT);
+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)
+GDECL
+ufix8 FONTFAR *pointer; /* Pointer to next byte in char data */
+ufix8 format; /* Character format byte */
+{
+fix15 i,n;
+ufix8 intsize[9];
+
+intsize[0] = 1;
+intsize[1] = 2;
+intsize[2] = 3;
+intsize[3] = 1;
+intsize[4] = 2;
+intsize[5] = 1;
+intsize[6] = 2;
+intsize[7] = 0;
+intsize[8] = 0;
+
+n = ((format & BIT6)? (fix15)NEXT_BYTE(pointer): 0) +
+ ((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 */
+ if (format & BIT7) /* Short Start/End point spec? */
+ {
+ pointer++; /* Skip Start/End point byte */
+ }
+ else
+ {
+ pointer += intsize[format & 0x7]; /* Skip Start point spec */
+ pointer += intsize[(format >> 3) & 0x7]; /* Skip End point spec */
+ }
+ }
+return pointer;
+}
+FUNCTION ufix8 FONTFAR *skip_control_zone(pointer,format)
+GDECL
+ufix8 FONTFAR *pointer; /* Pointer to next byte in char data */
+ufix8 format; /* Character format byte */
+{
+fix15 i,n;
+ufix16 tmpufix16;
+fix15 constr;
+
+n = sp_globals.no_X_orus + sp_globals.no_Y_orus - 2;
+for (i = 0; i < n; i++) /* For each entry in control table ... */
+ {
+ if (format & BIT4)
+ pointer++; /* Skip short form From/To fields */
+ else
+ pointer += 2; /* Skip FROM and TO fields */
+ /* skip constraints field */
+ constr = NEXT_BYTES (pointer, tmpufix16);
+
+ }
+return pointer;
+}
+
+#if INCL_RULES
+#else
+FUNCTION ufix8 FONTFAR *plaid_tcb(pointer, format)
+GDECL
+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
+ * in the character data.
+ * Updates pointer to first byte after plaid data.
+ * This is used only if intelligent scaling is not supported in the
+ * configuration definitions.
+ */
+{
+fix15 i, n;
+
+
+
+sp_globals.no_X_orus = (format & BIT2)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+sp_globals.no_Y_orus = (format & BIT3)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+pointer = read_oru_table(pointer); /* Updates no_X/Y/orus */
+sp_globals.Y_edge_org = sp_globals.no_X_orus;
+
+/* Skip over control zone table */
+pointer = skip_control_zone(pointer,format);
+
+/* Skip over interpolation table */
+pointer = skip_interpolation_table(pointer,format);
+return pointer;
+}
+#endif
+
+#if INCL_RULES
+FUNCTION ufix8 FONTFAR *plaid_tcb(pointer, format)
+GDECL
+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
+ * in the character data.
+ * Updates pointer to first byte after plaid data.
+ * This is used only if intelligent scaling is enabled in the
+ * configuration definitions.
+ */
+{
+fix15 no_X_ctrl_zones;
+fix15 no_Y_ctrl_zones;
+fix15 no_X_int_zones;
+fix15 no_Y_int_zones;
+
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+begin_plaid_data();
+#endif
+
+sp_constr_update(); /* Update constraint table if required */
+
+sp_globals.no_X_orus = (format & BIT2)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+sp_globals.no_Y_orus = (format & BIT3)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+pointer = read_oru_table(pointer); /* Updates no_X/Y/orus to include zero values */
+sp_globals.Y_edge_org = sp_globals.no_X_orus;
+if (sp_globals.no_X_orus > 1) /* 2 or more controlled X coordinates? */
+ sp_globals.tcb.xmode = sp_globals.tcb.xtype; /* Enable intelligent scaling in X */
+
+if (sp_globals.no_Y_orus > 1) /* 2 or more controlled Y coordinates? */
+ sp_globals.tcb.ymode = sp_globals.tcb.ytype; /* Enable intelligent scaling in Y */
+
+no_X_ctrl_zones = sp_globals.no_X_orus - 1;
+no_Y_ctrl_zones = sp_globals.no_Y_orus - 1;
+pointer = sp_setup_pix_table(pointer, (boolean)(format & BIT4),
+ no_X_ctrl_zones, no_Y_ctrl_zones);
+
+no_X_int_zones = (format & BIT6)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+no_Y_int_zones = (format & BIT7)?
+ (fix15)NEXT_BYTE(pointer):
+ 0;
+sp_globals.Y_int_org = no_X_int_zones;
+pointer = sp_setup_int_table(pointer, no_X_int_zones, no_Y_int_zones);
+
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+end_plaid_data();
+#endif
+
+return pointer;
+}
+#endif
+
+#if INCL_RULES
+FUNCTION static void sp_constr_update()
+GDECL
+/*
+ * Called by plaid_tcb() to update the constraint table for the current
+ * transformation.
+ * This is always carried out whenever a character is generated following
+ * a change of font or scale factor or after initialization.
+ */
+{
+fix31 ppo;
+fix15 xppo;
+fix15 yppo;
+ufix8 FONTFAR *pointer;
+fix15 no_X_constr;
+fix15 no_Y_constr;
+fix15 i, j, k, l, n;
+fix15 ppm;
+ufix8 format;
+ufix8 format1;
+fix15 limit;
+ufix16 constr_org;
+fix15 constr_nr;
+fix15 size;
+fix31 off;
+fix15 min;
+fix15 orus;
+fix15 pix;
+ufix16 tmpufix16; /* in extended mode, macro uses secnd term */
+
+if (sp_globals.constr.data_valid && /* Constr table already done and ... */
+ (sp_globals.tcb.xppo == sp_globals.constr.xppo) && /* ... X pix per oru unchanged and ... */
+ (sp_globals.tcb.yppo == sp_globals.constr.yppo)) /* ... Y pix per oru unchanged? */
+ {
+ return; /* No need to update constraint table */
+ }
+
+sp_globals.constr.xppo = xppo = sp_globals.tcb.xppo; /* Update X pixels per oru indicator */
+sp_globals.constr.yppo = yppo = sp_globals.tcb.yppo; /* Update Y pixels per oru indicator */
+sp_globals.constr.data_valid = TRUE; /* Mark constraint table valid */
+
+pointer = sp_globals.constr.org; /* Point to first byte of constraint data */
+no_X_constr = NEXT_BYTES(pointer, tmpufix16); /* Read nmbr of X constraints */
+no_Y_constr = NEXT_BYTES(pointer, tmpufix16); /* Read nmbr of Y constraints */
+
+i = 0;
+constr_org = 0;
+n = no_X_constr;
+ppo = xppo;
+for (j = 0; ; j++)
+ {
+ sp_globals.c_act[i] = FALSE; /* Flag constraint 0 not active */
+ sp_globals.c_pix[i++] = 0; /* Constraint 0 implies no minimum */
+ sp_globals.c_act[i] = FALSE; /* Flag constraint 1 not active */
+ sp_globals.c_pix[i++] = sp_globals.onepix; /* Constraint 1 implies min 1 pixel*/
+ ppm = (ppo * (fix31)sp_globals.orus_per_em) >> sp_globals.multshift;
+ for (k = 0; k < n; k++)
+ {
+ format = NEXT_BYTE(pointer); /* Read format byte */
+ limit = (fix15)NEXT_BYTE(pointer); /* Read limit field */
+ sp_globals.c_act[i] =
+ ((ppm < limit) || (limit == 255)) &&
+ sp_globals.constr.active;
+ if (sp_globals.c_act[i]) /* Constraint active? */
+ {
+ if ((format & BIT1) && /* Constraint specified and ... */
+ (constr_nr = constr_org +
+ ((format & BIT0)? /* Read unsigned constraint value */
+ NEXT_WORD(pointer):
+ (fix15)NEXT_BYTE(pointer)),
+ sp_globals.c_act[constr_nr])) /* ... and specified constraint active? */
+ {
+ pix = sp_globals.c_pix[constr_nr]; /* Use constrained pixel value */
+ format1 = format;
+ for (l = 2; l > 0; l--) /* Skip 2 arguments */
+ {
+ format1 >>= 2;
+ if ((size = format1 & 0x03))
+ pointer += size - 1;
+ }
+ }
+ else /* Constraint absent or inactive? */
+ {
+ orus = (format & BIT2)? /* Read unsigned oru value */
+ NEXT_WORD(pointer):
+ (fix15)NEXT_BYTE(pointer);
+
+ if (format & BIT5) /* Specified offset value? */
+ {
+ off = (fix31)((format & BIT4)? /* Read offset value */
+ NEXT_WORD(pointer):
+ (fix7)NEXT_BYTE(pointer));
+ off = (off << (sp_globals.multshift - 6)) + sp_globals.multrnd;
+ }
+ else /* Unspecified (zero) offset value? */
+ {
+ off = sp_globals.multrnd;
+ }
+
+ pix = (fix15)(((fix31)orus * ppo + off) / (1 << sp_globals.mpshift)) & sp_globals.pixfix;
+ }
+ }
+ else /* Constraint inactive? */
+ {
+ format1 = format;
+ for (l = 3; l > 0; l--) /* Skip over 3 arguments */
+ {
+ if ((size = format1 & 0x03))
+ pointer += size - 1;
+ format1 >>= 2;
+ }
+ pix = 0;
+ }
+
+ if (format & 0xc0) /* Specified minimum value? */
+ {
+ min = (format & BIT7)? /* Read unsigned minimum value */
+ (fix15)NEXT_BYTE(pointer) << sp_globals.pixshift:
+ sp_globals.onepix;
+ }
+ else /* Unspecified (zero) minimum value? */
+ {
+ min = 0;
+ }
+
+ sp_globals.c_pix[i] = (pix < min)? min: pix;
+ i++;
+ }
+ if (j) break; /* Finished if second time around loop */
+ constr_org = sp_globals.Y_constr_org = i;
+ n = no_Y_constr;
+ ppo = yppo;
+ }
+
+#if DEBUG
+printf("\nCONSTRAINT TABLE\n");
+n = no_X_constr + 2;
+for (i = 0; i < n; i++)
+ {
+ printf("%3d ", i);
+ if (sp_globals.c_act[i])
+ {
+ printf("T ");
+ }
+ else
+ {
+ printf("F ");
+ }
+ printf("%5.1f\n", ((real)sp_globals.c_pix[i] / (real)sp_globals.onepix));
+ }
+printf("--------------\n");
+n = no_Y_constr + 2;
+for (i = 0; i < n; i++)
+ {
+ j = i + sp_globals.Y_constr_org;
+ printf("%3d ", i);
+ if (sp_globals.c_act[j])
+ {
+ printf("T ");
+ }
+ else
+ {
+ printf("F ");
+ }
+ printf("%5.1f\n", ((real)sp_globals.c_pix[j] / (real)sp_globals.onepix));
+ }
+#endif
+
+}
+#endif
+
+FUNCTION ufix8 FONTFAR *read_oru_table(pointer)
+GDECL
+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.
+ * Updates the pointer to the byte following the controlled coordinate
+ * data.
+ */
+{
+fix15 i, j, k, n;
+boolean zero_not_in;
+boolean zero_added;
+fix15 oru;
+
+#if INCL_RULES
+fix15 pos;
+#endif
+
+i = 0;
+n = sp_globals.no_X_orus;
+#if INCL_RULES
+pos = sp_globals.tcb.xpos;
+#endif
+for (j = 0; ; j++)
+ {
+ zero_not_in = TRUE;
+ zero_added = FALSE;
+ for (k = 0; k < n; k++)
+ {
+ oru = NEXT_WORD(pointer);
+ if (zero_not_in && (oru >= 0)) /* First positive oru value? */
+ {
+#if INCL_RULES
+ sp_plaid.pix[i] = pos; /* Insert position in pix array */
+#endif
+ if (oru != 0) /* Zero oru value omitted? */
+ {
+ sp_plaid.orus[i++] = 0; /* Insert zero value in oru array */
+ zero_added = TRUE; /* Remember to increment size of array */
+ }
+ zero_not_in = FALSE; /* Inhibit further testing for zero ins */
+ }
+ sp_plaid.orus[i++] = oru; /* Add specified oru value to array */
+ }
+ if (zero_not_in) /* All specified oru values negative? */
+ {
+#if INCL_RULES
+ sp_plaid.pix[i] = pos; /* Insert position in pix array */
+#endif
+ sp_plaid.orus[i++] = 0; /* Add zero oru value */
+ zero_added = TRUE; /* Remember to increment size of array */
+ }
+ if (j) /* Both X and Y orus read? */
+ break;
+ if (zero_added)
+ sp_globals.no_X_orus++; /* Increment X array size */
+ n = sp_globals.no_Y_orus; /* Prepare to read Y oru values */
+#if INCL_RULES
+ pos = sp_globals.tcb.ypos;
+#endif
+ }
+if (zero_added) /* Zero Y oru value added to array? */
+ sp_globals.no_Y_orus++; /* Increment Y array size */
+
+#if DEBUG
+printf("\nX ORUS\n");
+n = sp_globals.no_X_orus;
+for (i = 0; i < n; i++)
+ {
+ printf("%2d %4d\n", i, sp_plaid.orus[i]);
+ }
+printf("\nY ORUS\n");
+n = sp_globals.no_Y_orus;
+for (i = 0; i < n; i++)
+ {
+ printf("%2d %4d\n", i, sp_plaid.orus[i + sp_globals.no_X_orus]);
+ }
+#endif
+
+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)
+GDECL
+ufix8 start_edge, 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
+ */
+{
+fix15 zone_pix;
+fix15 start_oru, end_oru;
+
+/* compute scaled oru coordinates */
+start_oru= (fix15)(SQUEEZE_X_ORU(sp_plaid.orus[start_edge], x_scale, x_offset));
+end_oru = (fix15)(SQUEEZE_X_ORU(sp_plaid.orus[end_edge], x_scale, x_offset));
+
+if (!sp_globals.c_act[constr_nr]) /* constraint inactive */
+ {
+ /* calculate zone width */
+ zone_pix = (fix15)(((((fix31)end_oru - (fix31)start_oru) * ppo) /
+ (1<<sp_globals.mpshift)) + sp_globals.pixrnd) & sp_globals.pixfix;
+ /* check for overflow */
+ if (((end_oru-start_oru) > 0) && (zone_pix < 0))
+ zone_pix = 0x7ffff;
+ /* check for minimum */
+ if ((ABS(zone_pix)) >= sp_globals.c_pix[constr_nr])
+ goto Lx;
+ }
+/* use the zone size from the constr table - scale it */
+zone_pix = (fix15)(((SQUEEZE_MULT(x_scale,sp_globals.c_pix[constr_nr]))
+ + sp_globals.pixrnd) & sp_globals.pixfix);
+
+/* look for overflow */
+if ((sp_globals.c_pix[constr_nr] > 0) && (zone_pix < 0))
+ zone_pix = 0x7fff;
+
+if (start_edge > end_edge)
+ {
+ zone_pix = -zone_pix;
+ }
+Lx:
+/* assign pixel value to global pix array */
+sp_plaid.pix[end_edge]=sp_plaid.pix[start_edge] + zone_pix;
+
+/* check for overflow */
+if (((sp_plaid.pix[start_edge] >0) && (zone_pix >0)) &&
+ (sp_plaid.pix[end_edge] < 0))
+ sp_plaid.pix[end_edge] = 0x7fff; /* set it to the max */
+
+/* be sure to be in the setwidth !*/
+#if INCL_ISW
+if (!sp_globals.import_setwidth_act) /* only check left edge if not isw only */
+#endif
+if ((sp_globals.pspecs->flags & SQUEEZE_LEFT) && (sp_plaid.pix[end_edge] < 0))
+ sp_plaid.pix[end_edge] = 0;
+if ((sp_globals.pspecs->flags & SQUEEZE_RIGHT) &&
+ (sp_plaid.pix[end_edge] > setwidth_pix))
+ sp_plaid.pix[end_edge] = setwidth_pix;
+
+}
+#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)
+GDECL
+ufix8 start_edge, end_edge;
+ufix16 constr_nr;
+fix31 top_scale, bottom_scale;
+fix31 ppo;
+fix15 em_top_pix, em_bot_pix;
+
+/*
+ * Called by sp_setup_pix_table() when Y squeezing is necessary
+ * to insert the correct edge in the global pix array
+ */
+{
+fix15 zone_pix;
+fix15 start_oru, end_oru;
+fix31 zone_width, above_base, below_base;
+
+/* check whether edge is above or below the baseline */
+/* and apply appropriate scale factor to get scaled oru coordinates */
+if (sp_plaid.orus[start_edge] < 0)
+ start_oru =(fix15)(SQUEEZE_MULT(sp_plaid.orus[start_edge], bottom_scale));
+else
+ start_oru =(fix15)(SQUEEZE_MULT(sp_plaid.orus[start_edge], top_scale));
+
+if (sp_plaid.orus[end_edge] < 0)
+ end_oru =(fix15)(SQUEEZE_MULT(sp_plaid.orus[end_edge], bottom_scale));
+else
+ end_oru =(fix15)(SQUEEZE_MULT(sp_plaid.orus[end_edge], top_scale));
+
+if (!sp_globals.c_act[constr_nr]) /* Constraint inactive? */
+ {
+ /* calculate zone width */
+ zone_pix = (fix15)(((((fix31)end_oru - (fix31)start_oru) * ppo)
+ >> sp_globals.mpshift)+ sp_globals.pixrnd) & sp_globals.pixfix;
+ /* check minimum */
+ if ((ABS(zone_pix)) >= sp_globals.c_pix[constr_nr])
+ goto Ly;
+ }
+
+/* Use zone size from constr table */
+if ((end_oru >= 0) && (start_oru >=0))
+ /* all above baseline */
+ zone_pix = (fix15)(SQUEEZE_MULT(top_scale, sp_globals.c_pix[constr_nr]));
+else if ((end_oru <= 0) && (start_oru <=0))
+ /* all below baseline */
+ zone_pix = (fix15)(SQUEEZE_MULT(bottom_scale, sp_globals.c_pix[constr_nr]));
+else
+ {
+ /* mixture */
+ if (start_oru > 0)
+ {
+ zone_width = start_oru - end_oru;
+ /* get % above baseline in 16.16 fixed point */
+ above_base = (((fix31)start_oru) << 16) /
+ ((fix31)zone_width) ;
+ /* get % below baseline in 16.16 fixed point */
+ below_base = (((fix31)-end_oru) << 16) /
+ ((fix31)zone_width) ;
+ }
+ else
+ {
+ zone_width = end_oru - start_oru;
+ /* get % above baseline in 16.16 fixed point */
+ above_base = (((fix31)-start_oru) << 16) /
+ ((fix31)zone_width) ;
+ /* get % below baseline in 16.16 fixed point */
+ below_base = (((fix31)end_oru) << 16) /
+ ((fix31)zone_width) ;
+ }
+ /* % above baseline * total zone * top_scale + */
+ /* % below baseline * total zone * bottom_scale */
+ zone_pix = ((((above_base * (fix31)sp_globals.c_pix[constr_nr]) >> 16) *
+ top_scale) +
+ (((below_base * (fix31)sp_globals.c_pix[constr_nr]) >> 16) *
+ bottom_scale)) >> 16;
+ }
+
+/* make this zone pix fall on a pixel boundary */
+zone_pix = (zone_pix + sp_globals.pixrnd) & sp_globals.pixfix;
+
+/* if minimum is in effect make the zone one pixel */
+if ((sp_globals.c_pix[constr_nr] != 0) && (zone_pix < sp_globals.onepix))
+ zone_pix = sp_globals.onepix;
+
+if (start_edge > end_edge)
+ {
+ zone_pix = -zone_pix; /* Use negatve zone size */
+ }
+Ly:
+/* assign global pix value */
+sp_plaid.pix[end_edge] = sp_plaid.pix[start_edge] + zone_pix; /* Insert end pixels */
+
+/* make sure it is in the EM !*/
+if ((sp_globals.pspecs->flags & SQUEEZE_TOP) &&
+ (sp_plaid.pix[end_edge] > em_top_pix))
+ sp_plaid.pix[end_edge] = em_top_pix;
+if ((sp_globals.pspecs->flags & SQUEEZE_BOTTOM) &&
+ (sp_plaid.pix[end_edge] < em_bot_pix))
+ sp_plaid.pix[end_edge] = em_bot_pix;
+}
+
+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 */
+/*
+ * Called by sp_setup_pix_table() when squeezing is included
+ * to determine whether X scaling is necessary. If it is, the
+ * scale factor and offset are computed. This function returns
+ * a boolean value TRUE = X squeezind is necessary, FALSE = no
+ * X squeezing is necessary.
+ */
+{
+boolean squeeze_left, squeeze_right;
+boolean out_on_right, out_on_left;
+fix15 bbox_width,set_width;
+fix15 bbox_xmin, bbox_xmax;
+fix15 x_offset_pix;
+fix15 i;
+#if INCL_ISW
+fix31 isw_scale;
+fix15 shift;
+#endif
+
+
+/* set up some flags and common calculations */
+squeeze_left = (sp_globals.pspecs->flags & SQUEEZE_LEFT)? TRUE:FALSE;
+squeeze_right = (sp_globals.pspecs->flags & SQUEEZE_RIGHT)? TRUE:FALSE;
+bbox_xmin = sp_globals.bbox_xmin_orus;
+bbox_xmax = sp_globals.bbox_xmax_orus;
+set_width = sp_globals.setwidth_orus;
+
+if (bbox_xmax > set_width)
+ out_on_right = TRUE;
+else
+ out_on_right = FALSE;
+if (bbox_xmin < 0)
+ out_on_left = TRUE;
+else
+ out_on_left = FALSE;
+bbox_width =bbox_xmax - bbox_xmin;
+
+/*
+ * don't need X squeezing if:
+ * - X squeezing not enabled
+ * - bbox doesn't violate on left or right
+ * - left squeezing only is enabled and char isn't out on left
+ * - right squeezing only is enabled and char isn't out on right
+ */
+
+if ((!squeeze_left && !squeeze_right) ||
+ (!out_on_right && !out_on_left) ||
+ (squeeze_left && !squeeze_right && !out_on_left) ||
+ (squeeze_right && !squeeze_left && !out_on_right))
+ return FALSE;
+
+#if INCL_ISW
+if (sp_globals.import_setwidth_act)
+ {
+ /* if both isw and squeezing is going on - let the imported */
+ /* setwidth factor be factored in with the squeeze */
+ isw_scale = compute_isw_scale();
+ /*sp_globals.setwidth_orus = sp_globals.imported_width;*/
+ }
+else
+ isw_scale = 0x10000L; /* 1 in 16.16 notation */
+#endif
+
+/* squeezing on left and right ? */
+if (squeeze_left && squeeze_right)
+ {
+ /* calculate scale factor */
+ if (bbox_width < set_width)
+ *x_factor = 0x10000L; /* 1 in 16.16 notation */
+ else
+ *x_factor = ((fix31)set_width<<16)/(fix31)bbox_width;
+#if INCL_ISW
+ IMPORT_FACTOR
+#endif
+ /* calculate offset */
+ if (out_on_left) /* fall out on left ? */
+ *x_offset = -(fix31)*x_factor * (fix31)bbox_xmin;
+ /* fall out on right and I am shifting only ? */
+ else if (out_on_right && (*x_factor == 0x10000L))
+ *x_offset = -(fix31)*x_factor * (fix31)(bbox_xmax - set_width);
+ else
+ *x_offset = 0x0L; /* 0 in 16.16 notation */
+ }
+/* squeezing on left only and violates left */
+else if (squeeze_left)
+ {
+ if (bbox_width < set_width) /* will it fit if I shift it ? */
+ *x_factor = 0x10000L; /* 1 in 16.16 notation */
+ else if (out_on_right)
+ *x_factor = ((fix31)set_width<<16)/(fix31)bbox_width;
+ else
+ *x_factor = ((fix31)set_width<<16)/
+ (fix31)(bbox_width - (bbox_xmax-set_width));
+#if INCL_ISW
+ IMPORT_FACTOR
+#endif
+ *x_offset = (fix31)-*x_factor * (fix31)bbox_xmin;
+ }
+
+/* I must be squeezing on right, and violates right */
+else
+ {
+ if (bbox_width < set_width) /* will it fit if I shift it ? */
+ { /* just shift it left - it will fit in the bbox */
+ *x_factor = 0x10000L; /* 1 in 16.16 notation */
+#if INCL_ISW
+ IMPORT_FACTOR
+#endif
+ *x_offset = (fix31)-*x_factor * (fix31)bbox_xmin;
+ }
+ else if (out_on_left)
+ {
+ *x_factor = ((fix31)set_width<<16)/(fix31)bbox_width;
+#if INCL_ISW
+ IMPORT_FACTOR
+#endif
+ *x_offset = 0x0L; /* 0 in 16.16 notation */
+ }
+ else
+ {
+ *x_factor = ((fix31)set_width<<16)/(fix31)bbox_xmax;
+#if INCL_ISW
+ IMPORT_FACTOR
+#endif
+ *x_offset = 0x0L; /* 0 in 16.16 notation */
+ }
+ }
+
+x_offset_pix = (fix15)(((*x_offset >> 16) * sp_globals.tcb0.xppo)
+ / (1<<sp_globals.mpshift));
+
+if ((x_offset_pix >0) && (x_offset_pix < sp_globals.onepix))
+ x_offset_pix = sp_globals.onepix;
+
+/* look for the first non-negative oru value, scale and add the offset */
+/* to the corresponding pixel value - note that the pixel value */
+/* is set in read_oru_table. */
+
+/* look at all the X edges */
+for (i=0; i < (no_X_ctrl_zones+1); i++)
+ if (sp_plaid.orus[i] >= 0)
+ {
+ sp_plaid.pix[i] = (SQUEEZE_MULT(sp_plaid.pix[i], *x_factor)
+ +sp_globals.pixrnd + x_offset_pix) & sp_globals.pixfix;
+ break;
+ }
+
+return TRUE;
+}
+
+FUNCTION boolean calculate_y_scale(top_scale, bottom_scale,
+ first_Y_zone, no_Y_ctrl_zones)
+GDECL
+fix31 *top_scale, *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,
+ * two scale factors are computed, one for above the baseline,
+ * and one for below the basline.
+ * This function returns a boolean value TRUE = Y squeezind is necessary,
+ * FALSE = no Y squeezing is necessary.
+ */
+{
+boolean squeeze_top, squeeze_bottom;
+boolean out_on_top, out_on_bottom;
+fix15 bbox_top, bbox_bottom;
+fix15 bbox_height;
+fix15 i;
+
+/* set up some flags and common calculations */
+squeeze_top = (sp_globals.pspecs->flags & SQUEEZE_TOP)? TRUE:FALSE;
+squeeze_bottom = (sp_globals.pspecs->flags & SQUEEZE_BOTTOM)? TRUE:FALSE;
+bbox_top = sp_globals.bbox_ymax_orus;
+bbox_bottom = sp_globals.bbox_ymin_orus;
+bbox_height = bbox_top - bbox_bottom;
+
+if (bbox_top > EM_TOP)
+ out_on_top = TRUE;
+else
+ out_on_top = FALSE;
+
+if (bbox_bottom < EM_BOT)
+ out_on_bottom = TRUE;
+else
+ out_on_bottom = FALSE;
+
+/*
+ * don't need Y squeezing if:
+ * - Y squeezing not enabled
+ * - bbox doesn't violate on top or bottom
+ * - top squeezing only is enabled and char isn't out on top
+ * - bottom squeezing only is enabled and char isn't out on bottom
+ */
+if ((!squeeze_top && !squeeze_bottom) ||
+ (!out_on_top && !out_on_bottom) ||
+ (squeeze_top && !squeeze_bottom && !out_on_top) ||
+ (squeeze_bottom && !squeeze_top && !out_on_bottom))
+ return FALSE;
+
+if (squeeze_top && (bbox_top > EM_TOP))
+ *top_scale = ((fix31)EM_TOP << 16)/(fix31)(bbox_top);
+else
+ *top_scale = 0x10000L; /* 1 in 16.16 fixed point */
+
+if (squeeze_bottom && (bbox_bottom < EM_BOT))
+ *bottom_scale = ((fix31)-(EM_BOT) << 16)/(fix31)-bbox_bottom;
+else
+ *bottom_scale = 0x10000L;
+
+if (sp_globals.squeezing_compound)
+ {
+ for (i=first_Y_zone; i < (first_Y_zone + no_Y_ctrl_zones + 1); i++)
+ {
+ if (sp_plaid.orus[i] >= 0)
+ sp_plaid.pix[i] = (SQUEEZE_MULT(sp_plaid.pix[i], *top_scale)
+ +sp_globals.pixrnd) & sp_globals.pixfix;
+ else
+ sp_plaid.pix[i] = (SQUEEZE_MULT(sp_plaid.pix[i], *bottom_scale)
+ +sp_globals.pixrnd) & sp_globals.pixfix;
+ }
+ }
+return TRUE;
+}
+#endif
+
+#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 */
+/*
+ * Called by plaid_tcb() to read the control zone table from the
+ * character data in the font.
+ * Sets up a table of pixel values for all controlled coordinates.
+ * Updates the pointer to the byte following the control zone
+ * data.
+ */
+{
+fix15 i, j, n;
+fix31 ppo;
+fix31 xppo0; /* top level pixels per oru */
+fix31 yppo0; /* top level pixels per oru */
+ufix8 edge_org;
+ufix8 edge;
+ufix8 start_edge;
+ufix8 end_edge;
+ufix16 constr_org;
+fix15 constr_nr;
+fix15 zone_pix;
+fix31 whole_zone; /* non-transformed value of the first X zone */
+ufix16 tmpufix16; /* in extended mode, macro uses secnd term */
+#if INCL_SQUEEZING
+fix31 x_scale;
+fix31 y_top_scale, y_bottom_scale;
+fix31 x_offset;
+boolean squeezed_y;
+fix15 setwidth_pix, em_top_pix, em_bot_pix;
+#endif
+
+#if INCL_ISW
+boolean imported_width;
+fix31 isw_scale;
+fix15 isw_setwidth_pix;
+#endif
+
+#if INCL_ISW || INCL_SQUEEZING
+boolean squeezed_x;
+#endif
+
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+begin_ctrl_zones(no_X_ctrl_zones, no_Y_ctrl_zones);
+#endif
+
+
+edge_org = 0;
+constr_org = 0;
+sp_globals.rnd_xmin = 0; /* initialize the error for chars with no zone */
+n = no_X_ctrl_zones;
+ppo = sp_globals.tcb.xppo;
+xppo0 = sp_globals.tcb0.xppo;
+yppo0 = sp_globals.tcb0.yppo;
+#if INCL_SQUEEZING || INCL_ISW
+squeezed_x = FALSE;
+#endif
+
+#if INCL_SQUEEZING
+squeezed_x = calculate_x_scale (&x_scale, &x_offset, no_X_ctrl_zones);
+squeezed_y = calculate_y_scale(&y_top_scale,&y_bottom_scale,(n+1),
+ no_Y_ctrl_zones);
+#if INCL_ISW
+if (sp_globals.import_setwidth_act == TRUE)
+setwidth_pix = ((fix15)(((fix31)sp_globals.imported_width * xppo0) >>
+ sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+
+else
+#endif
+setwidth_pix = ((fix15)(((fix31)sp_globals.setwidth_orus * xppo0) >>
+ sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+/* check for overflow */
+if (setwidth_pix < 0)
+ setwidth_pix = 0x7fff; /* set to maximum */
+em_bot_pix = ((fix15)(((fix31)EM_BOT * yppo0) >>
+ sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+em_top_pix = ((fix15)(((fix31)EM_TOP * yppo0) >>
+ sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+#endif
+
+#if INCL_ISW
+/* convert to pixels */
+isw_setwidth_pix = ((fix15)(((fix31)sp_globals.imported_width * xppo0) >>
+ sp_globals.mpshift) + sp_globals.pixrnd) & sp_globals.pixfix;
+/* check for overflow */
+if (isw_setwidth_pix < 0)
+ isw_setwidth_pix = 0x7fff; /* set to maximum */
+if (!squeezed_x && ((imported_width = sp_globals.import_setwidth_act) == TRUE))
+ {
+ isw_scale = compute_isw_scale();
+
+ /* look for the first non-negative oru value, scale and add the offset */
+ /* to the corresponding pixel value - note that the pixel value */
+ /* is set in read_oru_table. */
+
+ /* look at all the X edges */
+ for (i=0; i < (no_X_ctrl_zones+1); i++)
+ if (sp_plaid.orus[i] >= 0)
+ {
+ sp_plaid.pix[i] = (SQUEEZE_MULT(sp_plaid.pix[i], isw_scale)
+ +sp_globals.pixrnd) & sp_globals.pixfix;
+ break;
+ }
+
+ }
+#endif
+
+for (i = 0; ; i++) /* For X and Y control zones... */
+ {
+ for (j = 0; j < n; j++) /* For each zone in X or Y... */
+ {
+ if (short_form) /* 1 byte from/to specification? */
+ {
+ edge = NEXT_BYTE(pointer); /* Read packed from/to spec */
+ start_edge = edge_org + (edge & 0x0f); /* Extract start edge */
+ end_edge = edge_org + (edge >> 4); /* Extract end edge */
+ }
+ else /* 2 byte from/to specification? */
+ {
+ start_edge = edge_org + NEXT_BYTE(pointer); /* Read start edge */
+ end_edge = edge_org + NEXT_BYTE(pointer); /* read end edge */
+ }
+ constr_nr = constr_org +
+ NEXT_BYTES(pointer, tmpufix16); /* Read constraint number */
+#if INCL_SQUEEZING
+ if (i == 0 && squeezed_x)
+ calculate_x_pix(start_edge, end_edge, constr_nr,
+ x_scale, x_offset, ppo, setwidth_pix);
+ else if (i == 1 && squeezed_y)
+ calculate_y_pix(start_edge, end_edge,constr_nr,
+ y_top_scale, y_bottom_scale, ppo, em_top_pix, em_bot_pix);
+ else
+ {
+#endif
+#if INCL_ISW
+ if (i==0 && imported_width)
+ calculate_x_pix(start_edge, end_edge, constr_nr,
+ isw_scale, 0, ppo, isw_setwidth_pix);
+ else
+ {
+#endif
+ if (!sp_globals.c_act[constr_nr]) /* Constraint inactive? */
+ {
+ zone_pix = ((fix15)((((fix31)sp_plaid.orus[end_edge] -
+ (fix31)sp_plaid.orus[start_edge]) * ppo) /
+ (1<<sp_globals.mpshift)) + sp_globals.pixrnd) &
+ sp_globals.pixfix;
+ if ((ABS(zone_pix)) >= sp_globals.c_pix[constr_nr])
+ goto L1;
+ }
+ zone_pix = sp_globals.c_pix[constr_nr]; /* Use zone size from constr table */
+ if (start_edge > end_edge) /* sp_plaid.orus[start_edge] > sp_plaid.orus[end_edge]? */
+ {
+ zone_pix = -zone_pix; /* Use negatve zone size */
+ }
+ L1:
+ /* inter-character spacing fix */
+ if ((j == 0) && (i == 0)) /* if this is the 1st X zone, save rounding error */
+ { /* get the non-xformed - xformed zone, in right direction */
+ whole_zone = (((fix31)sp_plaid.orus[end_edge] -
+ (fix31)sp_plaid.orus[start_edge]) *
+ ppo) / (1<<sp_globals.mpshift);
+ sp_globals.rnd_xmin = whole_zone - zone_pix;
+ }
+ sp_plaid.pix[end_edge] = sp_plaid.pix[start_edge] + zone_pix; /* Insert end pixels */
+#if INCL_SQUEEZING
+ if (i == 0) /* in the x direction */
+ { /* brute force squeeze */
+ if ((sp_globals.pspecs->flags & SQUEEZE_LEFT) &&
+ (sp_plaid.pix[end_edge] < 0))
+ sp_plaid.pix[end_edge] = 0;
+ if ((sp_globals.pspecs->flags & SQUEEZE_RIGHT) &&
+ (sp_plaid.pix[end_edge] > setwidth_pix))
+ sp_plaid.pix[end_edge] = setwidth_pix;
+ }
+ if (i == 1) /* in the y direction */
+ { /* brute force squeeze */
+ if ((sp_globals.pspecs->flags & SQUEEZE_TOP) &&
+ (sp_plaid.pix[end_edge] > em_top_pix))
+ sp_plaid.pix[end_edge] = em_top_pix;
+ if ((sp_globals.pspecs->flags & SQUEEZE_BOTTOM) &&
+ (sp_plaid.pix[end_edge] < em_bot_pix))
+ sp_plaid.pix[end_edge] = em_bot_pix;
+ }
+#endif
+#if INCL_SQUEEZING
+ }
+#endif
+#if INCL_ISW
+ }
+#endif
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+ record_ctrl_zone(
+ (fix31)sp_plaid.pix[start_edge] << (16 - sp_globals.pixshift),
+ (fix31)sp_plaid.pix[end_edge] << (16 - sp_globals.pixshift),
+ (fix15)(constr_nr - constr_org));
+#endif
+ }
+ if (i) /* Y pixels done? */
+ break;
+ edge_org = sp_globals.Y_edge_org; /* Prepare to process Y ctrl zones */
+ constr_org = sp_globals.Y_constr_org;
+ n = no_Y_ctrl_zones;
+ ppo = sp_globals.tcb.yppo;
+ }
+
+#if DEBUG
+printf("\nX PIX TABLE\n");
+n = no_X_ctrl_zones + 1;
+for (i = 0; i < n; i++)
+ printf("%2d %6.1f\n", i, (real)sp_plaid.pix[i] / (real)sp_globals.onepix);
+printf("\nY PIX TABLE\n");
+n = no_Y_ctrl_zones + 1;
+for (i = 0; i < n; i++)
+ {
+ j = i + no_X_ctrl_zones + 1;
+ printf("%2d %6.1f\n", i, (real)sp_plaid.pix[j] / (real)sp_globals.onepix);
+ }
+#endif
+
+return pointer;
+}
+#endif
+
+
+#if INCL_RULES
+FUNCTION static ufix8 FONTFAR *sp_setup_int_table(pointer, no_X_int_zones, no_Y_int_zones)
+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 */
+/*
+ * Called by plaid_tcb() to read the interpolation zone table from the
+ * character data in the font.
+ * Sets up a table of interpolation coefficients with one entry for
+ * every X or Y interpolation zone.
+ * Updates the pointer to the byte following the interpolation zone
+ * data.
+ */
+{
+fix15 i, j, k, l, n;
+ufix8 format;
+ufix8 format_copy;
+ufix8 tmpufix8;
+fix15 start_orus;
+ufix8 edge_org;
+ufix8 edge;
+ufix16 adj_factor;
+fix15 adj_orus;
+fix15 end_orus;
+fix31 zone_orus;
+fix15 start_pix;
+fix15 end_pix;
+
+
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+begin_int_zones(no_X_int_zones, no_Y_int_zones);
+#endif
+
+i = 0;
+edge_org = 0;
+n = no_X_int_zones;
+for (j = 0; ; j++)
+ {
+ for (k = 0; k < n; k++)
+ {
+ format = NEXT_BYTE(pointer);
+ if (format & BIT7) /* Short start/end point spec? */
+ {
+ tmpufix8 = NEXT_BYTE(pointer);
+ edge = edge_org + (tmpufix8 & 0xf);
+ start_orus = sp_plaid.orus[edge];
+ start_pix = sp_plaid.pix[edge];
+ edge = edge_org + (tmpufix8 >> 4);
+ end_orus = sp_plaid.orus[edge];
+ end_pix = sp_plaid.pix[edge];
+ }
+ else /* Standard start and end point spec? */
+ {
+ format_copy = format;
+ for (l = 0; ; l++) /* Loop for start and end point */
+ {
+ switch (format_copy & 0x7) /* Decode start/end point format */
+ {
+
+ case 0: /* Index to control edge */
+ edge = edge_org + NEXT_BYTE(pointer);
+ end_orus = sp_plaid.orus[edge];
+ end_pix = sp_plaid.pix[edge];
+ break;
+
+ case 1: /* 1 byte fractional distance to next edge */
+ adj_factor = 0xffff & NEXT_BYTE(pointer) << 8;
+ goto L1;
+
+
+ case 2: /* 2 byte fractional distance to next edge */
+ adj_factor = 0xffff & NEXT_WORD(pointer);
+ L1: edge = edge_org + NEXT_BYTE(pointer);
+ end_orus = sp_plaid.orus[edge] +
+ ((((fix31)sp_plaid.orus[edge + 1] - (fix31)sp_plaid.orus[edge]) *
+ (ufix32)adj_factor + (fix31)32768) >> 16);
+ end_pix = sp_plaid.pix[edge] +
+ ((((fix31)sp_plaid.pix[edge + 1] - (fix31)sp_plaid.pix[edge]) *
+ (ufix32)adj_factor + (fix31)32768) >> 16);
+ break;
+
+ case 3: /* 1 byte delta orus before first edge */
+ adj_orus = -(fix15)NEXT_BYTE(pointer);
+ goto L2;
+
+ case 4: /* 2 byte delta orus before first edge */
+ adj_orus = -NEXT_WORD(pointer);
+ L2: edge = edge_org;
+ goto L4;
+
+ case 5: /* 1 byte delta orus after last edge */
+ adj_orus = (fix15)NEXT_BYTE(pointer);
+ goto L3;
+
+ case 6: /* 2 byte delta orus after last edge */
+ adj_orus = NEXT_WORD(pointer);
+ L3: edge = j? sp_globals.Y_edge_org + sp_globals.no_Y_orus - 1: sp_globals.no_X_orus - 1;
+ L4: end_orus = sp_plaid.orus[edge] + adj_orus;
+ end_pix = sp_plaid.pix[edge] +
+ (((fix31)adj_orus * (fix31)(j? sp_globals.tcb.yppo: sp_globals.tcb.xppo) +
+ sp_globals.mprnd) / (1<<sp_globals.mpshift));
+ break;
+
+ }
+
+ if (l) /* Second time round loop? */
+ break;
+ format_copy >>= 3; /* Adj format to decode end point format */
+ start_orus = end_orus; /* Save start point oru value */
+ start_pix = end_pix; /* Save start point pixel value */
+ }
+ }
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+ record_int_zone(
+ (fix31)start_pix << (16 - sp_globals.pixshift),
+ (fix31)end_pix << (16 - sp_globals.pixshift));
+#endif
+ zone_orus = (fix31)end_orus - (fix31)start_orus;
+ sp_plaid.mult[i] = ((((fix31)end_pix - (fix31)start_pix) << sp_globals.mpshift) +
+ (zone_orus / 2)) / zone_orus;
+ sp_plaid.offset[i] =
+ (((((fix31)start_pix + (fix31)end_pix) << sp_globals.mpshift) -
+ ((fix31)sp_plaid.mult[i] * ((fix31)start_orus + (fix31)end_orus))) / 2) +
+ sp_globals.mprnd;
+ i++;
+ }
+ if (j) /* Finished? */
+ break;
+ edge_org = sp_globals.Y_edge_org; /* Prepare to process Y ctrl zones */
+ n = no_Y_int_zones;
+ }
+
+#if DEBUG
+printf("\nX INT TABLE\n");
+n = no_X_int_zones;
+for (i = 0; i < n; i++)
+ {
+ printf("%2d %7.4f %7.4f\n", i,
+ (real)sp_plaid.mult[i] / (real)(1 << sp_globals.multshift),
+ (real)sp_plaid.offset[i] / (real)(1 << sp_globals.multshift));
+ }
+printf("\nY INT TABLE\n");
+n = no_Y_int_zones;
+for (i = 0; i < n; i++)
+ {
+ j = i + no_X_int_zones;
+ printf("%2d %7.4f %7.4f\n", i,
+ (real)sp_plaid.mult[j] / (real)(1 << sp_globals.multshift),
+ (real)sp_plaid.offset[j] / (real)(1 << sp_globals.multshift));
+ }
+#endif
+
+return pointer;
+}
+#endif
+#if INCL_ISW
+FUNCTION fix31 compute_isw_scale()
+GDECL
+{
+fix31 isw_scale;
+
+if (sp_globals.setwidth_orus == 0)
+ isw_scale = 0x00010000;
+else
+ isw_scale = ((fix31)sp_globals.imported_width << 16)/
+ (fix31)sp_globals.setwidth_orus;
+return isw_scale;
+}
+#endif
diff --git a/src/Speedo/spdo_prv.h b/src/Speedo/spdo_prv.h
new file mode 100644
index 0000000..47c5252
--- /dev/null
+++ b/src/Speedo/spdo_prv.h
@@ -0,0 +1,425 @@
+/* $Xorg: spdo_prv.h,v 1.3 2000/08/17 19:46:27 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+
+
+/***************************** S P D O _ P R V . H *******************************/
+
+#include "speedo.h" /* include public definitions */
+
+/***** 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 */
+#define FH_CUSNR 4 /* U Customer Number 2 bytes */
+#define FH_OFFCD 6 /* E Offset to Char Directory 3 bytes */
+#define FH_OFCNS 9 /* E Offset to Constraint Data 3 bytes */
+#define FH_OFFTK 12 /* E Offset to Track Kerning 3 bytes */
+#define FH_OFFPK 15 /* E Offset to Pair Kerning 3 bytes */
+#define FH_OCHRD 18 /* E Offset to Character Data 3 bytes */
+#define FH_NBYTE 21 /* E Number of Bytes in File 3 bytes */
+
+
+/***** MODE FLAGS CONSTANTS *****/
+#define CURVES_OUT 0X0008 /* Output module accepts curves */
+#define BOGUS_MODE 0X0010 /* Linear scaling mode */
+#define CONSTR_OFF 0X0020 /* Inhibit constraint table */
+#define IMPORT_WIDTHS 0X0040 /* Imported width mode */
+#define SQUEEZE_LEFT 0X0100 /* Squeeze left mode */
+#define SQUEEZE_RIGHT 0X0200 /* Squeeze right mode */
+#define SQUEEZE_TOP 0X0400 /* Squeeze top mode */
+#define SQUEEZE_BOTTOM 0X0800 /* Squeeze bottom mode */
+#define CLIP_LEFT 0X1000 /* Clip left mode */
+#define CLIP_RIGHT 0X2000 /* Clip right mode */
+#define CLIP_TOP 0X4000 /* Clip top mode */
+#define CLIP_BOTTOM 0X8000 /* Clip bottom mode */
+
+
+/***** MACRO DEFINITIONS *****/
+
+#define SQUEEZE_MULT(A,B) (((fix31)A * (fix31)B) / (1 << 16))
+
+#define NEXT_BYTE(A) (*(A)++)
+
+#define NEXT_WORD(A) \
+ ((fix15)(sp_globals.key32 ^ ((A) += 2, \
+ ((fix15)((A)[-1]) << 8) | (fix15)((A)[-2]) | \
+ ((A)[-1] & 0x80? ~0xFFFF : 0))))
+
+#if INCL_EXT /* Extended fonts supported? */
+
+#define NEXT_BYTES(A, B) \
+ (((B = (ufix16)(*(A)++) ^ sp_globals.key7) >= 248)? \
+ ((ufix16)(B & 0x07) << 8) + ((*(A)++) ^ sp_globals.key8) + 248: \
+ B)
+
+#else /* Compact fonts only supported? */
+
+#define NEXT_BYTES(A, B) ((*(A)++) ^ sp_globals.key7)
+
+#endif
+
+
+#define NEXT_BYTE_U(A) (*(A)++)
+
+#define NEXT_WORD_U(A, B) \
+ (fix15)(B = (*(A)++) << 8, (fix15)(*(A)++) + B)
+
+#define NEXT_CHNDX(A, B) \
+ ((B)? (ufix16)NEXT_WORD(A): (ufix16)NEXT_BYTE(A))
+
+/* Multiply (fix15)X by (fix15)Y to produce (fix31)product */
+#define MULT16(X, Y) \
+ ((fix31)X * (fix31)Y)
+
+/* Multiply (fix15)X by (fix15)MULT, add (fix31)OFFSET,
+ * shift right SHIFT bits to produce (fix15)result */
+#define TRANS(X, MULT, OFFSET, SHIFT) \
+ ((fix15)((((fix31)X * (fix31)MULT) + OFFSET) / (1 << SHIFT)))
+
+/******************************************************************************
+ *
+ * the following block of definitions redefines every function
+ * reference to be prefixed with an "sp_". In addition, if this
+ * is a reentrant version, the parameter sp_globals will be added
+ * as the first parameter.
+ *
+ *****************************************************************************/
+
+#if STATIC_ALLOC || DYNAMIC_ALLOC
+
+#define GDECL
+
+#define get_char_id(char_index) sp_get_char_id(char_index)
+#define get_char_width(char_index) sp_get_char_width(char_index)
+#define get_track_kern(track,point_size) sp_get_track_kern(track,point_size)
+#define get_pair_kern(char_index1,char_index2) sp_get_pair_kern(char_index1,char_index2)
+#define get_char_bbox(char_index,bbox) sp_get_char_bbox(char_index,bbox)
+#define make_char(char_index) sp_make_char(char_index)
+#if INCL_ISW
+#define compute_isw_scale() sp_compute_isw_scale()
+#define do_make_char(char_index) sp_do_make_char(char_index)
+#define make_char_isw(char_index,imported_width) sp_make_char_isw(char_index,imported_width)
+#define reset_xmax(xmax) sp_reset_xmax(xmax)
+#endif
+#if INCL_ISW || INCL_SQUEEZING
+#define preview_bounding_box(pointer,format) sp_preview_bounding_box(pointer,format)
+#endif
+#define make_simp_char(pointer,format) sp_make_simp_char(pointer,format)
+#define make_comp_char(pointer) sp_make_comp_char(pointer)
+#define get_char_org(char_index,top_level) sp_get_char_org(char_index,top_level)
+#define get_posn_arg(ppointer,format) sp_get_posn_arg(ppointer,format)
+#define get_scale_arg(ppointer,format) sp_get_scale_arg(ppointer,format)
+#define read_bbox(ppointer,pPmin,pPmax,set_flag) sp_read_bbox(ppointer,pPmin,pPmax,set_flag)
+#define proc_outl_data(pointer) sp_proc_outl_data(pointer)
+#define split_curve(P1,P2,P3,depth) sp_split_curve(P1,P2,P3,depth)
+#define get_args(ppointer,format,pP) sp_get_args(ppointer,format,pP)
+
+#define init_black(specsarg) sp_init_black(specsarg)
+#define begin_char_black(Psw,Pmin,Pmax) sp_begin_char_black(Psw,Pmin,Pmax)
+#define begin_contour_black(P1,outside) sp_begin_contour_black(P1,outside)
+#define line_black(P1) sp_line_black(P1)
+#define end_char_black() sp_end_char_black()
+#define add_intercept_black(y,x) sp_add_intercept_black(y,x)
+#define proc_intercepts_black() sp_proc_intercepts_black()
+
+#define init_screen(specsarg) sp_init_screen(specsarg)
+#define begin_char_screen(Psw,Pmin,Pmax) sp_begin_char_screen(Psw,Pmin,Pmax)
+#define begin_contour_screen(P1,outside) sp_begin_contour_screen(P1,outside)
+#define curve_screen(P1,P2,P3,depth) sp_curve_screen(P1,P2,P3,depth)
+#define scan_curve_screen(X0,Y0,X1,Y1,X2,Y2,X3,Y3) sp_scan_curve_screen(X0,Y0,X1,Y1,X2,Y2,X3,Y3)
+#define vert_line_screen(x,y1,y2) sp_vert_line_screen(x,y1,y2)
+#define line_screen(P1) sp_line_screen(P1)
+#define end_contour_screen() sp_end_contour_screen()
+#define end_char_screen() sp_end_char_screen()
+#define add_intercept_screen(y,x) sp_add_intercept_screen(y,x)
+#define proc_intercepts_screen() sp_proc_intercepts_screen()
+
+#define init_outline(specsarg) sp_init_outline(specsarg)
+#define begin_char_outline(Psw,Pmin,Pmax) sp_begin_char_outline(Psw,Pmin,Pmax)
+#define begin_sub_char_outline(Psw,Pmin,Pmax) sp_begin_sub_char_outline(Psw,Pmin,Pmax)
+#define begin_contour_outline(P1,outside) sp_begin_contour_outline(P1,outside)
+#define curve_outline(P1,P2,P3,depth) sp_curve_outline(P1,P2,P3,depth)
+#define line_outline(P1) sp_line_outline(P1)
+#define end_contour_outline() sp_end_contour_outline()
+#define end_sub_char_outline() sp_end_sub_char_outline()
+#define end_char_outline() sp_end_char_outline()
+
+#define init_2d(specsarg) sp_init_2d(specsarg)
+#define begin_char_2d(Psw, Pmin, Pmax) sp_begin_char_2d(Psw, Pmin, Pmax)
+#define begin_contour_2d(P1, outside) sp_begin_contour_2d(P1, outside)
+#define line_2d(P1) sp_line_2d(P1)
+#define end_char_2d() sp_end_char_2d()
+#define add_intercept_2d(y, x) sp_add_intercept_2d(y, x)
+#define proc_intercepts_2d() sp_proc_intercepts_2d()
+#define draw_vector_to_2d(x0, y0, x1, y1, band) sp_draw_vector_to_2d(x0, y0, x1, y1, band)
+
+#define init_char_out(Psw,Pmin,Pmax) sp_init_char_out(Psw,Pmin,Pmax)
+#define begin_sub_char_out(Psw,Pmin,Pmax) sp_begin_sub_char_out(Psw,Pmin,Pmax)
+#define curve_out(P1,P2,P3,depth) sp_curve_out(P1,P2,P3,depth)
+#define end_contour_out() sp_end_contour_out()
+#define end_sub_char_out() sp_end_sub_char_out()
+#define init_intercepts_out() sp_init_intercepts_out()
+#define restart_intercepts_out() sp_restart_intercepts_out()
+#define set_first_band_out(Pmin,Pmax) sp_set_first_band_out(Pmin,Pmax)
+#define reduce_band_size_out() sp_reduce_band_size_out()
+#define next_band_out() sp_next_band_out()
+
+#define init_userout(specsarg) sp_init_userout(specsarg)
+
+#define reset() sp_reset()
+#define set_key(key) sp_set_key(key)
+#define get_cust_no(font_buff) sp_get_cust_no(font_buff)
+#define set_specs(specsarg) sp_set_specs(specsarg)
+#define setup_consts(xmin,xmax,ymin,ymax) sp_setup_consts(xmin,xmax,ymin,ymax)
+#define setup_tcb(ptcb) sp_setup_tcb(ptcb)
+#define setup_mult(input_mult) sp_setup_mult(input_mult)
+#define setup_offset(input_offset) sp_setup_offset(input_offset)
+#define type_tcb(ptcb) sp_type_tcb(ptcb)
+#define read_long(pointer) sp_read_long(pointer)
+#define read_word_u(pointer) sp_read_word_u(pointer)
+#define init_tcb() sp_init_tcb()
+#define scale_tcb(ptcb,x_pos,y_pos,x_scale,y_scale) sp_scale_tcb(ptcb,x_pos,y_pos,x_scale,y_scale)
+#define plaid_tcb(ppointer,format) sp_plaid_tcb(ppointer,format)
+#define skip_orus(ppointer,short_form,no_ctrl_zones) sp_skip_orus(ppointer,short_form,no_ctrl_zones)
+#define skip_interpolation_table(ppointer,format) sp_skip_interpolation_table(ppointer,format)
+#define skip_control_zone(ppointer,format) sp_skip_control_zone(ppointer,format)
+#define constr_update() sp_constr_update()
+#define read_oru_table(ppointer) sp_read_oru_table(ppointer)
+#define calculate_x_pix(start_edge,end_edge,constr_nr,x_scale,x_offset,ppo,setwidth_pix) sp_calculate_x_pix(start_edge,end_edge,constr_nr,x_scale,x_offset,ppo,setwidth_pix)
+#define calculate_y_pix(start_edge,end_edge,constr_nr,top_scale,bottom_scale,ppo,emtop_pix,embot_pix) sp_calculate_y_pix(start_edge,end_edge,constr_nr,top_scale,bottom_scale,ppo,emtop_pix,embot_pix)
+#define calculate_x_scale(x_factor,x_offset,no_x_ctrl_zones) sp_calculate_x_scale(x_factor,x_offset,no_x_ctrl_zones)
+#define calculate_y_scale(top_scale,bottom_scale,first_y_zone,no_Y_ctrl_zones) sp_calculate_y_scale(top_scale,bottom_scale,first_y_zone,no_Y_ctrl_zones)
+#define setup_pix_table(ppointer,short_form,no_X_ctrl_zones,no_Y_ctrl_zones) sp_setup_pix_table(ppointer,short_form,no_X_ctrl_zones,no_Y_ctrl_zones)
+#define setup_int_table(ppointer,no_X_int_zones, no_Y_int_zones) sp_setup_int_table(ppointer,no_X_int_zones, no_Y_int_zones)
+
+#define fn_init_out(specsarg) (*sp_globals.init_out)(specsarg)
+#define fn_begin_char(Psw,Pmin,Pmax) (*sp_globals.begin_char)(Psw,Pmin,Pmax)
+#define fn_begin_sub_char(Psw,Pmin,Pmax) (*sp_globals.begin_sub_char)(Psw,Pmin,Pmax)
+#define fn_end_sub_char() (*sp_globals.end_sub_char)()
+#define fn_end_char() (*sp_globals.end_char)()
+#define fn_line(P1) (*sp_globals.line)(P1)
+#define fn_end_contour() (*sp_globals.end_contour)()
+#define fn_begin_contour(P0,fmt) (*sp_globals.begin_contour)(P0,fmt)
+#define fn_curve(P1,P2,P3,depth) (*sp_globals.curve)(P1,P2,P3,depth)
+
+#define load_char_data(offset, no_bytes, buff_off) sp_load_char_data(offset, no_bytes, buff_off)
+#define report_error(n) sp_report_error(n)
+
+#if INCL_MULTIDEV
+
+#define set_bitmap_device(bfuncs,size) sp_set_bitmap_device(bfuncs,size)
+#define set_outline_device(ofuncs,size) sp_set_outline_device(ofuncs,size)
+
+#define open_bitmap(x_set_width, y_set_width, xmin, xmax, ymin, ymax) (*sp_globals.bitmap_device.p_open_bitmap)(x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define set_bitmap_bits(y, xbit1, xbit2) (*sp_globals.bitmap_device.p_set_bits)(y, xbit1, xbit2)
+#define close_bitmap() (*sp_globals.bitmap_device.p_close_bitmap)()
+
+#define open_outline(x_set_width, y_set_width, xmin, xmax, ymin, ymax) (*sp_globals.outline_device.p_open_outline)(x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define start_new_char() (*sp_globals.outline_device.p_start_char)()
+#define start_contour(x,y,outside) (*sp_globals.outline_device.p_start_contour)(x,y,outside)
+#define curve_to(x1,y1,x2,y2,x3,y3) (*sp_globals.outline_device.p_curve)(x1,y1,x2,y2,x3,y3)
+#define line_to(x,y) (*sp_globals.outline_device.p_line)(x,y)
+#define close_contour() (*sp_globals.outline_device.p_close_contour)()
+#define close_outline() (*sp_globals.outline_device.p_close_outline)()
+
+#else
+
+#define open_bitmap(x_set_width, y_set_width, xmin, xmax, ymin, ymax) sp_open_bitmap(x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define set_bitmap_bits(y, xbit1, xbit2) sp_set_bitmap_bits(y, xbit1, xbit2)
+#define close_bitmap() sp_close_bitmap()
+
+#define open_outline(x_set_width, y_set_width, xmin, xmax, ymin, ymax) sp_open_outline(x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define start_new_char() sp_start_new_char()
+#define start_contour(x,y,outside) sp_start_contour(x,y,outside)
+#define curve_to(x1,y1,x2,y2,x3,y3) sp_curve_to(x1,y1,x2,y2,x3,y3)
+#define line_to(x,y) sp_line_to(x,y)
+#define close_contour() sp_close_contour()
+#define close_outline() sp_close_outline()
+
+#endif
+
+#else
+
+#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)
+#define get_track_kern(track,point_size) sp_get_track_kern(sp_global_ptr,track,point_size)
+#define get_pair_kern(char_index1,char_index2) sp_get_pair_kern(sp_global_ptr,char_index1,char_index2)
+#define get_char_bbox(char_index,bbox) sp_get_char_bbox(sp_global_ptr,char_index,bbox)
+#define make_char(char_index) sp_make_char(sp_global_ptr,char_index)
+#if INCL_ISW
+#define compute_isw_scale() sp_compute_isw_scale(sp_global_ptr)
+#define do_make_char(char_index) sp_do_make_char(sp_global_ptr,char_index)
+#define make_char_isw(char_index,imported_width) sp_make_char_isw(sp_global_ptr,char_index,imported_width)
+#define reset_xmax(xmax) sp_reset_xmax(sp_global_ptr,xmax)
+#endif
+#if INCL_ISW || INCL_SQUEEZING
+#define preview_bounding_box(pointer,format) sp_preview_bounding_box(sp_global_ptr,pointer,format)
+#endif
+#define make_simp_char(pointer,format) sp_make_simp_char(sp_global_ptr,pointer,format)
+#define make_comp_char(pointer) sp_make_comp_char(sp_global_ptr,pointer)
+#define get_char_org(char_index,top_level) sp_get_char_org(sp_global_ptr,char_index,top_level)
+#define get_posn_arg(ppointer,format) sp_get_posn_arg(sp_global_ptr,ppointer,format)
+#define get_scale_arg(ppointer,format) sp_get_scale_arg(sp_global_ptr,ppointer,format)
+#define read_bbox(ppointer,pPmin,pPmax,set_flag) sp_read_bbox(sp_global_ptr,ppointer,pPmin,pPmax,set_flag)
+#define proc_outl_data(pointer) sp_proc_outl_data(sp_global_ptr,pointer)
+#define split_curve(P1,P2,P3,depth) sp_split_curve(sp_global_ptr,P1,P2,P3,depth)
+#define get_args(ppointer,format,pP) sp_get_args(sp_global_ptr,ppointer,format,pP)
+
+#define init_black(specsarg) sp_init_black(sp_global_ptr,specsarg)
+#define begin_char_black(Psw,Pmin,Pmax) sp_begin_char_black(sp_global_ptr,Psw,Pmin,Pmax)
+#define begin_contour_black(P1,outside) sp_begin_contour_black(sp_global_ptr,P1,outside)
+#define line_black(P1) sp_line_black(sp_global_ptr,P1)
+#define end_char_black() sp_end_char_black(sp_global_ptr)
+#define add_intercept_black(y,x) sp_add_intercept_black(sp_global_ptr,y,x)
+#define proc_intercepts_black() sp_proc_intercepts_black(sp_global_ptr)
+
+#define init_screen(specsarg) sp_init_screen(sp_global_ptr,specsarg)
+#define begin_char_screen(Psw,Pmin,Pmax) sp_begin_char_screen(sp_global_ptr,Psw,Pmin,Pmax)
+#define begin_contour_screen(P1,outside) sp_begin_contour_screen(sp_global_ptr,P1,outside)
+#define curve_screen(P1,P2,P3,depth) sp_curve_screen(sp_global_ptr,P1,P2,P3,depth)
+#define scan_curve_screen(X0,Y0,X1,Y1,X2,Y2,X3,Y3) sp_scan_curve_screen(sp_global_ptr,X0,Y0,X1,Y1,X2,Y2,X3,Y3)
+#define vert_line_screen(x,y1,y2) sp_vert_line_screen(sp_global_ptr,x,y1,y2)
+#define line_screen(P1) sp_line_screen(sp_global_ptr,P1)
+#define end_char_screen() sp_end_char_screen(sp_global_ptr)
+#define end_contour_screen() sp_end_contour_screen(sp_global_ptr)
+#define add_intercept_screen(y,x) sp_add_intercept_screen(sp_global_ptr,y,x)
+#define proc_intercepts_screen() sp_proc_intercepts_screen(sp_global_ptr)
+
+#define init_outline(specsarg) sp_init_outline(sp_global_ptr,specsarg)
+#define begin_char_outline(Psw,Pmin,Pmax) sp_begin_char_outline(sp_global_ptr,Psw,Pmin,Pmax)
+#define begin_sub_char_outline(Psw,Pmin,Pmax) sp_begin_sub_char_outline(sp_global_ptr,Psw,Pmin,Pmax)
+#define begin_contour_outline(P1,outside) sp_begin_contour_outline(sp_global_ptr,P1,outside)
+#define curve_outline(P1,P2,P3,depth) sp_curve_outline(sp_global_ptr,P1,P2,P3,depth)
+#define line_outline(P1) sp_line_outline(sp_global_ptr,P1)
+#define end_contour_outline() sp_end_contour_outline(sp_global_ptr)
+#define end_sub_char_outline() sp_end_sub_char_outline(sp_global_ptr)
+#define end_char_outline() sp_end_char_outline(sp_global_ptr)
+
+#define init_2d(specsarg) sp_init_2d(sp_global_ptr,specsarg)
+#define begin_char_2d(Psw, Pmin, Pmax) sp_begin_char_2d(sp_global_ptr,Psw, Pmin, Pmax)
+#define begin_contour_2d(P1, outside) sp_begin_contour_2d(sp_global_ptr,P1, outside)
+#define line_2d(P1) sp_line_2d(sp_global_ptr,P1)
+#define end_char_2d() sp_end_char_2d(sp_global_ptr)
+#define add_intercept_2d(y, x) sp_add_intercept_2d(sp_global_ptr,y, x)
+#define proc_intercepts_2d() sp_proc_intercepts_2d(sp_global_ptr)
+#define draw_vector_to_2d(x0, y0, x1, y1, band) sp_draw_vector_to_2d(sp_global_ptr,x0, y0, x1, y1, band)
+
+#define init_char_out(Psw,Pmin,Pmax) sp_init_char_out(sp_global_ptr,Psw,Pmin,Pmax)
+#define begin_sub_char_out(Psw,Pmin,Pmax) sp_begin_sub_char_out(sp_global_ptr,Psw,Pmin,Pmax)
+#define curve_out(P1,P2,P3,depth) sp_curve_out(sp_global_ptr,P1,P2,P3,depth)
+#define end_contour_out() sp_end_contour_out(sp_global_ptr)
+#define end_sub_char_out() sp_end_sub_char_out(sp_global_ptr)
+#define init_intercepts_out() sp_init_intercepts_out(sp_global_ptr)
+#define restart_intercepts_out() sp_restart_intercepts_out(sp_global_ptr)
+#define set_first_band_out(Pmin,Pmax) sp_set_first_band_out(sp_global_ptr,Pmin,Pmax)
+#define reduce_band_size_out() sp_reduce_band_size_out(sp_global_ptr)
+#define next_band_out() sp_next_band_out(sp_global_ptr)
+
+#define init_userout(specsarg) sp_init_userout(sp_global_ptr,specsarg)
+
+#define reset() sp_reset(sp_global_ptr)
+#define set_key(key) sp_set_key(sp_global_ptr,key)
+#define get_cust_no(font_buff) sp_get_cust_no(sp_global_ptr,font_buff)
+#define set_specs(specsarg) sp_set_specs(sp_global_ptr,specsarg)
+#define setup_consts(xmin,xmax,ymin,ymax) sp_setup_consts(sp_global_ptr,xmin,xmax,ymin,ymax)
+#define setup_tcb(ptcb) sp_setup_tcb(sp_global_ptr,ptcb)
+#define setup_mult(input_mult) sp_setup_mult(sp_global_ptr,input_mult)
+#define setup_offset(input_offset) sp_setup_offset(sp_global_ptr,input_offset)
+#define type_tcb(ptcb) sp_type_tcb(sp_global_ptr,ptcb)
+#define read_long(pointer) sp_read_long(sp_global_ptr,pointer)
+#define read_word_u(pointer) sp_read_word_u(sp_global_ptr,pointer)
+#define init_tcb() sp_init_tcb(sp_global_ptr)
+#define scale_tcb(ptcb,x_pos,y_pos,x_scale,y_scale) sp_scale_tcb(sp_global_ptr,ptcb,x_pos,y_pos,x_scale,y_scale)
+#define plaid_tcb(ppointer,format) sp_plaid_tcb(sp_global_ptr,ppointer,format)
+#define skip_orus(ppointer,short_form,no_ctrl_zones) sp_skip_orus(sp_global_ptr,ppointer,short_form,no_ctrl_zones)
+#define skip_interpolation_table(ppointer,format) sp_skip_interpolation_table(sp_global_ptr,ppointer,format)
+#define skip_control_zone(ppointer,format) sp_skip_control_zone(sp_global_ptr,ppointer,format)
+#define constr_update() sp_constr_update(sp_global_ptr)
+#define read_oru_table(ppointer) sp_read_oru_table(sp_global_ptr,ppointer)
+#define calculate_x_pix(start_edge,end_edge,constr_nr,x_scale,x_offset,ppo,setwidth_pix) sp_calculate_x_pix(sp_global_ptr,start_edge,end_edge,constr_nr,x_scale,x_offset,ppo,setwidth_pix)
+#define calculate_y_pix(start_edge,end_edge,constr_nr,top_scale,bottom_scale,ppo,emtop_pix,embot_pix) sp_calculate_y_pix(sp_global_ptr,start_edge,end_edge,constr_nr,top_scale,bottom_scale,ppo,emtop_pix,embot_pix)
+#define calculate_x_scale(x_factor,x_offset,no_x_ctrl_zones) sp_calculate_x_scale(sp_global_ptr,x_factor,x_offset,no_x_ctrl_zones)
+#define calculate_y_scale(top_scale,bottom_scale,first_y_zone,no_Y_ctrl_zones) sp_calculate_y_scale(sp_global_ptr,top_scale,bottom_scale,first_y_zone,no_Y_ctrl_zones)
+#define setup_pix_table(ppointer,short_form,no_X_ctrl_zones,no_Y_ctrl_zones) sp_setup_pix_table(sp_global_ptr,ppointer,short_form,no_X_ctrl_zones,no_Y_ctrl_zones)
+#define setup_int_table(ppointer,no_X_int_zones, no_Y_int_zones) sp_setup_int_table(sp_global_ptr,ppointer,no_X_int_zones, no_Y_int_zones)
+
+#define fn_init_out(specsarg) (*sp_globals.init_out)(sp_global_ptr,specsarg)
+#define fn_begin_char(Psw,Pmin,Pmax) (*sp_globals.begin_char)(sp_global_ptr,Psw,Pmin,Pmax)
+#define fn_begin_sub_char(Psw,Pmin,Pmax) (*sp_globals.begin_sub_char)(sp_global_ptr,Psw,Pmin,Pmax)
+#define fn_end_sub_char() (*sp_globals.end_sub_char)(sp_global_ptr)
+#define fn_end_char() (*sp_globals.end_char)(sp_global_ptr)
+#define fn_line(P1) (*sp_globals.line)(sp_global_ptr,P1)
+#define fn_end_contour() (*sp_globals.end_contour)(sp_global_ptr)
+#define fn_begin_contour(P0,fmt) (*sp_globals.begin_contour)(sp_global_ptr,P0,fmt)
+#define fn_curve(P1,P2,P3,depth) (*sp_globals.curve)(sp_global_ptr,P1,P2,P3,depth)
+
+
+#define load_char_data(offset, no_bytes, buff_off) sp_load_char_data(sp_global_ptr, offset, no_bytes, buff_off)
+#define report_error(n) sp_report_error(sp_global_ptr, n)
+
+#if INCL_MULTIDEV
+
+#define set_bitmap_device(bfuncs,size) sp_set_bitmap_device(sp_global_ptr,bfuncs,size)
+#define set_outline_device(ofuncs,size) sp_set_outline_device(sp_global_ptr,ofuncs,size)
+
+#define open_bitmap(x_set_width, y_set_width, xmin, xmax, ymin, ymax)(*sp_globals.bitmap_device.p_open_bitmap)(sp_global_ptr,x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define set_bitmap_bits(y, xbit1, xbit2)(*sp_globals.bitmap_device.p_set_bits)(sp_global_ptr,y, xbit1, xbit2)
+#define close_bitmap()(*sp_globals.bitmap_device.p_close_bitmap)(sp_global_ptr)
+
+#define open_outline(x_set_width, y_set_width, xmin, xmax, ymin, ymax)(*sp_globals.outline_device.p_open_outline)(sp_global_ptr,x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define start_new_char()(*sp_globals.outline_device.p_start_char)(sp_global_ptr)
+#define start_contour(x,y,outside)(*sp_globals.outline_device.p_start_contour)(sp_global_ptr,x,y,outside)
+#define curve_to(x1,y1,x2,y2,x3,y3)(*sp_globals.outline_device.p_curve)(sp_global_ptr,x1,y1,x2,y2,x3,y3)
+#define line_to(x,y)(*sp_globals.outline_device.p_line)(sp_global_ptr,x,y)
+#define close_contour()(*sp_globals.outline_device.p_close_contour)(sp_global_ptr)
+#define close_outline()(*sp_globals.outline_device.p_close_outline)(sp_global_ptr)
+
+#else
+
+#define open_bitmap(x_set_width, y_set_width, xmin, xmax, ymin, ymax) sp_open_bitmap(sp_global_ptr, x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define set_bitmap_bits(y, xbit1, xbit2) sp_set_bitmap_bits(sp_global_ptr, y, xbit1, xbit2)
+#define close_bitmap() sp_close_bitmap(sp_global_ptr)
+
+#define open_outline(x_set_width, y_set_width, xmin, xmax, ymin, ymax) sp_open_outline(sp_global_ptr, x_set_width, y_set_width, xmin, xmax, ymin, ymax)
+#define start_new_char() sp_start_new_char(sp_global_ptr )
+#define start_contour(x,y,outside) sp_start_contour(sp_global_ptr, x,y,outside)
+#define curve_to(x1,y1,x2,y2,x3,y3) sp_curve_to(sp_global_ptr, x1,y1,x2,y2,x3,y3)
+#define line_to(x,y) sp_line_to(sp_global_ptr, x,y)
+#define close_contour() sp_close_contour(sp_global_ptr)
+#define close_outline() sp_close_outline(sp_global_ptr)
+
+#endif
+#endif
+
+
diff --git a/src/Speedo/speedo.h b/src/Speedo/speedo.h
new file mode 100644
index 0000000..277c6a6
--- /dev/null
+++ b/src/Speedo/speedo.h
@@ -0,0 +1,1081 @@
+/* $Xorg: speedo.h,v 1.3 2000/08/17 19:46:27 cpqbld Exp $ */
+
+/*
+
+Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
+You are hereby granted permission under all Bitstream propriety rights to
+use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
+software and the Bitstream Charter outline font for any purpose and without
+restrictions; provided, that this notice is left intact on all copies of such
+software or font and that Bitstream's trademark is acknowledged as shown below
+on all unmodified copies of such font.
+
+BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
+
+
+BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
+DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
+WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
+
+*/
+
+#ifndef _SPEEDO_H_
+#define _SPEEDO_H_
+
+#include <X11/Xmd.h>
+
+/***************************** S P E E D O . H *******************************
+ ****************************************************************************/
+
+/***** USER OPTIONS OVERRIDE DEFAULTS ******/
+#include "useropt.h"
+
+/***** CONFIGURATION DEFINITIONS *****/
+
+#ifndef INCL_CLIPPING
+#define INCL_CLIPPING 0 /* 0 indicates CLIPPING code is not compiled in*/
+#endif
+
+#ifndef INCL_SQUEEZING
+#define INCL_SQUEEZING 0 /* 0 indicates SQUEEZE code is not compiled in*/
+#endif
+
+#ifndef INCL_EXT
+#define INCL_EXT 1 /* 1 to include extended font support */
+#endif /* 0 to omit extended font support */
+
+#ifndef INCL_RULES
+#define INCL_RULES 1 /* 1 to include intelligent scaling support */
+#endif /* 0 to omit intelligent scaling support */
+
+#ifndef INCL_BLACK
+#define INCL_BLACK 1 /* 1 to include blackwriter output support */
+#endif /* 0 to omit output mode 0 support */
+
+#ifndef INCL_SCREEN
+#define INCL_SCREEN 0 /* 1 to include screen writeroutput support */
+#endif /* 0 to omit support */
+
+#ifndef INCL_OUTLINE
+#define INCL_OUTLINE 0 /* 1 to include outline output support */
+#endif /* 0 to omit output mode 2 support */
+
+#ifndef INCL_2D
+#define INCL_2D 0 /* 1 to include 2d blackwriter output support */
+#endif /* 0 to omit output mode 3 support */
+
+#ifndef INCL_USEROUT
+#define INCL_USEROUT 0 /* 1 to include user defined output module support */
+#endif /* 0 to omit user defined output module support */
+
+#ifndef INCL_LCD
+#define INCL_LCD 1 /* 1 to include load char data support*/
+#endif /* 0 to omit load char data support */
+#ifndef INCL_ISW
+#define INCL_ISW 0 /* 1 to include imported width support */
+#endif /* 0 to omit imported width support */
+
+#ifndef INCL_METRICS
+#define INCL_METRICS 1 /* 1 to include metrics support */
+#endif /* 0 to omit metrics support */
+
+#ifndef INCL_KEYS
+#define INCL_KEYS 0 /* 1 to include multi key support */
+#endif /* 0 to omit multi key support */
+
+#ifndef INCL_MULTIDEV
+#define INCL_MULTIDEV 0 /* 1 to include multiple output device support */
+#endif /* 0 to omit multi device support */
+
+#ifndef SHORT_LISTS
+#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 FONTFAR /* if Intel mixed memory model implementation */
+#define FONTFAR /* pointer type modifier for font buffer */
+#endif
+
+#ifndef STACKFAR /* if Intel mixed memory model implementation */
+#define STACKFAR /* pointer type modifier for font buffer */
+#endif
+
+#ifndef GLOBALFAR
+#define GLOBALFAR
+#endif
+
+#define MODE_BLACK 0
+#define MODE_SCREEN MODE_BLACK + INCL_BLACK
+#define MODE_OUTLINE MODE_SCREEN + INCL_SCREEN
+#define MODE_2D MODE_OUTLINE + INCL_OUTLINE
+
+#ifdef DYNAMIC_ALLOC
+#if DYNAMIC_ALLOC
+#define STATIC_ALLOC 0
+#endif
+#endif
+
+#ifdef REENTRANT_ALLOC
+#if REENTRANT_ALLOC
+#define STATIC_ALLOC 0
+#endif
+#endif
+
+#ifndef STATIC_ALLOC
+#define STATIC_ALLOC 1
+#endif
+
+#ifndef DYNAMIC_ALLOC
+#define DYNAMIC_ALLOC 0
+#endif
+
+#ifndef REENTRANT_ALLOC
+#define REENTRANT_ALLOC 0
+#endif
+
+/***** TYPE DEFINITIONS *****/
+
+#ifndef STDEF
+#ifndef SPD_BMAP
+
+typedef INT8 fix7;
+
+typedef double real;
+
+typedef CARD8 ufix8;
+#ifndef VFONT
+typedef CARD8 boolean;
+#endif
+#endif
+
+typedef INT16 fix15;
+
+typedef CARD16 ufix16;
+
+typedef INT32 fix31;
+
+typedef CARD32 ufix32;
+#endif
+
+/***** GENERAL CONSTANTS *****/
+
+#ifndef FALSE
+#define FALSE 0
+#define TRUE 1
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#define FUNCTION
+
+#define BIT0 0x01
+#define BIT1 0x02
+#define BIT2 0x04
+#define BIT3 0x08
+#define BIT4 0x10
+#define BIT5 0x20
+#define BIT6 0x40
+#define BIT7 0x80
+
+#if INCL_EXT /* Extended fonts supported? */
+
+#define MAX_CONSTR 750 /* Max constraints (incl 4 dummies) */
+#define MAX_CTRL_ZONES 256 /* Max number of controlled orus */
+#define MAX_INT_ZONES 256 /* Max number of interpolation zones */
+
+#else /* Compact fonts only supported */
+
+#define MAX_CONSTR 512 /* Max constraints (incl 4 dummies) */
+#define MAX_CTRL_ZONES 64 /* Max number of controlled orus */
+#define MAX_INT_ZONES 64 /* Max number of interpolation zones */
+
+#endif
+
+#define SCALE_SHIFT 12 /* Binary point positiion for scale values */
+#define SCALE_RND 2048 /* Rounding bit for scaling transformation */
+#define ONE_SCALE 4096 /* Unity scale value */
+
+#ifdef INCL_SCREEN /* constants used by Screenwriter module */
+#define LEFT_INT 1 /* left intercept */
+#define END_INT 2 /* last intercept */
+#define FRACTION 0xFC /* fractional portion of intercept type list */
+#endif
+
+#if INCL_SQUEEZING || INCL_CLIPPING /* constants used by SQUEEZEing code */
+#define EM_TOP 764
+#define EM_BOT -236
+#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 ,
+#else
+#define PROTO_DECL1 void
+#define PROTO_DECL2
+#endif
+#endif
+
+typedef
+struct buff_tag
+ {
+ ufix8 FONTFAR *org; /* Pointer to start of buffer */
+ ufix32 no_bytes; /* Size of buffer in bytes */
+ }
+buff_t; /* Buffer descriptor */
+
+typedef struct constr_tag
+ {
+ ufix8 FONTFAR *org; /* Pointer to first byte in constr data */
+ ufix16 font_id; /* Font id for calculated data */
+ fix15 xppo; /* X pixels per oru for calculated data */
+ fix15 yppo; /* Y pixels per oru for calculated data */
+ boolean font_id_valid; /* TRUE if font id valid */
+ boolean data_valid; /* TRUE if calculated data valid */
+ boolean active; /* TRUE if constraints enabled */
+ }
+constr_t; /* Constraint data state */
+
+typedef struct kern_tag
+ {
+ ufix8 FONTFAR *tkorg; /* First byte of track kerning data */
+ ufix8 FONTFAR *pkorg; /* First byte of pair kerning data */
+ fix15 no_tracks; /* Number of kerning tracks */
+ fix15 no_pairs; /* Number of kerning pairs */
+ }
+kern_t; /* Kerning control block */
+
+typedef struct specs_tag
+ {
+ buff_t STACKFAR *pfont; /* Pointer to font data */
+ fix31 xxmult; /* Coeff of X orus to compute X pix */
+ fix31 xymult; /* Coeff of Y orus to compute X pix */
+ fix31 xoffset; /* Constant to compute X pix */
+ fix31 yxmult; /* Coeff of X orus to compute Y pix */
+ fix31 yymult; /* Coeff of Y orus to compute Y pix */
+ fix31 yoffset; /* Constant to compute Y pix */
+ ufix32 flags; /* Mode flags: */
+ /* Bit 0 - 2: Output module selector: */
+ /* Bit 3: Send curves to output module*/
+ /* Bit 4: Use linear scaling if set */
+ /* Bit 5: Inhibit constraint table */
+ /* Bit 6: Import set width if set */
+ /* Bit 7: not used */
+ /* Bit 8: Squeeze left if set */
+ /* Bit 9: Squeeze right if set */
+ /* Bit 10: Squeeze top if set */
+ /* Bit 11: Squeeze bottom if set */
+ /* Bit 12: Clip left if set */
+ /* Bit 13: Clip right if set */
+ /* 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 */
+
+typedef struct tcb_tag
+ {
+ fix15 xxmult; /* Linear coeff of Xorus to compute Xpix */
+ fix15 xymult; /* Linear coeff of Yorus to compute Xpix */
+ fix31 xoffset; /* Linear constant to compute Xpix */
+ fix15 yxmult; /* Linear coeff of Xorus to compute Ypix */
+ fix15 yymult; /* Linear coeff of Yorus to compute Ypix */
+ fix31 yoffset; /* Linear constant to compute Ypix */
+ fix15 xppo; /* Pixels per oru in X dimension of char */
+ fix15 yppo; /* Pixels per oru in Y dimension of char */
+ fix15 xpos; /* Origin in X dimension of character */
+ fix15 ypos; /* Origin in Y dimension of character */
+ ufix16 xtype; /* Transformation type for X oru coords */
+ ufix16 ytype; /* Transformation type for Y oru coords */
+ ufix16 xmode; /* Transformation mode for X oru coords */
+ ufix16 ymode; /* Transformation mode for Y oru coords */
+ fix15 mirror; /* Transformation creates mirror image */
+ }
+tcb_t; /* Transformation control block */
+
+typedef struct point_tag
+ {
+ fix15 x; /* X coord of point (shifted pixels) */
+ fix15 y; /* Y coord of point (shifted pixels) */
+ }
+point_t; /* Point in device space */
+
+typedef struct band_tag
+ {
+ fix15 band_max;
+ fix15 band_min;
+ fix15 band_array_offset;
+ fix15 band_floor;
+ fix15 band_ceiling;
+ } band_t;
+
+typedef struct bbox_tag
+ {
+ fix31 xmin;
+ fix31 xmax;
+ fix31 ymin;
+ fix31 ymax;
+ } bbox_t;
+
+#if SHORT_LISTS
+#define MAX_INTERCEPTS 256 /* Max storage for intercepts */
+typedef ufix8 cdr_t; /* 8 bit links in intercept chains */
+#else
+#define MAX_INTERCEPTS 1000 /* Max storage for intercepts */
+typedef ufix16 cdr_t; /* 16 bit links in intercept chains */
+#endif
+
+#if REENTRANT_ALLOC
+
+typedef struct intercepts_tag
+ {
+ fix15 car[MAX_INTERCEPTS];
+ fix15 cdr[MAX_INTERCEPTS];
+#if INCL_SCREEN
+ ufix8 inttype[MAX_INTERCEPTS];
+ ufix8 leftedge;
+ ufix16 fracpix;
+#endif
+ } intercepts_t;
+
+typedef struct plaid_tag
+ {
+ fix15 orus[MAX_CTRL_ZONES]; /* Controlled coordinate table (orus) */
+#if INCL_RULES
+ fix15 pix[MAX_CTRL_ZONES]; /* Controlled coordinate table (sub-pixels) */
+ fix15 mult[MAX_INT_ZONES]; /* Interpolation multiplier table */
+ fix31 offset[MAX_INT_ZONES]; /* Interpolation offset table */
+#endif
+ } plaid_t;
+#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);
+ void (*p_set_bits)(PROTO_DECL2 fix15 y, fix15 xbit1, fix15 xbit2);
+ void (*p_close_bitmap)(PROTO_DECL1);
+ } bitmap_t;
+
+typedef struct outline_tag
+ {
+ void (*p_open_outline)(PROTO_DECL2 fix31 x_set_width, fix31 y_set_width, fix31 xmin, fix31 xmax, fix31 ymin,fix31 ymax);
+ void (*p_start_char)(PROTO_DECL1);
+ void (*p_start_contour)(PROTO_DECL2 fix31 x,fix31 y,boolean outside);
+ void (*p_curve)(PROTO_DECL2 fix31 x1, fix31 y1, fix31 x2, fix31 y2, fix31 x3, fix31 y3);
+ void (*p_line)(PROTO_DECL2 fix31 x, fix31 y);
+ 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
+
+/* ---------------------------------------------------*/
+/**** MAIN GLOBAL DATA STRUCTURE, SPEEDO_GLOBALS *****/
+
+typedef struct speedo_global_data
+ {
+/* do_char.c data definitions */
+#if INCL_METRICS /* Metrics functions supported? */
+ kern_t kern; /* Kerning control block */
+#endif /* endif incl_metrics */
+ point_t Psw; /* End of escapement vector (1/65536 pixel units) */
+
+#if INCL_LCD /* Dynamic load character data supported? */
+ fix15 cb_offset; /* Offset to sub-char data in char buffer */
+#endif /* endif incl_lcd */
+
+/* do_trns.c data definitions */
+ point_t P0; /* Current point (sub-pixels) */
+ fix15 x_orus; /* Current X argument (orus) */
+ fix15 y_orus; /* Current Y argument (orus) */
+ fix15 x_pix; /* Current X argument (sub-pixels) */
+ fix15 y_pix; /* Current Y argument (sub-pixels) */
+ ufix8 x_int; /* Current X interpolation zone */
+ ufix8 y_int; /* Current Y interpolation zone */
+
+#if INCL_MULTIDEV && INCL_OUTLINE
+ outline_t outline_device;
+ boolean outline_device_set;
+#endif
+
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+#if INCL_MULTIDEV
+ bitmap_t bitmap_device;
+ boolean bitmap_device_set;
+#endif
+ band_t y_band; /* Y current band(whole pixels) */
+
+ struct set_width_tag
+ {
+ fix31 x;
+ fix31 y;
+ } set_width; /* Character escapement vector */
+
+ boolean first_pass; /* TRUE during first pass thru outline data */
+ boolean extents_running; /* T if extent accumulation for each vector */
+ fix15 x0_spxl; /* X coord of current point (sub pixels) */
+ fix15 y0_spxl; /* Y coord of current point (sub pixels) */
+ fix15 y_pxl; /* Y coord of current point (whole pixels) */
+#if REENTRANT_ALLOC
+ intercepts_t STACKFAR *intercepts;
+#else /* else if not reentrant */
+ fix15 car[MAX_INTERCEPTS]; /* Data field of intercept storage */
+ cdr_t cdr[MAX_INTERCEPTS]; /* Link field of intercept storage */
+#if INCL_SCREEN
+ ufix8 inttype[MAX_INTERCEPTS];
+ ufix8 leftedge;
+ ufix16 fracpix;
+#endif /* endif incl_screen */
+#endif /* endif reentrant */
+ fix15 bmap_xmin; /* Min X value (sub-pixel units) */
+ fix15 bmap_xmax; /* Max X value (sub-pixel units) */
+ fix15 bmap_ymin; /* Min Y value (sub-pixel units) */
+ fix15 bmap_ymax; /* Max Y value (sub-pixel units) */
+ fix15 no_y_lists; /* Number of active intercept lists */
+ fix15 first_offset; /* Index of first active list cell */
+ fix15 next_offset; /* Index of next free list cell */
+ boolean intercept_oflo; /* TRUE if intercepts data lost */
+#endif /* endif incl_black, incl_screen, incl_2d */
+
+/* bounding box now used by all output modules, including outline */
+ fix15 xmin; /* Min X value in whole character */
+ fix15 xmax; /* Max X value in whole character */
+ fix15 ymin; /* Min Y value in whole character */
+ fix15 ymax; /* Max Y value in whole character */
+
+#if INCL_2D
+ fix15 no_x_lists; /* Number of active x intercept lists */
+ band_t x_band; /* X current band(whole pixels) */
+ boolean x_scan_active; /* X scan flag during scan conversion */
+#endif
+
+/* reset.c data definitions */
+ ufix16 key32; /* Decryption keys 3,2 combined */
+ ufix8 key4; /* Decryption key 4 */
+ ufix8 key6; /* Decryption key 6 */
+ ufix8 key7; /* Decryption key 7 */
+ ufix8 key8; /* Decryption key 8 */
+
+/* set_spcs.c data definitions */
+ buff_t font;
+ buff_t GLOBALFAR *pfont; /* Pointer to font buffer structure */
+ fix31 font_buff_size; /* Number of bytes loaded in font buffer */
+ ufix8 FONTFAR *pchar_dir; /* Pointer to character directory */
+ fix15 first_char_idx; /* Index to first character in font */
+ fix15 no_chars_avail; /* Total characters in font layout */
+ fix15 orus_per_em; /* Outline resolution */
+ fix15 metric_resolution; /* metric resolution for setwidths, kerning pairs
+ (defaults to orus_per_em) */
+ tcb_t tcb0; /* Top level transformation control block */
+
+ boolean specs_valid; /* TRUE if fw_set_specs() successful */
+
+ fix15 depth_adj; /* Curve splitting depth adjustment */
+ boolean curves_out; /* Allow curves to output module */
+ fix15 output_mode; /* Output module selector */
+ fix15 thresh; /* Scan conversion threshold (sub-pixels) */
+ boolean normal; /* TRUE if 0 obl and mult of 90 deg rot */
+
+ fix15 multshift; /* Fixed point shift for multipliers */
+ fix15 pixshift; /* Fixed point shift for sub-pixels */
+ fix15 poshift; /* Left shift from pixel to output format */
+ fix15 mpshift; /* Fixed point shift for mult to sub-pixels */
+ fix31 multrnd; /* 0.5 in multiplier units */
+ fix15 pixrnd; /* 0.5 in sub-pixel units */
+ fix31 mprnd; /* 0.5 sub-pixels in multiplier units */
+ 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);
+ void (*begin_contour)(PROTO_DECL2 point_t P1,boolean outside);
+ void (*curve)(PROTO_DECL2 point_t P1, point_t P2, point_t P3, fix15 depth);
+ void (*line)(PROTO_DECL2 point_t P1);
+ 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 */
+ ufix8 FONTFAR *hdr2_org; /* Pointer to start of private header data */
+
+/* set_trns.c data definitions */
+ tcb_t tcb; /* Current transformation control block */
+ ufix8 Y_edge_org; /* Index to first Y controlled coordinate */
+ ufix8 Y_int_org; /* Index to first Y interpolation zone */
+ fix31 rnd_xmin; /* rounded out value of xmin for int-char spac. fix */
+
+#if REENTRANT_ALLOC
+ plaid_t STACKFAR *plaid;
+#else /* if not reentrant */
+ fix15 orus[MAX_CTRL_ZONES]; /* Controlled coordinate table (orus) */
+#if INCL_RULES
+ fix15 pix[MAX_CTRL_ZONES]; /* Controlled coordinate table (sub-pixels) */
+ fix15 mult[MAX_INT_ZONES]; /* Interpolation multiplier table */
+ fix31 offset[MAX_INT_ZONES]; /* Interpolation offset table */
+#endif /* endif incl_rules */
+#endif /* endif not reentrant */
+
+ fix15 no_X_orus; /* Number of X controlled coordinates */
+ fix15 no_Y_orus; /* Number of Y controlled coordinates */
+ ufix16 Y_constr_org; /* Origin of constraint table in font data */
+
+#if INCL_RULES
+ constr_t constr; /* Constraint data state */
+ boolean c_act[MAX_CONSTR]; /* TRUE if constraint currently active */
+ fix15 c_pix[MAX_CONSTR]; /* Size of constrained zone if active */
+#endif
+#if INCL_ISW
+ boolean import_setwidth_act; /* boolean to indicate imported setwidth */
+ boolean isw_modified_constants;
+ ufix32 imported_width; /* value of imported setwidth */
+ fix15 isw_xmax; /* maximum oru value for constants*/
+#endif
+#if INCL_SQUEEZING || INCL_ISW
+ fix15 setwidth_orus; /* setwidth value in orus */
+ /* bounding box in orus for squeezing */
+ fix15 bbox_xmin_orus; /* X minimum in orus */
+ fix15 bbox_xmax_orus; /* X maximum in orus */
+ fix15 bbox_ymin_orus; /* Y minimum in orus */
+ fix15 bbox_ymax_orus; /* Y maximum in orus */
+#endif
+#ifdef INCL_SQUEEZING
+ boolean squeezing_compound; /* flag to indicate a compound character*/
+#endif
+#ifdef INCL_CLIPPING
+ fix31 clip_xmax;
+ fix31 clip_ymax;
+ fix31 clip_xmin;
+ fix31 clip_ymin;
+#endif
+ } SPEEDO_GLOBALS;
+
+/***********************************************************************************
+ *
+ * Speedo global data structure allocation
+ *
+ ***********************************************************************************/
+
+#ifdef SET_SPCS
+#define EXTERN
+#else
+#define EXTERN extern
+#endif
+#if STATIC_ALLOC
+EXTERN SPEEDO_GLOBALS GLOBALFAR sp_globals;
+#define sp_intercepts sp_globals
+#define sp_plaid sp_globals
+#else
+#if DYNAMIC_ALLOC
+EXTERN SPEEDO_GLOBALS GLOBALFAR *sp_global_ptr;
+#define sp_globals (*sp_global_ptr)
+#define sp_intercepts (*sp_global_ptr)
+#define sp_plaid (*sp_global_ptr)
+#else
+#if REENTRANT_ALLOC
+#define sp_globals (*sp_global_ptr)
+#define sp_intercepts (*(*sp_global_ptr).intercepts)
+#define sp_plaid (*(*sp_global_ptr).plaid)
+#endif
+#endif
+#endif
+#ifdef EXTERN
+#undef EXTERN
+#endif
+
+
+/***** PUBLIC FONT HEADER OFFSET CONSTANTS *****/
+#define FH_FMVER 0 /* U D4.0 CR LF NULL NULL 8 bytes */
+#define FH_FNTSZ 8 /* U Font size (bytes) 4 bytes */
+#define FH_FBFSZ 12 /* U Min font buffer size (bytes) 4 bytes */
+#define FH_CBFSZ 16 /* U Min char buffer size (bytes) 2 bytes */
+#define FH_HEDSZ 18 /* U Header size (bytes) 2 bytes */
+#define FH_FNTID 20 /* U Source Font ID 2 bytes */
+#define FH_SFVNR 22 /* U Source Font Version Number 2 bytes */
+#define FH_FNTNM 24 /* U Source Font Name 70 bytes */
+#define FH_MDATE 94 /* U Manufacturing Date 10 bytes */
+#define FH_LAYNM 104 /* U Layout Name 70 bytes */
+#define FH_CPYRT 174 /* U Copyright Notice 78 bytes */
+#define FH_NCHRL 252 /* U Number of Chars in Layout 2 bytes */
+#define FH_NCHRF 254 /* U Total Number of Chars in Font 2 bytes */
+#define FH_FCHRF 256 /* U Index of first char in Font 2 bytes */
+#define FH_NKTKS 258 /* U Number of kerning tracks in font 2 bytes */
+#define FH_NKPRS 260 /* U Number of kerning pairs in font 2 bytes */
+#define FH_FLAGS 262 /* U Font flags 1 byte: */
+ /* Bit 0: Extended font */
+ /* Bit 1: not used */
+ /* Bit 2: not used */
+ /* Bit 3: not used */
+ /* Bit 4: not used */
+ /* Bit 5: not used */
+ /* Bit 6: not used */
+ /* Bit 7: not used */
+#define FH_CLFGS 263 /* U Classification flags 1 byte: */
+ /* Bit 0: Italic */
+ /* Bit 1: Monospace */
+ /* Bit 2: Serif */
+ /* Bit 3: Display */
+ /* Bit 4: not used */
+ /* Bit 5: not used */
+ /* Bit 6: not used */
+ /* Bit 7: not used */
+#define FH_FAMCL 264 /* U Family Classification 1 byte: */
+ /* 0: Don't care */
+ /* 1: Serif */
+ /* 2: Sans serif */
+ /* 3: Monospace */
+ /* 4: Script or calligraphic */
+ /* 5: Decorative */
+ /* 6-255: not used */
+#define FH_FRMCL 265 /* U Font form Classification 1 byte: */
+ /* Bits 0-3 (width type): */
+ /* 0-3: not used */
+ /* 4: Condensed */
+ /* 5: not used */
+ /* 6: Semi-condensed */
+ /* 7: not used */
+ /* 8: Normal */
+ /* 9: not used */
+ /* 10: Semi-expanded */
+ /* 11: not used */
+ /* 12: Expanded */
+ /* 13-15: not used */
+ /* Bits 4-7 (Weight): */
+ /* 0: not used */
+ /* 1: Thin */
+ /* 2: Ultralight */
+ /* 3: Extralight */
+ /* 4: Light */
+ /* 5: Book */
+ /* 6: Normal */
+ /* 7: Medium */
+ /* 8: Semibold */
+ /* 9: Demibold */
+ /* 10: Bold */
+ /* 11: Extrabold */
+ /* 12: Ultrabold */
+ /* 13: Heavy */
+ /* 14: Black */
+ /* 15-16: not used */
+#define FH_SFNTN 266 /* U Short Font Name 32 bytes */
+#define FH_SFACN 298 /* U Short Face Name 16 bytes */
+#define FH_FNTFM 314 /* U Font form 14 bytes */
+#define FH_ITANG 328 /* U Italic angle 2 bytes (1/256th deg) */
+#define FH_ORUPM 330 /* U Number of ORUs per em 2 bytes */
+#define FH_WDWTH 332 /* U Width of Wordspace 2 bytes */
+#define FH_EMWTH 334 /* U Width of Emspace 2 bytes */
+#define FH_ENWTH 336 /* U Width of Enspace 2 bytes */
+#define FH_TNWTH 338 /* U Width of Thinspace 2 bytes */
+#define FH_FGWTH 340 /* U Width of Figspace 2 bytes */
+#define FH_FXMIN 342 /* U Font-wide min X value 2 bytes */
+#define FH_FYMIN 344 /* U Font-wide min Y value 2 bytes */
+#define FH_FXMAX 346 /* U Font-wide max X value 2 bytes */
+#define FH_FYMAX 348 /* U Font-wide max Y value 2 bytes */
+#define FH_ULPOS 350 /* U Underline position 2 bytes */
+#define FH_ULTHK 352 /* U Underline thickness 2 bytes */
+#define FH_SMCTR 354 /* U Small caps transformation 6 bytes */
+#define FH_DPSTR 360 /* U Display sups transformation 6 bytes */
+#define FH_FNSTR 366 /* U Footnote sups transformation 6 bytes */
+#define FH_ALSTR 372 /* U Alpha sups transformation 6 bytes */
+#define FH_CMITR 378 /* U Chemical infs transformation 6 bytes */
+#define FH_SNMTR 384 /* U Small nums transformation 6 bytes */
+#define FH_SDNTR 390 /* U Small denoms transformation 6 bytes */
+#define FH_MNMTR 396 /* U Medium nums transformation 6 bytes */
+#define FH_MDNTR 402 /* U Medium denoms transformation 6 bytes */
+#define FH_LNMTR 408 /* U Large nums transformation 6 bytes */
+#define FH_LDNTR 414 /* U Large denoms transformation 6 bytes */
+ /* Transformation data format: */
+ /* Y position 2 bytes */
+ /* X scale 2 bytes (1/4096ths) */
+ /* Y scale 2 bytes (1/4096ths) */
+#define SIZE_FW FH_LDNTR + 6 /* size of nominal font header */
+#define EXP_FH_METRES SIZE_FW /* offset to expansion field metric resolution (optional) */
+
+
+
+/***** MODE FLAGS CONSTANTS *****/
+#define CURVES_OUT 0X0008 /* Output module accepts curves */
+#define BOGUS_MODE 0X0010 /* Linear scaling mode */
+#define CONSTR_OFF 0X0020 /* Inhibit constraint table */
+#define IMPORT_WIDTHS 0X0040 /* Imported width mode */
+#define SQUEEZE_LEFT 0X0100 /* Squeeze left mode */
+#define SQUEEZE_RIGHT 0X0200 /* Squeeze right mode */
+#define SQUEEZE_TOP 0X0400 /* Squeeze top mode */
+#define SQUEEZE_BOTTOM 0X0800 /* Squeeze bottom mode */
+#define CLIP_LEFT 0X1000 /* Clip left mode */
+#define CLIP_RIGHT 0X2000 /* Clip right mode */
+#define CLIP_TOP 0X4000 /* Clip top mode */
+#define CLIP_BOTTOM 0X8000 /* Clip bottom mode */
+
+/***********************************************************************************
+ *
+ * Speedo function declarations - use prototypes if available
+ *
+ ***********************************************************************************/
+
+#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);
+#if INCL_ISW
+fix31 sp_compute_isw_scale(PROTO_DECL2);
+static boolean sp_do_make_char(PROTO_DECL2 ufix16 char_index);
+boolean sp_make_char_isw(PROTO_DECL2 ufix16 char_index, ufix32 imported_width);
+static boolean sp_reset_xmax(PROTO_DECL2 fix31 xmax);
+#endif
+#if INCL_ISW || INCL_SQUEEZING
+static void sp_preview_bounding_box(PROTO_DECL2 ufix8 FONTFAR *pointer,ufix8 format);
+#endif
+
+#if INCL_METRICS /* Metrics functions supported? */
+fix31 sp_get_char_width(PROTO_DECL2 ufix16 char_index);
+fix15 sp_get_track_kern(PROTO_DECL2 fix15 track,fix15 point_size);
+fix31 sp_get_pair_kern(PROTO_DECL2 ufix16 char_index1,ufix16 char_index2);
+boolean sp_get_char_bbox(PROTO_DECL2 ufix16 char_index, bbox_t *bbox);
+#endif
+
+/* do_trns.c functions */
+ufix8 FONTFAR *sp_read_bbox(PROTO_DECL2 ufix8 FONTFAR *pointer,point_t STACKFAR *pPmin,point_t STACKFAR *pPmax,boolean set_flag);
+void sp_proc_outl_data(PROTO_DECL2 ufix8 FONTFAR *pointer);
+
+/* out_blk.c functions */
+#if INCL_BLACK
+boolean sp_init_black(PROTO_DECL2 specs_t GLOBALFAR *specsarg);
+boolean sp_begin_char_black(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
+void sp_begin_contour_black(PROTO_DECL2 point_t P1,boolean outside);
+void sp_line_black(PROTO_DECL2 point_t P1);
+boolean sp_end_char_black(PROTO_DECL1);
+#endif
+
+/* out_scrn.c functions */
+#if INCL_SCREEN
+boolean sp_init_screen(PROTO_DECL2 specs_t GLOBALFAR *specsarg);
+boolean sp_begin_char_screen(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
+void sp_begin_contour_screen(PROTO_DECL2 point_t P1,boolean outside);
+void sp_curve_screen(PROTO_DECL2 point_t P1,point_t P2,point_t P3, fix15 depth);
+void sp_scan_curve_screen(PROTO_DECL2 fix31 X0,fix31 Y0,fix31 X1,fix31 Y1,fix31 X2,fix31 Y2,fix31 X3,fix31 Y3);
+void sp_vert_line_screen(PROTO_DECL2 fix31 x, fix15 y1, fix15 y2);
+void sp_line_screen(PROTO_DECL2 point_t P1);
+void sp_end_contour_screen(PROTO_DECL1);
+boolean sp_end_char_screen(PROTO_DECL1);
+#endif
+
+/* out_outl.c functions */
+#if INCL_OUTLINE
+#if INCL_MULTIDEV
+boolean sp_set_outline_device(PROTO_DECL2 outline_t *ofuncs, ufix16 size);
+#endif
+
+
+boolean sp_init_outline(PROTO_DECL2 specs_t GLOBALFAR *specsarg);
+boolean sp_begin_char_outline(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
+void sp_begin_sub_char_outline(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
+void sp_begin_contour_outline(PROTO_DECL2 point_t P1,boolean outside);
+void sp_curve_outline(PROTO_DECL2 point_t P1,point_t P2,point_t P3, fix15 depth);
+void sp_line_outline(PROTO_DECL2 point_t P1);
+void sp_end_contour_outline(PROTO_DECL1);
+void sp_end_sub_char_outline(PROTO_DECL1);
+boolean sp_end_char_outline(PROTO_DECL1);
+#endif
+
+/* out_bl2d.c functions */
+#if INCL_2D
+boolean sp_init_2d(PROTO_DECL2 specs_t GLOBALFAR *specsarg);
+boolean sp_begin_char_2d(PROTO_DECL2 point_t Psw,point_t Pmin,point_t Pmax);
+void sp_begin_contour_2d(PROTO_DECL2 point_t P1,boolean outside);
+void sp_line_2d(PROTO_DECL2 point_t P1);
+boolean sp_end_char_2d(PROTO_DECL1);
+#endif
+
+/* out_util.c functions */
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+
+#if INCL_MULTIDEV
+boolean sp_set_bitmap_device(PROTO_DECL2 bitmap_t *bfuncs, ufix16 size);
+#endif
+
+void sp_init_char_out(PROTO_DECL2 point_t Psw, point_t Pmin, point_t Pmax);
+void sp_begin_sub_char_out(PROTO_DECL2 point_t Psw, point_t Pmin, point_t Pmax);
+void sp_curve_out(PROTO_DECL2 point_t P1, point_t P2, point_t P3, fix15 depth);
+void sp_end_contour_out(PROTO_DECL1);
+void sp_end_sub_char_out(PROTO_DECL1);
+void sp_init_intercepts_out(PROTO_DECL1);
+void sp_restart_intercepts_out(PROTO_DECL1);
+void sp_set_first_band_out(PROTO_DECL2 point_t Pmin, point_t Pmax);
+void sp_reduce_band_size_out(PROTO_DECL1);
+boolean sp_next_band_out(PROTO_DECL1);
+#endif
+
+#if INCL_USEROUT
+boolean sp_init_userout(specs_t *specsarg);
+#endif
+
+
+/* reset.c functions */
+void sp_reset(PROTO_DECL1);
+#if INCL_KEYS
+void sp_set_key(PROTO_DECL2 ufix8 key[]);
+#endif
+ufix16 sp_get_cust_no(PROTO_DECL2 buff_t font_buff);
+
+/* set_spcs.c functions */
+boolean sp_set_specs(PROTO_DECL2 specs_t STACKFAR *specsarg);
+void sp_type_tcb(PROTO_DECL2 tcb_t GLOBALFAR *ptcb);
+
+fix31 sp_read_long(PROTO_DECL2 ufix8 FONTFAR *pointer);
+fix15 sp_read_word_u(PROTO_DECL2 ufix8 FONTFAR *pointer);
+
+/* set_trns.c functions */
+void sp_init_tcb(PROTO_DECL1);
+void sp_scale_tcb(PROTO_DECL2 tcb_t GLOBALFAR *ptcb,fix15 x_pos,fix15 y_pos,fix15 x_scale,fix15 y_scale);
+ufix8 FONTFAR *sp_plaid_tcb(PROTO_DECL2 ufix8 FONTFAR *pointer,ufix8 format);
+ufix8 FONTFAR *sp_skip_interpolation_table(PROTO_DECL2 ufix8 FONTFAR *pointer, ufix8 format);
+ufix8 FONTFAR *sp_skip_control_zone(PROTO_DECL2 ufix8 FONTFAR *pointer, ufix8 format);
+
+ufix8 FONTFAR *sp_read_oru_table(PROTO_DECL2 ufix8 FONTFAR *pointer);
+#if INCL_SQUEEZING || INCL_ISW
+static void sp_calculate_x_pix(PROTO_DECL2 ufix8 start_edge,ufix8 end_edge,ufix16 constr_nr,fix31 x_scale,fix31 x_offset,fix31 ppo,fix15 setwidth_pix);
+#endif
+#if INCL_SQUEEZING
+static void sp_calculate_y_pix(PROTO_DECL2 ufix8 start_edge,ufix8 end_edge,ufix16 constr_nr,fix31 top_scale,fix31 bottom_scale,fix31 ppo,fix15 emtop_pix,fix15 embot_pix);
+boolean sp_calculate_x_scale(PROTO_DECL2 fix31 *x_factor,fix31 *x_offset,fix15 no_x_ctrl_zones);
+boolean sp_calculate_y_scale(PROTO_DECL2 fix31 *top_scale,fix31 *bottom_scale,fix15 first_y_zone, fix15 no_Y_ctrl_zones);
+#endif
+
+
+/* user defined functions */
+
+void sp_report_error(PROTO_DECL2 fix15 n);
+
+#if INCL_BLACK || INCL_SCREEN || INCL_2D
+void sp_open_bitmap(PROTO_DECL2 fix31 x_set_width, fix31 y_set_width, fix31 xorg, fix31 yorg, fix15 xsize,fix15 ysize);
+void sp_set_bitmap_bits(PROTO_DECL2 fix15 y, fix15 xbit1, fix15 xbit2);
+void sp_close_bitmap(PROTO_DECL1);
+#endif
+
+#if INCL_OUTLINE
+void sp_open_outline(PROTO_DECL2 fix31 x_set_width, fix31 y_set_width, fix31 xmin, fix31 xmax, fix31 ymin,fix31 ymax);
+void sp_start_new_char(PROTO_DECL1);
+void sp_start_contour(PROTO_DECL2 fix31 x,fix31 y,boolean outside);
+void sp_curve_to(PROTO_DECL2 fix31 x1, fix31 y1, fix31 x2, fix31 y2, fix31 x3, fix31 y3);
+void sp_line_to(PROTO_DECL2 fix31 x, fix31 y);
+void sp_close_contour(PROTO_DECL1);
+void sp_close_outline(PROTO_DECL1);
+#endif
+
+#if INCL_LCD /* Dynamic load character data supported? */
+buff_t *sp_load_char_data(PROTO_DECL2 fix31 file_offset,fix15 no_bytes,fix15 cb_offset); /* Load character data from font file */
+#endif
+
+#if INCL_PLAID_OUT /* Plaid data monitoring included? */
+void sp_record_xint(PROTO_DECL2 fix15 int_num); /* Record xint data */
+void sp_record_yint(PROTO_DECL2 fix15 int_num); /* Record yint data */
+void sp_begin_plaid_data(PROTO_DECL1); /* Signal start of plaid data */
+void sp_begin_ctrl_zones(PROTO_DECL2 fix15, no_X_zones, fix15 no_Y_zones); /* Signal start of control zones */
+void sp_record_ctrl_zone(PROTO_DECL2 fix31 start, fix31 end, fix15 constr); /* Record control zone data */
+void sp_begin_int_zones(PROTO_DECL2 fix15 no_X_int_zones, fix15 no_Y_int_zones); /* Signal start of interpolation zones */
+void sp_record_int_zone(PROTO_DECL2 fix31 start, fix31 end); /* Record interpolation zone data */
+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
new file mode 100644
index 0000000..b74e71d
--- /dev/null
+++ b/src/Speedo/spencode.c
@@ -0,0 +1,62 @@
+/* $Xorg: spencode.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "spint.h"
+
+#include "bics-iso.h"
+
+int sp_bics_map_size = (sizeof(sp_bics_map) / (sizeof(int) * 2));
+
+#ifdef EXTRAFONTS
+#include "adobe-iso.h"
+
+int adobe_map_size = (sizeof(adobe_map) / (sizeof(int) * 2));
+
+#endif /* EXTRAFONTS */
diff --git a/src/Speedo/sperr.c b/src/Speedo/sperr.c
new file mode 100644
index 0000000..8d94d85
--- /dev/null
+++ b/src/Speedo/sperr.c
@@ -0,0 +1,134 @@
+/* $Xorg: sperr.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of M.I.T., Network Computing Devices,
+ * or Digital not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. M.I.T. Network Computing Devices, or Digital
+ * make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES, DIGITAL AND MIT DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, DIGITAL OR MIT BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+#include "spint.h"
+
+#if NeedVarargsPrototypes
+#include <stdarg.h>
+
+void
+SpeedoErr(char *str, ...)
+{
+ va_list v;
+ int a1;
+
+ va_start(v, str);
+ ErrorF("Speedo: ");
+ a1 = va_arg(v, int);
+ ErrorF(str, a1);
+ 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.
+ *
+ * Since character data not available is one of those errors
+ * that happens many times, don't report it to user
+ */
+void
+sp_report_error(n)
+ fix15 n;
+{
+ switch (n) {
+ case 1:
+ SpeedoErr("Insufficient font data loaded\n");
+ break;
+ case 3:
+ SpeedoErr("Transformation matrix out of range\n");
+ break;
+ case 4:
+ SpeedoErr("Font format error\n");
+ break;
+ case 5:
+ SpeedoErr("Requested specs not compatible with output module\n");
+ break;
+ case 7:
+ SpeedoErr("Intelligent transformation requested but not supported\n");
+ break;
+ case 8:
+ SpeedoErr("Unsupported output mode requested\n");
+ break;
+ case 9:
+ SpeedoErr("Extended font loaded but only compact fonts supported\n");
+ break;
+ case 10:
+ SpeedoErr("Font specs not set prior to use of font\n");
+ break;
+ case 12:
+ break;
+ case 13:
+ SpeedoErr("Track kerning data not available()\n");
+ break;
+ case 14:
+ SpeedoErr("Pair kerning data not available()\n");
+ break;
+ default:
+ SpeedoErr("report_error(%d)\n", n);
+ break;
+ }
+}
diff --git a/src/Speedo/spfile.c b/src/Speedo/spfile.c
new file mode 100644
index 0000000..2eac82e
--- /dev/null
+++ b/src/Speedo/spfile.c
@@ -0,0 +1,349 @@
+/* $Xorg: spfile.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Dave Lemke, Network Computing Devices Inc
+ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <stdio.h>
+#include "fntfilst.h"
+
+#include "spint.h"
+
+SpeedoFontPtr sp_fp_cur = (SpeedoFontPtr) 0;
+
+#ifdef EXTRAFONTS
+#include "ncdkeys.h"
+#endif
+
+#include "keys.h"
+
+#ifdef EXTRAFONTS
+static ufix8 skey[] =
+{
+ SKEY0,
+ SKEY1,
+ SKEY2,
+ SKEY3,
+ SKEY4,
+ SKEY5,
+ SKEY6,
+ SKEY7,
+ SKEY8
+}; /* Sample Font decryption key */
+
+static ufix8 rkey[] =
+{
+ RKEY0,
+ RKEY1,
+ RKEY2,
+ RKEY3,
+ RKEY4,
+ RKEY5,
+ RKEY6,
+ RKEY7,
+ RKEY8
+}; /* Retail Font decryption key */
+
+#endif /* EXTRAFONTS */
+
+#ifdef XSAMPLEFONTS
+static ufix8 xkey[] =
+{
+ XKEY0,
+ XKEY1,
+ XKEY2,
+ XKEY3,
+ XKEY4,
+ XKEY5,
+ XKEY6,
+ XKEY7,
+ XKEY8
+}; /* Sample Font decryption key */
+#endif
+
+static ufix8 mkey[] =
+{
+ KEY0,
+ KEY1,
+ KEY2,
+ KEY3,
+ KEY4,
+ KEY5,
+ KEY6,
+ KEY7,
+ KEY8
+}; /* Font decryption key */
+
+
+static fix15
+read_2b(ptr)
+ ufix8 *ptr;
+{
+ fix15 tmp;
+
+ tmp = *ptr++;
+ tmp = (tmp << 8) + *ptr;
+ return tmp;
+}
+
+static fix31
+read_4b(ptr)
+ ufix8 *ptr;
+{
+ fix31 tmp;
+
+ tmp = *ptr++;
+ tmp = (tmp << 8) + *ptr++;
+ tmp = (tmp << 8) + *ptr++;
+ tmp = (tmp << 8) + *ptr;
+ return tmp;
+}
+
+/*
+ * 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;
+{
+ SpeedoMasterFontPtr master = sp_fp_cur->master;
+
+ if (fseek(master->fp, (long) file_offset, (int) 0)) {
+ SpeedoErr("can't seek to char\n");
+ }
+ if ((num + cb_offset) > master->mincharsize) {
+ SpeedoErr("char buf overflow\n");
+ }
+ if (fread((master->c_buffer + cb_offset), sizeof(ufix8), num,
+ master->fp) != num) {
+ SpeedoErr("can't get char data\n");
+ }
+ master->char_data.org = (ufix8 *) master->c_buffer + cb_offset;
+ master->char_data.no_bytes = num;
+
+ return &master->char_data;
+}
+
+int
+sp_open_master(filename, master)
+ char *filename;
+ SpeedoMasterFontPtr *master;
+{
+ SpeedoMasterFontPtr spmf;
+ ufix8 tmp[16];
+ ufix16 cust_no;
+ FILE *fp;
+ ufix32 minbufsize;
+ ufix16 mincharsize;
+ ufix8 *f_buffer;
+ ufix8 *c_buffer;
+ int ret;
+ ufix8 *key;
+
+ spmf = (SpeedoMasterFontPtr) xalloc(sizeof(SpeedoMasterFontRec));
+ if (!spmf)
+ return AllocError;
+ bzero(spmf, sizeof(SpeedoMasterFontRec));
+ spmf->entry = NULL;
+ spmf->f_buffer = NULL;
+ spmf->c_buffer = NULL;
+
+ /* open font */
+ spmf->fname = (char *) xalloc(strlen(filename) + 1);
+ if (!spmf->fname)
+ return AllocError;
+ fp = fopen(filename, "r");
+ if (!fp) {
+ ret = BadFontName;
+ goto cleanup;
+ }
+ strcpy(spmf->fname, filename);
+ spmf->fp = fp;
+ spmf->state |= MasterFileOpen;
+
+ if (fread(tmp, sizeof(ufix8), 16, fp) != 16) {
+ ret = BadFontName;
+ goto cleanup;
+ }
+ minbufsize = (ufix32) read_4b(tmp + FH_FBFSZ);
+ f_buffer = (ufix8 *) xalloc(minbufsize);
+ if (!f_buffer) {
+ ret = AllocError;
+ goto cleanup;
+ }
+ spmf->f_buffer = f_buffer;
+
+ fseek(fp, (ufix32) 0, 0);
+
+ /* read in the font */
+ if (fread(f_buffer, sizeof(ufix8), (ufix16) minbufsize, fp) != minbufsize) {
+ ret = BadFontName;
+ goto cleanup;
+ }
+ spmf->copyright = (char *) (f_buffer + FH_CPYRT);
+ spmf->mincharsize = mincharsize = read_2b(f_buffer + FH_CBFSZ);
+
+ c_buffer = (ufix8 *) xalloc(mincharsize);
+ if (!c_buffer) {
+ ret = AllocError;
+ goto cleanup;
+ }
+ spmf->c_buffer = c_buffer;
+
+ spmf->font.org = spmf->f_buffer;
+ spmf->font.no_bytes = minbufsize;
+
+ cust_no = sp_get_cust_no(spmf->font);
+
+ /* XXX add custom encryption stuff here */
+
+#ifdef EXTRAFONTS
+ if (cust_no == SCUS0) {
+ key = skey;
+ } else if (cust_no == RCUS0) {
+ key = rkey;
+ } else
+#endif
+
+#ifdef XSAMPLEFONTS
+ if (cust_no == XCUS0) {
+ key = xkey;
+ } else
+#endif
+
+ if (cust_no == CUS0) {
+ key = mkey;
+ } else {
+ SpeedoErr("Non - standard encryption for \"%s\"\n", filename);
+ ret = BadFontName;
+ goto cleanup;
+ }
+ spmf->key = key;
+ sp_set_key(key);
+
+ spmf->first_char_id = read_2b(f_buffer + FH_FCHRF);
+ spmf->num_chars = read_2b(f_buffer + FH_NCHRL);
+
+
+ spmf->enc = sp_bics_map;
+ spmf->enc_size = sp_bics_map_size;
+
+#ifdef EXTRAFONTS
+ { /* choose the proper encoding */
+ char *f;
+
+ f = strrchr(filename, '/');
+ if (f) {
+ f++;
+ if (strncmp(f, "bx113", 5) == 0) {
+ spmf->enc = adobe_map;
+ spmf->enc_size = adobe_map_size;
+ }
+ }
+ }
+#endif
+
+ /* XXX slam back to ISO Latin1 */
+ spmf->first_char_id = spmf->enc[0];
+ /* size of extents array */
+ spmf->max_id = spmf->enc[(spmf->enc_size - 1) * 2];
+ spmf->num_chars = spmf->enc_size;
+
+ *master = spmf;
+
+ return Successful;
+
+cleanup:
+ *master = (SpeedoMasterFontPtr) 0;
+ sp_close_master_font(spmf);
+ return ret;
+}
+
+void
+sp_close_master_font(spmf)
+ SpeedoMasterFontPtr spmf;
+{
+ if (!spmf)
+ return;
+ if (spmf->state & MasterFileOpen)
+ fclose(spmf->fp);
+ if (spmf->entry)
+ spmf->entry->u.scalable.extra->private = NULL;
+ xfree(spmf->fname);
+ xfree(spmf->f_buffer);
+ xfree(spmf->c_buffer);
+ xfree(spmf);
+}
+
+void
+sp_close_master_file(spmf)
+ SpeedoMasterFontPtr spmf;
+{
+ (void) fclose(spmf->fp);
+ spmf->state &= ~MasterFileOpen;
+}
+
+
+/*
+ * reset the encryption key, and make sure the file is opened
+ */
+void
+sp_reset_master(spmf)
+ SpeedoMasterFontPtr spmf;
+{
+ sp_set_key(spmf->key);
+ if (!(spmf->state & MasterFileOpen)) {
+ spmf->fp = fopen(spmf->fname, "r");
+ /* XXX -- what to do if we can't open the file? */
+ spmf->state |= MasterFileOpen;
+ }
+ fseek(spmf->fp, 0, 0);
+}
diff --git a/src/Speedo/spfont.c b/src/Speedo/spfont.c
new file mode 100644
index 0000000..ebfc526
--- /dev/null
+++ b/src/Speedo/spfont.c
@@ -0,0 +1,450 @@
+/* $Xorg: spfont.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Dave Lemke, Network Computing Devices Inc
+ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/*
+ * Speedo font loading
+ */
+
+#include "FSproto.h"
+#include "spint.h"
+#include <servermd.h>
+#ifdef _XOPEN_SOURCE
+#include <math.h>
+#else
+#define _XOPEN_SOURCE /* to get prototype for hypot on some systems */
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+
+#ifndef M_PI
+#define M_PI 3.14159
+#endif /* M_PI */
+#ifndef DEFAULT_BIT_ORDER
+
+#ifdef BITMAP_BIT_ORDER
+#define DEFAULT_BIT_ORDER BITMAP_BIT_ORDER
+#else
+#define DEFAULT_BIT_ORDER UNKNOWN_BIT_ORDER
+#endif
+
+#endif
+
+extern void SpeedoCloseFont();
+static int sp_get_glyphs();
+static int sp_get_metrics();
+static int sp_load_font();
+
+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 */
+{
+ SpeedoFontPtr spf;
+ unsigned int firstCol;
+ register unsigned int numCols;
+ unsigned int firstRow;
+ unsigned int numRows;
+ CharInfoPtr *glyphsBase;
+ register unsigned int c;
+ register CharInfoPtr pci;
+ unsigned int r;
+ CharInfoPtr encoding;
+ CharInfoPtr pDefault;
+ int itemSize;
+ int err = Successful;
+
+ spf = (SpeedoFontPtr) pFont->fontPrivate;
+ encoding = spf->encoding;
+ pDefault = spf->pDefault;
+ firstCol = pFont->info.firstCol;
+ numCols = pFont->info.lastCol - firstCol + 1;
+ glyphsBase = glyphs;
+
+
+ /* XXX - this should be much smarter */
+ /* make sure the glyphs are there */
+ if (charEncoding == Linear8Bit || charEncoding == TwoD8Bit)
+ itemSize = 1;
+ else
+ itemSize = 2;
+
+#ifdef notyet
+ if (!fsd->complete)
+ err = fs_load_glyphs(NULL, pFont, count, itemSize, chars);
+#endif
+
+ if (err != Successful)
+ return err;
+
+ switch (charEncoding) {
+
+ case Linear8Bit:
+ case TwoD8Bit:
+ if (pFont->info.firstRow > 0)
+ break;
+ if (pFont->info.allExist && pDefault) {
+ while (count--) {
+ c = (*chars++) - firstCol;
+ if (c < numCols)
+ *glyphs++ = &encoding[c];
+ else
+ *glyphs++ = pDefault;
+ }
+ } else {
+ while (count--) {
+ c = (*chars++) - firstCol;
+ if (c < numCols && (pci = &encoding[c])->bits)
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ }
+ break;
+ case Linear16Bit:
+ if (pFont->info.allExist && pDefault) {
+ while (count--) {
+ c = *chars++ << 8;
+ c = (c | *chars++) - firstCol;
+ if (c < numCols)
+ *glyphs++ = &encoding[c];
+ else
+ *glyphs++ = pDefault;
+ }
+ } else {
+ while (count--) {
+ c = *chars++ << 8;
+ c = (c | *chars++) - firstCol;
+ if (c < numCols && (pci = &encoding[c])->bits)
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ }
+ break;
+
+ case TwoD16Bit:
+ firstRow = pFont->info.firstRow;
+ numRows = pFont->info.lastRow - firstRow + 1;
+ while (count--) {
+ r = (*chars++) - firstRow;
+ c = (*chars++) - firstCol;
+ if (r < numRows && c < numCols &&
+ (pci = &encoding[r * numCols + c])->bits)
+ *glyphs++ = pci;
+ else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ }
+ *glyphCount = glyphs - glyphsBase;
+ return Successful;
+}
+
+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 */
+{
+ int ret;
+ SpeedoFontPtr spf;
+ CharInfoPtr oldDefault;
+
+ spf = (SpeedoFontPtr) pFont->fontPrivate;
+ oldDefault = spf->pDefault;
+ spf->pDefault = &nonExistantChar;
+ ret = sp_get_glyphs(pFont, count, chars, charEncoding,
+ glyphCount, (CharInfoPtr *) glyphs);
+
+ spf->pDefault = oldDefault;
+ return ret;
+}
+
+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;
+{
+ SpeedoFontPtr spf;
+ SpeedoMasterFontPtr spmf;
+ int ret;
+ specs_t specs;
+ int xx8, xy8, yx8, yy8;
+
+ /* find a master (create it if necessary) */
+ spmf = (SpeedoMasterFontPtr) entry->u.scalable.extra->private;
+ if (!spmf)
+ {
+ ret = sp_open_master(filename, &spmf);
+ if (ret != Successful)
+ return ret;
+ entry->u.scalable.extra->private = (pointer) spmf;
+ spmf->entry = entry;
+ }
+
+ spf = (SpeedoFontPtr) xalloc(sizeof(SpeedoFontRec));
+ if (!spf)
+ return AllocError;
+ bzero((char *) spf, sizeof(SpeedoFontRec));
+
+ *spfont = spf;
+
+ /* clobber everything -- this may be leaking, but other wise evil
+ * stuff is left behind -- succesive transformed fonts get mangled */
+ bzero((char *)&sp_globals, sizeof(sp_globals));
+
+ spf->master = spmf;
+ spf->entry = entry;
+ spmf->refcount++;
+ sp_reset_master(spmf);
+ /* now we've done enough that if we bail out we must call sp_close_font */
+
+ spf->vals = *vals;
+
+ /* set up specs */
+
+ specs.pfont = &spmf->font;
+
+ specs.xxmult = (int)(vals->pixel_matrix[0] * (double)(1L << 16));
+ specs.xymult = (int)(vals->pixel_matrix[2] * (double)(1L << 16));
+ specs.yxmult = (int)(vals->pixel_matrix[1] * (double)(1L << 16));
+ specs.yymult = (int)(vals->pixel_matrix[3] * (double)(1L << 16));
+
+ specs.xoffset = 0L << 16; /* XXX tweak? */
+ specs.yoffset = 0L << 16; /* XXX tweak? */
+
+ specs.flags = MODE_SCREEN;
+ specs.out_info = NULL;
+
+ /* When Speedo tries to generate a very small font bitmap, it
+ often crashes or goes into an infinite loop.
+ Don't know why this is so, but until we can fix it properly,
+ return BadFontName for anything smaller than 4 pixels.
+ */
+#define TINY_FACTOR (16 << 16)
+ xx8 = specs.xxmult >> 8;
+ xy8 = specs.xymult >> 8;
+ yx8 = specs.yxmult >> 8;
+ yy8 = specs.yymult >> 8;
+ if (xx8 * xx8 + xy8 * xy8 < TINY_FACTOR ||
+ yx8 * yx8 + yy8 * yy8 < TINY_FACTOR)
+ {
+ sp_close_font(spf);
+ return BadFontName;
+ }
+
+ /* clobber global state to avoid wrecking future transformed fonts */
+ bzero ((char *) &sp_globals, sizeof(sp_globals));
+
+ if (!sp_set_specs(&specs))
+ {
+ sp_close_font(spf);
+ return BadFontName;
+ }
+
+ spf->specs = specs;
+ spf->master = spmf;
+
+ *spfont = spf;
+ return Successful;
+}
+
+static int
+sp_load_font(fontname, filename, entry, vals, format, fmask, pfont, flags)
+ char *fontname,
+ *filename;
+ FontEntryPtr entry;
+ FontScalablePtr vals;
+ fsBitmapFormat format;
+ fsBitmapFormatMask fmask;
+ FontPtr pfont;
+ Mask flags;
+{
+ SpeedoFontPtr spf;
+ SpeedoMasterFontPtr spmf;
+ int esize;
+ int ret;
+ long sWidth;
+
+ ret = sp_open_font(fontname, filename, entry, vals, format, fmask,
+ flags, &spf);
+
+ if (ret != Successful)
+ return ret;
+
+ spmf = spf->master;
+ sp_reset_master(spmf);
+ esize = sizeof(CharInfoRec) * (spmf->max_id - spmf->first_char_id + 1);
+
+ spf->encoding = (CharInfoPtr) xalloc(esize);
+ if (!spf->encoding) {
+ sp_close_font(spf);
+ return AllocError;
+ }
+ bzero((char *) spf->encoding, esize);
+
+ sp_fp_cur = spf;
+
+ sp_make_header(spf, &pfont->info);
+
+ sp_compute_bounds(spf, &pfont->info, SaveMetrics, &sWidth);
+
+ sp_compute_props(spf, fontname, &pfont->info, sWidth);
+
+ pfont->fontPrivate = (pointer) spf;
+
+/* XXX */
+ flags |= FontLoadBitmaps;
+
+ if (flags & FontLoadBitmaps) {
+ sp_fp_cur = spf;
+ ret = sp_build_all_bitmaps(pfont, format, fmask);
+ }
+ if (ret != Successful)
+ return ret;
+
+ /* compute remaining accelerators */
+ FontComputeInfoAccelerators(&pfont->info);
+
+ pfont->format = format;
+
+ pfont->get_metrics = sp_get_metrics;
+ pfont->get_glyphs = sp_get_glyphs;
+ 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);
+
+ return ret;
+}
+
+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;
+{
+ FontPtr pfont;
+ int ret;
+
+ /* Reject ridiculously small 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;
+
+ pfont = (FontPtr) xalloc(sizeof(FontRec));
+ if (!pfont) {
+ return AllocError;
+ }
+ ret = sp_load_font(fontname, filename, entry, vals, format, fmask,
+ pfont, flags);
+
+ if (ret == Successful)
+ *ppfont = pfont;
+ else
+ xfree (pfont);
+
+ return ret;
+}
+
+void
+sp_close_font(spf)
+ SpeedoFontPtr spf;
+{
+ SpeedoMasterFontPtr spmf;
+
+ spmf = spf->master;
+ --spmf->refcount;
+ if (spmf->refcount == 0)
+ sp_close_master_font (spmf);
+ xfree(spf->encoding);
+ xfree(spf->bitmaps);
+ xfree(spf);
+}
+
+void
+SpeedoCloseFont(pfont)
+ FontPtr pfont;
+{
+ SpeedoFontPtr spf;
+
+ spf = (SpeedoFontPtr) pfont->fontPrivate;
+ sp_close_font(spf);
+ xfree(pfont->info.isStringProp);
+ xfree(pfont->info.props);
+ xfree(pfont->devPrivates);
+ xfree(pfont);
+}
diff --git a/src/Speedo/spfuncs.c b/src/Speedo/spfuncs.c
new file mode 100644
index 0000000..0cd09ee
--- /dev/null
+++ b/src/Speedo/spfuncs.c
@@ -0,0 +1,161 @@
+/* $Xorg: spfuncs.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Dave Lemke, Network Computing Devices, Inc
+ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <X11/Xos.h>
+#include "fntfilst.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 */
+{
+ char fullName[MAXFONTNAMELEN];
+
+ strcpy (fullName, entry->name.name);
+ return SpeedoFontLoad (pFont, fullName, fileName, entry, vals,
+ format, fmask, flags);
+}
+
+/*
+ * XXX
+ *
+ * this does a lot more then i'd like, but it has to get the bitmaps
+ * in order to get accurate metrics (which it *must* have).
+ *
+ * a possible optimization is to avoid allocating the glyph memory
+ * 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;
+{
+ SpeedoFontPtr spf;
+ int err;
+ long sWidth;
+
+ err = sp_open_font(fontname, filename, entry, vals,
+ (fsBitmapFormat) 0, (fsBitmapFormatMask) 0, (unsigned long) 0,
+ &spf);
+
+ if (err != Successful)
+ return err;
+
+ sp_fp_cur = spf;
+ sp_reset_master(spf->master);
+
+ sp_make_header(spf, pinfo);
+
+ sp_compute_bounds(spf, pinfo, (unsigned long) 0, &sWidth);
+
+ sp_compute_props(spf, fontname, pinfo, sWidth);
+
+ /* compute remaining accelerators */
+ FontComputeInfoAccelerators (pinfo);
+
+ *spfont = spf;
+
+ return Successful;
+}
+
+/* ARGSUSED */
+int
+SpeedoGetInfoScaleable(fpe, pFontInfo, entry, fontName, fileName, vals)
+ FontPathElementPtr fpe;
+ FontInfoPtr pFontInfo;
+ FontEntryPtr entry;
+ FontNamePtr fontName;
+ char *fileName;
+ FontScalablePtr vals;
+{
+ SpeedoFontPtr spf = NULL;
+ char fullName[MAXFONTNAMELEN];
+ int err;
+
+ strcpy(fullName, entry->name.name);
+ FontParseXLFDName(fullName, vals, FONT_XLFD_REPLACE_VALUE);
+
+ err = get_font_info(pFontInfo, fullName, fileName, entry, vals, &spf);
+
+ if (spf)
+ sp_close_font(spf);
+
+ return err;
+}
+
+static FontRendererRec renderer = {
+ ".spd", 4, (int (*)()) 0, SpeedoOpenScalable,
+ (int (*)()) 0, SpeedoGetInfoScaleable, 0
+ , CAP_MATRIX | CAP_CHARSUBSETTING
+};
+
+void
+SpeedoRegisterFontFileFunctions()
+{
+ sp_make_standard_props();
+ sp_reset();
+ FontFileRegisterRenderer(&renderer);
+}
diff --git a/src/Speedo/spglyph.c b/src/Speedo/spglyph.c
new file mode 100644
index 0000000..ff0f370
--- /dev/null
+++ b/src/Speedo/spglyph.c
@@ -0,0 +1,403 @@
+/* $Xorg: spglyph.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Dave Lemke, Network Computing Devices Inc
+ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <X11/X.h> /* for bit order #defines */
+#include "spint.h"
+
+#undef CLIP_BBOX_NOISE
+
+static CurrentFontValuesRec current_font_values;
+static CurrentFontValuesPtr cfv = &current_font_values;
+static int bit_order,
+ byte_order,
+ scan;
+
+unsigned long
+sp_compute_data_size(pfont, mappad, scanlinepad, start, end)
+ FontPtr pfont;
+ int mappad,
+ scanlinepad;
+ unsigned long start,
+ end;
+{
+ unsigned long ch;
+ unsigned long size = 0;
+ int bpr;
+ SpeedoFontPtr spf = (SpeedoFontPtr) pfont->fontPrivate;
+ FontInfoPtr pinfo = &pfont->info;
+ int firstChar;
+
+ firstChar = spf->master->first_char_id;
+
+ /* allocate the space */
+ switch (mappad) {
+ int charsize;
+ CharInfoPtr ci;
+ xCharInfo *cim;
+
+ case BitmapFormatImageRectMin:
+ cfv->bpr = 0;
+ for (ch = start; ch <= end; ch++) {
+ ci = &spf->encoding[ch - firstChar];
+ if (!ci)
+ ci = spf->pDefault;
+ cim = &ci->metrics;
+ charsize = GLYPH_SIZE(ci, scanlinepad);
+ charsize *= cim->ascent + cim->descent;
+ size += charsize;
+ }
+ break;
+ case BitmapFormatImageRectMaxWidth:
+ bpr = GLWIDTHBYTESPADDED(FONT_MAX_WIDTH(pinfo), scanlinepad);
+ cfv->bpr = bpr;
+ for (ch = start; ch <= end; ch++) {
+ ci = &spf->encoding[ch - firstChar];
+ if (!ci)
+ ci = spf->pDefault;
+ cim = &ci->metrics;
+ charsize = bpr * (cim->ascent + cim->descent);
+ size += charsize;
+ }
+ break;
+ case BitmapFormatImageRectMax:
+ bpr = GLWIDTHBYTESPADDED(FONT_MAX_WIDTH(pinfo), scanlinepad);
+ cfv->bpr = bpr;
+ size = (end - start + 1) * bpr * FONT_MAX_HEIGHT(pinfo);
+ break;
+ default:
+ assert(0);
+ }
+
+ return size;
+}
+
+static void
+finish_line(spf)
+ SpeedoFontPtr spf;
+{
+ int bpr = cfv->bpr;
+ CharInfoPtr ci = &spf->encoding[cfv->char_id - spf->master->first_char_id];
+
+ if (bpr == 0) {
+ bpr = GLYPH_SIZE(ci, cfv->scanpad);
+ }
+ if (bpr) { /* char may not have any metrics... */
+ 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;
+{
+ int nmiddle;
+ CARD8 startmask,
+ endmask;
+ CARD8 *dst;
+
+ if (xbit1 > cfv->bit_width) {
+
+#ifdef CLIP_BBOX_NOISE
+ SpeedoErr("Run wider than bitmap width -- truncated\n");
+#endif
+
+ xbit1 = cfv->bit_width;
+ }
+ if (xbit2 > cfv->bit_width) {
+
+#ifdef CLIP_BBOX_NOISE
+ SpeedoErr("Run wider than bitmap width -- truncated\n");
+#endif
+
+ xbit2 = cfv->bit_width;
+ }
+
+ if (xbit2 < xbit1) {
+ xbit2 = xbit1;
+ }
+
+ while (cfv->cur_y != y) {
+ finish_line(sp_fp_cur);
+ cfv->cur_y++;
+ }
+
+ cfv->last_y = y;
+ if (y >= cfv->bit_height) {
+
+#ifdef CLIP_BBOX_NOISE
+ SpeedoErr("Y larger than bitmap height -- truncated\n");
+#endif
+
+ cfv->trunc = 1;
+ return;
+ }
+ if (xbit1 < 0) /* XXX this is more than a little bit rude... */
+ xbit1 = 0;
+
+ nmiddle = (xbit1 >> 3);
+ dst = (CARD8 *) (cfv->bp + nmiddle);
+ xbit2 -= (xbit1 & ~7);
+ nmiddle = (xbit2 >> 3);
+ xbit1 &= 7;
+ xbit2 &= 7;
+ if (bit_order == MSBFirst) {
+ startmask = ((CARD8) ~0) >> xbit1;
+ endmask = ~(((CARD8) ~0) >> xbit2);
+ } else {
+ startmask = ((CARD8) ~0) << xbit1;
+ endmask = ~(((CARD8) ~0) << xbit2);
+ }
+ if (nmiddle == 0)
+ *dst |= endmask & startmask;
+ else {
+ *dst++ |= startmask;
+ while (--nmiddle)
+ *dst++ = (CARD8)~0;
+ *dst |= endmask;
+ }
+}
+
+/* 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;
+{
+ CharInfoPtr ci = &sp_fp_cur->encoding[cfv->char_id - sp_fp_cur->master->first_char_id];
+
+/*-
+ * this is set to provide better quality bitmaps. since the Speedo
+ * sp_get_bbox() function returns an approximate (but guarenteed to contain)
+ * set of metrics, some of the bitmaps can be place poorly inside and
+ * look bad.
+ *
+ * with this set, the actual bitmap values are used instead of the bboxes.
+ * it makes things look better, but causes two possible problems:
+ *
+ * 1 - the reported min & max bounds may not correspond to the extents
+ * reported
+ * 2 - if the extents are reported before the character is generated,
+ * a client could see them change. this currently never happens,
+ * but will when a desired enhancement (don't reneder till needed)
+ * is made.
+ */
+
+#define BBOX_FIXUP 1
+
+#ifdef BBOX_FIXUP
+ int off_horz;
+ int off_vert;
+
+ if (xorg < 0)
+ off_horz = (fix15) ((xorg - 32768L) / 65536);
+ else
+ off_horz = (fix15) ((xorg + 32768L) / 65536);
+ if (yorg < 0)
+ off_vert = (fix15) ((yorg - 32768L) / 65536);
+ else
+ off_vert = (fix15) ((yorg + 32768L) / 65536);
+ if (xsize != 0 || ysize != 0 || ci->metrics.characterWidth)
+ {
+ ci->metrics.leftSideBearing = off_horz;
+ ci->metrics.descent = -off_vert;
+ ci->metrics.rightSideBearing = xsize + off_horz;
+ ci->metrics.ascent = ysize + off_vert;
+ }
+ else
+ {
+ /* If setting the proper size would cause the character to appear to
+ be non-existent, fudge things by giving it a pixel to occupy. */
+ xsize = ysize = 1;
+ ci->metrics.leftSideBearing = ci->metrics.descent = 0;
+ ci->metrics.rightSideBearing = ci->metrics.ascent = 1;
+ }
+
+ cfv->bit_width = xsize;
+ cfv->bit_height = ysize;
+#else
+ cfv->bit_width = ci->metrics.rightSideBearing -
+ ci->metrics.leftSideBearing;
+ cfv->bit_height = ci->metrics.ascent + ci->metrics.descent;
+#endif
+
+ assert(cfv->bp - sp_fp_cur->bitmaps <= sp_fp_cur->bitmap_size);
+ ci->bits = (char *) cfv->bp;
+
+ cfv->cur_y = 0;
+}
+
+void
+sp_close_bitmap()
+{
+ CharInfoPtr ci = &sp_fp_cur->encoding[cfv->char_id - sp_fp_cur->master->first_char_id];
+ int bpr = cfv->bpr;
+
+ if (bpr == 0)
+ bpr = GLYPH_SIZE(ci, cfv->scanpad);
+ if (!cfv->trunc)
+ finish_line(sp_fp_cur);
+ cfv->trunc = 0;
+ cfv->last_y++;
+ while (cfv->last_y < cfv->bit_height) {
+ finish_line(sp_fp_cur);
+ cfv->last_y++;
+ }
+ if (byte_order != bit_order) {
+ switch (scan) {
+ case 1:
+ break;
+ case 2:
+ TwoByteSwap(cfv->bp, bpr * cfv->bit_height);
+ break;
+ case 4:
+ FourByteSwap(cfv->bp, bpr * cfv->bit_height);
+ break;
+ }
+ }
+}
+
+int
+sp_build_all_bitmaps(pfont, format, fmask)
+ FontPtr pfont;
+ fsBitmapFormat format;
+ fsBitmapFormatMask fmask;
+{
+ int ret,
+ glyph = 1,
+ image = BitmapFormatImageRectMin;
+ unsigned long glyph_size;
+ SpeedoFontPtr spf = (SpeedoFontPtr) pfont->fontPrivate;
+ SpeedoMasterFontPtr spmf = spf->master;
+ pointer bitmaps;
+ int start,
+ end,
+ i;
+
+ scan = 1;
+ ret = CheckFSFormat(format, fmask,
+ &bit_order, &byte_order, &scan, &glyph, &image);
+
+ pfont->bit = bit_order;
+ pfont->byte = byte_order;
+ pfont->glyph = glyph;
+ pfont->scan = scan;
+ if (ret != Successful)
+ return BadFontFormat;
+
+ start = spmf->first_char_id;
+ end = spmf->max_id;
+ glyph_size = sp_compute_data_size(pfont, image, glyph, start, end);
+
+ /* XXX -- MONDO KLUDGE -- add some slop */
+ /*
+ * not sure why this is wanted, but it keeps the packer from going off the
+ * end and toasting us down the line
+ */
+ glyph_size += 20;
+
+#ifdef DEBUG
+ spf->bitmap_size = glyph_size;
+#endif
+
+ bitmaps = (pointer) xalloc(glyph_size);
+ if (!bitmaps)
+ return AllocError;
+ bzero((char *) bitmaps, glyph_size);
+
+ /* set up some state */
+ sp_fp_cur = spf;
+ spf->bitmaps = bitmaps;
+ cfv->format = format;
+ cfv->scanpad = glyph;
+ cfv->bp = bitmaps;
+
+ for (i = 0; i < spmf->num_chars; i++) {
+ int j;
+ cfv->char_index = spmf->enc[i * 2 + 1];
+ cfv->char_id = spmf->enc[i * 2];
+#if DEBUG
+fprintf(stderr, "build_all_sp_bitmaps:i = %d, Char ID = %d\n", i, cfv->char_id);
+#endif
+ if (!cfv->char_id)
+ continue;
+
+ /*
+ * See if this character is in the list of ranges specified in the
+ * XLFD name
+ */
+ for (j = 0; j < spf->vals.nranges; j++)
+ if (cfv->char_id >= mincharno(spf->vals.ranges[j]) &&
+ cfv->char_id <= maxcharno(spf->vals.ranges[j]))
+ break;
+
+ /* If not, don't realize it. */
+ if (spf->vals.nranges && j == spf->vals.nranges)
+ continue;
+
+ if (!sp_make_char(cfv->char_index)) {
+
+#ifdef DEBUG /* can be very common with some encodings */
+ SpeedoErr("Can't make char %d\n", cfv->char_index);
+#endif
+ }
+ }
+
+ return Successful;
+}
diff --git a/src/Speedo/spinfo.c b/src/Speedo/spinfo.c
new file mode 100644
index 0000000..05d3f24
--- /dev/null
+++ b/src/Speedo/spinfo.c
@@ -0,0 +1,441 @@
+/* $Xorg: spinfo.c,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Dave Lemke, Network Computing Devices, Inc
+ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "fntfilst.h"
+#include "spint.h"
+#include <math.h>
+
+/* percentage of pointsize used to specify ascent & descent */
+#define STRETCH_FACTOR 120
+
+enum scaleType {
+ atom, truncate_atom, pixel_size, point_size, resolution_x,
+ resolution_y, average_width
+};
+
+typedef struct _fontProp {
+ char *name;
+ long atom;
+ enum scaleType type;
+} fontProp;
+
+static fontProp fontNamePropTable[] = {
+ { "FOUNDRY", 0, atom },
+ { "FAMILY_NAME", 0, atom },
+ { "WEIGHT_NAME", 0, atom },
+ { "SLANT", 0, atom },
+ { "SETWIDTH_NAME", 0, atom },
+ { "ADD_STYLE_NAME", 0, atom },
+ { "PIXEL_SIZE", 0, pixel_size },
+ { "POINT_SIZE", 0, point_size },
+ { "RESOLUTION_X", 0, resolution_x },
+ { "RESOLUTION_Y", 0, resolution_y },
+ { "SPACING", 0, atom },
+ { "AVERAGE_WIDTH", 0, average_width },
+ { "CHARSET_REGISTRY", 0, atom },
+ { "CHARSET_ENCODING", 0, truncate_atom }
+};
+
+/* Warning: following array is closely related to the sequence of
+ defines after it. */
+
+static fontProp extraProps[] = {
+ { "FONT", 0, },
+ { "COPYRIGHT", 0, },
+ { "RAW_PIXEL_SIZE", 0, },
+ { "RAW_POINT_SIZE", 0, },
+ { "RAW_ASCENT", 0, },
+ { "RAW_DESCENT", 0, },
+ { "RAW_AVERAGE_WIDTH", 0, }
+};
+
+/* this is a bit kludgy */
+#define FONTPROP 0
+#define COPYRIGHTPROP 1
+#define RAWPIXELPROP 2
+#define RAWPOINTPROP 3
+#define RAWASCENTPROP 4
+#define RAWDESCENTPROP 5
+#define RAWWIDTHPROP 6
+
+
+#define NNAMEPROPS (sizeof(fontNamePropTable) / sizeof(fontProp))
+#define NEXTRAPROPS (sizeof(extraProps) / sizeof(fontProp))
+
+#define NPROPS (NNAMEPROPS + NEXTRAPROPS)
+
+extern Atom MakeAtom();
+
+void
+sp_make_standard_props()
+{
+ int i;
+ fontProp *t;
+
+ 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);
+}
+
+void
+sp_make_header(spf, pinfo)
+ SpeedoFontPtr spf;
+ FontInfoPtr pinfo;
+{
+ int pixel_size;
+ SpeedoMasterFontPtr spmf = spf->master;
+
+ pinfo->firstCol = spmf->first_char_id & 0xff;
+ pinfo->firstRow = spmf->first_char_id >> 8;
+ pinfo->lastCol = spmf->max_id & 0xff;
+ pinfo->lastRow = spmf->max_id >> 8;
+
+ /* XXX -- hackery here */
+ pinfo->defaultCh = 0;
+/* computed by FontComputeInfoAccelerators:
+ * noOverlap
+ * constantMetrics
+ * terminalFont
+ * constantWidth
+ * inkInside
+ */
+ pinfo->inkMetrics = 0;
+ pinfo->allExist = 0;
+ pinfo->drawDirection = LeftToRight;
+ pinfo->cachable = 1;
+ if (spf->specs.xxmult != spf->specs.yymult)
+ pinfo->anamorphic = TRUE;
+ else
+ pinfo->anamorphic = FALSE;
+/* computed by sp_compute_bounds:
+ * maxOverlap
+ * maxbounds
+ * minbounds
+ * ink_maxbounds
+ * ink_minbounds
+ */
+ pixel_size = spf->vals.pixel_matrix[3] * STRETCH_FACTOR / 100;
+ pinfo->fontAscent = pixel_size * 764 / 1000; /* 764 == EM_TOP */
+ pinfo->fontDescent = pixel_size - pinfo->fontAscent;
+}
+
+static void
+adjust_min_max(minc, maxc, tmp)
+ xCharInfo *minc,
+ *maxc,
+ *tmp;
+{
+#define MINMAX(field,ci) \
+ if (minc->field > (ci)->field) \
+ minc->field = (ci)->field; \
+ if (maxc->field < (ci)->field) \
+ maxc->field = (ci)->field;
+
+ MINMAX(ascent, tmp);
+ MINMAX(descent, tmp);
+ MINMAX(leftSideBearing, tmp);
+ MINMAX(rightSideBearing, tmp);
+ MINMAX(characterWidth, tmp);
+
+ if ((INT16)minc->attributes > (INT16)tmp->attributes)
+ minc->attributes = tmp->attributes;
+ if ((INT16)maxc->attributes < (INT16)tmp->attributes)
+ maxc->attributes = tmp->attributes;
+
+#undef MINMAX
+}
+
+
+void
+sp_compute_bounds(spf, pinfo, flags, sWidth)
+ SpeedoFontPtr spf;
+ FontInfoPtr pinfo;
+ unsigned long flags;
+ long *sWidth;
+{
+ int i,
+ id,
+ index,
+ maxOverlap,
+ overlap,
+ total_width = 0;
+ xCharInfo minchar,
+ maxchar,
+ tmpchar;
+ bbox_t bbox;
+ fix31 width;
+ double pix_width;
+ SpeedoMasterFontPtr spmf = spf->master;
+ int firstChar;
+ int num_chars = 0;
+
+ firstChar = spmf->first_char_id;
+ 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;
+ maxOverlap = -32767;
+ *sWidth = 0;
+ for (i = 0; i < spmf->num_chars; i++) {
+ int j;
+ int char_id;
+
+ index = spmf->enc[i * 2 + 1];
+ char_id = spmf->enc[i * 2];
+ /*
+ * See if this character is in the list of ranges specified in the
+ * XLFD name
+ */
+ for (j = 0; j < spf->vals.nranges; j++)
+ if (char_id >= mincharno(spf->vals.ranges[j]) &&
+ char_id <= maxcharno(spf->vals.ranges[j]))
+ break;
+ if (spf->vals.nranges && j == spf->vals.nranges)
+ continue;
+ num_chars++;
+
+ if (!(flags & ComputeBoundsOnly)) {
+
+ width = sp_get_char_width(index);
+
+ /* convert to pixel coords */
+ pix_width = (int)width * (spf->specs.xxmult / 65536L) +
+ ((int) width * (spf->specs.xxmult % 65536L))
+ / 65536L;
+ pix_width /= 65536L;
+
+ (void) sp_get_char_bbox(index, &bbox);
+ bbox.ymax = (bbox.ymax + 32768L) >> 16;
+ bbox.ymin = (bbox.ymin + 32768L) >> 16;
+ bbox.xmin = (bbox.xmin + 32768L) >> 16;
+ bbox.xmax = (bbox.xmax + 32768L) >> 16;
+ tmpchar.ascent = bbox.ymax;
+ tmpchar.descent = -bbox.ymin;
+ tmpchar.characterWidth = (int)(pix_width + /* round */
+ (pix_width > 0 ? 0.5 : -0.5));
+ tmpchar.rightSideBearing = bbox.xmax;
+ tmpchar.leftSideBearing = bbox.xmin;
+
+ if (!tmpchar.characterWidth &&
+ tmpchar.ascent == -tmpchar.descent &&
+ tmpchar.rightSideBearing == tmpchar.leftSideBearing)
+ {
+ /* Character appears non-existent, probably as a result
+ of the transformation. Let's give it one pixel in
+ the universe so it's not mistaken for non-existent. */
+ tmpchar.leftSideBearing = tmpchar.descent = 0;
+ tmpchar.rightSideBearing = tmpchar.ascent = 1;
+ }
+
+ tmpchar.attributes = (int)((double)(int)width / 65.536 + .5);
+ }
+ else
+ tmpchar = spf->encoding[char_id - firstChar].metrics;
+
+ adjust_min_max(&minchar, &maxchar, &tmpchar);
+ overlap = tmpchar.rightSideBearing - tmpchar.characterWidth;
+ if (maxOverlap < overlap)
+ maxOverlap = overlap;
+
+ total_width += ((int)(INT16)tmpchar.attributes);
+ *sWidth += abs((int)(INT16)tmpchar.attributes);
+
+ if (flags & SaveMetrics) {
+ id = spmf->enc[i * 2] - firstChar;
+ assert(id <= spmf->max_id - firstChar);
+ spf->encoding[id].metrics = tmpchar;
+ }
+ }
+
+
+ if (num_chars > 0)
+ {
+ *sWidth = (int)(((double)*sWidth * 10.0 + (double)num_chars / 2.0) /
+ num_chars);
+ if (total_width < 0)
+ {
+ /* Predominant direction is R->L */
+ *sWidth = -*sWidth;
+ }
+ spf->vals.width = (int)((double)*sWidth * spf->vals.pixel_matrix[0] /
+ 1000.0 +
+ (spf->vals.pixel_matrix[0] > 0 ? .5 : -.5));
+ }
+ else
+ {
+ spf->vals.width = 0;
+ }
+ pinfo->maxbounds = maxchar;
+ pinfo->minbounds = minchar;
+ pinfo->ink_maxbounds = maxchar;
+ pinfo->ink_minbounds = minchar;
+ pinfo->maxOverlap = maxOverlap;
+}
+
+void
+sp_compute_props(spf, fontname, pinfo, sWidth)
+ SpeedoFontPtr spf;
+ char *fontname;
+ FontInfoPtr pinfo;
+ long sWidth;
+{
+ FontPropPtr pp;
+ int i,
+ nprops;
+ fontProp *fpt;
+ char *is_str;
+ char *ptr1,
+ *ptr2;
+ char *ptr3;
+ char tmpname[1024];
+ FontScalableRec tmpvals;
+
+ 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;
+ return;
+ }
+ bzero(pinfo->isStringProp, (sizeof(char) * nprops));
+
+ ptr2 = fontname;
+ 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:
+ *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)(spf->vals.pixel_matrix[3] +
+ (spf->vals.pixel_matrix[3] > 0 ? .5 : -.5));
+ break;
+ case point_size:
+ pp->value = (int)(spf->vals.point_matrix[3] * 10.0 +
+ (spf->vals.point_matrix[3] > 0 ? .5 : -.5));
+ break;
+ case resolution_x:
+ pp->value = spf->vals.x;
+ break;
+ case resolution_y:
+ pp->value = spf->vals.y;
+ break;
+ case average_width:
+ pp->value = spf->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;
+ strcpy(tmpname, fontname);
+ FontParseXLFDName(tmpname, &tmpvals, FONT_XLFD_REPLACE_ZERO);
+ FontParseXLFDName(tmpname, &spf->vals, FONT_XLFD_REPLACE_VALUE);
+ pp->value = MakeAtom(tmpname, strlen(tmpname), TRUE);
+ break;
+ case COPYRIGHTPROP:
+ *is_str = TRUE;
+ pp->value = MakeAtom(spf->master->copyright,
+ strlen(spf->master->copyright), TRUE);
+ break;
+ case RAWPIXELPROP:
+ *is_str = FALSE;
+ pp->value = 1000;
+ break;
+ case RAWPOINTPROP:
+ *is_str = FALSE;
+ pp->value = (long)(72270.0 / (double)spf->vals.y + .5);
+ break;
+ case RAWASCENTPROP:
+ *is_str = FALSE;
+ pp->value = STRETCH_FACTOR * 764 / 100;
+ break;
+ case RAWDESCENTPROP:
+ *is_str = FALSE;
+ pp->value = STRETCH_FACTOR * 236 / 100;
+ break;
+ case RAWWIDTHPROP:
+ *is_str = FALSE;
+ pp->value = sWidth;
+ break;
+ }
+ }
+}
diff --git a/src/Speedo/spint.h b/src/Speedo/spint.h
new file mode 100644
index 0000000..d915238
--- /dev/null
+++ b/src/Speedo/spint.h
@@ -0,0 +1,172 @@
+/* $Xorg: spint.h,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#ifndef _SPINT_H_
+#define _SPINT_H_
+
+#include <stdio.h>
+#include "fntfilst.h"
+#include <X11/Xfuncproto.h>
+#include "speedo.h"
+
+#define SaveMetrics 0x1
+#define ComputeBoundsOnly 0x2
+
+#define GLWIDTHBYTESPADDED(bits,nbytes) \
+ ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
+ :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
+ :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
+ :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
+ : 0)
+
+#define GLYPH_SIZE(ch, nbytes) \
+ GLWIDTHBYTESPADDED((ch)->metrics.rightSideBearing - \
+ (ch)->metrics.leftSideBearing, (nbytes))
+
+#define mincharno(p) ((p).min_char_low + ((p).min_char_high << 8))
+#define maxcharno(p) ((p).max_char_low + ((p).max_char_high << 8))
+
+#define MasterFileOpen 0x1
+
+typedef struct _sp_master {
+ FontEntryPtr entry; /* back pointer */
+ FILE *fp;
+ char *fname;
+ ufix8 *f_buffer;
+ ufix8 *c_buffer;
+ char *copyright;
+ ufix8 *key;
+ buff_t font;
+ buff_t char_data;
+ ufix16 mincharsize;
+ int first_char_id;
+ int num_chars;
+ int max_id;
+ int state; /* open, closed */
+ int refcount; /* number of instances */
+ int *enc;
+ int enc_size;
+} SpeedoMasterFontRec, *SpeedoMasterFontPtr;
+
+typedef struct _cur_font_stats {
+ fsBitmapFormat format;
+ /* current glyph info */
+ ufix16 char_index;
+ ufix16 char_id;
+
+ fix15 bit_width,
+ bit_height;
+ fix15 cur_y;
+ int bpr;
+
+ /*
+ * since Speedo returns extents that are not identical to what it feeds to
+ * the bitmap builder, and we want to be able to use the extents for
+ * preformance reasons, some of the bitmaps require padding out. the next
+ * two flags keep track of this.
+ */
+ fix15 last_y;
+ int trunc;
+
+ pointer bp;
+ int scanpad;
+} CurrentFontValuesRec, *CurrentFontValuesPtr;
+
+
+typedef struct _sp_font {
+ struct _sp_master *master;
+ specs_t specs;
+
+ FontEntryPtr entry;
+
+ FontScalableRec vals;
+
+ /* char & metric data */
+ CharInfoPtr encoding;
+ CharInfoPtr pDefault;
+ pointer bitmaps;
+
+#ifdef DEBUG
+ unsigned long bitmap_size;
+#endif
+
+} SpeedoFontRec, *SpeedoFontPtr;
+
+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 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 int sp_bics_map[];
+extern int sp_bics_map_size;
+
+#ifdef EXTRAFONTS
+extern int adobe_map[];
+extern int adobe_map_size;
+
+#endif
+
+#endif /* _SPINT_H_ */
diff --git a/src/Speedo/useropt.h b/src/Speedo/useropt.h
new file mode 100644
index 0000000..e879aae
--- /dev/null
+++ b/src/Speedo/useropt.h
@@ -0,0 +1,41 @@
+/* $Xorg: useropt.h,v 1.4 2001/02/09 02:04:00 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define INCL_LCD 1
+#define STATIC_ALLOC 1
+
+#define INCL_BLACK 1
+#define INCL_SCREEN 1
+#define INCL_2D 1
+#define SHORT_LISTS 0
+
+#define INCL_RULES 1
+#define INCL_METRICS 1
+
+#define INCL_KEYS 1
diff --git a/src/Type1/arith.c b/src/Type1/arith.c
new file mode 100644
index 0000000..65162ea
--- /dev/null
+++ b/src/Type1/arith.c
@@ -0,0 +1,484 @@
+/* $Xorg: arith.c,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+ /* ARITH CWEB V0006 ******** */
+/*
+:h1.ARITH Module - Portable Module for Multiple Precision Fixed Point Arithmetic
+
+This module provides division and multiplication of 64-bit fixed point
+numbers. (To be more precise, the module works on numbers that take
+two 'longs' to store. That is almost always equivalent to saying 64-bit
+numbers.)
+
+Note: it is frequently easy and desirable to recode these functions in
+assembly language for the particular processor being used, because
+assembly language, unlike C, will have 64-bit multiply products and
+64-bit dividends. This module is offered as a portable version.
+
+&author. Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com) and Sten F. Andler
+
+
+:h3.Include Files
+
+The included files are:
+*/
+
+#include "objects.h"
+#include "spaces.h"
+#include "arith.h"
+
+/*
+:h3.
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+Reference for all algorithms: Donald E. Knuth, "The Art of Computer
+Programming, Volume 2, Semi-Numerical Algorithms," Addison-Wesley Co.,
+Massachusetts, 1969, pp. 229-279.
+
+Knuth talks about a 'digit' being an arbitrary sized unit and a number
+being a sequence of digits. We'll take a digit to be a 'short'.
+The following assumption must be valid for these algorithms to work:
+:ol.
+:li.A 'long' is two 'short's.
+:eol.
+The following code is INDEPENDENT of:
+:ol.
+:li.The actual size of a short.
+:li.Whether shorts and longs are stored most significant byte
+first or least significant byte first.
+:eol.
+
+SHORTSIZE is the number of bits in a short; LONGSIZE is the number of
+bits in a long; MAXSHORT is the maximum unsigned short:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+ASSEMBLE concatenates two shorts to form a long:
+*/
+#define ASSEMBLE(hi,lo) ((((unsigned long)hi)<<SHORTSIZE)+(lo))
+/*
+HIGHDIGIT extracts the most significant short from a long; LOWDIGIT
+extracts the least significant short from a long:
+*/
+#define HIGHDIGIT(u) ((u)>>SHORTSIZE)
+#define LOWDIGIT(u) ((u)&MAXSHORT)
+
+/*
+SIGNBITON tests the high order bit of a long 'w':
+*/
+#define SIGNBITON(w) (((long)w)<0)
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h2.Double Long Arithmetic
+
+:h3.DLmult() - Multiply Two Longs to Yield a Double Long
+
+The two multiplicands must be positive.
+*/
+
+void DLmult(product, u, v)
+ register doublelong *product;
+ register unsigned long u;
+ register unsigned long v;
+{
+#ifdef LONG64
+/* printf("DLmult(? ?, %lx, %lx)\n", u, v); */
+ *product = u*v;
+/* printf("DLmult returns %lx\n", *product); */
+#else
+ register unsigned long u1, u2; /* the digits of u */
+ register unsigned long v1, v2; /* the digits of v */
+ register unsigned int w1, w2, w3, w4; /* the digits of w */
+ register unsigned long t; /* temporary variable */
+/* printf("DLmult(? ?, %x, %x)\n", u, v); */
+ u1 = HIGHDIGIT(u);
+ u2 = LOWDIGIT(u);
+ v1 = HIGHDIGIT(v);
+ v2 = LOWDIGIT(v);
+
+ if (v2 == 0) w4 = w3 = w2 = 0;
+ else
+ {
+ t = u2 * v2;
+ w4 = LOWDIGIT(t);
+ t = u1 * v2 + HIGHDIGIT(t);
+ w3 = LOWDIGIT(t);
+ w2 = HIGHDIGIT(t);
+ }
+
+ if (v1 == 0) w1 = 0;
+ else
+ {
+ t = u2 * v1 + w3;
+ w3 = LOWDIGIT(t);
+ t = u1 * v1 + w2 + HIGHDIGIT(t);
+ w2 = LOWDIGIT(t);
+ w1 = HIGHDIGIT(t);
+ }
+
+ product->high = ASSEMBLE(w1, w2);
+ product->low = ASSEMBLE(w3, w4);
+#endif /* LONG64 else */
+}
+
+/*
+:h2.DLdiv() - Divide Two Longs by One Long, Yielding Two Longs
+
+Both the dividend and the divisor must be positive.
+*/
+
+void DLdiv(quotient, divisor)
+ doublelong *quotient; /* also where dividend is, originally */
+ unsigned long divisor;
+{
+#ifdef LONG64
+/* printf("DLdiv(%lx %lx)\n", quotient, divisor); */
+ *quotient /= divisor;
+/* printf("DLdiv returns %lx\n", *quotient); */
+#else
+ register unsigned long u1u2 = quotient->high;
+ register unsigned long u3u4 = quotient->low;
+ register long u3; /* single digit of dividend */
+ register int v1,v2; /* divisor in registers */
+ register long t; /* signed copy of u1u2 */
+ register int qhat; /* guess at the quotient digit */
+ register unsigned long q3q4; /* low two digits of quotient */
+ register int shift; /* holds the shift value for normalizing */
+ register int j; /* loop variable */
+
+/* printf("DLdiv(%x %x, %x)\n", quotient->high, quotient->low, divisor); */
+ /*
+ * Knuth's algorithm works if the dividend is smaller than the
+ * divisor. We can get to that state quickly:
+ */
+ if (u1u2 >= divisor) {
+ quotient->high = u1u2 / divisor;
+ u1u2 %= divisor;
+ }
+ else
+ quotient->high = 0;
+
+ if (divisor <= MAXSHORT) {
+
+ /*
+ * This is the case where the divisor is contained in one
+ * 'short'. It is worthwhile making this fast:
+ */
+ u1u2 = ASSEMBLE(u1u2, HIGHDIGIT(u3u4));
+ q3q4 = u1u2 / divisor;
+ u1u2 %= divisor;
+ u1u2 = ASSEMBLE(u1u2, LOWDIGIT(u3u4));
+ quotient->low = ASSEMBLE(q3q4, u1u2 / divisor);
+ return;
+ }
+
+
+ /*
+ * At this point the divisor is a true 'long' so we must use
+ * Knuth's algorithm.
+ *
+ * Step D1: Normalize divisor and dividend (this makes our 'qhat'
+ * guesses more accurate):
+ */
+ for (shift=0; !SIGNBITON(divisor); shift++, divisor <<= 1) { ; }
+ shift--;
+ divisor >>= 1;
+
+ if ((u1u2 >> (LONGSIZE - shift)) != 0 && shift != 0)
+ abort("DLdiv: dividend too large");
+ u1u2 = (u1u2 << shift) + ((shift == 0) ? 0 : u3u4 >> (LONGSIZE - shift));
+ u3u4 <<= shift;
+
+ /*
+ * Step D2: Begin Loop through digits, dividing u1,u2,u3 by v1,v2,
+ * then shifting U left by 1 digit:
+ */
+ v1 = HIGHDIGIT(divisor);
+ v2 = LOWDIGIT(divisor);
+ q3q4 = 0;
+ u3 = HIGHDIGIT(u3u4);
+
+ for (j=0; j < 2; j++) {
+
+ /*
+ * Step D3: make a guess (qhat) at the next quotient denominator:
+ */
+ qhat = (HIGHDIGIT(u1u2) == v1) ? MAXSHORT : u1u2 / v1;
+ /*
+ * At this point Knuth would have us further refine our
+ * guess, since we know qhat is too big if
+ *
+ * v2 * qhat > ASSEMBLE(u1u2 % v, u3)
+ *
+ * That would make sense if u1u2 % v was easy to find, as it
+ * would be in assembly language. I ignore this step, and
+ * repeat step D6 if qhat is too big.
+ */
+
+ /*
+ * Step D4: Multiply v1,v2 times qhat and subtract it from
+ * u1,u2,u3:
+ */
+ u3 -= qhat * v2;
+ /*
+ * The high digit of u3 now contains the "borrow" for the
+ * rest of the substraction from u1,u2.
+ * Sometimes we can lose the sign bit with the above.
+ * If so, we have to force the high digit negative:
+ */
+ t = HIGHDIGIT(u3);
+ if (t > 0)
+ t |= -1 << SHORTSIZE;
+ t += u1u2 - qhat * v1;
+/* printf("..>divide step qhat=%x t=%x u3=%x u1u2=%x v1=%x v2=%x\n",
+ qhat, t, u3, u1u2, v1, v2); */
+ while (t < 0) { /* Test is Step D5. */
+
+ /*
+ * D6: Oops, qhat was too big. Add back in v1,v2 and
+ * decrease qhat by 1:
+ */
+ u3 = LOWDIGIT(u3) + v2;
+ t += HIGHDIGIT(u3) + v1;
+ qhat--;
+/* printf("..>>qhat correction t=%x u3=%x qhat=%x\n", t, u3, qhat); */
+ }
+ /*
+ * Step D7: shift U left one digit and loop:
+ */
+ u1u2 = t;
+ if (HIGHDIGIT(u1u2) != 0)
+ abort("divide algorithm error");
+ u1u2 = ASSEMBLE(u1u2, LOWDIGIT(u3));
+ u3 = LOWDIGIT(u3u4);
+ q3q4 = ASSEMBLE(q3q4, qhat);
+ }
+ quotient->low = q3q4;
+/* printf("DLdiv returns %x %x\n", quotient->high, quotient->low); */
+#endif /* !LONG64 */
+ return;
+}
+
+/*
+:h3.DLadd() - Add Two Double Longs
+
+In this case, the doublelongs may be signed. The algorithm takes the
+piecewise sum of the high and low longs, with the possibility that the
+high should be incremented if there is a carry out of the low. How to
+tell if there is a carry? Alex Harbury suggested that if the sum of
+the lows is less than the max of the lows, there must have been a
+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;
+{
+#ifdef LONG64
+/* printf("DLadd(%lx %lx)\n", *u, *v); */
+ *u = *u + *v;
+/* printf("DLadd returns %lx\n", *u); */
+#else
+ register unsigned long lowmax = MAX(u->low, v->low);
+
+/* printf("DLadd(%x %x, %x %x)\n", u->high, u->low, v->high, v->low); */
+ u->high += v->high;
+ u->low += v->low;
+ if (lowmax > u->low)
+ u->high++;
+#endif
+}
+/*
+:h3.DLsub() - Subtract Two Double Longs
+
+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;
+{
+#ifdef LONG64
+/* printf("DLsub(%lx %lx)\n", *u, *v); */
+ *u = *u - *v;
+/* printf("DLsub returns %lx\n", *u); */
+#else
+/* printf("DLsub(%x %x, %x %x)\n", u->high, u->low, v->high, v->low);*/
+ u->high -= v->high;
+ if (v->low > u->low)
+ u->high--;
+ u->low -= v->low;
+#endif
+}
+/*
+:h3.DLrightshift() - Macro to Shift Double Long Right by N
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h2.Fractional Pel Arithmetic
+*/
+/*
+:h3.FPmult() - Multiply Two Fractional Pel Values
+
+This funtion first calculates w = u * v to "doublelong" precision.
+It then shifts w right by FRACTBITS bits, and checks that no
+overflow will occur when the resulting value is passed back as
+a fractpel.
+*/
+
+fractpel FPmult(u, v)
+ register fractpel u,v;
+{
+ doublelong w;
+ register int negative = FALSE; /* sign flag */
+#ifdef LONG64
+ register fractpel ret;
+#endif
+
+ if ((u == 0) || (v == 0)) return (0);
+
+
+ if (u < 0) {u = -u; negative = TRUE;}
+ if (v < 0) {v = -v; negative = !negative;}
+
+ if (u == TOFRACTPEL(1)) return ((negative) ? -v : v);
+ if (v == TOFRACTPEL(1)) return ((negative) ? -u : u);
+
+ DLmult(&w, u, v);
+ DLrightshift(w, FRACTBITS);
+#ifndef LONG64
+ if (w.high != 0 || SIGNBITON(w.low)) {
+ IfTrace2(TRUE,"FPmult: overflow, %px%p\n", u, v);
+ w.low = TOFRACTPEL(MAXSHORT);
+ }
+
+ return ((negative) ? -w.low : w.low);
+#else
+ if (w & 0xffffffff80000000L ) {
+ IfTrace2(TRUE,"FPmult: overflow, %px%p\n", u, v);
+ ret = TOFRACTPEL(MAXSHORT);
+ }
+ else
+ ret = (fractpel)w;
+
+ return ((negative) ? -ret : ret);
+#endif
+}
+
+/*
+:h3.FPdiv() - Divide Two Fractional Pel Values
+
+These values may be signed. The function returns the quotient.
+*/
+
+fractpel FPdiv(dividend, divisor)
+ register fractpel dividend;
+ register fractpel divisor;
+{
+ doublelong w; /* result will be built here */
+ int negative = FALSE; /* flag for sign bit */
+#ifdef LONG64
+ register fractpel ret;
+#endif
+
+ if (dividend < 0) {
+ dividend = -dividend;
+ negative = TRUE;
+ }
+ if (divisor < 0) {
+ divisor = -divisor;
+ negative = !negative;
+ }
+#ifndef LONG64
+ w.low = dividend << FRACTBITS;
+ w.high = dividend >> (LONGSIZE - FRACTBITS);
+ DLdiv(&w, divisor);
+ if (w.high != 0 || SIGNBITON(w.low)) {
+ IfTrace2(TRUE,"FPdiv: overflow, %p/%p\n", dividend, divisor);
+ w.low = TOFRACTPEL(MAXSHORT);
+ }
+ return( (negative) ? -w.low : w.low);
+#else
+ w = ((long)dividend) << FRACTBITS;
+ DLdiv(&w, divisor);
+ if (w & 0xffffffff80000000L ) {
+ IfTrace2(TRUE,"FPdiv: overflow, %p/%p\n", dividend, divisor);
+ ret = TOFRACTPEL(MAXSHORT);
+ }
+ else
+ ret = (fractpel)w;
+ return( (negative) ? -ret : ret);
+#endif
+}
+
+/*
+:h3.FPstarslash() - Multiply then Divide
+
+Borrowing a chapter from the language Forth, it is useful to define
+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 */
+{
+ doublelong w; /* result will be built here */
+ int negative = FALSE;
+#ifdef LONG64
+ register fractpel ret;
+#endif
+
+ if (a < 0) { a = -a; negative = TRUE; }
+ if (b < 0) { b = -b; negative = !negative; }
+ if (c < 0) { c = -c; negative = !negative; }
+
+ DLmult(&w, a, b);
+ DLdiv(&w, c);
+#ifndef LONG64
+ if (w.high != 0 || SIGNBITON(w.low)) {
+ IfTrace3(TRUE,"FPstarslash: overflow, %p*%p/%p\n", a, b, c);
+ w.low = TOFRACTPEL(MAXSHORT);
+ }
+ return((negative) ? -w.low : w.low);
+#else
+ if (w & 0xffffffff80000000L ) {
+ IfTrace3(TRUE,"FPstarslash: overflow, %p*%p/%p\n", a, b, c);
+ ret = TOFRACTPEL(MAXSHORT);
+ }
+ else
+ ret = (fractpel)w;
+ return( (negative) ? -ret : ret);
+#endif
+}
diff --git a/src/Type1/arith.h b/src/Type1/arith.h
new file mode 100644
index 0000000..ab9412b
--- /dev/null
+++ b/src/Type1/arith.h
@@ -0,0 +1,70 @@
+/* $Xorg: arith.h,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+/*SHARED*/
+
+#include <X11/Xmd.h> /* LONG64 */
+
+void DLmult(),DLdiv(),DLadd(),DLsub();
+
+fractpel FPmult();
+fractpel FPdiv();
+fractpel FPstarslash();
+
+/*END SHARED*/
+/*SHARED*/
+
+#define SHORTSIZE (sizeof(short)*8)
+#define LONGSIZE (SHORTSIZE*2)
+#define MAXSHORT ((1<<SHORTSIZE)-1)
+
+/*END SHARED*/
+/*SHARED*/
+
+#ifdef LONG64
+typedef long doublelong;
+#else
+typedef struct {
+ long high;
+ unsigned long low;
+} doublelong;
+#endif /* LONG64 else */
+
+/*END SHARED*/
+/*SHARED*/
+
+#ifdef LONG64
+#define DLrightshift(dl,N) ((dl) >>= (N))
+#else
+#define DLrightshift(dl,N) { \
+ dl.low = (dl.low >> N) + (((unsigned long) dl.high) << (LONGSIZE - N)); \
+ dl.high >>= N; \
+}
+#endif
+
+/*END SHARED*/
diff --git a/src/Type1/blues.h b/src/Type1/blues.h
new file mode 100644
index 0000000..2480b14
--- /dev/null
+++ b/src/Type1/blues.h
@@ -0,0 +1,93 @@
+/* $Xorg: blues.h,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ * Portions Copyright (c) 1990 Adobe Systems Incorporated.
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM or Lexmark or Adobe
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission.
+ *
+ * IBM, LEXMARK, AND ADOBE PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY
+ * WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE
+ * ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING
+ * ANY DUTY TO SUPPORT OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY
+ * PORTION OF THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM,
+ * LEXMARK, OR ADOBE) ASSUMES THE ENTIRE COST OF ALL SERVICING, REPAIR AND
+ * CORRECTION. IN NO EVENT SHALL IBM, LEXMARK, OR ADOBE BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+extern psobj *GetType1CharString();
+
+#define TOPLEFT 1
+#define BOTTOMRIGHT 2
+
+#define NUMBLUEVALUES 14
+#define NUMOTHERBLUES 10
+#define NUMFAMILYBLUES 14
+#define NUMFAMILYOTHERBLUES 10
+#define NUMSTEMSNAPH 12
+#define NUMSTEMSNAPV 12
+#define NUMSTDHW 1
+#define NUMSTDVW 1
+
+#define DEFAULTBOLDSTEMWIDTH 2.0
+
+#define MAXALIGNMENTZONES ((NUMBLUEVALUES+NUMOTHERBLUES)/2)
+#define DEFAULTBLUESCALE 0.039625
+#define DEFAULTBLUESHIFT 7
+#define DEFAULTBLUEFUZZ 1
+#define DEFAULTSTDHW 0
+#define DEFAULTSTDVW 0
+#define DEFAULTFORCEBOLD FALSE
+#define DEFAULTLANGUAGEGROUP 0
+#define DEFAULTRNDSTEMUP FALSE
+#define DEFAULTLENIV 4
+#define DEFAULTEXPANSIONFACTOR 0.06
+
+/* see Type 1 Font Format book for explanations of these values */
+/* Note that we're currently doing nothing for minfeature and password. */
+struct blues_struct {
+ struct blues_struct *next; /* ptr to next Blues structure in list */
+ int numBlueValues; /* # of BlueValues in following array */
+ int BlueValues[NUMBLUEVALUES];
+ int numOtherBlues; /* # of OtherBlues values in following array */
+ int OtherBlues[NUMOTHERBLUES];
+ int numFamilyBlues; /* # of FamilyBlues values in following array */
+ int FamilyBlues[NUMFAMILYBLUES];
+ int numFamilyOtherBlues; /* # of FamilyOtherBlues values in */
+ int FamilyOtherBlues[NUMFAMILYOTHERBLUES]; /* this array */
+ double BlueScale;
+ int BlueShift;
+ int BlueFuzz;
+ double StdHW;
+ double StdVW;
+ int numStemSnapH; /* # of StemSnapH values in following array */
+ double StemSnapH[NUMSTEMSNAPH];
+ int numStemSnapV; /* # of StemSnapV values in following array */
+ double StemSnapV[NUMSTEMSNAPV];
+ int ForceBold;
+ int LanguageGroup;
+ int RndStemUp;
+ int lenIV;
+ double ExpansionFactor;
+};
+
+/* the alignment zone structure -- somewhat similar to the stem structure */
+/* see Adobe Type1 Font Format book about the terms used in this structure */
+struct alignmentzone {
+ int topzone; /* TRUE if a topzone, FALSE if a bottom zone */
+ double bottomy, topy; /* interval of this alignment zone */
+};
diff --git a/src/Type1/cluts.h b/src/Type1/cluts.h
new file mode 100644
index 0000000..67d9303
--- /dev/null
+++ b/src/Type1/cluts.h
@@ -0,0 +1,35 @@
+/* $Xorg: cluts.h,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software
+ * and its documentation for any purpose and without fee is
+ * hereby granted, provided that the above copyright notice
+ * appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation,
+ * and that the name of IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+/* STUB */
+
+#define KillCLUT(T)
+#define CopyCLUT(T) T
+#define UniqueCLUT(T)
+
diff --git a/src/Type1/curves.c b/src/Type1/curves.c
new file mode 100644
index 0000000..d1033fe
--- /dev/null
+++ b/src/Type1/curves.c
@@ -0,0 +1,217 @@
+/* $Xorg: curves.c,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991 */
+/* All Rights Reserved */
+
+/* License to use, copy, modify, and distribute this software */
+/* and its documentation for any purpose and without fee is */
+/* hereby granted, provided that licensee provides a license to */
+/* IBM, Corp. to use, copy, modify, and distribute derivative */
+/* works and their documentation for any purpose and without */
+/* fee, that the above copyright notice appear in all copies */
+/* and that both that copyright notice and this permission */
+/* notice appear in supporting documentation, and that the name */
+/* of IBM not be used in advertising or publicity pertaining to */
+/* distribution of the software without specific, written prior */
+/* permission. */
+
+/* IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES */
+/* OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT */
+/* LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY, */
+/* FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF */
+/* THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND */
+/* PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT */
+/* OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF */
+/* THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES */
+/* THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN */
+/* NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR */
+/* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING */
+/* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF */
+/* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT */
+/* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS */
+/* SOFTWARE. */
+/*
+:h1.CURVES Module - Stepping Beziers
+
+This module is responsible for "rasterizing"
+third order curves. That is, it changes the high level curve
+specification into a list of pels that that curve travels
+through.
+
+:h3.Include Files
+
+Include files needed:
+*/
+
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h"
+#include "curves.h"
+#include "lines.h"
+#include "arith.h"
+
+
+/*
+:h3.Functions Provided to Other Modules
+
+External entry points:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+Note that "stepping" and "flattening" are so similiar that they use the
+same routine. When the "region" parameter is NULL, that is a flag that
+we are flattening instead of stepping.
+*/
+/*
+:h2.Bezier Third Order Curves
+*/
+/*
+:h3.The "bezierinfo" Structure
+
+This structure is used to store information used when we subdivide
+Bezier curves.
+*/
+
+struct bezierinfo {
+ struct region *region; /* the region being built or NULL */
+ struct fractpoint last; /* not used yet; maybe could save some work */
+ struct fractpoint origin; /* the origin of the bezier */
+} ;
+
+/*
+ Checking for termination of the subdivision process:
+ This is the stupidest test in the world, just check if the coordinatewise
+ distance from an end control point to the next control point is less than
+ one half pel. If so, we must be done.
+ This returns 1 if the subdivision is terminated and 0 if you still need
+ to subdivide.
+*/
+
+static int BezierTerminationTest(xa,ya,xb,yb,xc,yc,xd,yd)
+fractpel xa,ya,xb,yb,xc,yc,xd,yd;
+{
+ fractpel dmax;
+ dmax = ABS(xa - xb);
+ dmax = MAX(dmax,ABS(ya - yb));
+ dmax = MAX(dmax,ABS(xd - xc));
+ dmax = MAX(dmax,ABS(yd - yc));
+ if(dmax > FPHALF)
+ return(0); /* not done yet */
+ else
+ return(1); /* done */
+}
+
+/*
+:h3.StepBezierRecurse() - The Recursive Logic in StepBezier()
+
+The recursion involves dividing the control polygon into two smaller
+control polygons by finding the midpoints of the lines. This idea is
+described in any graphics text book and its simplicity is what caused
+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 */
+
+{
+ if (BezierTerminationTest(xA,yA,xB,yB,xC,yC,xD,yD))
+ {
+ if (I->region == NULL)
+ return(PathSegment(LINETYPE, xD - xA, yD - yA));
+ else
+ StepLine(I->region, I->origin.x + xA, I->origin.y + yA,
+ I->origin.x + xD, I->origin.y + yD);
+ }
+ else
+ {
+ fractpel xAB,yAB;
+ fractpel xBC,yBC;
+ fractpel xCD,yCD;
+ fractpel xABC,yABC;
+ fractpel xBCD,yBCD;
+ fractpel xABCD,yABCD;
+
+ xAB = xA + xB; yAB = yA + yB;
+ xBC = xB + xC; yBC = yB + yC;
+ xCD = xC + xD; yCD = yC + yD;
+
+ xABC = xAB + xBC; yABC = yAB + yBC;
+ xBCD = xBC + xCD; yBCD = yBC + yCD;
+
+ xABCD = xABC + xBCD; yABCD = yABC + yBCD;
+
+ xAB >>= 1; yAB >>= 1;
+ xBC >>= 1; yBC >>= 1;
+ xCD >>= 1; yCD >>= 1;
+ xABC >>= 2; yABC >>= 2;
+ xBCD >>= 2; yBCD >>= 2;
+ xABCD >>= 3; yABCD >>= 3;
+
+ if (I->region == NULL)
+ {
+ return( Join(
+ StepBezierRecurse(I, xA, yA, xAB, yAB, xABC, yABC, xABCD, yABCD),
+ StepBezierRecurse(I, xABCD, yABCD, xBCD, yBCD, xCD, yCD, xD, yD)
+ )
+ );
+ }
+ else
+ {
+ StepBezierRecurse(I, xA, yA, xAB, yAB, xABC, yABC, xABCD, yABCD);
+ StepBezierRecurse(I, xABCD, yABCD, xBCD, yBCD, xCD, yCD, xD, yD);
+ }
+ }
+ /*NOTREACHED*/
+}
+
+/*
+:h3.TOOBIG() - Macro to Test if a Coordinate is Too Big to Bezier SubDivide Normally
+
+Intermediate values in the Bezier subdivision are 8 times bigger than
+the starting values. If this overflows, a 'long', we are in trouble:
+*/
+
+#define BITS (sizeof(long)*8)
+#define HIGHTEST(p) (((p)>>(BITS-4)) != 0) /* includes sign bit */
+#define TOOBIG(xy) ((xy < 0) ? HIGHTEST(-xy) : HIGHTEST(xy))
+
+/*
+:h3.StepBezier() - Produce Run Ends for a Bezier Curve
+
+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 bezierinfo Info;
+
+ Info.region = R;
+ Info.origin.x = xA;
+ Info.origin.y = yA;
+
+ xB -= xA;
+ xC -= xA;
+ xD -= xA;
+ yB -= yA;
+ yC -= yA;
+ yD -= yA;
+
+ if ( TOOBIG(xB) || TOOBIG(yB) || TOOBIG(xC) || TOOBIG(yC)
+ || TOOBIG(xD) || TOOBIG(yD) )
+ 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
new file mode 100644
index 0000000..4138a6f
--- /dev/null
+++ b/src/Type1/curves.h
@@ -0,0 +1,40 @@
+/* $Xorg: curves.h,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+/*SHARED*/
+
+#define StepConic(R,xA,yA,xB,yB,xC,yC,r) t1_StepConic(R,xA,yA,xB,yB,xC,yC,r)
+#define StepBezier(R,xA,yA,xB,yB,xC,yC,xD,yD) t1_StepBezier(R,xA,yA,xB,yB,xC,yC,xD,yD)
+
+#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)
+
+struct segment *t1_StepConic();
+struct segment *t1_StepBezier();
+
+/*END SHARED*/
diff --git a/src/Type1/digit.h b/src/Type1/digit.h
new file mode 100644
index 0000000..c693809
--- /dev/null
+++ b/src/Type1/digit.h
@@ -0,0 +1,64 @@
+/* $Xorg: digit.h,v 1.3 2000/08/17 19:46:29 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software
+ * and its documentation for any purpose and without fee is
+ * hereby granted, provided that the above copyright notice
+ * appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation,
+ * and that the name of IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+/* -------------------------------------- */
+/* --- MACHINE GENERATED, DO NOT EDIT --- */
+/* -------------------------------------- */
+
+#ifndef DIGIT
+#define DIGIT 1
+
+/*
+ * Digit Value Table --
+ *
+ * The entries in the Digit Value Table map character
+ * codes in the set {0-9,a-z,A-Z} to their numeric
+ * values as part of numbers of radix 2-36.
+ *
+ */
+unsigned char digit_value[256] = {
+0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,
+ 0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,
+ 0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+};
+
+#endif
diff --git a/src/Type1/fontfcn.c b/src/Type1/fontfcn.c
new file mode 100644
index 0000000..5516468
--- /dev/null
+++ b/src/Type1/fontfcn.c
@@ -0,0 +1,308 @@
+/* $Xorg: fontfcn.c,v 1.5 2000/12/01 16:26:25 steve Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software
+ * and its documentation for any purpose and without fee is
+ * hereby granted, provided that the above copyright notice
+ * appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation,
+ * and that the name of IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+/* Author: Katherine A. Hitchcock IBM Almaden Research Laboratory */
+
+#include <stdio.h>
+#include <string.h>
+#include "t1imager.h"
+#include "util.h"
+#include "fontfcn.h"
+#include "fontmisc.h"
+
+extern xobject Type1Char();
+/***================================================================***/
+/* GLOBALS */
+/***================================================================***/
+char CurFontName[120];
+char *CurFontEnv;
+char *vm_base = NULL;
+psfont *FontP = NULL;
+psfont TheCurrentFont;
+
+
+/***================================================================***/
+/* SearchDict - look for name */
+/* - compare for match on len and string */
+/* return 0 - not found. */
+/* return n - nth element in dictionary. */
+/***================================================================***/
+int SearchDictName(dictP,keyP)
+ psdict *dictP;
+ psobj *keyP;
+{
+ int i,n;
+
+
+ n = dictP[0].key.len;
+ for (i=1;i<=n;i++) { /* scan the intire dictionary */
+ if (
+ (dictP[i].key.len == keyP->len )
+ &&
+ (strncmp(dictP[i].key.data.valueP,
+ keyP->data.valueP,
+ keyP->len) == 0
+ )
+ ) return(i);
+ }
+ return(0);
+}
+/***================================================================***/
+boolean initFont(cnt)
+int cnt;
+{
+
+ if (!(vm_init(cnt))) return(FALSE);
+ vm_base = vm_next_byte();
+ if (!(Init_BuiltInEncoding())) return(FALSE);
+ strcpy(CurFontName, ""); /* iniitialize to none */
+ FontP = &TheCurrentFont;
+ FontP->vm_start = vm_next_byte();
+ FontP->FontFileName.len = 0;
+ FontP->FontFileName.data.valueP = CurFontName;
+ return(TRUE);
+}
+/***================================================================***/
+static void resetFont(env)
+ char *env;
+{
+
+ 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 */
+ strcpy(CurFontName,env);
+ FontP->FontFileName.len = strlen(CurFontName);
+ FontP->FontFileName.data.valueP = CurFontName;
+
+}
+/***================================================================***/
+int readFont(env)
+char *env;
+{
+ int rcode;
+
+ /* restore the virtual memory and eliminate old font */
+ resetFont(env);
+ /* This will load the font into the FontP */
+ rcode = scan_font(FontP);
+ 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);
+ /* only double the memory once, then report error */
+ }
+ return(rcode);
+}
+/***================================================================***/
+xobject fontfcnB(S,code,lenP,mode)
+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 */
+ psobj CodeName; /* used to store the translation of the name*/
+ psobj *SubrsArrayP;
+ psobj *theStringP;
+
+ path charpath; /* the path for this character */
+
+ charnameP = &CodeName;
+ charnameP->len = *lenP;
+ charnameP->data.stringP = code;
+
+ CharStringsDictP = FontP->CharStringsP;
+
+ /* search the chars string for this charname as key */
+ N = SearchDictName(CharStringsDictP,charnameP);
+ if (N<=0) {
+ *mode = FF_PARSE_ERROR;
+ return(NULL);
+ }
+ /* ok, the nth item is the psobj that is the string for this char */
+ theStringP = &(CharStringsDictP[N].value);
+
+ /* get the dictionary pointers to the Subrs */
+
+ 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,
+ 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);
+ }
+ return(charpath);
+}
+/***================================================================***/
+/* fontfcnA(env, mode) */
+/* */
+/* env is a pointer to a string that contains the fontname. */
+/* */
+/* 1) initialize the font - global indicates it has been done */
+/* 2) load the font */
+/***================================================================***/
+Bool fontfcnA(env,mode)
+char *env;
+int *mode;
+{
+ int rc;
+
+ /* Has the FontP initialized? If not, then */
+ /* Initialize */
+ if (FontP == NULL) {
+ InitImager();
+ if (!(initFont(VM_SIZE))) {
+ /* we are really out of memory */
+ *mode = SCAN_OUT_OF_MEMORY;
+ return(FALSE);
+ }
+ }
+
+ /* if the env is null, then use font already loaded */
+
+ /* if the not same font name */
+ if ( (env) && (strcmp(env,CurFontName) != 0 ) ) {
+ /* restore the virtual memory and eliminate old font, read new one */
+ rc = readFont(env);
+ if (rc != 0 ) {
+ strcpy(CurFontName, ""); /* no font loaded */
+ *mode = rc;
+ return(FALSE);
+ }
+ }
+ return(TRUE);
+
+}
+/***================================================================***/
+/* QueryFontLib(env, infoName,infoValue,rcodeP) */
+/* */
+/* env 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 QueryFontLib(env,infoName,infoValue,rcodeP)
+char *env;
+char *infoName;
+pointer infoValue; /* parameter returned here */
+int *rcodeP;
+{
+ int rc,N,i;
+ psdict *dictP;
+ psobj nameObj;
+ psobj *valueP;
+
+ /* Has the FontP initialized? If not, then */
+ /* Initialize */
+ if (FontP == NULL) {
+ InitImager();
+ if (!(initFont(VM_SIZE))) {
+ *rcodeP = 1;
+ return;
+ }
+ }
+ /* if the env is null, then use font already loaded */
+ /* if the not same font name, reset and load next font */
+ if ( (env) && (strcmp(env,CurFontName) != 0 ) ) {
+ /* restore the virtual memory and eliminate old font */
+ rc = readFont(env);
+ if (rc != 0 ) {
+ strcpy(CurFontName, ""); /* no font loaded */
+ *rcodeP = 1;
+ return;
+ }
+ }
+ dictP = FontP->fontInfoP;
+ 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;
+ /* don't dereference a NULL pointer, in the case of a bad font file */
+ 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;
+}
diff --git a/src/Type1/fontfcn.h b/src/Type1/fontfcn.h
new file mode 100644
index 0000000..cbf23a1
--- /dev/null
+++ b/src/Type1/fontfcn.h
@@ -0,0 +1,98 @@
+/* $Xorg: fontfcn.h,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software
+ * and its documentation for any purpose and without fee is
+ * hereby granted, provided that the above copyright notice
+ * appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation,
+ * and that the name of IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+/* Definition of a PostScript FONT */
+typedef struct ps_font {
+ char *vm_start;
+ psobj FontFileName;
+ psobj Subrs;
+ psdict *CharStringsP;
+ psdict *Private;
+ psdict *fontInfoP;
+struct blues_struct *BluesP;
+} psfont;
+/***================================================================***/
+/* Routines in scan_font */
+/***================================================================***/
+
+extern boolean Init_StdEnc();
+extern int scan_font();
+extern int GetFontInfo();
+/***================================================================***/
+/* Return codes from scan_font */
+/***================================================================***/
+#define SCAN_OK 0
+#define SCAN_FILE_EOF -1
+#define SCAN_ERROR -2
+#define SCAN_OUT_OF_MEMORY -3
+#define SCAN_FILE_OPEN_ERROR -4
+#define SCAN_TRUE -5
+#define SCAN_FALSE -6
+#define SCAN_END -7
+
+/***================================================================***/
+/* Name of FontInfo fields */
+/***================================================================***/
+
+#define FONTNAME 1
+#define PAINTTYPE 2
+#define FONTTYPENUM 3
+#define FONTMATRIX 4
+#define FONTBBOX 5
+#define UNIQUEID 6
+#define STROKEWIDTH 7
+#define VERSION 8
+#define NOTICE 9
+#define FULLNAME 10
+#define FAMILYNAME 11
+#define WEIGHT 12
+#define ITALICANGLE 13
+#define ISFIXEDPITCH 14
+#define UNDERLINEPOSITION 15
+#define UNDERLINETHICKNESS 16
+#define ENCODING 17
+/***================================================================***/
+/* Name of Private values */
+/***================================================================***/
+#define BLUEVALUES 1
+#define OTHERBLUES 2
+#define FAMILYBLUES 3
+#define FAMILYOTHERBLUES 4
+#define BLUESCALE 5
+#define BLUESHIFT 6
+#define BLUEFUZZ 7
+#define STDHW 8
+#define STDVW 9
+#define STEMSNAPH 10
+#define STEMSNAPV 11
+#define FORCEBOLD 12
+#define LANGUAGEGROUP 13
+#define LENIV 14
+#define RNDSTEMUP 15
+#define EXPANSIONFACTOR 16
diff --git a/src/Type1/fonts.h b/src/Type1/fonts.h
new file mode 100644
index 0000000..7215e0f
--- /dev/null
+++ b/src/Type1/fonts.h
@@ -0,0 +1,49 @@
+/* $Xorg: fonts.h,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software
+ * and its documentation for any purpose and without fee is
+ * hereby granted, provided that the above copyright notice
+ * appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation,
+ * and that the name of IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* STUB */
+
+#define CopyFont(f) f
+#define UniqueFont(f) f
+#define KillFont(f)
+#define KillText(t)
+#define CopyText(t) t
+#define I_DumpText(t)
+#define CoerceText(t) t
+#define TextDelta(t,pt)
+#define XformText(p,s)
+#define GimeSpace() FALSE
+
+#define LibInit()
+#define InitFonts()
+#define InitFiles()
+#define TraceClose()
+
+#define FF_PARSE_ERROR -1
diff --git a/src/Type1/hdigit.h b/src/Type1/hdigit.h
new file mode 100644
index 0000000..fbaa9c1
--- /dev/null
+++ b/src/Type1/hdigit.h
@@ -0,0 +1,94 @@
+/* $Xorg: hdigit.h,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines,Corp. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software
+ * and its documentation for any purpose and without fee is
+ * hereby granted, provided that the above copyright notice
+ * appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation,
+ * and that the name of IBM not be used in advertising or
+ * publicity pertaining to distribution of the software without
+ * specific, written prior permission.
+ *
+ * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
+ * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+ * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
+ * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
+ * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
+ * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
+ * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+/* -------------------------------------- */
+/* --- MACHINE GENERATED, DO NOT EDIT --- */
+/* -------------------------------------- */
+
+#ifndef HDIGIT
+#define HDIGIT 1
+
+/*
+ * Hex Digit Value Table --
+ *
+ * The entries in the Digit Value Table map character codes in the set
+ * {0-9,a-f,A-F} to their numeric values for readhexstring
+ * (00 10...F0 for the high hex digit and 00 01...0F for the low).
+ * The white-space and hex string termination characters are.
+ * mapped to codes > 0xf0 to enable usage by several modules.
+ * 2 tables are build HighHex and LowHex.
+ *
+ */
+
+/* Indicators for special characters in these tables */
+#define HERROR (0xfe)
+#define HWHITE_SPACE (0xfd)
+#define HRIGHT_ANGLE (0xfc)
+#define LAST_HDIGIT (0xf0)
+
+#define HighHexP (HighHex+1)
+unsigned char HighHex[257] = { 0xFF,
+ 0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFD,0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xFE,0xFE,0xFE,0xFE,0xFC,0xFE,
+ 0xFE,0xA0,0xB0,0xC0,0xD0,0xE0,0xF0,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xA0,0xB0,0xC0,0xD0,0xE0,0xF0,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE
+};
+#define LowHexP (LowHex+1)
+unsigned char LowHex[257] = { 0xFF,
+ 0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFD,0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0xFE,0xFE,0xFE,0xFE,0xFC,0xFE,
+ 0xFE,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
+ 0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE
+};
+
+#endif
diff --git a/src/Type1/hints.c b/src/Type1/hints.c
new file mode 100644
index 0000000..c3db5a4
--- /dev/null
+++ b/src/Type1/hints.c
@@ -0,0 +1,919 @@
+/* $Xorg: hints.c,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+ /* HINTS CWEB V0006 ******** */
+/*
+:h1.HINTS Module - Processing Rasterization Hints
+
+&author. Sten F. Andler; continuity by Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com) and Duaine
+W. Pryor, Jr.
+
+
+:h3.Include Files
+
+The included files are:
+*/
+
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h"
+#include "hints.h"
+
+/*
+:h3.Functions Provided to the TYPE1IMAGER User
+
+None.
+*/
+
+/*
+:h3.Functions Provided to Other Modules
+
+This module provides the following entry point to other modules:
+*/
+
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.Macros Provided to Other Modules
+
+None.
+*/
+
+/*
+:h2.InitHints() - Initialize hint data structure
+*/
+
+#define MAXLABEL 20
+static struct {
+ int inuse;
+ int computed;
+ struct fractpoint hint;
+} oldHint[MAXLABEL];
+
+#define ODD(x) (((int)(x)) & 01)
+#define FPFLOOR(fp) TOFRACTPEL((fp) >> FRACTBITS)
+#define FPROUND(fp) FPFLOOR((fp) + FPHALF)
+
+void InitHints()
+{
+ int i;
+
+ for (i = 0; i < MAXLABEL; i++)
+ {
+ oldHint[i].inuse = FALSE;
+ oldHint[i].computed = FALSE;
+ }
+}
+
+/*
+:h3.CloseHints(hintP) - Reverse hints that are still open
+*/
+
+void CloseHints(hintP)
+ struct fractpoint *hintP;
+{
+ int i;
+
+ for (i = 0; i < MAXLABEL; i++)
+ {
+ if (oldHint[i].inuse)
+ {
+ hintP->x -= oldHint[i].hint.x;
+ hintP->y -= oldHint[i].hint.y;
+
+ oldHint[i].inuse = FALSE;
+
+ IfTrace3((HintDebug > 1)," Hint %d was open, hint=(%p,%p)\n",
+ i, hintP->x, hintP->y);
+ }
+ }
+}
+
+/*
+: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;
+{
+ fractpel currRef, currWidth;
+ int idealWidth;
+ fractpel hintValue;
+ char orientation;
+
+/*
+By construction, width is never zero. Therefore we can use the
+width value to determine if the hint has been rotated by a
+multiple of 90 degrees.
+*/
+
+ if (hP->width.y == 0)
+ {
+ orientation = 'v'; /* vertical */
+ IfTrace0((HintDebug > 0)," vertical hint\n");
+ }
+ else if (hP->width.x == 0)
+ {
+ orientation = 'h'; /* horizontal */
+ IfTrace0((HintDebug > 0)," horizontal hint\n");
+ }
+ else
+ {
+ IfTrace0((HintDebug > 0)," hint not vertical or horizontal\n");
+ hintP->x = hintP->y = 0;
+ return;
+ }
+
+ /* Compute currRef and currWidth with a unit of 1 pel */
+ if (orientation == 'v') /* vertical */
+ {
+ currRef = hP->ref.x + currX;
+ currWidth = ABS(hP->width.x);
+ }
+ else if (orientation == 'h') /* horizontal */
+ {
+ currRef = hP->ref.y + currY;
+ currWidth = ABS(hP->width.y);
+ }
+ else /* error */
+ {
+ abort("ComputeHint: invalid orientation");
+ }
+
+ IfTrace4((HintDebug > 1),
+ " currX=%p, currY=%p, currRef=%p, currWidth=%p\n",
+ currX, currY,
+ currRef, currWidth);
+
+ if ((hP->hinttype == 'b') /* Bar or stem */
+ || (hP->hinttype == 's')) /* Serif */
+ {
+ idealWidth = NEARESTPEL(currWidth);
+ if (idealWidth == 0) idealWidth = 1;
+ if (ODD(idealWidth)) /* Is ideal width odd? */
+ {
+ /* center "ref" over pel */
+ hintValue = FPFLOOR(currRef) + FPHALF - currRef;
+ }
+ else
+ {
+ /* align "ref" on pel boundary */
+ hintValue = FPROUND(currRef) - currRef;
+ }
+ if (HintDebug > 2) {
+ IfTrace1(TRUE," idealWidth=%d, ", idealWidth);
+ }
+ }
+ else if (hP->hinttype == 'c') /* Curve extrema */
+ {
+ /* align "ref" on pel boundary */
+ hintValue = FPROUND(currRef) - currRef;
+ }
+ else /* error */
+ {
+ abort("ComputeHint: invalid hinttype");
+ }
+
+ IfTrace1((HintDebug > 1)," hintValue=%p", hintValue);
+
+ if (orientation == 'v') /* vertical */
+ {
+ hintP->x = hintValue;
+ hintP->y = 0;
+ }
+ else if (orientation == 'h') /* horizontal */
+ {
+ hintP->x = 0;
+ hintP->y = hintValue;
+ }
+ else /* error */
+ {
+ abort("ComputeHint: invalid orientation");
+ }
+}
+
+/*
+: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;
+{
+ struct fractpoint thisHint;
+
+ IfTrace4((HintDebug > 1)," ref=(%p,%p), width=(%p,%p)",
+ hP->ref.x, hP->ref.y,
+ hP->width.x, hP->width.y);
+ IfTrace4((HintDebug > 1),", %c %c %c %c",
+ hP->orientation, hP->hinttype,
+ hP->adjusttype, hP->direction);
+ IfTrace1((HintDebug > 1),", label=%d\n", hP->label);
+
+ if ((hP->adjusttype == 'm') /* Move */
+ || (hP->adjusttype == 'a')) /* Adjust */
+ {
+ /* Look up hint in oldHint table */
+ if ((hP->label >= 0) && (hP->label < MAXLABEL))
+ {
+ if (oldHint[hP->label].computed)
+ /* Use old hint value if already computed */
+ {
+ thisHint.x = oldHint[hP->label].hint.x;
+ thisHint.y = oldHint[hP->label].hint.y;
+ oldHint[hP->label].inuse = TRUE;
+ }
+ else
+ /* Compute new value for hint and store it for future use */
+ {
+ ComputeHint(hP, currX, currY, &thisHint);
+
+ oldHint[hP->label].hint.x = thisHint.x;
+ oldHint[hP->label].hint.y = thisHint.y;
+ oldHint[hP->label].inuse = TRUE;
+ oldHint[hP->label].computed = TRUE;
+ }
+ }
+ else /* error */
+ {
+ abort("ProcessHint: invalid label");
+ }
+ }
+ else if (hP->adjusttype == 'r') /* Reverse */
+ {
+ /* Use the inverse of the existing hint value to reverse hint */
+ if ((hP->label >= 0) && (hP->label < MAXLABEL))
+ {
+ if (oldHint[hP->label].inuse)
+ {
+ thisHint.x = -oldHint[hP->label].hint.x;
+ thisHint.y = -oldHint[hP->label].hint.y;
+ oldHint[hP->label].inuse = FALSE;
+ }
+ else /* error */
+ {
+ abort("ProcessHint: label is not in use");
+ }
+ }
+ else /* error */
+ {
+ abort("ProcessHint: invalid label");
+ }
+
+ }
+ else /* error */
+ {
+ abort("ProcessHint: invalid adjusttype");
+ }
+ IfTrace3((HintDebug > 1)," label=%d, thisHint=(%p,%p)\n",
+ hP->label, thisHint.x, thisHint.y);
+
+ hintP->x += thisHint.x;
+ hintP->y += thisHint.y;
+
+ IfTrace2((HintDebug > 1)," hint=(%p,%p)\n",
+ hintP->x, hintP->y);
+}
+
+/*
+:h2 id=subpath.Navigation Through Edge Lists
+
+For continuity checking purposes, we need to navigate through edge
+lists by the "subpath" chains and answer questions about edges. The
+subpath chain links together edges that were part of the same subpath
+(no intervening move segments) when the interior of the path was
+calculated. Here we use the term "edge" to mean every edge list
+that was created in between changes of direction.
+
+The subpath chains are singly-linked circular chains. For the convenience
+of building them, they direction of the list (from edge to edge) is the
+reverse of the order in which they were built. Within any single edge,
+the subpath chain goes from top-to-bottom. (There might be a violation
+of this because of the way the user started the first chain; see
+:hdref refid=fixsubp..).
+
+:h3.ISTOP() and ISBOTTOM() - Flag Bits for Edge Lists at the Top and
+Bottom of Their SubPaths
+*/
+
+#define ISTOP(flag) ((flag)&0x20)
+#define ISBOTTOM(flag) ((flag)&0x10)
+/*
+:h3.ISLEFT() - Flag Bit for Left Edges
+*/
+
+#define ISLEFT(flag) ((flag)&0x08)
+
+/*
+:h3.XofY() - Macro to Find X Value at Given Y
+
+This macro can only be used if it is known that the Y is within the
+given edgelist's ymin and ymax.
+*/
+
+#define XofY(edge, y) edge->xvalues[y - edge->ymin]
+
+/*
+:h3.findXofY() - Like XofY(), Except not Restricted
+
+If the Y is out of bounds of the given edgelist, this macro will
+call SearchXofY to search the edge's subpath chain for the correct
+Y range. If the Y value is off the edge, MINPEL is returned.
+*/
+#define findXofY(edge, y) ((y < edge->ymin || y >= edge->ymax) ? SearchXofY(edge, y) : XofY(edge, y))
+
+/*
+:h4.SearchXofY() - Routine Called by FindXofY() for Difficult Cases
+
+The concept of this routine is to follow the subpath chain to find the
+edge just below (i.e., next in chain) or just above (i.e., immediately
+before in chain. It is assumed that the Y value is no more than one
+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 */
+{
+ register struct edgelist *e; /* loop variable */
+
+ if (y < edge->ymin) {
+ if (ISTOP(edge->flag))
+ return(MINPEL);
+ for (e = edge->subpath; e->subpath != edge; e = e->subpath) { ; }
+ if (e->ymax == edge->ymin)
+ return(XofY(e, y));
+ }
+ else if (y >= edge->ymax) {
+ if (ISBOTTOM(edge->flag))
+ return(MINPEL);
+ e = edge->subpath;
+ if (e->ymin == edge->ymax)
+ return(XofY(e, y));
+ }
+ else
+ return(XofY(edge, y));
+
+ abort("bad subpath chain");
+ /*NOTREACHED*/
+}
+/*
+:h3.ISBREAK() Macro - Tests if an Edge List is at a "Break"
+
+The subpath chains are organized top to bottom. When the bottom of
+a given edge is reached, the subpath chain points to the top of the
+next edge. We call this a "break" in the chain. The following macro
+is the simple test for the break condition:
+*/
+
+#define ISBREAK(top,bot) (top->ymax != bot->ymin)
+
+
+/*
+:h3.ImpliedHorizontalLine() - Tests for Horizontal Connectivity
+
+This function returns true if two edges are connected horizontally.
+They are connected horizontally if they are consecutive in the subpath,
+and either we are at the bottom and the first edge is going down or we
+are at the top and the first edge is going up.
+*/
+
+#define BLACKABOVE -1
+#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 */
+{
+ register struct edgelist *e3,*e4;
+
+ if (ISDOWN(e1->flag) == ISDOWN(e2->flag))
+ return(NONE); /* can't be consecutive unless different directions */
+/*
+Now we check for consecutiveness: Can we get from 'e1' to 'e2' with
+only one intervening break? Can we get from 'e2' to 'e1' with only one
+intervening break? 'e3' will be as far as we can get after 'e1'; 'e4'
+will be has far as we can get after 'e2':
+*/
+ for (e3 = e1; !ISBREAK(e3, e3->subpath); e3 = e3->subpath) { ; }
+ for (e3 = e3->subpath; e3 != e2; e3 = e3->subpath)
+ if (ISBREAK(e3, e3->subpath))
+ break;
+
+ for (e4 = e2; !ISBREAK(e4, e4->subpath); e4 = e4->subpath) { ; }
+ for (e4 = e4->subpath; e4 != e1; e4 = e4->subpath)
+ if (ISBREAK(e4, e4->subpath))
+ break;
+/*
+If the edges are mutually consecutive, we must have horizontal lines
+both top and bottom:
+*/
+ if (e3 == e2 && e4 == e1)
+ return(TRUE);
+/*
+If the edges are not consecutive either way, no horizontal lines are
+possible:
+*/
+ if (e3 != e2 && e4 != e1)
+ return(NONE);
+/*
+Now let's swap 'e1' and 'e2' if necessary to enforce the rule that 'e2'
+follows 'e1'. Remember that subpath chains go in the opposite direction
+from the way the subpaths were built; this led to the simplest way
+do build them.
+*/
+ if (e4 != e1) {
+ e2 = e1;
+ e1 = e3; /* remember e3 == e2, this just swaps 'e1' and 'e2' */
+ }
+/*
+Now we have everything to return the answer:
+*/
+ if (ISTOP(e1->flag) && y == e1->ymin)
+ return(ISDOWN(e2->flag));
+ else if (ISBOTTOM(e1->flag) && y == e1->ymax)
+ return(!ISDOWN(e2->flag));
+ else
+ abort("ImpliedHorizontalLine: why ask?");
+ /*NOTREACHED*/
+}
+
+/*
+:h3 id=fixsubp.FixSubPaths() - Must be Called to Organize Subpath Chains
+
+The region-building code in Interior(), in particular splitedge(),
+maintains the rule that sub-paths are linked top-to-bottom except
+at breaks. However, it is possible that there may be a "false break"
+because the user started the subpath in the middle of an edge (and
+went in the "wrong" direction from there, up instead of down). This
+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 */
+{
+ 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 *prev; /* previous edge for fixing links */
+ int left = TRUE;
+
+ for (edge = R->anchor; edge != NULL; edge = edge->link) {
+
+ if (left)
+ edge->flag |= ISLEFT(ON);
+ left = !left;
+
+ next = edge->subpath;
+
+ if (!ISBREAK(edge, next))
+ continue;
+ if (edge->ymax < next->ymin)
+ 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
+the top. We refer to this a "break" in the subpath.
+*/
+ next->flag |= ISTOP(ON);
+ edge->flag |= ISBOTTOM(ON);
+
+ if (ISDOWN(edge->flag) != ISDOWN(next->flag))
+ continue;
+/*
+We are now in the unusual case; both edges are going in the same
+direction so this must be a "false break" due to the way that the user
+created the path. We'll have to fix it.
+*/
+ for (break1 = next; !ISBREAK(break1, break1->subpath); break1 = break1->subpath) { ; }
+
+ for (e = break1->subpath; e != edge; e = e->subpath)
+ if (ISBREAK(e, e->subpath))
+ break2 = e;
+/*
+Now we've set up 'break1' and 'break2'. I've found the following
+diagram invaluable. 'break1' is the first break after 'next'. 'break2'
+is the LAST break before 'edge'.
+&drawing.
+ next
+ +------+ +---->+------+
+ +--->| >-----+ | | >-----+
+ | | | | | | | |
+ | +-------------+ | +-------------+
+ | | |break1| | | | |
+ | +->| >-------+ +->| >-----+
+ | | | | | |
+ | | | +-------------+
+ | +------+ | | |
+ | +----------------+ | | |
+ | | +------+ | +->| >-----+
+ | +->| >-----+ | | | |
+ | | | | | +-------------+
+ | +-------------+ | | | |
+ | | |edge | | | |break2|
+ | +->| >-----+ | +->| >-----+
+ | | | | | | | |
+ | | | | | | | |
+ | | | | | | | |
+ | +------+ | | +------+ |
+ | | | |
+ +---------------+ +---------------+
+
+&edrawing.
+We want to fix this situation by having 'edge' point to where 'break1'
+now points, and having 'break1' point to where 'break2' now points.
+Finally, 'break2' should point to 'next'. Also, we observe that
+'break1' can't be a bottom, and is also not a top unless it is the same
+as 'next':
+*/
+ edge->subpath = break1->subpath;
+
+ break1->subpath = break2->subpath;
+ if (ISBREAK(break1, break1->subpath))
+ abort("unable to fix subpath break?");
+
+ break2->subpath = next;
+
+ break1->flag &= ~ISBOTTOM(ON);
+ if (break1 != next)
+ break1->flag &= ~ISTOP(ON);
+ }
+/*
+This region might contain "ambiguous" edges; edges exactly equal to
+edge->link. Due to the random dynamics of where they get sorted into
+the list, they can yield false crossings, where the edges appear
+to cross. This confuses our continuity logic no end. Since we can
+swap them without changing the region, we do.
+*/
+ for (edge = R->anchor, prev = NULL; VALIDEDGE(edge); prev = edge, edge = prev->link) {
+
+ if (! ISAMBIGUOUS(edge->flag))
+ continue;
+
+ next = edge->subpath;
+
+ while (ISAMBIGUOUS(next->flag) && next != edge)
+ next = next->subpath;
+/*
+We've finally found a non-ambiguous edge; we make sure it is left/right
+compatible with 'edge':
+*/
+ if ( (ISLEFT(edge->flag) == ISLEFT(next->flag) && ISDOWN(edge->flag) == ISDOWN(next->flag) )
+ || (ISLEFT(edge->flag) != ISLEFT(next->flag) && ISDOWN(edge->flag) != ISDOWN(next->flag) ) )
+ continue;
+
+/*
+Incompatible, we will swap 'edge' and the following edge in the list.
+You may think that there must be a next edge in this swath. So did I.
+No! If there is a totally ambiguous inner loop, for example, we could
+get all the way to the outside without resolving ambiguity.
+*/
+ next = edge->link; /* note new meaning of 'next' */
+ if (next == NULL || edge->ymin != next->ymin)
+ continue;
+ if (prev == NULL)
+ R->anchor = next;
+ else
+ prev->link = next;
+ edge->link = next->link;
+ next->link = edge;
+ edge->flag ^= ISLEFT(ON);
+ edge->flag &= ~ISAMBIGUOUS(ON);
+ next->flag ^= ISLEFT(ON);
+ next->flag &= ~ISAMBIGUOUS(ON);
+ edge = next;
+ }
+}
+/*
+:h3.DumpSubPaths()
+
+A debug tool.
+*/
+
+static struct edgelist *before(); /* subroutine of DumpSubPaths */
+
+static void DumpSubPaths(anchor)
+ struct edgelist *anchor;
+{
+
+ register struct edgelist *edge,*e,*e2;
+ pel y;
+
+ for (edge = anchor; VALIDEDGE(edge); edge = edge->link) {
+ if (ISPERMANENT(edge->flag))
+ continue;
+ IfTrace0(TRUE, "BEGIN Subpath\n");
+ for (e2 = edge; !ISPERMANENT(e2->flag);) {
+ if (ISDOWN(e2->flag)) {
+ IfTrace1(TRUE, ". Downgoing edge's top at %x\n", e2);
+ for (e = e2;; e = e->subpath) {
+ IfTrace4(TRUE, ". . [%5d] %5d @ %x[%x]\n",
+ e->ymin, *e->xvalues, e, e->flag);
+ for (y=e->ymin+1; y < e->ymax; y++)
+ IfTrace2(TRUE, ". . [%5d] %5d \"\n", y, e->xvalues[y-e->ymin]);
+ e->flag |= ISPERMANENT(ON);
+ if (ISBREAK(e, e->subpath))
+ break;
+ }
+ }
+ else {
+ IfTrace1(TRUE, ". Upgoing edge's top at %x\n", e2);
+ for (e = e2; !ISBREAK(e, e->subpath); e = e->subpath) { ; }
+ for (;; e=before(e)) {
+ IfTrace4(TRUE, ". . [%5d] %5d @ %x[%x]\n",
+ e->ymax-1, e->xvalues[e->ymax-1-e->ymin], e, e->flag);
+ for (y=e->ymax-2; y >= e->ymin; y--)
+ IfTrace2(TRUE, ". . [%5d] %5d \"\n", y, e->xvalues[y-e->ymin]);
+ e->flag |= ISPERMANENT(ON);
+ if (e == e2)
+ break;
+ }
+ }
+ do {
+ e2 = before(e2);
+ } while (!ISBREAK(before(e2), e2));
+ }
+ }
+}
+
+static struct edgelist *before(e)
+ struct edgelist *e;
+{
+ struct edgelist *r;
+ for (r = e->subpath; r->subpath != e; r = r->subpath) { ; }
+ return(r);
+}
+
+/*
+:h2.Fixing Region Continuity Problems
+
+Small regions may become disconnected when their connecting segments are
+less than a pel wide. This may be correct in some applications, but in
+many (especially small font characters), it is more pleasing to keep
+connectivity. ApplyContinuity() (invoked by +CONTINUITY on the
+Interior() fill rule) fixes connection breaks. The resulting region
+is geometrically less accurate, but may be more pleasing to the eye.
+*/
+/*
+Here are some macros which we will need:
+*/
+
+#define IsValidPel(j) (j!=MINPEL)
+
+/*
+:h3.writeXofY() - Stuffs an X Value Into an "edgelist"
+
+writeXofY writes an x value into an edge at position 'y'. It must
+update the edge's xmin and xmax. If there is a possibility that this
+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 */
+{
+ if (e->xmin > x) e->xmin = x;
+ if (e->xmax < x) e->xmax = x;
+ e->xvalues[y - e->ymin] = x;
+}
+
+/*-------------------------------------------------------------------------*/
+/* the following three macros tell us whether we are at a birth point, a */
+/* death point, or simply in the middle of the character */
+/*-------------------------------------------------------------------------*/
+#define WeAreAtTop(e,i) (ISTOP(e->flag) && e->ymin == i)
+#define WeAreAtBottom(e,i) (ISBOTTOM(e->flag) && e->ymax-1 == i)
+#define WeAreInMiddle(e,i) \
+ ((!ISTOP(e->flag) && !ISBOTTOM(e->flag))||(i < e->ymax-1 && i > e->ymin))
+/*
+The following macro tests if two "edgelist" structures are in the same
+swath:
+*/
+#define SAMESWATH(e1,e2) (e1->ymin == e2->ymin)
+
+/*
+:h3.CollapseWhiteRun() - Subroutine of ApplyContinuity()
+
+When we have a white run with an implied horizontal line above or
+below it, we better have black on the other side of this line. This
+function both tests to see if black is there, and adjusts the end
+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 */
+{
+ struct edgelist *edge;
+ struct edgelist *swathstart = anchor;
+ register pel x;
+
+ if (XofY(left, ywhite) >= XofY(right, ywhite))
+ return;
+/*
+Find the swath with 'yblack'. If we don't find it, completely collapse
+the white run and return:
+*/
+ while (VALIDEDGE(swathstart)) {
+ if (yblack < swathstart->ymin) {
+ writeXofY(left, ywhite, XofY(right, ywhite));
+ return;
+ }
+ if (yblack < swathstart->ymax) break;
+ swathstart = swathstart->link->link;
+ }
+ if(!VALIDEDGE(swathstart)) {
+ writeXofY(left, ywhite, XofY(right, ywhite));
+ return;
+ }
+/*
+Now we are in the swath that contains 'y', the reference line above
+or below that we are trying to maintain continuity with. If black
+in this line begins in the middle of our white run, we must collapse
+the white run from the left to that point. If black ends in the
+middle of our white run, we must collapse the white run from the right
+to that point.
+*/
+ for (edge = swathstart; VALIDEDGE(edge); edge = edge->link) {
+
+ if (!SAMESWATH(swathstart,edge))
+ break;
+ if( XofY(edge, yblack) > XofY(left, ywhite)) {
+ if (ISLEFT(edge->flag)) {
+ x = XofY(edge, yblack);
+ if (XofY(right, ywhite) < x)
+ x = XofY(right, ywhite);
+ writeXofY(left, ywhite, x);
+ }
+ else {
+ x = XofY(edge, yblack);
+ while (edge->link != NULL && SAMESWATH(edge, edge->link)
+ && x >= XofY(edge->link, yblack) ) {
+ edge = edge->link->link;
+ x = XofY(edge, yblack);
+ }
+ if (x < XofY(right, ywhite))
+ writeXofY(right, ywhite, x);
+ return;
+ }
+ }
+ }
+ writeXofY(left, ywhite, XofY(right, ywhite));
+}
+
+/*
+:h3.ApplyContinuity() - Fix False Breaks in a Region
+
+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;
+{
+ struct edgelist *left;
+ struct edgelist *right;
+ struct edgelist *edge,*e2;
+ pel rightXabove,rightXbelow,leftXabove,leftXbelow;
+ pel leftX,rightX;
+ int i;
+ long newcenter,abovecenter,belowcenter;
+
+ FixSubPaths(R);
+ if (RegionDebug >= 3)
+ DumpSubPaths(R->anchor);
+ left = R->anchor;
+/* loop through and do all of the easy checking. ( no tops or bottoms) */
+ while(VALIDEDGE(left))
+ {
+ right = left->link;
+ for(i=left->ymin;i<left->ymax;++i)
+ {
+ leftX = findXofY(left,i);
+ rightX = findXofY(right,i);
+ leftXbelow = findXofY(left,i+1);
+ rightXbelow = findXofY(right,i+1);
+ if(rightX <= leftX)
+ {
+/* then, we have a break in a near vertical line */
+ leftXabove = findXofY(left,i-1);
+ rightXabove = findXofY(right,i-1);
+ if( IsValidPel(leftXabove) && IsValidPel(rightXabove) )
+ {
+ abovecenter = leftXabove + rightXabove;
+ }
+ else
+ {
+ abovecenter = leftX + rightX;
+ }
+ if( IsValidPel(leftXbelow) && IsValidPel(rightXbelow) )
+ {
+ belowcenter = leftXbelow + rightXbelow;
+ }
+ else
+ {
+ belowcenter = leftX + rightX;
+ }
+ newcenter = abovecenter + belowcenter;
+ if( newcenter > 4*leftX )
+ {
+ rightX = rightX + 1;
+ }
+ else if( newcenter < 4*leftX)
+ {
+ leftX = leftX - 1;
+ }
+ else
+ {
+ rightX = rightX + 1;
+ }
+ writeXofY(right,i,rightX);
+ writeXofY(left,i,leftX);
+ if(rightX > R->xmax) {R->xmax = rightX;}
+ if(leftX < R->xmin) {R->xmin = leftX;}
+ }
+ if( !WeAreAtBottom(left,i) && (leftXbelow>=rightX))
+ {
+/* then we have a break in a near horizontal line in the middle */
+ writeXofY(right,i,leftXbelow);
+ }
+ if( !WeAreAtBottom(right,i) && (leftX >=rightXbelow))
+ {
+/* then we have a break in a near horizontal line in the middle */
+ writeXofY(left,i,rightXbelow);
+ }
+ }
+ left = right->link;
+ }
+/*
+There may be "implied horizontal lines" between edges that have
+implications for continuity. This loop looks for white runs that
+have implied horizontal lines on the top or bottom, and calls
+CollapseWhiteRuns to check and fix any continuity problems from
+them.
+*/
+ for (edge = R->anchor; VALIDEDGE(edge); edge = edge->link) {
+ if ((!ISTOP(edge->flag) && !ISBOTTOM(edge->flag)) || ISLEFT(edge->flag))
+ continue; /* at some future date we may want left edge logic here too */
+ for (e2 = edge->link; VALIDEDGE(e2) && SAMESWATH(edge,e2); e2 = e2->link) {
+ if (ISTOP(e2->flag) && ISTOP(edge->flag)
+ && NONE != ImpliedHorizontalLine(edge,e2,edge->ymin)) {
+ if (ISLEFT(e2->flag))
+ CollapseWhiteRun(R->anchor, edge->ymin-1,
+ edge, e2, edge->ymin);
+ }
+ if (ISBOTTOM(e2->flag) && ISBOTTOM(edge->flag)
+ && NONE != ImpliedHorizontalLine(edge,e2, edge->ymax)) {
+ if (ISLEFT(e2->flag))
+ CollapseWhiteRun(R->anchor, edge->ymax,
+ edge, e2, edge->ymax-1);
+ }
+ }
+ }
+}
+
+
+
+
diff --git a/src/Type1/hints.h b/src/Type1/hints.h
new file mode 100644
index 0000000..79ef326
--- /dev/null
+++ b/src/Type1/hints.h
@@ -0,0 +1,42 @@
+/* $Xorg: hints.h,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+/*SHARED*/
+
+#define InitHints() t1_InitHints()
+void t1_InitHints(); /* Initialize hint data structure */
+
+#define CloseHints(hintP) t1_CloseHints(hintP)
+void t1_CloseHints(); /* Reverse hints that are still open */
+
+#define ProcessHint(hP, currX, currY, hintP) t1_ProcessHint(hP, currX, currY, hintP)
+void t1_ProcessHint(); /* Process a rasterization hint */
+
+#define ApplyContinuity(R) t1_ApplyContinuity(R)
+void t1_ApplyContinuity(); /* fix false connection breaks in a region */
+/*END SHARED*/
diff --git a/src/Type1/lines.c b/src/Type1/lines.c
new file mode 100644
index 0000000..3afcfc1
--- /dev/null
+++ b/src/Type1/lines.c
@@ -0,0 +1,186 @@
+/* $Xorg: lines.c,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+ /* LINES CWEB V0003 ******** */
+/*
+:h1.LINES Module - Rasterizing Lines
+
+&author. Duaine W. Pryor, Jr. and Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com)
+
+
+:h3.Include Files
+
+The included files are:
+*/
+
+#include "objects.h"
+#include "spaces.h"
+#include "regions.h"
+#include "lines.h"
+
+/*
+:h3.Functions Provided to the TYPE1IMAGER User
+
+None.
+*/
+
+/*
+:h3.Functions Provided to Other Modules
+
+This module provides the following entry point to other modules:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.Macros Provided to Other Modules
+
+None.
+*/
+
+/*
+:h2.StepLine() - Produces Run Ends for a Line After Checks
+
+The main work is done by Bresenham(); here we just perform checks and
+get the line so that its Y direction is always increasing:
+*/
+
+void StepLine(R, x1, y1, x2, y2)
+ register struct region *R; /* region being built */
+ register fractpel x1,y1; /* starting point */
+ register fractpel x2,y2; /* ending point */
+{
+ register fractpel dy;
+
+ IfTrace4((LineDebug > 0), ".....StepLine: (%p,%p) to (%p,%p)\n",
+ x1, y1, x2, y2);
+
+ dy = y2 - y1;
+
+/*
+We execute the "GOING_TO" macro to call back the REGIONS module, if
+necessary (like if the Y direction of the edge has changed):
+*/
+ GOING_TO(R, x1, y1, x2, y2, dy);
+
+ if (dy == 0)
+ return;
+
+ if (dy < 0)
+ Bresenham(R->edge, x2, y2, x1, y1);
+ else
+ Bresenham(R->edge, x1, y1, x2, y2);
+ return;
+}
+/*
+:h3.Bresenham() - Actually Produces Run Ends
+
+This routine runs a Bresenham line-stepping
+algorithm. See, for example, Newman and Sproul, :hp1/Principles
+of Interactive Computer Graphics/, pp. 25-27.
+When we enter this, we
+are guaranteed that dy is positive.
+We'd like to work in 8 bit precision, so we'll define some macros and
+constants to let us do that:
+*/
+
+#define PREC 8 /* we'll keep fraction pels in 8 bit precision */
+/*
+RoundFP() rounds down by 'b' bits:
+*/
+#define RoundFP(xy,b) (((xy)+(1<<((b)-1)))>>(b))
+
+/*
+TruncFP() truncates down by 'b' bits:
+*/
+#define TruncFP(xy,b) ((xy)>>(b))
+
+
+void Bresenham(edgeP,x1,y1,x2,y2)
+ register pel *edgeP; /* pointer to top of list (y == 0) */
+ register fractpel x1,y1; /* starting point on line */
+ register fractpel x2,y2; /* ending point on the line (down) */
+{
+ register long dx,dy; /* change in x and y, in my own precision */
+ register long x,y; /* integer pel starting point */
+ register int count; /* integer pel delta y */
+ register long d; /* the Bresenham algorithm error term */
+
+ x1 = TruncFP(x1, FRACTBITS-PREC);
+ y1 = TruncFP(y1, FRACTBITS-PREC);
+ x2 = TruncFP(x2, FRACTBITS-PREC);
+ y2 = TruncFP(y2, FRACTBITS-PREC);
+
+ dx = x2 - x1;
+ dy = y2 - y1;
+/*
+Find the starting x and y integer pel coordinates:
+*/
+
+ x = RoundFP(x1,PREC);
+ y = RoundFP(y1,PREC);
+ edgeP += y;
+ count = RoundFP(y2,PREC) - y;
+/*------------------------------------------------------------------*/
+/* Force dx to be positive so that dfy will be negative */
+/* this means that vertical moves will decrease d */
+/*------------------------------------------------------------------*/
+ if (dx<0)
+ {
+ dx = -dx;
+#define P PREC
+ d=(dy*(x1-(x<<P)+(1<<(P-1)))-dx*((y<<P)-y1+(1<<(P-1))))>>P;
+#undef P
+ while(--count >= 0 )
+ {
+ while(d<0)
+ {
+ --x;
+ d += dy;
+ }
+ *(edgeP++) = x;
+ d -= dx;
+ }
+ }
+ else /* positive dx */
+ {
+#define P PREC
+ d = (dy*((x<<P)-x1+(1<<(P-1)))-dx*((y<<P)-y1+(1<<(P-1))))>>P;
+#undef P
+ while(--count >= 0 )
+ {
+ while(d<0)
+ {
+ ++x;
+ d += dy;
+ }
+ *(edgeP++) = x;
+ d -= dx;
+ }
+ }
+}
diff --git a/src/Type1/lines.h b/src/Type1/lines.h
new file mode 100644
index 0000000..8e2cc74
--- /dev/null
+++ b/src/Type1/lines.h
@@ -0,0 +1,37 @@
+/* $Xorg: lines.h,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+/*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 */
+
+/*END SHARED*/
diff --git a/src/Type1/objects.c b/src/Type1/objects.c
new file mode 100644
index 0000000..438e859
--- /dev/null
+++ b/src/Type1/objects.c
@@ -0,0 +1,1125 @@
+/* $Xorg: objects.c,v 1.3 2000/08/17 19:46:30 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+ /* OBJECTS CWEB V0025 ******** */
+/*
+:h1.OBJECTS Module - TYPE1IMAGER Objects Common Routines
+
+This module defines and implements the C structures that represent
+objects in the TYPE1IMAGER. All common routines for manipulating these
+objects are defined in this module. Specific routines for
+specific objects are defined in the modules that deal with that
+object type.
+
+
+&author. Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com)
+
+
+:h3.Include Files
+
+The included files are:
+*/
+#define GLOBALS 1 /* see :hdref refid=debugvar. */
+/*
+The following two includes are C standards; we include them because we
+use 'toupper' and the 'str'-type functions in this module. Potentially
+these may be defined as macros; if these ".h" files do not exist on your
+system it is a pretty safe bet that these are external entry points and
+you do do not need to include these header files.
+*/
+
+#include <string.h>
+#include <ctype.h>
+
+/*
+override incorrect system functions; for example you might define
+a macro for "strcpy" that diverts it to "my_strcpy".
+*/
+
+ /* moved these includes from above the */
+ /* was included first (it contains com- */
+ /* piler defines). dsr 081291 */
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h"
+#include "fonts.h"
+#include "pictures.h"
+#include "strokes.h"
+#include "cluts.h"
+static char *TypeFmt();
+
+/*
+:h3.The "pointer" Macro - Define a Generic Pointer
+
+Sadly, many compilers will give a warning message when a pointer to
+one structure is assigned to a pointer to another. We've even seen
+some that give severe errors (when the wrong pointer type is used as
+an initializer or returned from a function). TYPE1IMAGER has routines
+like Dup and Allocate that are perfectly willing to duplicate or
+allocate any of a number of different types of structures. How to
+declare them in a truely portable way?
+
+Well, there is no single good answer that I've found. You can always
+beg the question and "cast" everything. I find this distracting and the
+resulting code ugly. On the other hand, we have found at least one
+compiler that will accept "void *" as a generic pointer that can
+assigned to any other pointer type without error or warning (apparently
+this is also the ANSI standard). So, we define "void *" to be a generic
+pointer. (You might have to change this for your compiler; the "ifndef"
+allows the change to be made on the command line if you want.)
+:i1/portability assumptions/
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Functions Provided to the TYPE1IMAGER User
+
+This module provides the following TYPE1IMAGER entry points:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+Note that entry points that are intended for use external to TYPE1IMAGER
+begin with the characters :q/xi/. Macros are used to make the names
+more mnemonic.
+*/
+
+/*
+:h3.Functions Provided to Other Modules
+
+This module provides the following functions for other modules:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+Note that entry points that intended for use within TYPE1IMAGER, but
+which must be global because they are used across module boundaries,
+begin with the characters :q/I_/. Macros are used to make the names
+more mnemonic.
+
+Entry points totally within a module use mnemonic names and are
+declared :hp2/static/. One of the compilers I used had a bug when
+static functions were passed as addresses. Thus, some functions
+which are logically "static" are not so declared.
+
+Note also the trick of declaring routines, like Consume(), with a
+variable number of arguments. To avoid the restrictions on variable
+numbers of arguments in the macro processor, we just replace the
+text 'Consume' with 'I_Consume'.
+*/
+/*
+:h3.Macros Provided to Other Modules
+
+This is the module where we define all the useful constants like
+TRUE, FALSE, and NULL, and simple expressions like MIN(), MAX(), and ABS().
+We might as well get to it right here:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+Notice that upper case is used for constant values and macro
+definitions. I generally follow that convention.
+
+Many more global macros are defined later in this module.
+*/
+/*
+:h2.Basic TYPE1IMAGER Object Structure
+
+All TYPE1IMAGER objects which are available to the user have a common
+header. This header is defined below:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+The following define is an attempt to centralize the definition of the
+common xobject data shared by structures that are derived from the
+generic xobject structure. For example, the structure font, defined in
+fonts.shr :
+&code.
+ struct font {
+ char type;
+ char flag;
+ int references;
+ ... other data types & structs ...
+ }
+&ecode.
+would now be defined as:
+&code.
+ struct font {
+ XOBJ_COMMON
+ ... other data types & structs ...
+ }
+&ecode.
+Thus we have a better-structured inheritance mechanism. 3-26-91 PNM
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Object Type Definitions
+
+These constants define the values which go in the 'type' field of
+an TYPE1IMAGER object structure:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Flag Byte Definitions
+
+Many programmers define flag bits as a mask (for example, 0x04), and
+test, set, and reset them as follows:
+
+&code.
+ if ((flag & PERMANENT) != 0)
+
+ flag |= PERMANENT;
+ flag &= &inv.PERMANENT;
+:exmp.
+
+I favor a style where the 'if' statement can ask a question:
+
+&code.
+ if (ISPERMANENT(flag))
+
+ flag |= ISPERMANENT(ON);
+ flag &= &inv.ISPERMANENT(ON);
+
+:exmp.
+This said, we now define two bit settings of the flag byte of the
+object. "ISPERMANENT" will be set by the user, when he calls
+Permanent(). "ISIMMORTAL" will be used for compiled-in objects
+that we don't want the user to ever destroy.
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+Flag bit definitions that apply to all objects are assigned
+starting with the least significant (0x01) bit. Flag bit definitions
+specific to a certain object type are assigned starting with the
+most significant (0x80) bit. We hope they never meet.
+*/
+/*
+:h3 id=preserve.PRESERVE() Macro
+
+Occasionally an TYPE1IMAGER operator is implemented by calling other
+TYPE1IMAGER operators. For example, Arc2() calls Conic(). When we
+call more than one operator as a subroutine, we have to be careful
+of temporary objects. A temporary object will be consumed by the
+subroutine operator and then is no longer available for the caller.
+This can be prevented simply by bumping a temporary object's reference
+count.
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.RefRoll() Macro to Detect References Count Rollover
+
+The following macro is designed to check for reference count rollover.
+A return value of TRUE means rollover has not occurred; a return value
+of FALSE means we cannot increment the reference count. Note also that
+those functions that use this macro must decrement the reference count
+afterwards. 3-26-91 PNM
+*/
+
+#define RefRoll(obj) (++(obj)->references > 0)
+
+/*
+:h2.TYPE1IMAGER Object Functions
+
+:h3.LONGCOPY() - Macro to Copy "long" Aligned Data
+
+Copying arbitrary bytes in C is a bit of a problem. "strcpy" can't be
+used, because 0 bytes are special-cased. Most environments have a
+routine "memcopy" or "bcopy" or "bytecopy" that copies memory containing
+zero bytes. Sadly, there is no standard on the name of such a routine,
+which makes it impossible to write truely portable code to use it.
+
+It turns out that TYPE1IMAGER, when it wants to copy data, frequently
+knows that both the source and destination are aligned on "long"
+boundaries. This allows us to copy by using "long *" pointers. This
+is usually very efficient on almost all processors. Frequently, it
+is more efficient than using general-purpose assembly language routines.
+So, we define a macro to do this in a portable way. "dest" and "source"
+must be long-aligned, and "bytes" must be a multiple of "sizeof(long)":
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Allocate() - Allocating a Memory Block
+
+Allocate returns a pointer to memory object that is a copy of
+the template passed (if any). In addition, extra bytes may be
+allocated contiguously with the object. (This may be useful for
+variable size objects such as edge lists. See :hdref refid=regions..)
+
+Allocate() always returns a non-immortal object, even if the template is
+immortal. Therefore a non-NULL template must have a "flag" byte.
+
+If the template is NULL, then 'size' bytes are cleared to all NULLs.
+
+If the template is non-NULL, a new object is allocated in memory.
+It therefore seems logical that its reference count field should be
+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 */
+{
+ extern char *xiMalloc(); /* standard C routine */
+
+ register struct xobject *r;
+
+ /*
+ * round up 'size' and 'extra' to be an integer number of 'long's:
+ */
+ size = (size + sizeof(long) - 1) & -(int)sizeof(long);
+ extra = (extra + sizeof(long) - 1) & -(int)sizeof(long);
+ if (size + extra <= 0)
+ 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");
+ }
+ r = (struct xobject *) xiMalloc(size + extra);
+ }
+
+ /*
+ * copy the template into the new memory:
+ */
+ if (template != NULL) {
+ /* Added references count decrement if template is not permanent.
+ This is for the case where Allocate is called by a Dupxxxx
+ function, which was in turn called by Unique(). (PNM) */
+ if (!ISPERMANENT(template->flag))
+ --template->references;
+ LONGCOPY(r, template, size);
+ r->flag &= ~(ISPERMANENT(ON) | ISIMMORTAL(ON));
+ /* added reference field 3-2-6-91 PNM */
+ r->references = 1;
+ }
+ else {
+ register char **p1;
+
+ for (p1=(char **)r; size > 0; size -= sizeof(char *))
+ *p1++ = NULL;
+ }
+
+ if (MemoryDebug > 1) {
+ register long *L;
+ L = (long *) r;
+ IfTrace4(TRUE, "Allocating at %x: %x %x %x\n",
+ L, L[-1], L[0], L[1]);
+ }
+ return(r);
+}
+
+/*
+:h3.Free() - Frees an Allocated Object
+
+This routine makes a sanity check to make sure the "type" field of the
+standard object structure has not been cleared. If the object is
+not a standard structure, then the macro "NonObjectFree" is available
+that does not perform this check.
+
+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 */
+{
+ if (obj->type == INVALIDTYPE)
+ abort("Free of already freed object?");
+ obj->type = INVALIDTYPE;
+
+ if (MemoryDebug > 1) {
+ register long *L;
+ L = (long *) obj;
+ IfTrace4(TRUE,"Freeing at %x: %x %x %x\n", L, L[-1], L[0], L[1]);
+ }
+
+ xiFree(obj);
+}
+
+/*
+:h3.Permanent() - Makes an Object Permanent
+
+Real simple--just set a flag. Every routine that consumes its objects
+(which is almost every user entry) must check this flag, and not consume
+the object if it is set.
+
+If a temporary object is made permanent, and there is more than one
+reference to it, we must first Copy() it, then set the ISPERMANENT
+flag. Note also that the reference count must be incremented when an
+object is changed from temporary to permanent (see the ISUNIQUE macro).
+
+Note that the purpose of this function is to convert an object into a
+permanent object:
+ If it was permanent to begin with, we do nothing;
+ If it was temporary and unique, we set the PERMANENT flag and increment
+the reference count;
+ If it was temporary and nonunique, we must make a unique Copy(), set
+the PERMANENT flag, and set the reference count to 2. We must also
+decrement the original object's reference count, because what we have
+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 */
+{
+ IfTrace1((MustTraceCalls),"Permanent(%z)\n", obj);
+
+ if ( (obj != NULL) && ( !(ISPERMANENT(obj->flag)) ) )
+ {
+ /* there is a non-NULL, temporary object to be made permanent.
+ If there are multiple references to this object, first get
+ a new COPY().
+ Note also that we have to decrement the reference count if
+ we do a Copy() here, because we are consuming the temporary
+ argument passed, and returning a unique, permanent one.
+ */
+ if ( obj->references > 1)
+ {
+ obj = Copy(obj);
+ }
+ /* now set the permanent flag, and increment the reference
+ count, since a temporary object has now become permanent. */
+ obj->references++;
+ obj->flag |= ISPERMANENT(ON);
+ }
+ return(obj);
+}
+
+/*
+:h3.Temporary() - Undoes the Effect of "Permanent()"
+
+This simply resets the "ISPERMANENT" flag.
+
+If a permanent object is made temporary, and there is more than one reference
+to it, we must first Copy() it, then reset the ISPERMANENT flag. However,
+if the permanent object has obly one reference, we need only decrement the
+reference count ( and reset the flag).
+
+Note that this function, in the case of a PERMANENT argument, basically
+converts the PERMANENT handle to a TEMPORARY one. Thus, in the case of
+a nonunique, permanent argument passed, we not only make a Copy(),
+we also decrement the reference count, to reflect the fact that we have
+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 */
+{
+ IfTrace1((MustTraceCalls),"Temporary(%z)\n", obj);
+
+ if (obj != NULL) {
+ /* if it's already temporary, there's nothing to do. */
+ if ISPERMANENT(obj->flag)
+ {
+ /* if there are multiple references to this object, get a
+ Copy we can safely alter. Recall that the reference count
+ is incremented for permanent objects.
+ Recall further that Copy returns an object with the
+ same flag state and a reference count of 2 (for PERMANENT
+ objects).
+ Thus, regardless of whether or not we need to copy a
+ permanent object, we still decrement its reference
+ count and reset the flag.
+ */
+ if (obj->references != 2 || ISIMMORTAL(obj->flag))
+ {
+ /* not unique; consume handle, get a temporary Copy! */
+ obj = Copy(obj);
+ }
+ /* else decrement the reference count (since it's going from
+ permanent to temporary) and clear the flag. */
+ else {
+ obj->references--;
+ obj->flag &= ~ISPERMANENT(ON);
+ }
+ }
+ }
+ return(obj);
+}
+
+/*
+:h3.Dup() - Duplicate an Object
+
+Dup will increment the reference count of an object, only making a
+Copy() if needed.
+Note that Dup() retains the state of the permanent flag.
+3-26-91 PNM
+*/
+
+
+struct xobject *t1_Dup(obj) /* non-ANSI avoids overly strict type checking */
+ register struct xobject *obj; /* object to be duplicated */
+{
+ register char oldflag; /* copy of original object's flag byte */
+
+ IfTrace1((MustTraceCalls),"Dup(%z)\n", obj);
+
+ if (obj == NULL)
+ return(NULL);
+ /* An immortal object must be Copy'ed, so that we get a mortal
+ copy of it, since we try not to destroy immortal objects. */
+ if (ISIMMORTAL(obj->flag))
+ return(Copy(obj));
+
+ /* if incrementing the reference count doesn't cause the count
+ to wrap, simply return the object with the count bumped. Note
+ that the RefRoll macro increments the count to perform the
+ rollover check, so we must decrement the count. */
+ if (RefRoll(obj))
+ return(obj);
+
+ /* that didn't work out, so put the count back and call Copy(). */
+ --obj->references;
+ oldflag = obj->flag;
+ obj = Copy(obj);
+ if (ISPERMANENT(oldflag))
+ obj = Permanent(obj);
+ return(obj);
+}
+
+/*
+:h3.Copy() - Make a New Copy of an Object
+
+This is the generic Copy() where the object type is unknown. There
+are specific Copyxxx functions for known object types.
+
+Copy will create a NEW temporary object, and WILL NOT simply bump the
+reference count.
+
+Sometimes duplicating an object is just as simple as Allocating with it
+as a template. But other objects are complicated linked lists. So, we
+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 */
+{
+ if (obj == NULL)
+ return(NULL);
+
+ if (ISPATHTYPE(obj->type))
+ obj = (struct xobject *) CopyPath(obj);
+ else
+ switch (obj->type) {
+ case SPACETYPE:
+ obj = (struct xobject *) CopySpace(obj); break;
+ case FONTTYPE:
+ obj = (struct xobject *) CopyFont(obj); break;
+ case REGIONTYPE:
+ obj = (struct xobject *) CopyRegion(obj); break;
+ case PICTURETYPE:
+ obj = (struct xobject *) CopyPicture(obj); break;
+ case LINESTYLETYPE:
+ obj = (struct xobject *) CopyLineStyle(obj); break;
+ case STROKEPATHTYPE:
+ obj = (struct xobject *) CopyStrokePath(obj); break;
+ case CLUTTYPE:
+ obj = (struct xobject *) CopyCLUT(obj); break;
+ default:
+ return(ArgErr("Copy: invalid object", obj, NULL));
+ }
+
+ return(obj);
+}
+
+/*
+:h3.Destroy() - Destroys an Object
+
+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 */
+{
+ IfTrace1((MustTraceCalls),"Destroy(%z)\n", obj);
+
+ if (obj == NULL)
+ return(NULL);
+ if (ISIMMORTAL(obj->flag)) {
+ IfTrace1(TRUE,"Destroy of immortal object %z ignored\n", obj);
+ return(NULL);
+ }
+ if (ISPATHTYPE(obj->type))
+ KillPath(obj);
+ else {
+ switch (obj->type) {
+ case REGIONTYPE:
+ KillRegion(obj);
+ break;
+ case SPACETYPE:
+ KillSpace(obj);
+ break;
+ case LINESTYLETYPE:
+ KillLineStyle(obj);
+ break;
+ case FONTTYPE:
+ KillFont(obj);
+ break;
+ case PICTURETYPE:
+ KillPicture(obj);
+ break;
+ case STROKEPATHTYPE:
+ KillStrokePath(obj);
+ break;
+ case CLUTTYPE:
+ KillCLUT(obj);
+ break;
+ default:
+ return(ArgErr("Destroy: invalid object", obj, NULL));
+ }
+ }
+ return(NULL);
+}
+/*
+:h2.Generally Useful Macros
+
+:h3.FOLLOWING() - Macro to Point to the Data Following a Structure
+
+There are several places in TYPE1IMAGER where we will allocate variable
+data that belongs to a structure immediately after that structure.
+This is a performance technique, because it reduces the number of
+trips we have to take through xiMalloc() and xiFree(). It turns out C has
+a very convenient way to point past a structure--if 'p' is a pointer
+to a structure, 'p+1' is a pointer to the data after it. This
+behavior of C is somewhat startling and somewhat hard to follow, if
+you are not used to it, so we define a macro to point to the data
+following a structure:
+*/
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.TYPECHECK() - Verify the Type of an Argument
+
+This macro tests the type of an argument. If the test fails, it consumes
+any other arguments as necessary and causes the imbedding routine to
+return the value 'whenBAD'.
+
+Note that the consumeables list should be an argument list itself, for
+example (0) or (2,A,B). See :hdref refid=consume. below.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.ARGCHECK() - Perform an Arbitrary Check on an Argument
+
+This macro is a generalization of TYPECHECK to take an arbitrary
+predicate. If the error occurs (i.e., the predicate is true), the
+arbitrary message 'msg' is returned.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.TYPENULLCHECK() - Extension of TYPECHECK() for NULL arguments
+
+Many routines allow NULLs to be passed as arguments. 'whenBAD' will
+be returned in this case, too.
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.MAKECONSUME() - Create a "Consume"-type Macro
+
+Consuming an object means destroying it if it is not permanent. This
+logic is so common to all the routines, that it is immortalized in this
+macro. For example, ConsumePath(p) can be simply defined as
+MAKECONSUME(p,KillPath(p)). In effect, this macro operates on a
+meta-level.
+:i1/consuming objects/
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h3.MAKEUNIQUE() - Create a "Unique"-type Macro
+
+Many routines are written to modify their arguments in place. Thus,
+they want to insure that they duplicate an object if it is permanent.
+This is called making an object "unique". For example, UniquePath(p)
+can be simply defined as MAKEUNIQUE(p,DupPath(p)).
+:i1/unique objects/
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+An object is unique (and directly alterable) if there is only one
+reference to it, and it is not permanent (in which case we increment
+the reference count, so we don't have to check the permanent bit).
+3-26-91 PNM
+
+Note the rules for making a unique object:
+&drawing.
+ IF (obj->references = 1) return(obj);
+ ELSE (references > 1)
+ IF (ISPERMANENT(obj->flag)) return(Dupxxx(obj));
+ ELSE (nonunique, temporary object!)
+ obj->references--; return(Dupxxx(obj));
+&edrawing.
+If we must make a Copy of a nonunique, temporary object, we decrement
+reference count of the original object!
+*/
+
+/*
+:h3.Unique() - Make a Unique Object
+
+Here is a generic 'Unique' function if the object type is not known.
+Why didn't we build it with the MAKEUNIQUE macro, you ask? Well, we
+used to, but there is at least one damn compiler in the world that
+raises errors if the types of an "(a) ? b : c" expression do not match.
+Also, when we changed Dup() to retain the permanent/temporary flag, we
+wanted to make sure "Unique" always returned a temporary object.
+
+Note that we cannot use Dup() to create a copy of the object in question,
+because Dup() may simply bump the reference count, and not return a
+unique copy to us. That is why we use t1_Copy().
+
+The purpose of this function is to make sure we have a copy of an object
+that we can safely alter:
+:ol.
+:li.If we have a unique, temporary object, we simply return the argument.
+:li.If we have a nonunique, temporary object, we have to make a new copy
+of it, and decrement the reference count of the original object, to reflect
+the fact that we traded temporary handles.
+:li.If we have a permanent object, we make a temporary copy of it, but
+we do not decrement the reference count of the original permanent object,
+because permanent objects, by definition, are persistent. 3-2-6-91 PNM
+:eol.
+*/
+
+struct xobject *t1_Unique(obj)
+ struct xobject *obj;
+{
+ /* 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
+ NOTE : consumption of the old handle moved to Allocate. 4-18-91 */
+ if (!obj || obj->references == 1)
+ return(obj);
+
+ obj = Copy(obj);
+ /* and make sure we return a temporary object ! */
+ if (ISPERMANENT(obj->flag))
+ {
+ obj->flag &= ~ISPERMANENT(ON);
+ obj->references--;
+ }
+ return(obj);
+}
+
+
+/*
+:h2.Initialization, Error, and Debug Routines
+
+:h3 id=debugvar.Declarations for Debug Purposes
+
+We declare all the debug flags here. Some link editors make the not
+unreasonable restriction that only one module may declare and
+initialize global variables; all the rest must declare the variable
+'extern'. This is logical, but is somewhat awkward to implement with
+C include files. We solve the problem by temporarily making the name
+'extern' a null name if GLOBALS is defined. (GLOBALS is only defined
+in this OBJECTS module.) Since 'externs' can't be initialized, we
+have to handle that with #defines too.
+:i1/GLOBALS (&#define.)/
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+static char *ErrorMessage = NULL;
+
+/*
+:h3.Pragmatics() - Set/Reset Debug Flags
+
+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 */
+{
+ 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");
+ strcpy(name, username);
+ for (p = name; *p != '\0'; p++)
+ *p = toupper(*p);
+
+ if (!strcmp(name, "ALL"))
+ MustTraceCalls = InternalTrace = /* MustCrash = */
+ LineIOTrace = value;
+
+ else if (!strcmp(name, "LINEIOTRACE"))
+ LineIOTrace = value;
+
+ else if (!strcmp(name, "TRACECALLS"))
+ MustTraceCalls = value;
+
+ else if (!strcmp(name, "CHECKARGS"))
+ MustCheckArgs = value;
+
+ else if (!strcmp(name, "PROCESSHINTS"))
+ ProcessHints = value;
+
+ else if (!strcmp(name, "SAVEFONTPATHS"))
+ SaveFontPaths = value;
+
+ else if (!strcmp(name, "CRASTERCOMPRESSIONTYPE"))
+ CRASTERCompressionType = value;
+
+ else if (!strcmp(name, "CRASHONUSERERROR"))
+ MustCrash = value;
+
+ else if (!strcmp(name, "DEBUG"))
+ StrokeDebug = SpaceDebug = PathDebug = ConicDebug = LineDebug =
+ RegionDebug = MemoryDebug = FontDebug =
+ HintDebug = ImageDebug = OffPageDebug = value;
+
+ else if (!strcmp(name, "CONICDEBUG"))
+ ConicDebug = value;
+
+ else if (!strcmp(name, "LINEDEBUG"))
+ LineDebug = value;
+
+ else if (!strcmp(name, "REGIONDEBUG"))
+ RegionDebug = value;
+
+ else if (!strcmp(name, "PATHDEBUG"))
+ PathDebug = value;
+
+ else if (!strcmp(name, "SPACEDEBUG"))
+ SpaceDebug = value;
+
+ else if (!strcmp(name, "STROKEDEBUG"))
+ StrokeDebug = value;
+
+ else if (!strcmp(name, "MEMORYDEBUG"))
+ MemoryDebug = value;
+
+ else if (!strcmp(name, "FONTDEBUG"))
+ FontDebug = value;
+
+ else if (!strcmp(name, "HINTDEBUG"))
+ HintDebug = value;
+
+ else if (!strcmp(name, "IMAGEDEBUG"))
+ ImageDebug = value;
+
+ else if (!strcmp(name, "OFFPAGEDEBUG"))
+ OffPageDebug = value;
+
+#ifdef MC68000
+/*
+The following pragmatics flag turns on or off instruction histograming
+for performance analysis. It is only defined in the Delta card
+environment.
+*/
+ else if (!strcmp(name, "PROFILE")) {
+ if (value)
+ StartProfile();
+ else
+ StopProfile();
+ }
+#endif
+ else if (!strcmp(name, "FLUSHCACHE")) {
+#ifdef notdef
+ while (GimeSpace()) { ; }
+#endif
+ }
+
+ else if (!strcmp(name, "CACHEDCHARS"))
+ CachedChars = (value <= 0) ? 1 : value;
+
+ else if (!strcmp(name, "CACHEDFONTS"))
+ CachedFonts = (value <= 0) ? 1 : value;
+
+ else if (!strcmp(name, "CACHEBLIMIT"))
+ CacheBLimit = value;
+
+ else if (!strcmp(name, "CONTINUITY"))
+ Continuity = value;
+
+
+ else {
+ printf("Pragmatics flag = '%s'\n", name);
+ ArgErr("Pragmatics: flag not known", NULL, NULL);
+ }
+ return;
+}
+
+/*
+:h3.Consume() - Consume a List of Arguments
+
+This general purpose routine is provided in the case where the object
+type(s) to be consumed are unknown or not yet verified, and/or it is
+not known whether the object is permanent.
+
+If the type of the argument is known, it is faster to directly consume
+that type, for example, ConsumeRegion() or ConsumePath(). Furthermore,
+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;
+{
+ 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");
+ }
+}
+/*
+:h4.ObjectPostMortem() - Prints as Much as We Can About a Bad Object
+
+This is a subroutine of TypeErr() and ArgErr().
+*/
+
+/*ARGSUSED*/
+static void
+ObjectPostMortem(obj) /* non-ANSI avoids overly strict type checking */
+ register struct xobject *obj;
+{
+ extern struct XYspace *USER;
+
+ Pragmatics("Debug", 10);
+ IfTrace2(TRUE,"Bad object is of %s type %z\n", TypeFmt(obj->type), obj);
+
+ IfTrace0((obj == (struct xobject *) USER),
+ "Suspect that InitImager() was omitted.\n");
+ Pragmatics("Debug", 0);
+}
+
+/*
+: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 */
+{
+ /*
+ * This buffer must be large enough to hold 'name' plus
+ * two of the largest strings that can be returned by TypeFmt.
+ * The largest value of 'name' is currently 9 ("ClosePath")
+ * and the longest strings in TypeFmt are 30 characters.
+ */
+ static char typemsg[115];
+
+ if (MustCrash)
+ LineIOTrace = TRUE;
+
+ sprintf(typemsg, "Wrong object type in %s. Expected %s; was %s.\n",
+ name, TypeFmt(expect), TypeFmt(obj->type));
+ IfTrace0(TRUE,typemsg);
+
+ ObjectPostMortem(obj);
+
+ if (MustCrash)
+ abort("Terminating because of CrashOnUserError...");
+ else
+ ErrorMessage = typemsg;
+
+/* changed ISPERMANENT to ret->references > 1 3-26-91 PNM */
+ if (ret != NULL && (ret->references > 1))
+ ret = Dup(ret);
+ return(ret);
+}
+
+/*
+:h4.TypeFmt() - Returns Pointer to English Name of Object Type
+
+This is a subroutine of TypeErr().
+*/
+
+static char *TypeFmt(type)
+ int type; /* type field */
+{
+ char *r;
+
+ if (ISPATHTYPE(type))
+ if (type == TEXTTYPE)
+ r = "path or region (from TextPath)";
+ else
+ r = "path";
+ else {
+ switch (type) {
+ case INVALIDTYPE:
+ r = "INVALID (previously consumed?)";
+ break;
+ case REGIONTYPE:
+ r = "region";
+ break;
+ case SPACETYPE:
+ r = "XYspace";
+ break;
+ case LINESTYLETYPE:
+ r = "linestyle";
+ break;
+ case FONTTYPE:
+ r = "font";
+ break;
+ case PICTURETYPE:
+ r = "picture";
+ break;
+ case STROKEPATHTYPE:
+ r = "path (from StrokePath)";
+ break;
+ default:
+ r = "UNKNOWN";
+ break;
+ }
+ }
+ return(r);
+}
+/*
+:h3.ArgErr() - Invalid Argument Passed to a Routine
+
+A common routine to report argument errors. It is usually called
+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 */
+{
+ if (MustCrash)
+ LineIOTrace = TRUE;
+ IfTrace1(TRUE,"ARGUMENT ERROR-- %s.\n", string);
+ if (obj != NULL)
+ ObjectPostMortem(obj);
+ if (MustCrash)
+ abort("Terminating because of CrashOnUserError...");
+ else
+ ErrorMessage = string;
+ return(ret);
+}
+
+/*
+:h3.abort() - Crash Due to Error
+
+Defined in objects.h to be FatalError(), the server's abort routine.
+*/
+
+/*
+:h3.REAL Miscellaneous Stuff
+
+:h4.ErrorMsg() - Return the User an Error Message
+*/
+
+char *ErrorMsg()
+{
+ register char *r;
+
+ r = ErrorMessage;
+ ErrorMessage = NULL;
+ return(r);
+}
+
+/*
+:h4.InitImager() - Initialize TYPE1IMAGER
+
+We check that a short is 16 bits and a long 32 bits; we have made
+those assumptions elsewhere in the code. (This is almost a C standard,
+anyway.) Note that TYPE1IMAGER makes no assumptions about the size of an
+'int'!
+:i1/portability assumptions/
+*/
+
+void InitImager()
+{
+
+/* Check to see if we have been using our own malloc. If so,*/
+/* Undef malloc so that we can get to the system call. */
+/* All other calls to malloc are defined to xiMalloc. */
+
+
+/* if (sizeof(short) != 2 || sizeof(INT32) != 4)
+ abort("Fundamental TYPE1IMAGER assumptions invalid in this port");
+*/
+ InitSpaces();
+ InitFonts();
+ InitFiles();
+/*
+In some environments, constants and/or exception handling need to be
+*/
+ LibInit();
+}
+/*
+:h4.TermImager() - Terminate TYPE1IMAGER
+
+This only makes sense in a server environment; true TYPE1IMAGER needs do
+nothing.
+*/
+void TermImager()
+{
+ return;
+}
+/*
+:h4.reportusage() - A Stub to Get a Clean Link with Portable PMP
+*/
+void reportusage()
+{
+ return;
+}
diff --git a/src/Type1/objects.h b/src/Type1/objects.h
new file mode 100644
index 0000000..30a9773
--- /dev/null
+++ b/src/Type1/objects.h
@@ -0,0 +1,291 @@
+/* $Xorg: objects.h,v 1.3 2000/08/17 19:46:31 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+/*SHARED*/
+
+/*END SHARED*/
+/*SHARED*/
+
+#define Permanent(obj) t1_Permanent(obj)
+#define Temporary(obj) t1_Temporary(obj)
+#define Destroy(obj) t1_Destroy(obj)
+#define Dup(obj) t1_Dup(obj)
+#define InitImager() t1_InitImager()
+#define TermImager() t1_TermImager()
+#define Pragmatics(f,v) t1_Pragmatics(f,v)
+#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 */
+
+/*END SHARED*/
+/*SHARED*/
+
+#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 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 */
+
+/*END SHARED*/
+/*SHARED*/
+
+#define ON (~0) /* all bits on */
+#ifndef FALSE
+#define FALSE 0 /* handy zero value */
+#endif
+#ifndef TRUE
+#define TRUE 1 /* handy non-zero value */
+#endif
+
+#ifndef NULL
+#define NULL 0
+/*
+The NULL pointer is system specific. (Most systems, however, use 0.)
+TYPE1IMAGER could have its own NULL, independent of the rest of the system,
+were it not for malloc(). The system call malloc() returns NULL when
+out of memory.
+:i1/portibility assumptions/
+*/
+#endif
+
+#ifndef MIN
+#define MIN(a,b) (((a)<(b)) ? a : b)
+#endif
+#ifndef MAX
+#define MAX(a,b) (((a)>(b)) ? a : b)
+#endif
+#ifndef ABS
+#define ABS(a) (((a)>=0)?(a):-(a))
+#endif
+
+/*END SHARED*/
+/*SHARED*/
+
+struct xobject {
+ char type; /* encoded type of object */
+ unsigned char flag; /* flag byte for temporary object characteristics*/
+ short references; /* count of pointers to this object
+ (plus 1 for permanent objects) PNM */
+} ;
+
+/*END SHARED*/
+/*SHARED*/
+
+#define XOBJ_COMMON char type; unsigned char flag; short references;
+
+/*END SHARED*/
+/*SHARED*/
+
+
+#define INVALIDTYPE 0
+#define FONTTYPE 1
+#define REGIONTYPE 3
+#define PICTURETYPE 4
+#define SPACETYPE 5
+#define LINESTYLETYPE 6
+#define EDGETYPE 7
+#define STROKEPATHTYPE 8
+#define CLUTTYPE 9
+
+#define ISPATHTYPE(type) ((type)&0x10) /* all path segments have this bit on */
+#define LINETYPE (0+ISPATHTYPE(ON))
+#define CONICTYPE (1+ISPATHTYPE(ON))
+#define BEZIERTYPE (2+ISPATHTYPE(ON))
+#define HINTTYPE (3+ISPATHTYPE(ON))
+
+#define MOVETYPE (5+ISPATHTYPE(ON))
+#define TEXTTYPE (6+ISPATHTYPE(ON))
+
+/*END SHARED*/
+/*SHARED*/
+
+#define ISPERMANENT(flag) ((flag)&0x01)
+#define ISIMMORTAL(flag) ((flag)&0x02)
+
+/*END SHARED*/
+/*SHARED*/
+
+#define PRESERVE(obj) if (!ISPERMANENT((obj)->flag)) \
+ (obj)->references++;
+
+/*END SHARED*/
+/*SHARED*/
+
+#define LONGCOPY(dest,source,bytes) { \
+ register long *p1 = (long *)dest; register long *p2 = (long *)source; \
+ register int count = (bytes) / sizeof(long); \
+ while (--count >= 0) *p1++ = *p2++; }
+
+
+/*END SHARED*/
+/*SHARED*/
+
+#define FOLLOWING(p) ((p)+1)
+
+/*END SHARED*/
+/*SHARED*/
+
+#define TYPECHECK(name, obj, expect, whenBAD, consumables, rettype) { \
+ if (obj->type != expect) { \
+ (Consume)consumables; \
+ return((rettype)TypeErr(name, obj, expect, whenBAD)); \
+ } \
+}
+
+/*END SHARED*/
+/*SHARED*/
+
+#define ARGCHECK(test,msg,obj,whenBAD,consumables,rettype) { \
+ if (test) { \
+ (Consume)consumables; \
+ return((rettype)ArgErr(msg, obj, whenBAD)); \
+ } \
+}
+
+/*END SHARED*/
+/*SHARED*/
+
+/* Changed use of Dup() below to Temporary(Copy()) because Dup() does not
+ necessarily return a Unique Copy anymore! 3-26-91 */
+#define TYPENULLCHECK(name, obj, expect, whenBAD, consumables,rettype) \
+ if (obj == NULL) { \
+ (Consume)consumables; \
+ if (whenBAD != NULL && ISPERMANENT(whenBAD->flag)) \
+ return((rettype)Temporary(Copy(whenBAD))); \
+ else return((rettype)whenBAD); \
+ } else { \
+ if (obj->type != expect) { \
+ (Consume)consumables; \
+ return((rettype)TypeErr(name, obj, expect, whenBAD)); \
+ } \
+ }
+/*END SHARED*/
+/*SHARED*/
+
+#define MAKECONSUME(obj,stmt) { if (!ISPERMANENT(obj->flag)) stmt; }
+
+/*END SHARED*/
+/*SHARED*/
+
+#define MAKEUNIQUE(obj,stmt) ( ( (obj)->references > 1 ) ? stmt : obj )
+
+/*END SHARED*/
+/*SHARED*/
+#define IfTrace0(condition,model)
+#define IfTrace1(condition,model,arg0)
+#define IfTrace2(condition,model,arg0,arg1)
+#define IfTrace3(condition,model,arg0,arg1,arg2)
+#define IfTrace4(condition,model,arg0,arg1,arg2,arg3)
+#define IfTrace5(condition,model,arg0,arg1,arg2,arg3,arg4)
+#define IfTrace6(condition,model,arg0,arg1,arg2,arg3,arg4,arg5)
+
+
+void Trace0();
+char *Trace1(),*Trace2(),*Trace3(),*Trace4(),*Trace5(),*Trace6();
+
+#ifdef GLOBALS
+
+#define extern
+#define INITIALIZED(value) = value
+
+#else
+
+#define INITIALIZED(value)
+
+#endif
+
+extern char MustCheckArgs INITIALIZED(TRUE);
+extern char MustTraceCalls INITIALIZED(FALSE);
+extern char MustCrash INITIALIZED(TRUE);
+extern char InternalTrace INITIALIZED(TRUE);
+extern char LineIOTrace INITIALIZED(TRUE);
+
+extern char ProcessHints INITIALIZED(TRUE);
+
+extern char SaveFontPaths INITIALIZED(TRUE);
+
+extern short CRASTERCompressionType INITIALIZED(1);
+
+extern char ConicDebug INITIALIZED(0);
+extern char LineDebug INITIALIZED(0);
+extern char RegionDebug INITIALIZED(0);
+extern char PathDebug INITIALIZED(0);
+extern char FontDebug INITIALIZED(0);
+extern char SpaceDebug INITIALIZED(0);
+extern char StrokeDebug INITIALIZED(0);
+extern char MemoryDebug INITIALIZED(0);
+extern char HintDebug INITIALIZED(0);
+extern char ImageDebug INITIALIZED(0);
+extern char OffPageDebug INITIALIZED(0);
+
+extern short CachedChars INITIALIZED(0x7FFF);
+extern short CachedFonts INITIALIZED(0x7FFF);
+extern int CacheBLimit INITIALIZED(12500);
+extern char Continuity INITIALIZED(2);
+
+#ifdef extern
+#undef extern
+#endif
+
+/*
+We define other routines formatting parameters
+*/
+#define DumpArea(area) t1_DumpArea(area)
+#define DumpText(text) t1_DumpText(text)
+#define DumpPath(path) t1_DumpPath(path)
+#define DumpSpace(space) t1_DumpSpace(space)
+#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 */
+
+/*END SHARED*/
diff --git a/src/Type1/paths.c b/src/Type1/paths.c
new file mode 100644
index 0000000..35c3e41
--- /dev/null
+++ b/src/Type1/paths.c
@@ -0,0 +1,1506 @@
+/* $Xorg: paths.c,v 1.3 2000/08/17 19:46:31 cpqbld Exp $ */
+/* Copyright International Business Machines, Corp. 1991
+ * All Rights Reserved
+ * Copyright Lexmark International, Inc. 1991
+ * All Rights Reserved
+ *
+ * License to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM or Lexmark not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
+ * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE
+ * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
+ * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF THE
+ * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
+ * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN NO EVENT SHALL
+ * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+ /* PATHS CWEB V0021 ******** */
+/*
+:h1 id=paths.PATHS Module - Path Operator Handler
+
+This is the module that is responsible for building and transforming
+path lists.
+
+&author. Jeffrey B. Lotspiech (lotspiech@almaden.ibm.com)
+
+
+:h3.Include Files
+
+The included files are:
+*/
+
+ /* after the system includes (dsr) */
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h" /* understands about Union */
+#include "fonts.h" /* understands about TEXTTYPEs */
+#include "pictures.h" /* understands about handles */
+#include "strokes.h" /* understands how to coerce stroke paths */
+#include "trig.h"
+
+/*
+:h3.Routines Available to the TYPE1IMAGER User
+
+The PATHS routines that are made available to the outside user are:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Functions Provided to Other Modules
+
+The path routines that are made available to other TYPE1IMAGER modules
+are defined here:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+NOTE: because of the casts put in the macros for Loc, ArcCA, Conic,
+RoundConic, PathSegment, and JoinSegment, we cannot use the macro names
+when the functions are actually defined. We have to use the unique
+names with their unique first two characters. Thus, if anyone in the
+future ever decided to change the first two characters, it would not be
+enough just to change the macro (as it would for most other functions).
+He would have to also change the function definition.
+*/
+/*
+:h3.Macros Provided to Other Modules
+
+The CONCAT macro is defined here and used in the STROKES module. See
+:hdref refid=pathmac..
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+:h2.Path Segment Structures
+
+A path is represented as a linked list of the following structure:
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+When 'link' is NULL, we are at the last segment in the path (surprise!).
+
+'last' is only non-NULL on the first segment of a path,
+for all the other segments 'last' == NULL. We test for a non-NULL
+'last' (ISPATHANCHOR predicate) when we are given an alleged path
+to make sure the user is not trying to pull a fast one on us.
+
+A path may be a collection of disjoint paths. Every break in the
+disjoint path is represented by a MOVETYPE segment.
+
+Closed paths are discussed in :hdref refid=close..
+
+:h3.CopyPath() - Physically Duplicating a Path
+
+This simple function illustrates moving through the path linked list.
+Duplicating a segment just involves making a copy of it, except for
+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 */
+{
+ register struct segment *p,*n,*last,*anchor;
+
+ for (p = p0, anchor = NULL; p != NULL; p = p->link) {
+
+ ARGCHECK((!ISPATHTYPE(p->type) || (p != p0 && p->last != NULL)),
+ "CopyPath: invalid segment", p, NULL, (0), struct segment *);
+
+ if (p->type == TEXTTYPE)
+ n = (struct segment *) CopyText(p);
+ else
+ n = (struct segment *)Allocate(p->size, p, 0);
+ n->last = NULL;
+ if (anchor == NULL)
+ anchor = n;
+ else
+ last->link = n;
+ last = n;
+ }
+/*
+At this point we have a chain of newly allocated segments hanging off
+'anchor'. We need to make sure the first segment points to the last:
+*/
+ if (anchor != NULL) {
+ n->link = NULL;
+ anchor->last = n;
+ }
+
+ return(anchor);
+}
+/*
+:h3.KillPath() - Destroying a Path
+
+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 */
+{
+ register struct segment *linkp; /* temp register holding next segment*/
+
+ /* return conditional based on reference count 3-26-91 PNM */
+ if ( (--(p->references) > 1) ||
+ ( (p->references == 1) && !ISPERMANENT(p->flag) ) )
+ return;
+
+ while (p != NULL) {
+ if (!ISPATHTYPE(p->type)) {
+ ArgErr("KillPath: bad segment", p, NULL);
+ return;
+ }
+ linkp = p->link;
+ if (p->type == TEXTTYPE)
+ KillText(p);
+ else
+ Free(p);
+ p = linkp;
+ }
+}
+
+/*
+:h2 id=location."location" Objects
+
+The TYPE1IMAGER user creates and destroys objects of type "location". These
+objects locate points for the primitive path operators. We play a trick
+here and store these objects in the same "segment" structure used for
+paths, with a type field == MOVETYPE.
+
+This allows the Line() operator, for example, to be very trivial:
+It merely stamps its input structure as a LINETYPE and returns it to the
+caller--assuming, of course, the input structure was not permanent (as
+it usually isn't).
+
+:h3.The "movesegment" Template Structure
+
+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 };
+/*
+: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 */
+{
+ register struct segment *r;
+
+
+ IfTrace3((MustTraceCalls),"..Loc(S=%z, x=%f, y=%f)\n", S, &x, &y);
+
+ r = (struct segment *)Allocate(sizeof(struct segment), &movetemplate, 0);
+ TYPECHECK("Loc", S, SPACETYPE, r, (0), struct segment *);
+
+ r->last = r;
+ r->context = S->context;
+ (*S->convert)(&r->dest, S, x, y);
+ ConsumeSpace(S);
+ return(r);
+}
+/*
+: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 */
+{
+ register struct segment *r;
+
+ IfTrace3((MustTraceCalls),"..ILoc(S=%z, x=%d, y=%d)\n",
+ S, (long) x, (long) y);
+ r = (struct segment *)Allocate(sizeof(struct segment), &movetemplate, 0);
+ TYPECHECK("Loc", S, SPACETYPE, r, (0), struct segment *);
+
+ r->last = r;
+ r->context = S->context;
+ (*S->iconvert)(&r->dest, S, (long) x, (long) y);
+ ConsumeSpace(S);
+ return(r);
+}
+
+/*
+:h3.SubLoc() - Vector Subtraction of Two Locition Objects
+
+This user operator subtracts two location objects, yielding a new
+location object that is the result.
+
+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;
+{
+ IfTrace2((MustTraceCalls),"SubLoc(%z, %z)\n", p1, p2);
+
+ ARGCHECK(!ISLOCATION(p1), "SubLoc: bad first arg", p1, NULL, (0), struct segment *);
+ ARGCHECK(!ISLOCATION(p2), "SubLoc: bad second arg", p2, NULL, (0), struct segment *);
+ p1 = UniquePath(p1);
+ p1->dest.x -= p2->dest.x;
+ p1->dest.y -= p2->dest.y;
+ ConsumePath(p2);
+ return(p1);
+}
+
+/*
+:h2.Straight Line Segments
+
+:h3.PathSegment() - Create a Generic Path Segment
+
+Many routines need a LINETYPE or MOVETYPE path segment, but do not
+want to go through the external user's interface, because, for example,
+they already know the "fractpel" destination of the segment and the
+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 */
+{
+ register struct segment *r; /* newly created segment */
+
+ r = (struct segment *)Allocate(sizeof(struct segment), &movetemplate, 0);
+ r->type = type;
+ r->last = r; /* last points to itself for singleton */
+ r->dest.x = x;
+ r->dest.y = y;
+ return(r);
+}
+/*
+:h3.Line() - Create a Line Segment Between (0,0) and a Point P
+
+This involves just creating and filling out a segment structure:
+*/
+struct segment *Line(P)
+ register struct segment *P; /* relevant coordinate space */
+{
+
+ IfTrace1((MustTraceCalls),"..Line(%z)\n", P);
+ ARGCHECK(!ISLOCATION(P), "Line: arg not a location", P, NULL, (0), struct segment *);
+
+ P = UniquePath(P);
+ P->type = LINETYPE;
+ return(P);
+}
+/*
+:h2.Curved Path Segments
+
+We need more points to describe curves. So, the structures for curved
+path segments are slightly different. The first part is identical;
+the curved structures are larger with the extra points on the end.
+
+:h3.Bezier Segment Structure
+
+We support third order Bezier curves. They are specified with four
+control points A, B, C, and D. The curve starts at A with slope AB
+and ends at D with slope CD. The curvature at the point A is inversely
+related to the length |AB|, and the curvature at the point D is
+inversely related to the length |CD|. Point A is always point (0,0).
+
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+/*
+:h3.Bezier() - Generate a Bezier Segment
+
+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) */
+{
+/* added reference field of 1 to temporary template below 3-26-91 PNM */
+ static struct beziersegment template =
+ { BEZIERTYPE, 0, 1, sizeof(struct beziersegment), 0,
+ NULL, NULL, { 0, 0 }, { 0, 0 }, { 0, 0 } };
+
+ register struct beziersegment *r; /* output segment */
+
+ IfTrace3((MustTraceCalls),"..Bezier(%z, %z, %z)\n", B, C, D);
+ ARGCHECK(!ISLOCATION(B), "Bezier: bad B", B, NULL, (2,C,D), struct beziersegment *);
+ ARGCHECK(!ISLOCATION(C), "Bezier: bad C", C, NULL, (2,B,D), struct beziersegment *);
+ ARGCHECK(!ISLOCATION(D), "Bezier: bad D", D, NULL, (2,B,C), struct beziersegment *);
+
+ r = (struct beziersegment *)Allocate(sizeof(struct beziersegment), &template, 0);
+ r->last = (struct segment *) r;
+ r->dest.x = D->dest.x;
+ r->dest.y = D->dest.y;
+ r->B.x = B->dest.x;
+ r->B.y = B->dest.y;
+ r->C.x = C->dest.x;
+ r->C.y = C->dest.y;
+
+ ConsumePath(B);
+ ConsumePath(C);
+ ConsumePath(D);
+ return(r);
+}
+
+/*
+:h2.Font "Hint" Segments
+
+:h3.Hint() - A Font 'Hint' Segment
+
+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;
+{
+/* added reference field of 1 to hintsegment template below 3-26-91 PNM */
+ static struct hintsegment template = { HINTTYPE, 0, 1, sizeof(struct hintsegment), 0,
+ NULL, NULL, { 0, 0 }, { 0, 0 }, { 0, 0 },
+ ' ', ' ', ' ', ' ', 0};
+
+ register struct hintsegment *r;
+
+ r = (struct hintsegment *)Allocate(sizeof(struct hintsegment), &template, 0);
+
+ r->orientation = orientation;
+ if (width == 0.0) width = 1.0;
+
+ if (orientation == 'h') {
+ (*S->convert)(&r->ref, S, 0.0, ref);
+ (*S->convert)(&r->width, S, 0.0, width);
+ }
+ else if (orientation == 'v') {
+ (*S->convert)(&r->ref, S, ref, 0.0);
+ (*S->convert)(&r->width, S, width, 0.0);
+ }
+ else
+ return((struct hintsegment *)ArgErr("Hint: orient not 'h' or 'v'", NULL, NULL));
+ if (r->width.x < 0) r->width.x = - r->width.x;
+ if (r->width.y < 0) r->width.y = - r->width.y;
+ r->hinttype = hinttype;
+ r->adjusttype = adjusttype;
+ r->direction = direction;
+ r->label = label;
+ r->last = (struct segment *) r;
+ ConsumeSpace(S);
+ return(r);
+}
+
+/*
+*/
+
+/*SHARED LINE(S) ORIGINATED HERE*/
+
+/*
+POP removes the first segment in a path 'p' and Frees it. 'p' is left
+pointing to the end of the path:
+*/
+#define POP(p) \
+ { register struct segment *linkp; \
+ linkp = p->link; \
+ if (linkp != NULL) \
+ linkp->last = p->last; \
+ Free(p); \
+ p = linkp; }
+/*
+INSERT inserts a single segment in the middle of a chain. 'b' is
+the segment before, 'p' the segment to be inserted, and 'a' the
+segment after.
+*/
+#define INSERT(b,p,a) b->link=p; p->link=a; p->last=NULL
+
+/*
+:h3.Join() - Join Two Objects Together
+
+If these are paths, this operator simply invokes the CONCAT macro.
+Why so much code then, you ask? Well we have to check for object
+types other than paths, and also check for certain path consistency
+rules.
+*/
+
+struct segment *Join(p1, p2)
+ register struct segment *p1,*p2;
+{
+ IfTrace2((MustTraceCalls && PathDebug > 1),"..Join(%z, %z)\n", p1, p2);
+ IfTrace2((MustTraceCalls && PathDebug <=1),"..Join(%x, %x)\n", p1, p2);
+/*
+We start with a whole bunch of very straightforward argument tests:
+*/
+ if (p2 != NULL) {
+ if (!ISPATHTYPE(p2->type)) {
+
+ if (p1 == NULL)
+ return((struct segment *)Unique(p2));
+
+ switch (p1->type) {
+
+ case REGIONTYPE:
+
+ case STROKEPATHTYPE:
+ p1 = CoercePath(p1);
+ break;
+
+ default:
+ return((struct segment *)BegHandle(p1, p2));
+ }
+ }
+
+ ARGCHECK((p2->last == NULL), "Join: right arg not anchor", p2, NULL, (1,p1), struct segment *);
+ p2 = UniquePath(p2);
+
+/*
+In certain circumstances, we don't have to duplicate a permanent
+location. (We would just end up destroying it anyway). These cases
+are when 'p2' begins with a move-type segment:
+*/
+ if (p2->type == TEXTTYPE || p2->type == MOVETYPE) {
+ if (p1 == NULL)
+ return(p2);
+ if (ISLOCATION(p1)) {
+ p2->dest.x += p1->dest.x;
+ p2->dest.y += p1->dest.y;
+ ConsumePath(p1);
+ return(p2);
+ }
+ }
+ }
+ else
+ return((struct segment *)Unique(p1));
+
+ if (p1 != NULL) {
+ if (!ISPATHTYPE(p1->type))
+
+ switch (p2->type) {
+
+ case REGIONTYPE:
+
+ case STROKEPATHTYPE:
+ p2 = CoercePath(p2);
+ break;
+
+ default:
+ return((struct segment *)EndHandle(p1, p2));
+ }
+
+ ARGCHECK((p1->last == NULL), "Join: left arg not anchor", p1, NULL, (1,p2), struct segment *);
+ p1 = UniquePath(p1);
+ }
+ else
+ return(p2);
+
+/*
+At this point all the checking is done. We have two temporary non-null
+path types in 'p1' and 'p2'. If p1 ends with a MOVE, and p2 begins with
+a MOVE, we collapse the two MOVEs into one. We enforce the rule that
+there may not be two MOVEs in a row:
+*/
+
+ if (p1->last->type == MOVETYPE && p2->type == MOVETYPE) {
+ p1->last->flag |= p2->flag;
+ p1->last->dest.x += p2->dest.x;
+ p1->last->dest.y += p2->dest.y;
+ POP(p2);
+ if (p2 == NULL)
+ return(p1);
+ }
+/*
+Now we check for another silly rule. If a path has any TEXTTYPEs,
+then it must have only TEXTTYPEs and MOVETYPEs, and furthermore,
+it must begin with a TEXTTYPE. This rule makes it easy to check
+for the special case of text. If necessary, we will coerce
+TEXTTYPEs into paths so we don't mix TEXTTYPEs with normal paths.
+*/
+ if (p1->type == TEXTTYPE) {
+ if (p2->type != TEXTTYPE && !ISLOCATION(p2))
+ p1 = CoerceText(p1);
+ }
+ else {
+ if (p2->type == TEXTTYPE) {
+ if (ISLOCATION(p1)) {
+ p2->dest.x += p1->dest.x;
+ p2->dest.y += p1->dest.y;
+ Free(p1);
+ return(p2);
+ }
+ else
+ p2 = CoerceText(p2);
+ }
+ }
+/*
+Thank God! Finally! It's hard to believe, but we are now able to
+actually do the join. This is just invoking the CONCAT macro:
+*/
+ CONCAT(p1, p2);
+
+ return(p1);
+}
+
+/*
+:h3.JoinSegment() - Create a Path Segment and Join It to a Known Path
+
+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 */
+{
+ register struct segment *r; /* returned path built here */
+
+ r = PathSegment(type, x, y);
+ if (before != NULL) {
+ CONCAT(before, r);
+ r = before;
+ }
+ else
+ r->context = after->context;
+ if (after != NULL)
+ CONCAT(r, after);
+ return(r);
+}
+
+/*
+:h2.Other Path Functions
+
+*/
+
+
+struct segment *t1_ClosePath(p0,lastonly)
+ register struct segment *p0; /* path to close */
+ register int lastonly; /* flag deciding to close all subpaths or... */
+{
+ register struct segment *p,*last,*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 */
+
+ IfTrace1((MustTraceCalls),"ClosePath(%z)\n", p0);
+ if (p0 != NULL && p0->type == TEXTTYPE)
+ return(UniquePath(p0));
+ if (p0->type == STROKEPATHTYPE)
+ return((struct segment *)Unique(p0));
+ /*
+ * NOTE: a null closed path is different from a null open path
+ * and is denoted by a closed (0,0) move segment. We make
+ * sure this path begins and ends with a MOVETYPE:
+ */
+ if (p0 == NULL || p0->type != MOVETYPE)
+ p0 = JoinSegment(NULL, MOVETYPE, 0, 0, p0);
+ TYPECHECK("ClosePath", p0, MOVETYPE, NULL, (0), struct segment *);
+ if (p0->last->type != MOVETYPE)
+ p0 = JoinSegment(p0, MOVETYPE, 0, 0, NULL);
+
+ p0 = UniquePath(p0);
+
+/*
+We now begin a loop through the path,
+incrementing current 'x' and 'y'. We are searching
+for MOVETYPE segments (breaks in the path) that are not already closed.
+At each break, we insert a close segment.
+*/
+ for (p = p0, x = y = 0, start = NULL;
+ p != NULL;
+ x += p->dest.x, y += p->dest.y, last = p, p =