Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!shadooby!samsung!uunet!crdgw1!montnaro From: montnaro@sprite.crd.ge.com (Skip Montanaro) Newsgroups: alt.sources Subject: dviselect (Part 2 of 6) Message-ID:Date: 13 Nov 89 21:20:36 GMT Sender: news@crdgw1.crd.ge.com Reply-To: (Skip Montanaro) Organization: GE Corporate Research & Development, Schenectady, NY Lines: 1289 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh h/Makefile <<'END_OF_h/Makefile' XHDR =arith.h binding.h box.h conv.h dvi.h dviclass.h dvicodes.h \ X error.h fio.h font.h gfclass.h gfcodes.h imPcodes.h imagen.h \ X io.h num.h postamble.h search.h str.h tfm.h types.h verser.h X Xgoal: X @echo Nothing to make here X X$(HDR): X co -q $@ X Xhdr: $(HDR) X @echo Done END_OF_h/Makefile if test 271 -ne `wc -c h/README <<'END_OF_h/README' XThis directory is for header files. END_OF_h/README if test 36 -ne `wc -c h/conv.h <<'END_OF_h/conv.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* X * Conversions. Conversion factors convert between values in scaled X * points and values in device-dependenent units. The results of all X * conversions are rounded to the nearest integral value, of type (i32). X */ X X/* X * This is now done using `double' values, but may be changed to X * fixed-point or some other `fast' method, as long as the results X * are consistent and reasonably accurate. The structure `conversion' X * holds the conversion-method-dependent quantities; the macros X * fromSP and toSP apply the conversion to a value. (Note that X * fromSP and toSP need not be macros, but should be fast.) X * X * SetConversion sets the (single, global) conversion factor. X * If a driver needs special conversions, there is another routine, X * CSetConversion that sets a specific conversion, and cfromSP and X * ctoSP to apply these. X * X * IS USING DOTS PER INCH SUFFICIENT? (Pixels per point might be better.) X * X * Note that it is necessary to set the global conversion factor before X * using any fonts. X */ X Xtypedef struct conversion { X double c_fromsp; /* multiplier to convert from scaled points */ X double c_tosp; /* multiplier to convert to scaled points: X could divide by c_fromsp, but this should X be faster and more accurate */ X double c_mag; /* the magnification this conversion X represents; mainly for GetFont() */ X double c_dpi; /* dpi (should be pixels per point?) */ X} Conv; X X/* X * In order to do this, we need to round properly. The compilers I X * have tend to generate very poor code for this. The following is X * intended to help them out. Smarter compilers can do better, but X * if they are smart enough, they will realise that the variables X * here are not used anywhere else, and discard them. (For a compiler X * to do this given separate compliation, `static' is a must.) X */ X X#ifdef lint /* or a smart compiler */ X X#define ROUND(f) ((i32) ((f) < 0.0 ? (f) - 0.5 : (f) + 0.5)) X#define CEIL(f) ((double) (i32) (f) < (f) ? (i32) (f) + 1 : (i32) (f)) X X#else X Xstatic double _half = 0.5; Xstatic double _zero = 0.0; Xstatic double _d; X X#define ROUND(f) ((i32) (_d = (f), _d < _zero ? _d - _half : _d + _half)) X X#ifdef NEGATIVE_FLOAT_ROUNDS_TO_NEGATIVE_INFINITY X X#define CEIL(f) (-(i32) -(f)) X X#else /* we will assume that floating to integer truncates */ X Xstatic i32 _i; X X#define CEIL(f) (_i = _d = (f), _i < _d ? _i + 1 : _i) X X#endif /* round towards negative infinity */ X X#endif /* lint */ X X#define SetConversion(dpi, usermag, num, denom, dvimag) \ X CSetConversion(&Conversion, dpi, usermag, num, denom, dvimag) X X#define cfromSP(c, v) ROUND((c)->c_fromsp * (v)) X#define ctoSP(c, v) ROUND((c)->c_tosp * (v)) X X#define fromSP(v) cfromSP(&Conversion, v) X#define toSP(v) ctoSP(&Conversion, v) X X/* X * Conversions for rules are a bit different: we must round up, rather X * than off. ConvRule applies the global conversion value for a rule X * value (height or width); CConvRule applies a specific conversion. X */ X X#define CConvRule(c, v) CEIL((c)->c_fromsp * (v)) X#define ConvRule(v) CConvRule(&Conversion, v) X Xvoid CSetConversion(); END_OF_h/conv.h if test 3295 -ne `wc -c h/convstruct.h <<'END_OF_h/convstruct.h' Xtypedef struct conversion { X double c_fromsp; /* multiplier to convert from scaled points */ X double c_tosp; /* multiplier to convert to scaled points: X could divide by c_fromsp, but this should X be faster and more accurate */ X double c_mag; /* the magnification this conversion X represents; mainly for GetFont() */ X double c_dpi; /* dpi (should be pixels per point?) */ X} Conv; END_OF_h/convstruct.h if test 400 -ne `wc -c h/dvi.h <<'END_OF_h/dvi.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* DVI file info */ X X/* X * Units of distance are stored in scaled points, but we can convert to X * units of 10^-7 meters by multiplying by the numbers in the preamble. X */ X X/* the structure of the stack used to hold the values (h,v,w,x,y,z) */ X Xtypedef struct dvi_stack { X i32 h; /* the saved h */ X i32 v; /* the saved v */ X i32 w; /* etc */ X i32 x; X i32 y; X i32 z; X} DviStack; X Xextern DviStack dvi_current; /* the current values of h, v, etc */ Xextern int dvi_f; /* the current font */ X X#define dvi_h dvi_current.h X#define dvi_v dvi_current.v X#define dvi_w dvi_current.w X#define dvi_x dvi_current.x X#define dvi_y dvi_current.y X#define dvi_z dvi_current.z END_OF_h/dvi.h if test 876 -ne `wc -c h/dviclass.h <<'END_OF_h/dviclass.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* X * Macros to convert DVI opcodes to (hopefully) simpler values. X */ X X/* X * Large range types. X */ X#define DVI_IsChar(code) ((code) < 128) X#define DVI_IsFont(code) ((code) >= 171 && (code) < 235) X X/* X * Symbolic names for generic types (for things with parameters). X * These are obtained via the macro DVI_DT(int c), where 0 <= c <= 255. X */ X#define DT_CHAR 0 X#define DT_SET 1 X#define DT_SETRULE 2 X#define DT_PUT 3 X#define DT_PUTRULE 4 X#define DT_NOP 5 X#define DT_BOP 6 X#define DT_EOP 7 X#define DT_PUSH 8 X#define DT_POP 9 X#define DT_RIGHT 10 X#define DT_W0 11 X#define DT_W 12 X#define DT_X0 13 X#define DT_X 14 X#define DT_DOWN 15 X#define DT_Y0 16 X#define DT_Y 17 X#define DT_Z0 18 X#define DT_Z 19 X#define DT_FNTNUM 20 X#define DT_FNT 21 X#define DT_XXX 22 X#define DT_FNTDEF 23 X#define DT_PRE 24 X#define DT_POST 25 X#define DT_POSTPOST 26 X#define DT_UNDEF 27 X X/* X * Symbolic names for parameter lengths, obtained via the macro X * DVL_OpLen(int c). X * X * N.B.: older drivers may assume that 0 => none, 1-4 => 1-4 bytes X * and 5-7 => unsigned version of 1-4---so DO NOT change these values! X */ X#define DPL_NONE 0 X#define DPL_SGN1 1 X#define DPL_SGN2 2 X#define DPL_SGN3 3 X#define DPL_SGN4 4 X#define DPL_UNS1 5 X#define DPL_UNS2 6 X#define DPL_UNS3 7 X/* there are no unsigned four byte parameters */ X X#define DVI_OpLen(code) (dvi_oplen[code]) X#define DVI_DT(code) (dvi_dt[code]) Xextern char dvi_oplen[]; Xextern char dvi_dt[]; END_OF_h/dviclass.h if test 1662 -ne `wc -c h/dvicodes.h <<'END_OF_h/dvicodes.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* DVI opcodes */ X X#define DVI_VERSION 2 /* version number that should appear in X pre- and post-ambles */ X X#define DVI_SET1 128 /* set character, 1 byte param */ X#define DVI_SET2 129 /* set character, 2 byte param */ X#define DVI_SET3 130 /* set character, 3 byte param */ X#define DVI_SET4 131 /* set character, 4 byte param */ X#define DVI_SETRULE 132 /* set a rule */ X#define DVI_PUT1 133 /* put char, don't move right */ X#define DVI_PUT2 134 /* put char, 2 byte */ X#define DVI_PUT3 135 /* etc */ X#define DVI_PUT4 136 X#define DVI_PUTRULE 137 /* put rule, don't move right */ X#define DVI_NOP 138 /* no-op */ X#define DVI_BOP 139 /* begin page */ X#define DVI_EOP 140 /* end page */ X#define DVI_PUSH 141 /* push h,v,w,x,y,z */ X#define DVI_POP 142 /* pop h,v,w,x,y,z */ X#define DVI_RIGHT1 143 /* move right, 1 byte signed param */ X#define DVI_RIGHT2 144 /* move right, 2 byte signed param */ X#define DVI_RIGHT3 145 /* etc */ X#define DVI_RIGHT4 146 X#define DVI_W0 147 /* h += w */ X#define DVI_W1 148 /* w = 1 byte signed param, h += w */ X#define DVI_W2 149 /* w = 2 byte etc, h += w */ X#define DVI_W3 150 X#define DVI_W4 151 X#define DVI_X0 152 /* like DVI_W0 but for x */ X#define DVI_X1 153 /* etc */ X#define DVI_X2 154 X#define DVI_X3 155 X#define DVI_X4 156 X#define DVI_DOWN1 157 /* v += 1 byte signed param */ X#define DVI_DOWN2 158 /* v += 2 byte signed param */ X#define DVI_DOWN3 159 /* etc */ X#define DVI_DOWN4 160 X#define DVI_Y0 161 /* y = 1 byte signed param, v += y */ X#define DVI_Y1 162 /* etc */ X#define DVI_Y2 163 X#define DVI_Y3 164 X#define DVI_Y4 165 X#define DVI_Z0 166 /* z = 1 byte signed param, v += z */ X#define DVI_Z1 167 /* etc */ X#define DVI_Z2 168 X#define DVI_Z3 169 X#define DVI_Z4 170 X#define DVI_FNTNUM0 171 X X#define DVI_FNT1 235 /* select font, 1 byte param */ X#define DVI_FNT2 236 /* etc */ X#define DVI_FNT3 237 X#define DVI_FNT4 238 X#define DVI_XXX1 239 /* for \special: if length < 256 */ X#define DVI_XXX2 240 /* etc */ X#define DVI_XXX3 241 X#define DVI_XXX4 242 X#define DVI_FNTDEF1 243 /* Define font, 1 byte param (0 to 63) */ X#define DVI_FNTDEF2 244 /* etc */ X#define DVI_FNTDEF3 245 X#define DVI_FNTDEF4 246 X#define DVI_PRE 247 /* preamble */ X#define DVI_POST 248 /* postamble */ X#define DVI_POSTPOST 249 /* end of postamble */ X#define DVI_FILLER 223 /* filler bytes at end of dvi file */ END_OF_h/dvicodes.h if test 2554 -ne `wc -c h/dvistruct.h <<'END_OF_h/dvistruct.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* DVI file info */ X X/* X * Units of distance are stored in scaled points, but we can convert to X * units of 10^-7 meters by multiplying by the numbers in the preamble. X */ X X/* the structure of the stack used to hold the values (h,v,w,x,y,z) */ Xtypedef struct dvi_stack { X i32 h; /* the saved h */ X i32 v; /* the saved v */ X i32 w; /* etc */ X i32 x; X i32 y; X i32 z; X} DviStack; END_OF_h/dvistruct.h if test 595 -ne `wc -c h/fio.h <<'END_OF_h/fio.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* X * File I/O: numbers. X * X * We deal in fixed format numbers and (FILE *)s here. X * For pointer I/O, see pio.h. X * X * N.B.: These do the `wrong thing' at EOF. It is imperative X * that the caller add appropriate `if (feof(fp))' statements. X */ X X/* X * Get one unsigned byte. Note that this is a proper expression. X * The reset have more limited contexts, and are therefore OddLy X * CapItaliseD. X */ X#define fgetbyte(fp) (getc(fp)) X X/* X * Get a two-byte unsigned integer, a three-byte unsigned integer, X * or a four-byte signed integer. X */ X#define fGetWord(fp, r) ((r) = getc(fp) << 8, (r) |= getc(fp)) X#define fGet3Byte(fp,r) ((r) = getc(fp) << 16, (r) |= getc(fp) << 8, \ X (r) |= getc(fp)) X#define fGetLong(fp, r) ((r) = getc(fp) << 24, (r) |= getc(fp) << 16, \ X (r) |= getc(fp) << 8, (r) |= getc(fp)) X X/* X * Fast I/O write (and regular write) macros. X */ X#define putbyte(fp, r) (putc((r), fp)) X X#define PutWord(fp, r) (putc((r) >> 8, fp), putc((r), fp)) X#define Put3Byte(fp, r) (putc((r) >> 16, fp), putc((r) >> 8, fp), \ X putc((r), fp)) X#define PutLong(fp, r) (putc((r) >> 24, fp), putc((r) >> 16, fp), \ X putc((r) >> 8, fp), putc((r), fp)) X X/* X * Function types X */ Xi32 GetByte(), GetWord(), Get3Byte(), GetLong(); END_OF_h/fio.h if test 1456 -ne `wc -c h/font.h <<'END_OF_h/font.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* X * Font file information, readers, etc. X */ X X#ifndef _CTEX_TYPES_ X#include "types.h" X#endif X X/* X * First, font independent information: per glyph info, and per font X * info. X */ Xstruct glyph { X short g_flags; /* see below */ X /* X * The following cannot be used with GetRasterlessFont X */ X short g_rotation; /* see below */ X char *g_raster; /* raster, if known */ X /* X * These, however, do come with rasterless fonts, X * even though they relate only to the raster. X */ X i32 g_height; /* height of bounding box */ X i32 g_width; /* width of bounding box */ X i32 g_yorigin; /* y origin (>= 0 -> within box) */ X i32 g_xorigin; /* x origin (>= 0 -> within box) */ X /* X * This of course comes with every font. X */ X i32 g_rawtfmwidth; /* the tfmwidth as read from the file */ X i32 g_tfmwidth; /* width in scaled points (not FIXes!) */ X i32 g_xescapement; /* x escapement (`chardx') */ X i32 g_yescapement; /* y escapement (`chardy') */ X /* X * This is provided purely for DVI to device conversion programs. X */ X int g_pixwidth; /* width in pixels */ X /* X * Mainly for internal use, index is the glyph index within the X * font. That is, f->f_gly[i]->g_index == i. X */ X int g_index; /* character index */ X /* X * g_details and g_integer are purely for the font reading X * subroutines to use however they will. g_next makes lists X * of glyphs while the glyphs are free. X */ X union { /* various options */ X char *g_details; /* details: arbitrary */ X i32 g_integer; /* 32 bit integer */ X struct glyph *g_next; /* linked list */ X } g_un; X}; X X/* X * Glyph flags. X */ X#define GF_VALID 0x0001 /* glyph is `real' */ X#define GF_USR0 0x0100 /* reserved to user code */ X#define GF_USR1 0x0200 /* reserved to user code */ X#define GF_USR2 0x0400 /* reserved to user code */ X#define GF_USR3 0x0800 /* reserved to user code */ X X/* X * Rotations are in quarter-pi steps, counterclockwise of course. X * This order must be maintained; see rotate.c. X */ X#define ROT_NORM 0 /* no rotation: `normal' position */ X#define ROT_LEFT 1 /* 1/4 turn counterclockwise */ X#define ROT_DOWN 2 /* 1/2 turn, i.e., upside-down */ X#define ROT_RIGHT 3 /* 3/4 turn ccw, or 1/4 turn cw */ X Xstruct font { X int f_flags; /* see below */ X struct fontops *f_ops; /* operations */ X /* X * f_details is provided for font reading subroutines. X * It is intended to be cast to a pointer to a structure X * that is allocated by those routines, and used to keep X * track of whatever information those routines need to X * determine glyph boxes and (if asked for) rasters. X */ X char *f_details; /* type dependent stuff */ X /* X * f_path is the full pathname to the font file, filled in X * by GetFont and GetRasterlessFont. Note that since we X * hold on to the path until the font is freed, it should be X * possible to cache glyph accesses on memory-poor machines. X */ X char *f_path; /* font file pathname */ X /* X * f_dvimag and f_dvidsz are the magnification and design size X * values from the DVI file. f_font and f_scaled correspond to X * TeX's idea of the proper name for the font (e.g., `cmr10', X * `cmbx10 scaled 1440'). (Note that f_scaled is just the X * ratio of f_dvimag and f_dvidsz; you could save a bit of memory X * by eliminating it and altering the routine Font_TeXName()). X * f_checksum should be set by the font reading routines to X * the font checksum. If the value is nonzero, it will be X * compared to the checksum in the DVI file. X */ X i32 f_dvimag; /* magnification from DVI file */ X i32 f_dvidsz; /* design size from DVI file */ X char *f_font; /* TeX's name for the font */ X int f_scaled; /* the ratio of dvimag to dvidsz, x1000 */ X i32 f_design_size; X i32 f_checksum; /* font checksum, or 0 */ X i32 f_hppp; /* horizontal pixels per point */ X i32 f_vppp; /* vertical pixels per point */ X /* X * f_lowch and f_highch bound the region in which f_gly X * indicies are valid. Specificially, f_gly[i] may be X * read or written if and only if i is in the half-open X * interval [f_lowch..f_highch). f_gly is an array of X * pointers to glyph structures. The structures themselves X * are not allocated until requested. X * X * f_glybase is the actual return from malloc(), since it X * is theoretically possible for f_gly-f_lowch to become X * NULL. X */ X int f_lowch; /* first character */ X int f_highch; /* last character, plus 1 */ X struct glyph **f_gly; /* glyphs */ X struct glyph **f_glybase; X}; X X/* X * Font flags. X */ X#define FF_RASTERS 0x0001 /* font has rasters */ X#define FF_USR0 0x0100 /* reserved to user code */ X#define FF_USR1 0x0200 /* reserved to user code */ X#define FF_USR2 0x0400 /* reserved to user code */ X#define FF_USR3 0x0800 /* reserved to user code */ X X/* X * Operations on fonts. X * X * The `fo_dpitomag' field is used as a multiplier for a desired X * resolution in dots per inch. The result of the multiplication X * is converted to a font name by multipying by 1000.0 and rounding. X * The idea is that PXL files will have a multiplier of 5.0, and X * others will have a multiplier of 1.0. This suffices for the X * present, at any rate; in the future, this field may be replaced X * with something more general. X * X * N.B.: more operations may be added as they are discovered to be X * useful. X */ Xstruct fontops { X char *fo_name; /* name, e.g., "gf" */ X double fo_dpitomag; /* multiplier */ X int (*fo_read)(); /* open and read the font itself */ X int (*fo_getgly)(); /* obtain specified glyphs (range) */ X#ifdef notdef X int (*fo_freegly)(); /* release specified glyphs */ X#endif X int (*fo_rasterise)(); /* rasterise specified glyphs */ X int (*fo_freefont)(); /* discard font (free details) */ X struct fontops *fo_next; /* purely for font.c */ X}; X X/* X * Return a pointer to the glyph information for character `c' in X * font `f'. X */ X#define GLYPH(f, c) \ X ((c) < (f)->f_lowch || (c) >= (f)->f_highch ? (struct glyph *) 0 : \ X ((f)->f_gly[c] ? (f)->f_gly[c] : GetGlyph(f, c))) X X/* X * True iff glyph `g' is valid. Useful for checking return values X * from GLYPH(). X */ X#define GVALID(g) ((g) && ((g)->g_flags & GF_VALID)) X X/* X * True iff glyph g has a raster. X */ X#define HASRASTER(g) ((g)->g_height || (g)->g_width) X X/* X * Return a pointer to the raster information for glyph `g' in font X * `f' at rotation `r'. X */ X#define RASTER(g, f, r) ((g)->g_rotation == (r) && (g)->g_raster ? \ X (g)->g_raster : GetRaster(g, f, r)) X X/* X * Function types. X */ Xstruct font *GetFont(), *GetRasterlessFont(); Xstruct glyph *GetGlyph(); Xchar *GetRaster(); Xvoid FreeFont(); Xvoid FreeGlyph(); Xvoid FreeRaster(); Xchar *Font_TeXName(); Xdouble DMagFactor(); /* from magfactor.c */ X X/* X * Normally from stdio.h X */ X#ifndef NULL X#define NULL 0 X#endif X X/* X * The following environment variable overrides the default font X * configuration file. That default is used when fontinit() is not X * called, or is passed a null pointer. X */ X#define CONFENV "TEXFONTDESC" END_OF_h/font.h if test 7100 -ne `wc -c h/gfclass.h <<'END_OF_h/gfclass.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* X * GF classification codes X */ X X/* X * Predicate for simple paint commands. This is presumably the most X * common GF operation; it may be profitable to check for this before X * switching out on the command type. X */ X#define GF_IsPaint(c) ((c) < 64) X X/* X * Symbolic names for command `types', as returned by the macro X * GT_TYPE(int c). X */ X#define GT_PAINT0 0 /* paint without parameter */ X#define GT_PAINT 1 /* paint with parameter */ X#define GT_BOC 2 /* long BOC */ X#define GT_BOC1 3 /* short BOC */ X#define GT_EOC 4 /* EOC */ X#define GT_SKIP0 5 /* parameterless SKIP */ X#define GT_SKIP 6 /* parmeterised SKIP */ X#define GT_NEW_ROW 7 /* NEW_ROW_n */ X#define GT_XXX 8 /* XXXn */ X#define GT_YYY 9 /* YYY */ X#define GT_NOP 10 /* no op */ X#define GT_CHAR_LOC 11 /* CHAR_LOC */ X#define GT_CHAR_LOC0 12 /* abbreviated CHAR_LOC */ X#define GT_PRE 13 X#define GT_POST 14 X#define GT_POSTPOST 15 X#define GT_UNDEF 16 X X/* X * Symbolic names for parameter lengths, obtained via the macro X * GT_OpLen(int c). X */ X#define GPL_NONE 0 /* no parameter, or too complex */ X#define GPL_UNS1 1 /* one one-byte parameter in 0..255 */ X#define GPL_UNS2 2 /* one two-byte parameter in 0..65535 */ X#define GPL_UNS3 3 /* one three-byte parameter in 0..16777215 */ X#define GPL_SGN4 4 /* one four-byte signed parameter */ X/* X * there are no unsigned four byte parameters, and no shorter signed X * parameters X */ X X#define GF_OpLen(code) (gf_oplen[code]) X#define GF_TYPE(code) (gf_gt[code]) Xextern char gf_oplen[]; Xextern char gf_gt[]; END_OF_h/gfclass.h if test 1730 -ne `wc -c h/gfcodes.h <<'END_OF_h/gfcodes.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* X * GF (generic font) opcodes. X */ X X#define GF_PAINT_0 0 /* paint with `d' = 0 */ X /* ... through PAINT_63, d = 63 */ X#define GF_PAINT1 64 /* paint, with a one-byte parameter */ X#define GF_PAINT2 65 /* paint, with a two-byte parameter */ X#define GF_PAINT3 66 /* paint, with a three-byte parameter */ X#define GF_BOC 67 /* beginning of character */ X#define GF_BOC1 68 /* compressed form of BOC */ X#define GF_EOC 69 /* end of character */ X#define GF_SKIP0 70 /* finish this row, begin next with white */ X#define GF_SKIP1 71 /* finish row, one byte parameter */ X#define GF_SKIP2 72 X#define GF_SKIP3 73 X#define GF_NEW_ROW_0 74 /* begin a new row, ready to blacken */ X#define GF_NEW_ROW_1 75 /* begin a new row, but one col. from left */ X /* through GF_NEW_ROW_164 */ X#define GF_XXX1 239 /* special (interpreter dependent) command */ X#define GF_XXX2 240 /* like XXX1, but two byte length parameter */ X#define GF_XXX3 241 X#define GF_XXX4 242 X#define GF_YYY 243 /* takes four byte parameter, otherwise nop */ X /* (generated by METAFONT for numspecial) */ X#define GF_NOP 244 /* no op */ X#define GF_CHAR_LOC 245 /* character locator */ X#define GF_CHAR_LOC0 246 /* abbreviated form of CHAR_LOC */ X#define GF_PRE 247 /* introduces preamble */ X#define GF_POST 248 /* introduces postamble */ X#define GF_POSTPOST 249 /* marks end of postamble */ X X /* codes 250 through 255 are undefined */ X X#define GF_ID 131 /* identifies this revision of GF */ X X#define GF_FILLER 223 /* filler bytes at end of GF file */ END_OF_h/gfcodes.h if test 1732 -ne `wc -c h/imPcodes.h <<'END_OF_h/imPcodes.h' X/* imPRESS command codes */ X X#define imP_SP 128 /* advance one space */ X#define imP_SP1 129 /* advance one space plus 1 pixel */ X X#define imP_OLD_MMOVE 130 X#define imP_Forw 131 /* one pixel forward */ X#define imP_Backw 132 /* one pixel backward */ X#define imP_MMove 133 /* move in main advance dir. */ X#define imP_SMove 134 /* move in secondary advance dir. */ X#define imP_SetHAbs 135 /* set absolute H pos */ X#define imP_SetHRel 136 /* set relative H pos */ X#define imP_SetVAbs 137 /* set absolute V pos */ X#define imP_SetVRel 138 /* set relative V pos */ X X/* X * rephrase for imagen1-special.c X */ X#define imP_SET_ABS_H 135 /* set absolute H pos */ X#define imP_SET_REL_H 136 /* set relative H pos */ X#define imP_SET_ABS_V 137 /* set absolute V pos */ X#define imP_SET_REL_V 138 /* set relative V pos */ X X#define CIRC_ARC 150 X#define ELLIPSE_ARC 151 X#define CIRC_SEGM 160 X X#define imSRULE 192 X#define imP_Rule 193 /* print a rule */ X X#define imP_SET_HPOS 195 X#define imP_SET_VPOS 196 X#define imP_CRLF 197 /* move to begin. of line */ X#define imP_SGLY 198 X X#define imP_DefGlyph 199 /* define a glyph */ X X#define imP_BGLY 199 /* for imagen1-special.c */ X X#define imP_DelGlyph 200 /* mark a glyph for deletion */ X#define imP_DELC 201 X#define imP_DELF 202 X X#define imP_SetHVSystem 205 /* set the H/V coordinate system */ X#define imP_SET_HV_SYSTEM 205 /* for imagen1-special.c */ X X#define imP_SetAdvDirs 206 /* set the advance directions */ X#define imP_SetFamily 207 /* use this particular family */ X#define imP_SetILSpace 208 /* set the interline spacing */ X#define imP_SetBOL 209 /* define the beginning of line */ X#define imP_SetSP 210 /* define the space between words */ X X#define imP_CreateFam 211 /* define a family table */ X#define imP_PUSH 211 /* for imagen1-special.c */ X#define imP_POP 212 X X#define imP_Page 213 /* go to (0,0) */ X#define imP_SET_PUSH_MASK 214 X X#define imP_EndPage 219 /* print the current page */ X X#define imP_CREATE_FAMILY_TABLE 221 X#define imP_CREATE_MAP 222 X X#define SET_PUM 225 X X#define imP_CREATE_PATH 230 X#define imP_SET_TEXTURE 231 X#define imP_SET_PEN 232 X#define imP_FILL_PATH 233 X#define imP_DRAW_PATH 234 X#define imP_BITMAP 235 X#define imP_SET_MAGN 236 X X X#define imP_ForceDel 240 /* force glyph deletion */ X X#define imP_DEFINE_MACRO 242 X#define imP_EXEC_MACRO 243 X#define imP_EOF 255 /* end of document */ END_OF_h/imPcodes.h if test 2346 -ne `wc -c h/imagen.h <<'END_OF_h/imagen.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* imagen globals */ X X/* Accounting: */ X#ifndef ACCOUNT_FILE X/* X#define ACCOUNT_FILE "/usr/adm/imagen_acct"/* if defined, the name of the X imagen page accounting file */ X#endif ACCOUNT_FILE X X#define MaxImFamily 128 /* hardware limitation on font family index */ X#define DefaultDPI 300 /* 300 for Imagen 8/300, 240 for Imprint-10 */ X X#define DefaultMaxDrift 3 /* default value for MaxDrift */ X X/* Default margins, in dots */ X/* CRUFT ALERT: depending on DPI variable */ X#define DefaultTopMargin (DPI) /* 1" margins */ X#define DefaultLeftMargin (DPI) END_OF_h/imagen.h if test 777 -ne `wc -c h/num.h <<'END_OF_h/num.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* X * Pointer I/O: numbers. X * X * We deal in fixed format numbers and pointers here. X * For file I/O, see fio.h. X */ X X/* X * Get one unsigned byte. Note that this is a proper expression. X * The rest have more limited contexts, and are therefore OddLy X * CapItaliseD. X */ X#define pgetbyte(p) UnSign8(*(p)++) X X/* X * Get a two-byte unsigned integer, a three-byte unsigned integer, X * or a four-byte signed integer. X */ X#define pGetWord(p, r) ((r) = UnSign8(*(p)++) << 8, \ X (r) |= UnSign8(*(p)++)) X#define pGet3Byte(p,r) ((r) = UnSign8(*(p)++) << 16, \ X (r) |= UnSign8(*(p)++) << 8, \ X (r) |= UnSign8(*(p)++)) X#define pGetLong(p, r) ((r) = UnSign8(*(p)++) << 24, \ X (r) |= UnSign8(*(p)++) << 16, \ X (r) |= UnSign8(*(p)++) << 8, \ X (r) |= UnSign8(*(p)++)) X X/* X * ADD pputbyte, pPutWord, pPut3Byte, pPutLong HERE IF THEY PROVE X * USEFUL. (But then must consider changing PutWord &c in fio.h.) X */ END_OF_h/num.h if test 1123 -ne `wc -c h/postamble.h <<'END_OF_h/postamble.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* Definitions for ScanPostAmble */ X X/* X * ScanPostAmble reads the postamble of a DVI file from the (stdio) X * file specified in its first argument. It is handed two pointers to X * functions. The first (ScanPostAmble's second argument) is called X * after the header information has been read, and given a pointer to a X * PostAmbleInfo structure. It is the job of this function to extract the X * required information from this structure (which is deallocated when X * ScanPostAmble returns). X * X * The second function is called once for each font definition occurring in X * the postamble, and is given a pointer to a PostAmbleFont structure. This X * function should do whatever the device needs to read the actual font. X * X * If the DVI file appears malformed, ScanPostAmble will print an error X * message and exit. (Drastic, perhaps, but effective.) X */ X Xstruct PostAmbleInfo { X i32 pai_PrevPagePointer; /* previous page pointer */ X i32 pai_Numerator; /* numerator from dvi file */ X i32 pai_Denominator; /* denominator from dvi file*/ X i32 pai_DVIMag; /* \magnification */ X i32 pai_TallestPageHeight; /* height of tallest page */ X i32 pai_WidestPageWidth; /* width of widest page */ X int pai_DVIStackSize; /* DVI stack size required */ X int pai_NumberOfPages; /* total number of pages in DVI file */ X}; X Xstruct PostAmbleFont { X char *paf_name; /* name of font (null terminated) */ X int paf_n1; /* length of first part of name */ X int paf_n2; /* length of second part of name */ X i32 paf_DVIFontIndex; /* font index number */ X i32 paf_DVIChecksum; /* checksum from DVI file */ X i32 paf_DVIMag; /* "at size" */ X i32 paf_DVIDesignSize; /* design size of font */ X}; END_OF_h/postamble.h if test 1895 -ne `wc -c h/search.h <<'END_OF_h/search.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* search structures and routines for 32-bit key, arbitrary data */ X Xstruct search { X unsigned s_dsize; /* data object size (includes key size) */ X unsigned s_space; /* space left (in terms of objects) */ X unsigned s_n; /* number of objects in the table */ X char *s_data; /* data area */ X}; X X/* returns a pointer to the search table (for future search/installs) */ Xstruct search *SCreate(); /* create a search table */ X X/* returns a pointer to the data object found or created */ Xchar *SSearch(); /* search for a data object */ X X/* the third argument to SSearch controls operation as follows: */ X#define S_LOOKUP 0x00 /* pseudo flag */ X#define S_CREATE 0x01 /* create object if not found */ X#define S_EXCL 0x02 /* complain if already exists */ X X/* in addition, it is modified before return to hold status: */ X#define S_COLL 0x04 /* collision (occurs iff S_EXCL set) */ X#define S_FOUND 0x08 /* found (occurs iff existed already) */ X#define S_NEW 0x10 /* created (occurs iff S_CREATE && !S_EXCL) */ X#define S_ERROR 0x20 /* problem creating (out of memory) */ END_OF_h/search.h if test 1279 -ne `wc -c h/tfm.h <<'END_OF_h/tfm.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* X * TFM file information. X */ X X/* X * TFM files start with a series of unsigned 16 bit integers. We X * read this into the structure `tfm_header'. These are type i32 X * so that they may be used as integer quantities without concern X * as to sign extension. X */ Xstruct tfmheader { X i32 th_lf; /* length of the file (16 bit words) */ X i32 th_lh; /* length of the header data (words) */ X i32 th_bc; /* beginning character */ X i32 th_ec; /* ending character (inclusive) */ X i32 th_nw; /* number of words in width table */ X i32 th_nh; /* number of words in height table */ X i32 th_nd; /* number of words in depth table */ X i32 th_ni; /* words in italic correction table */ X i32 th_nl; /* words in ligature/kern table */ X i32 th_nk; /* words in kern table */ X i32 th_ne; /* words in extensible character table */ X i32 th_np; /* number of font parameter words */ X}; X X/* X * The remainder of the TFM file comprises the following information, X * all of which are 32 bit quantities: X * X * header: array [0..lh-1] of stuff X * char_info: array [bc..ec] of char_info_word X * width: array [0..nw-1] of fix_word X * height: array [0..nh-1] of fix_word X * depth: array [0..nd-1] of fix_word X * italic: array [0..ni-1] of fix_word X * lig_kern: array [0..nl-1] of lig_kern_command X * kern: array [0..ne-1] of extensible_recipie X * param: array [0..np-1] of fix_word X */ X X/* X * A char_info_word is built of four unsigned eight-bit quantities. The first X * is an index into the width table (this saves 24 bits for every X * character that has the same width as another character). The X * second is a composite height and depth index. The third is a X * composite italic index and tag, and the fourth is a remainder. X * X * XXX needs explaining X */ Xstruct char_info_word { X char ci_width; /* width index */ X char ci_h_d; /* height and depth index */ X char ci_i_t; /* italic index and tag */ X char ci_remainder; /* ??? */ X}; X X/* X * These macros split up h_and_d and i_and_t values. X */ X#define T_CI_H(ci) (((ci)->ci_h_d >> 4) & 0xf) X#define T_CI_D(ci) ((ci)->ci_h_d & 0xf) X#define T_CI_I(ci) (((ci)->ci_i_t >> 2) & 0x3f) X#define T_CI_T(ci) ((ci)->ci_i_t & 3) X X/* X * This structure contains everything one might need to know about X * a TFM file at run-time. X * X * XXX incomplete, or wrong, as yet X */ Xstruct tfmdata { X struct tfmheader t_hdr; /* full header */ X struct char_info_word *t_ci; /* char info */ X i32 *t_width; /* widths table */ X i32 *t_height; /* heights */ X i32 *t_depth; /* depths */ X}; END_OF_h/tfm.h if test 2711 -ne `wc -c h/types.h <<'END_OF_h/types.h' X/* X * Copyright (c) 1987 University of Maryland Department of Computer Science. X * All rights reserved. Permission to copy for any purpose is hereby granted X * so long as this copyright notice remains intact. X */ X X/* X * C-TeX types (system dependent). X */ X X#ifndef _CTEX_TYPES_ X#define _CTEX_TYPES_ X X/* a 16 bit integer (signed) */ Xtypedef short i16; X X/* a 32 bit integer (signed) */ Xtypedef long i32; X X/* macros to sign extend quantities that are less than 32 bits long */ X#if defined(u3b) || defined(u3b2) || defined(u3b5) || defined(ibm03) X#define Sign8(n) ((n) & (1 << 7) ? ((n) | 0xffffff00) : (n)) X#define Sign16(n) ((i32) (short) (n)) X#define Sign24(n) ((n) & (1 << 23) ? ((n) | 0xff000000) : (n)) X#else X#if defined(sun) || defined(hp300) X/* Sun mishandles (int)(char)(constant), but this subterfuge works: */ X#define Sign8(n) ((i32) (char) (int) (n)) X#else X#define Sign8(n) ((i32) (char) (n)) X#endif /* sun */ X#define Sign16(n) ((i32) (short) (n)) X#define Sign24(n) (((n) << 8) >> 8) X#endif /* u3b || u3b2 || u3b5 */ X X/* macros to truncate quantites that are signed but shouldn't be */ X#define UnSign8(n) ((n) & 0xff) X#define UnSign16(n) ((n) & 0xffff) X#define UnSign24(n) ((n) & 0xffffff) X X/* note that we never have unsigned 32 bit integers */ X X#endif /* _CTEX_TYPES_ */ END_OF_h/types.h if test 1282 -ne `wc -c