Newsgroups: comp.sources.misc From: parag@hpsdeb.sde.hp.com (Parag Patel) Subject: v25i039: dvi - C++ DVI filter for HP LaserJets, Patch02 Message-ID: <1991Nov10.195710.22829@sparky.imd.sterling.com> X-Md4-Signature: 32453f24e560e533d66a838e9ea184a7 Date: Sun, 10 Nov 1991 19:57:10 GMT Approved: kent@sparky.imd.sterling.com Submitted-by: parag@hpsdeb.sde.hp.com (Parag Patel) Posting-number: Volume 25, Issue 39 Archive-name: dvi/patch02 Environment: C++, LaserJet Patch-To: dvi: Volume 19, Issue 64-66 This is a mainly a bug-fix release, but adds one new feature. dvi can now run a MakeTeXPK script to create missing fonts at on-the-fly, just like Tomas Rokicki's fine dvips package from labrea.stanford.edu. A version of MakeTeXPK that's used within HP is included, but will doubtless require some hacking. From the README: 1.8 use DVIFONTPATH env var instead of FONTPATH to search for fonts try running a script which runs Metafont to generate fonts on the fly (this only works under Unix right now) LaserJet+ cannot really handle 8-bit data - back to the old code dvi -v runs properly when strings are put into read-only memory Set -DUSE_DIRENT in the Makefile if you have and not or dvi compiles and runs using C++ 3.0 now Many thanks to all the folks who sent in bug reports! -- Parag ---- Cut Here and feed the following to sh ---- #!/bin/sh # This is a shell archive (produced by shar 3.49) # To extract the files from this archive, save it to a file, remove # everything above the "!/bin/sh" line above, and type "sh file_name". # # made 10/22/1991 17:43 UTC by parag@hp-ses # Source directory /u1/parag/tools/tex/dvi # # existing files will NOT be overwritten unless -c is specified # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 34592 -rw-r--r-- patch-1.7-1.8 # 2396 -r-xr-xr-x MakeTeXPK # # ============= patch-1.7-1.8 ============== if test -f 'patch-1.7-1.8' -a X"$1" != X"-c"; then echo 'x - skipping patch-1.7-1.8 (File already exists)' else echo 'x - extracting patch-1.7-1.8 (Text)' sed 's/^X//' << 'SHAR_EOF' > 'patch-1.7-1.8' && *** tmp/Makefile Mon May 20 19:05:45 1991 --- Makefile Tue Oct 22 10:20:07 1991 *************** *** 1,5 X # Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! # $Header: Makefile,v 1.24 91/05/20 20:05:44 hmgr Exp $ X X CXX = CC X .SUFFIXES: .C X --- 1,5 ----- X # Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! # $Header: Makefile,v 1.28 91/10/22 11:20:05 hmgr Exp $ X X CXX = CC X .SUFFIXES: .C *************** *** 10,15 X # -DBSD for BSD derivatives X # -DMSDOS for Zortech C++ - also run "make msdos-files" X # -DFREE_TAKES_CHAR if you have a free(char*) instead of free(void*) X # -DHP2686_FPATH=/path1:/path2:... X # to modify the default font search path X CFLAGS = -g X --- 10,17 ----- X # -DBSD for BSD derivatives X # -DMSDOS for Zortech C++ - also run "make msdos-files" X # -DFREE_TAKES_CHAR if you have a free(char*) instead of free(void*) + # -DUSE_DIRENT use instead of or + # X # -DHP2686_FPATH=/path1:/path2:... X # to modify the default font search path for your system X # *************** *** 11,17 X # -DMSDOS for Zortech C++ - also run "make msdos-files" X # -DFREE_TAKES_CHAR if you have a free(char*) instead of free(void*) X # -DHP2686_FPATH=/path1:/path2:... ! # to modify the default font search path X CFLAGS = -g X LIBS = -lm X X --- 13,25 ----- X # -DUSE_DIRENT use instead of or X # X # -DHP2686_FPATH=/path1:/path2:... ! # to modify the default font search path for your system ! # ! # -DMF_SCRIPT=\"script\" ! # where the usage is: script dpi bdpi magnification [mode] ! # script tries to build the needed font on-the-fly ! # you can use the "MakeTeXPK" script that comes with the dvips package ! # X CFLAGS = -g X LIBS = -lm X *************** *** 19,25 X util.C global.C stack.C dirs.C dvi.C font.C readfont.C gffont.C \ X pkfont.C bitvec.C hp2684.h hp33440.h hp2686.h defs.h extern.h \ X dirs.h font.h dev.h darray.h boolean.h bitvec.h \ ! ljdump.c X X OBJS = main.o dev.o hp2686.o hp33440.o hp2684.o util.o global.o stack.o \ X dirs.o dvi.o font.o readfont.o gffont.o pkfont.o bitvec.o X --- 27,33 ----- X util.C global.C stack.C dirs.C dvi.C font.C readfont.C gffont.C \ X pkfont.C bitvec.C hp2684.h hp33440.h hp2686.h defs.h extern.h \ X dirs.h font.h dev.h darray.h boolean.h bitvec.h \ ! ljdump.c MakeTeXPK X X OBJS = main.o dev.o hp2686.o hp33440.o hp2684.o util.o global.o stack.o \ X dirs.o dvi.o font.o readfont.o gffont.o pkfont.o bitvec.o *** tmp/README Thu May 23 10:45:10 1991 --- README Tue Oct 22 10:42:57 1991 *************** *** 1,4 ! $Header: README,v 1.15 91/05/23 11:45:11 hmgr Exp $ X X Copyright (c) 1991 by Parag Patel. All Rights Reserved. X You can do what you wish with this as long as X --- 1,4 ----- ! $Header: README,v 1.22 91/10/22 11:42:54 hmgr Exp $ X X Copyright (c) 1991 by Parag Patel. All Rights Reserved. X You can do what you wish with this as long as *************** *** 59,64 X You will have to define -DMSDOS or -DBSD in the Makefile if you are on X those systems. My Sparc also needed -DFREE_TAKES_CHAR. X X Use "make ljdump" to build the "ljdump" program. This is useful for X debugging dvi by converting PCL to a semi-human-readable dump. X X --- 59,75 ----- X You will have to define -DMSDOS or -DBSD in the Makefile if you are on X those systems. My Sparc also needed -DFREE_TAKES_CHAR. X + You can make dvi run a script to build missing fonts on the fly. Add + the -DMF_SCRIPT="script" definition in the Makefile if you want this. + The script is run as "script dpi bdpi magnification [mode]". + + You can use the "MakeTeXPK" script that comes from the fine dvips + package by Tomas Rokicki at Stanford University. dvips, which converts + DVI output to PostScript, may be ftp-ed from labrea.stanford.edu. An + internal-HP version of MakeTeXPK is included with this package, though + it doubtless will need hacking to make it work on your system. This + feature is unlikely to work on MSDOS. + X Use "make ljdump" to build the "ljdump" program. This is useful for X debugging dvi by converting PCL to a semi-human-readable dump. X *************** *** 72,78 X available to others too. X X - X -- Parag Patel X X X --- 83,88 ----- X available to others too. X X X -- Parag Patel X X *************** *** 79,85 X X --------------------REVISION-INFO---------------------- X ! 1.6 released on HP INTERX Contrib Tape and comp.sources.misc X X 1.7 first bug-fix release X files modified: Makefile README extern.h main.C readfont.C hp2686.h X --- 89,95 ----- X X --------------------REVISION-INFO---------------------- X ! 1.6 released on HP INTEREX Contrib Tape and comp.sources.misc X X 1.7 first bug-fix release X files modified: Makefile README extern.h main.C readfont.C hp2686.h *************** *** 87,89 X version string slightly modified so say_hello() in main.C works X also look for fonts such as /path/cmr7.300pk and cmr7.300gf X allow overriding default font search path from Makefile X --- 97,108 ----- X version string slightly modified so say_hello() in main.C works X also look for fonts such as /path/cmr7.300pk and cmr7.300gf X allow overriding default font search path from Makefile + + 1.8 use DVIFONTPATH env var instead of FONTPATH to search for fonts + try running a script which runs Metafont to generate fonts on the fly + (this only works under Unix right now) + LaserJet+ cannot really handle 8-bit data - back to the old code + dvi -v runs properly when strings are put into read-only memory + Set -DUSE_DIRENT in the Makefile if you have and not + or + dvi compiles and runs using C++ 3.0 now *** tmp/dirs.C Fri Feb 22 14:57:30 1991 --- dirs.C Mon Aug 19 16:45:52 1991 *************** *** 1,5 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: dirs.C,v 1.10 91/02/22 15:57:16 hmgr Exp $"; X X // read font directory names into memory for fast traversal X // X --- 1,5 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: dirs.C,v 1.11 91/08/19 17:45:50 hmgr Exp $"; X X // read font directory names into memory for fast traversal X // *************** *** 12,18 X #define d_name name X #else X #ifdef BSD ! #include X #else X #include X #endif X --- 12,18 ----- X #define d_name name X #else X #ifdef BSD ! # include X #else X # ifdef USE_DIRENT X # include *************** *** 14,20 X #ifdef BSD X #include X #else ! #include X #endif X #endif X X --- 14,24 ----- X #ifdef BSD X # include X #else ! # ifdef USE_DIRENT ! # include ! # else ! # include ! # endif X #endif X #endif X *************** *** 82,88 X for (FIND *ent = findfirst(dos_dirpath, FA_DIREC); ent != NULL; X ent = findnext()) X #else ! for (direct * ent = readdir(dir); ent != NULL; ent = readdir(dir)) X #endif X { X char *s = strchr(ent->d_name, '.'); X --- 86,96 ----- X for (FIND *ent = findfirst(dos_dirpath, FA_DIREC); ent != NULL; X ent = findnext()) X #else ! # ifdef USE_DIRENT ! for (dirent *ent = readdir(dir); ent != NULL; ent = readdir(dir)) ! # else ! for (direct *ent = readdir(dir); ent != NULL; ent = readdir(dir)) ! # endif X #endif X { X char *s = strchr(ent->d_name, '.'); *** tmp/dvi.1 Fri Feb 22 14:53:53 1991 --- dvi.1 Mon Aug 19 16:41:17 1991 *************** *** 1,5 X .\" Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! .\" $Header: dvi.1,v 1.29 91/02/22 15:53:38 hmgr Exp $ X .TH DVI 1 unsupported X .ad b X .SH NAME X --- 1,5 ----- X .\" Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! .\" $Header: dvi.1,v 1.30 91/08/19 17:41:15 hmgr Exp $ X .TH DVI 1 unsupported X .ad b X .SH NAME *************** *** 117,123 X should look for either the GF or PK format font files. X The directories should have subdirectories for various magnifications. X Overrides the value of the environment var ! .B FONTPATH X if it exists. X The separator between the various path is platform dependent. X See the section on PLATFORM DEPENDENCIES for details. X --- 117,123 ----- X should look for either the GF or PK format font files. X The directories should have subdirectories for various magnifications. X Overrides the value of the environment var ! .B DVIFONTPATH X if it exists. X The separator between the various path is platform dependent. X See the section on PLATFORM DEPENDENCIES for details. *************** *** 196,202 X It searches along a default directory path for a printer X to find the necessary fonts. X The environment variable ! .B FONTPATH X or the X .B \-d X option X --- 196,202 ----- X It searches along a default directory path for a printer X to find the necessary fonts. X The environment variable ! .B DVIFONTPATH X or the X .B \-d X option *************** *** 201,207 X .B \-d X option X may be used to override this if desired. ! The default FONTPATHs are listed in the PRINTER DEPENDENCIES section below. X .PP X The GF format is part of the normal output from the Metafont program. X The PK format is a packed version of the GF file and is X --- 201,207 ----- X .B \-d X option X may be used to override this if desired. ! The default DVIFONTPATHs are listed in the PRINTER DEPENDENCIES section below. X .PP X The GF format is part of the normal output from the Metafont program. X The PK format is a packed version of the GF file and is *************** *** 307,313 X Other commands may be supported in the future. X .SH PLATFORM DEPENDENCIES X The separator between the component parts ! in either the FONTPATH environment variable X or the optional fontpath specification is platform dependent. X Default separator for UNIX is the colon character, X for MSDOS it is the semicolon character. X --- 307,313 ----- X Other commands may be supported in the future. X .SH PLATFORM DEPENDENCIES X The separator between the component parts ! in either the DVIFONTPATH environment variable X or the optional fontpath specification is platform dependent. X Default separator for UNIX is the colon character, X for MSDOS it is the semicolon character. *************** *** 321,327 X .br X Default options: page-reversal on, portrait X .br ! Default FONTPATH for UNIX: X /usr/lib/tex/fontbits/laser:/usr/lib/tex/fnt:/usr/local/tex/fontbits/laser X .br X Default FONTPATH for MSDOS: X --- 321,327 ----- X .br X Default options: page-reversal on, portrait X .br ! Default DVIFONTPATH for UNIX: X /usr/lib/tex/fontbits/laser:/usr/lib/tex/fnt:/usr/local/tex/fontbits/laser X .br X Default DVIFONTPATH for MSDOS: *************** *** 324,330 X Default FONTPATH for UNIX: X /usr/lib/tex/fontbits/laser:/usr/lib/tex/fnt:/usr/local/tex/fontbits/laser X .br ! Default FONTPATH for MSDOS: X /usr/lib/tex/fontbits/laser;/usr/lib/tex/fnt;/usr/local/tex/fontbits/laser X .TP X .B HP33440 LaserJetII ljII lj2 laser2 laserII default X --- 324,330 ----- X Default DVIFONTPATH for UNIX: X /usr/lib/tex/fontbits/laser:/usr/lib/tex/fnt:/usr/local/tex/fontbits/laser X .br ! Default DVIFONTPATH for MSDOS: X /usr/lib/tex/fontbits/laser;/usr/lib/tex/fnt;/usr/local/tex/fontbits/laser X .TP X .B HP33440 LaserJetII ljII lj2 laser2 laserII default *************** *** 336,342 X .br X Default options: page-reversal off, portrait X .br ! Default FONTPATH: X .TP X .B HP33447 LaserJetIID ljIId lj2d laser2D laserIID X HP LaserJetIID \- X --- 336,342 ----- X .br X Default options: page-reversal off, portrait X .br ! Default DVIFONTPATH: X .TP X .B HP33447 LaserJetIID ljIId lj2d laser2D laserIID X HP LaserJetIID \- *************** *** 344,350 X .br X Default options: page-reversal off, portrait, double-sided vertical binding X .br ! Default FONTPATH: X .TP X .B HP2684 JumboJet lj2000 laser2000 lj2k X HP LaserJet 2000 \- X --- 344,350 ----- X .br X Default options: page-reversal off, portrait, double-sided vertical binding X .br ! Default DVIFONTPATH: X .TP X .B HP2684 JumboJet lj2000 laser2000 lj2k X HP LaserJet 2000 \- *************** *** 353,359 X .br X Default options: page-reversal off, portrait, double-sided vertical binding X .br ! Default FONTPATH: X .SH FILES X .nf X /usr/lib/tex/fontbits/// X --- 353,359 ----- X .br X Default options: page-reversal off, portrait, double-sided vertical binding X .br ! Default DVIFONTPATH: X .SH FILES X .nf X /usr/lib/tex/fontbits/// *** tmp/dvi.C Fri Feb 22 14:57:47 1991 --- dvi.C Mon Aug 19 16:46:03 1991 *************** *** 1,5 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: dvi.C,v 1.24 91/02/22 15:57:33 hmgr Exp $"; X X // dvi scanning routines X // X --- 1,5 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: dvi.C,v 1.25 91/08/19 17:46:00 hmgr Exp $"; X X // dvi scanning routines X // *** tmp/extern.h Fri May 17 15:28:16 1991 --- extern.h Thu Oct 10 10:15:55 1991 *************** *** 1,5 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! // $Header: extern.h,v 1.25 91/05/17 16:28:17 hmgr Exp $ X X // externs for various LaserJet+ DVI filter functions X // X --- 1,5 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! // $Header: extern.h,v 1.26 91/09/13 16:14:20 hmgr Exp $ X X // externs for various LaserJet+ DVI filter functions X // *************** *** 94,100 X #if FREE_TAKES_CHAR X inline void strfree(const char *s) { if (s != NULL) free((char *)s); } X #else ! inline void strfree(const char *s) { if (s != NULL) free((const void *)s); } X #endif X inline char *strdup(const char *s) X { return s != NULL ? strcpy((char*)malloc(strlen(s) + 1), s) : NULL; } X --- 94,100 ----- X #if FREE_TAKES_CHAR X inline void strfree(const char *s) { if (s != NULL) free((char *)s); } X #else ! inline void strfree(const char *s) { if (s != NULL) free((void *)s); } X #endif X inline char *strdup(const char *s) X { return s != NULL ? strcpy((char*)malloc(strlen(s) + 1), s) : NULL; } *** tmp/gffont.C Fri Feb 22 14:58:20 1991 --- gffont.C Mon Aug 19 16:45:55 1991 *************** *** 1,5 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: gffont.C,v 1.20 91/02/22 15:58:04 hmgr Exp $"; X X // read font data from the METAFONT GF (generic font) files X // X --- 1,5 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: gffont.C,v 1.21 91/08/19 17:45:52 hmgr Exp $"; X X // read font data from the METAFONT GF (generic font) files X // *************** *** 85,95 X X long dsize = getsval(4, fp); X debug(4, "GF designsize=%ld", dsize); ! if (f.basename != NULL && dsize >> 4 != f.designsize) ! if (dochecksum && dsize != 0 && f.designsize != 0) ! quit("Designsize in DVI and GF file %s does not match", f.path); ! else ! warn("Designsize in DVI and GF file %s does not match", f.path); X X // check the checksum (!) X long check = getuval(4, fp); X --- 85,91 ----- X X long dsize = getsval(4, fp); X debug(4, "GF designsize=%ld", dsize); ! // do not bother checking the designsize - it seems pointless X X // check the checksum (!) X long check = getuval(4, fp); *** tmp/global.C Fri Feb 22 14:57:10 1991 --- global.C Mon Aug 19 16:42:34 1991 *************** *** 1,5 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: global.C,v 1.24 91/02/22 15:56:57 hmgr Exp $"; X X // Global variables for DVI filter. X // All globally visible variables are here. X --- 1,5 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: global.C,v 1.25 91/08/19 17:42:32 hmgr Exp $"; X X // Global variables for DVI filter. X // All globally visible variables are here. *************** *** 119,125 X char *str; X if (fontpath == NULL) X { ! str = getenv("FONTPATH"); X if (str != NULL && *str != '\0') X fontpath = str; X } X --- 119,127 ----- X char *str; X if (fontpath == NULL) X { ! str = getenv("DVIFONTPATH"); ! if (str == NULL || *str == '\0') ! str = getenv("FONTPATH"); // for backward-compatibility - sorry! X if (str != NULL && *str != '\0') X fontpath = str; X } *** tmp/hp2686.C Fri Feb 22 14:56:06 1991 --- hp2686.C Mon Aug 19 16:46:06 1991 *************** *** 1,5 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: hp2686.C,v 1.20 91/02/22 15:55:21 hmgr Exp $"; X X // HP2686 LaserJet+ and LaserJetII device-specific functions. X // The various Reference Manuals should be consulted for more X --- 1,5 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: hp2686.C,v 1.21 91/08/19 17:46:04 hmgr Exp $"; X X // HP2686 LaserJet+ and LaserJetII device-specific functions. X // The various Reference Manuals should be consulted for more *************** *** 66,74 X // X const char *HP2686::char2dev(int ch, int &len) X { ! static char buf[20]; ! if ((ch >= 32 && ch <= 127) || ch >= 160) ! sprintf(buf, "%c", ch); X else X sprintf(buf, "\033&p1X%c", ch); X len = strlen(buf); X --- 66,82 ----- X // X const char *HP2686::char2dev(int ch, int &len) X { ! static char buf[2]; ! // the LaserJet Plus can't really handle full 8-bit fonts. ! // it can handle only character codes 33-127 and 160-255 ! // we'll map as many of these as possible on a lowest-code first basis ! buf[0] = buf[1] = 0; ! if (ch <= 32) ! buf[0] = ch + 160; ! else if (ch > 32 && ch <= 127) ! buf[0] = ch; ! else if (ch <= 190) ! buf[0] = ch + 65; X else X quit("LaserJet+ cannot handle true 8-bit fonts -- Sorry"); X len = 1; *************** *** 70,79 X if ((ch >= 32 && ch <= 127) || ch >= 160) X sprintf(buf, "%c", ch); X else ! sprintf(buf, "\033&p1X%c", ch); ! len = strlen(buf); ! if (ch == 0) ! len++; X return buf; X } X X --- 78,85 ----- X else if (ch <= 190) X buf[0] = ch + 65; X else ! quit("LaserJet+ cannot handle true 8-bit fonts -- Sorry"); ! len = 1; X return buf; X } X *************** *** 219,227 X // X void HP2686::downchar(font &f, fontchar &g, int ch) X { ! // describe the character and its font to the LaserJet ! printf("\033*c%ldd%dE", f.num, ch); ! downljchar(f, g, ch); X } X X // this sets up this character in the LaserJet memory so that X --- 225,249 ----- X // X void HP2686::downchar(font &f, fontchar &g, int ch) X { ! // describe the character and its font to the LaserJet Plus ! // remember, only codes 33-127 and 160-255 can be sent ! if (ch <= 32) ! { ! printf("\033*c%ldd%dE", f.num, ch + 160); ! downljchar(f, g, ch + 160); ! } ! else if (ch > 32 && ch <= 127) ! { ! printf("\033*c%ldd%dE", f.num, ch); ! downljchar(f, g, ch); ! } ! else if (ch <= 190) ! { ! printf("\033*c%ldd%dE", f.num, ch + 65); ! downljchar(f, g, ch + 65); ! } ! else ! quit("LaserJet+ cannot handle true 8-bit fonts -- Sorry!"); X } X X // this sets up this character in the LaserJet memory so that *** tmp/hp33440.C Fri Feb 22 14:56:34 1991 --- hp33440.C Mon Aug 19 16:45:57 1991 *************** *** 1,5 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! // $Header: hp33440.C,v 1.13 91/02/22 15:56:21 hmgr Exp $ X X // LaserJetII series device-specific functions. X // The LaserJetII Reference Manual should be consulted for more X --- 1,5 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! // $Header: hp33440.C,v 1.15 91/08/19 17:45:54 hmgr Exp $ X X // LaserJetII series device-specific functions. X // The LaserJetII Reference Manual should be consulted for more *************** *** 16,22 X X // initialize the LaserJet II X HP33440::HP33440() : ! HP2686(257, 256, 32, 32, 300, HP2686_HOFFSET, HP2686_VOFFSET, X -128, 127, -128, 127, 128, 128, HP2686_FPATH) X { X } X --- 16,22 ----- X X // initialize the LaserJet II X HP33440::HP33440() : ! HP2686(257, 256, 16, 32, 300, HP2686_HOFFSET, HP2686_VOFFSET, X -128, 127, -128, 127, 128, 128, HP2686_FPATH) X { X } *************** *** 19,24 X HP2686(257, 256, 32, 32, 300, HP2686_HOFFSET, HP2686_VOFFSET, X -128, 127, -128, 127, 128, 128, HP2686_FPATH) X { X } X X // LaserJetIID: X --- 19,49 ----- X HP2686(257, 256, 16, 32, 300, HP2686_HOFFSET, HP2686_VOFFSET, X -128, 127, -128, 127, 128, 128, HP2686_FPATH) X { + } + + // convert a character number to something that the device can deal with + // for a LaserJet II + // + const char *HP33440::char2dev(int ch, int &len) + { + static char buf[20]; + if ((ch >= 32 && ch <= 127) || ch >= 160) + sprintf(buf, "%c", ch); + else + sprintf(buf, "\033&p1X%c", ch); + len = strlen(buf); + if (ch == 0) + len++; + return buf; + } + + // download a character for a particular font for the LaserJet II + // + void HP33440::downchar(font &f, fontchar &g, int ch) + { + // describe the character and its font to the LaserJet II + printf("\033*c%ldd%dE", f.num, ch); + downljchar(f, g, ch); X } X X // LaserJetIID: *** tmp/hp33440.h Fri Feb 22 14:58:53 1991 --- hp33440.h Mon Aug 19 16:46:12 1991 *************** *** 1,5 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! // $Header: hp33440.h,v 1.8 91/02/22 15:58:41 hmgr Exp $ X X // LaserJetII series device-specific definitions. X // The LaserJetII Reference Manual should be consulted for more X --- 1,5 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! // $Header: hp33440.h,v 1.9 91/08/19 17:46:06 hmgr Exp $ X X // LaserJetII series device-specific definitions. X // The LaserJetII Reference Manual should be consulted for more *************** *** 16,23 X HP33440(int maxf, int maxc, int maxpg, int maxld, int res, X int ho, int vo, int fhmn, int fhmx, int fvmn, int fvmx, X int fwd, int fhg, char *deffp) : ! HP2686(maxf, maxc, maxpg, maxld, res, ho, vo, ! fhmn, fhmx, fvmn, fvmx, fwd, fhg, deffp) { } X public: X HP33440(); X }; X --- 16,23 ----- X HP33440(int maxf, int maxc, int maxpg, int maxld, int res, X int ho, int vo, int fhmn, int fhmx, int fvmn, int fvmx, X int fwd, int fhg, char *deffp) : ! HP2686(maxf, maxc, maxpg, maxld, res, ho, vo, ! fhmn, fhmx, fvmn, fvmx, fwd, fhg, deffp) { } X public: X const char *char2dev(int ch, int &len); X void downchar(font &f, fontchar &g, int ch); *************** *** 19,24 X HP2686(maxf, maxc, maxpg, maxld, res, ho, vo, X fhmn, fhmx, fvmn, fvmx, fwd, fhg, deffp) { } X public: X HP33440(); X }; X X --- 19,26 ----- X HP2686(maxf, maxc, maxpg, maxld, res, ho, vo, X fhmn, fhmx, fvmn, fvmx, fwd, fhg, deffp) { } X public: + const char *char2dev(int ch, int &len); + void downchar(font &f, fontchar &g, int ch); X HP33440(); X }; X *** tmp/main.C Fri May 17 15:28:21 1991 --- main.C Fri Sep 27 15:13:37 1991 *************** *** 1,5 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: main.C,v 1.32 91/05/17 16:28:22 hmgr Exp $"; X X // TeX DVI filter main() - just parses arguments and calls functions X // X --- 1,5 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: main.C,v 1.33 91/08/19 17:45:57 hmgr Exp $"; X X // TeX DVI filter main() - just parses arguments and calls functions X // *************** *** 7,13 X X #include "defs.h" X ! static char *const whatid = "@(#)dvi 1.7 (02 April 1991)"; X X static void say_hello() X { X --- 7,13 ----- X X #include "defs.h" X ! static char *const whatid = "@(#)dvi 1.8 (19 August 1991)"; X X static void say_hello() X { *************** *** 13,18 X { X // hello message like (but unlike) TeX - the following mess should X // strip out the revision number out of the build ID string "whatid" X char *s = strchr(whatid, ' '); X while (*s == ' ') X s++; X --- 13,19 ----- X { X // hello message like (but unlike) TeX - the following mess should X // strip out the revision number out of the build ID string "whatid" + mesg("TeX DVI filter version "); X char *s = strchr(whatid, ' '); X while (*s == ' ') X s++; *************** *** 16,26 X char *s = strchr(whatid, ' '); X while (*s == ' ') X s++; ! char *t = s; ! while (*t != ' ' && *t != '$' && *t != '\0') ! t++; ! *t = '\0'; ! mesg("TeX DVI filter version %s for ", s); X } X X static long strtonum(char *s, char **ptr) X --- 17,25 ----- X char *s = strchr(whatid, ' '); X while (*s == ' ') X s++; ! while (*s != ' ' && *s != '$' && *s != '\0') ! mesg("%c", *s++); ! mesg(" for "); X } X X static long strtonum(char *s, char **ptr) *** tmp/pkfont.C Fri Feb 22 14:58:33 1991 --- pkfont.C Mon Aug 19 16:46:18 1991 *************** *** 1,5 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: pkfont.C,v 1.21 91/02/22 15:58:17 hmgr Exp $"; X X // read font data from the METAFONT PK (packed font) files X // X --- 1,5 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: pkfont.C,v 1.22 91/08/19 17:46:14 hmgr Exp $"; X X // read font data from the METAFONT PK (packed font) files X // *************** *** 67,77 X X long dsize = getsval(4, fp); X debug(4, "PK designsize=%ld", dsize); ! if (f.basename != NULL && dsize >> 4 != f.designsize) ! if (dochecksum && dsize != 0 && f.designsize != 0) ! quit("Designsize in DVI and PK file %s does not match", f.path); ! else ! warn("Designsize in DVI and PK file %s does not match", f.path); X X // check the checksum X long check = getuval(4, fp); X --- 67,73 ----- X X long dsize = getsval(4, fp); X debug(4, "PK designsize=%ld", dsize); ! // do not bother checking the designsize - it seems pointless X X // check the checksum X long check = getuval(4, fp); *** tmp/readfont.C Mon May 20 15:12:45 1991 --- readfont.C Tue Oct 22 10:13:23 1991 *************** *** 1,5 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: readfont.C,v 1.22 91/05/20 16:12:46 hmgr Exp $"; X X // read font data from the METAFONT GF (generic font) files X // X --- 1,5 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcsid[] = "$Header: readfont.C,v 1.24 91/10/22 11:13:21 hmgr Exp $"; X X // read font data from the METAFONT GF (generic font) files X // *************** *** 4,9 X // read font data from the METAFONT GF (generic font) files X // X // by Parag Patel X X #include "defs.h" X X --- 4,11 ----- X // read font data from the METAFONT GF (generic font) files X // X // by Parag Patel + // + // MF_SCRIPT hacks by Peter Marvit X X #include "defs.h" X *************** *** 90,96 X // the information from the DVI file - we now have to actually read the X // font file (GF or PK) to get the rest of the font's description X // ! void setupfont(font &f) X { X if (f.path != NULL) X if (tryfile(f, f.path, "", f.basename, "")) X --- 92,98 ----- X // the information from the DVI file - we now have to actually read the X // font file (GF or PK) to get the rest of the font's description X // ! static boolean trysetupfont(font &f) X { X if (f.path != NULL) X if (tryfile(f, f.path, "", f.basename, "")) *************** *** 94,100 X { X if (f.path != NULL) X if (tryfile(f, f.path, "", f.basename, "")) ! return; X X // setup the font directory cache if we need to X if (pathlist.size() < 1) X --- 96,102 ----- X { X if (f.path != NULL) X if (tryfile(f, f.path, "", f.basename, "")) ! return TRUE; X X // setup the font directory cache if we need to X if (pathlist.size() < 1) *************** *** 105,111 X Pathent & p = pathlist[i]; X X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, ".pk")) ! return; X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, ".gf")) X return; X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, "")) X --- 107,113 ----- X Pathent & p = pathlist[i]; X X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, ".pk")) ! return TRUE; X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, ".gf")) X return TRUE; X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, "")) *************** *** 107,113 X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, ".pk")) X return; X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, ".gf")) ! return; X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, "")) X return; X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, "")) X --- 109,115 ----- X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, ".pk")) X return TRUE; X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, ".gf")) ! return TRUE; X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, "")) X return TRUE; X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, "")) *************** *** 109,115 X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, ".gf")) X return; X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, "")) ! return; X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, "")) X return; X X --- 111,117 ----- X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, ".gf")) X return TRUE; X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, "")) ! return TRUE; X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, "")) X return TRUE; X *************** *** 111,117 X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, "")) X return; X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, "")) ! return; X X char ext[30]; X sprintf(ext, ".%dpk", RESOLUTION); X --- 113,119 ----- X if (tryfile(f, p.path, gfmagdir(p.dirs, f.mag), f.basename, "")) X return TRUE; X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, "")) ! return TRUE; X X char ext[30]; X sprintf(ext, ".%dpk", RESOLUTION); *************** *** 116,122 X char ext[30]; X sprintf(ext, ".%dpk", RESOLUTION); X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, ext)) ! return; X sprintf(ext, ".%dgf", RESOLUTION); X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, ext)) X return; X --- 118,124 ----- X char ext[30]; X sprintf(ext, ".%dpk", RESOLUTION); X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, ext)) ! return TRUE; X sprintf(ext, ".%dgf", RESOLUTION); X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, ext)) X return TRUE; *************** *** 119,125 X return; X sprintf(ext, ".%dgf", RESOLUTION); X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, ext)) ! return; X } X quit("Cannot find font file \"%s\" (at or near magnification %ld.%03ld) anywhere", X f.basename, f.mag / 1000, f.mag % 1000); X --- 121,127 ----- X return TRUE; X sprintf(ext, ".%dgf", RESOLUTION); X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, ext)) ! return TRUE; X } X return FALSE; X } *************** *** 121,126 X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, ext)) X return; X } X quit("Cannot find font file \"%s\" (at or near magnification %ld.%03ld) anywhere", X f.basename, f.mag / 1000, f.mag % 1000); X } X --- 123,245 ----- X if (tryfile(f, p.path, pkmagdir(p.dirs, f.mag), f.basename, ext)) X return TRUE; X } + return FALSE; + } + + #ifdef MF_SCRIPT + // The following routine is cribbed (with permission) from the fine "dvips" + // package by Tomas Rokicki at Stanford U. + // + static int magstep(int n, int bdpi) + { + register float t; + int neg = 0; + if (n < 0) + { + neg = 1; + n = -n; + } + if (n & 1) + { + n &= ~1; + t = 1.095445115; + } + else + t = 1.0; + while (n > 8) + { + n -= 8; + t = t * 2.0736; + } + while (n > 0) + { + n -= 2; + t = t * 1.2; + } + if (neg) + return (int)(0.5 + bdpi / t); + else + return (int)(0.5 + bdpi * t); + } + #endif + + + // Try to get and set the fonts we need. If it fails, it probably means + // we can't find the fonts and will have to make them. The #ifdef MF_SCRIPT + // allows an attempted creation of fonts, using an extrenal script which + // should call MetaFont, and then a retry of the [hopefully created] fonts. + // + void setupfont(font &f) + { + if (trysetupfont(f)) + return; + + #ifdef MF_SCRIPT + // The following code is cribbed (with permission) from the fine "dvips" + // package by Tomas Rokicki at Stanford U. + // + // First, the computation of magstep, stolen from dvips (makefont.c). + // This entire routine carefully lifted, though it works fine. + // + int m, n, dpi, bdpi; + char magstepc[MAXPATHLEN + 1]; + bdpi = RESOLUTION; + dpi = (int)f.mag * RESOLUTION / 1000; + + m = 0; + if (dpi < bdpi) + { + while (1) + { + m--; + n = magstep(m, bdpi); + if (n == dpi) + break; + if (n < dpi || m < -40) + { + m = 9999; + break; + } + } + } + else if (dpi > bdpi) + { + while (1) + { + m++; + n = magstep(m, bdpi); + if (n == dpi) + break; + if (n > dpi || m > 40) + { + m = 9999; + break; + } + } + } + if (m == 9999) + { + (void)sprintf(magstepc, "%d+%d/%d", dpi / bdpi, dpi % bdpi, bdpi); + } + else if (m >= 0) + { + (void)sprintf(magstepc, "magstep\\(%d.%d\\)", m / 2, (m & 1) * 5); + } + else + { + (void)sprintf(magstepc, "magstep\\(-%d.%d\\)", (-m) / 2, (m & 1) * 5); + } + + // Here is where we do the actually calling of the external script + // + char buf[MAXPATHLEN + 1]; + sprintf(buf, "%s %s %d %d %s\n", MF_SCRIPT, f.basename, + dpi, bdpi, magstepc); + system(buf); + if (trysetupfont(f)) + return; + #endif + X quit("Cannot find font file \"%s\" (at or near magnification %ld.%03ld) anywhere", X f.basename, f.mag / 1000, f.mag % 1000); X } SHAR_EOF chmod 0644 patch-1.7-1.8 || echo 'restore of patch-1.7-1.8 failed' Wc_c="`wc -c < 'patch-1.7-1.8'`" test 34592 -eq "$Wc_c" || echo 'patch-1.7-1.8: original size 34592, current size' "$Wc_c" fi # ============= MakeTeXPK ============== if test -f 'MakeTeXPK' -a X"$1" != X"-c"; then echo 'x - skipping MakeTeXPK (File already exists)' else echo 'x - extracting MakeTeXPK (Text)' sed 's/^X//' << 'SHAR_EOF' > 'MakeTeXPK' && #!/bin/sh -x # @(#)$Header: MakeTeXPK,v 1.2 91/08/19 17:53:48 hmgr Exp $ # @(#)Based on labrea.stanford.edu:/pub/dvips547.tar.Z dated Jan 27 02:14 size 244319 # # This script file makes a new TeX PK font, because one wasn't # found. Parameters are: # # name dpi bdpi magnification [mode] # # `name' is the name of the font, such as `cmr10'. `dpi' is # the resolution the font is needed at. `bdpi' is the base # resolution, useful for figuring out the mode to make the font # in. `magnification' is a string to pass to MF as the # magnification. `mode', if supplied, is the mode to use. # # Note that this file must execute Metafont, and then gftopk, # and place the result in the correct location for the PostScript # driver to find it subsequently. If this doesn't work, it will # be evident because MF will be invoked over and over again. # # Of course, it needs to be set up for your site. # # TEMPDIR needs to be unique for each process because of the possibility # of simultaneous processes running this script. TEMPDIR=/tmp/mtpk.$$ NAME=$1 DPI=$2 BDPI=$3 MAG=$4 MODE=$5 X umask 0 X if test "$MODE" = "" then X if test $BDPI = 300 X then X MODE=laser X elif test $BDPI = 1270 X then X MODE=lino X else X echo "I don't know the mode for $BDPI" X echo "Have your system admin update MakeTeXPK" X exit 1 X fi fi X # Something like the following is useful with TeX from hpdtl.ctgsc.hp.com PATH=$PATH:/usr/lib/tex/bin MFINPUTS=/usr/lib/tex/cm:/usr/lib/tex/mf:/usr/lib/tex/macros export MFINPUTS MAGDIR=`dc <