From 903f353d60d68dc5cd67ec72a808dfe247ea7142 Mon Sep 17 00:00:00 2001 From: Chris Lawrence Date: Wed, 2 Jul 2003 17:11:13 +0200 Subject: Import cjet_0.8.9.orig.tar.gz [dgit import orig cjet_0.8.9.orig.tar.gz] --- COPYING | 339 +++++++++++++++++++++ ChangeLog | 42 +++ INSTALL | 30 ++ Makefile | 36 +++ README | 160 ++++++++++ TODO | 37 +++ capsl.h | 122 ++++++++ cjet.h | 436 ++++++++++++++++++++++++++ config.h | 73 +++++ fonts.c | 606 ++++++++++++++++++++++++++++++++++++ function.c | 845 +++++++++++++++++++++++++++++++++++++++++++++++++++ header | 19 ++ io.c | 100 ++++++ macro.c | 69 +++++ main.c | 189 ++++++++++++ misc.c | 205 +++++++++++++ msdos/cjets.rsp | 11 + msdos/make.bcc | 33 ++ msdos/make.dj | 24 ++ page.c | 509 +++++++++++++++++++++++++++++++ parse.c | 586 +++++++++++++++++++++++++++++++++++ pcl.h | 137 +++++++++ pjl.c | 71 +++++ raster.c | 576 +++++++++++++++++++++++++++++++++++ samples/README | 32 ++ samples/desktops.pcl | 1 + samples/latin1s.pcl | 1 + samples/legalp.pcl | 1 + samples/legals.pcl | 1 + samples/mctexts.pcl | 1 + samples/roman8s.pcl | 1 + samples/vintls.pcl | 1 + samples/vmaths.pcl | 1 + samples/vuss.pcl | 1 + symbol.c | 335 ++++++++++++++++++++ symbol.h | 286 +++++++++++++++++ 36 files changed, 5917 insertions(+) create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 Makefile create mode 100644 README create mode 100644 TODO create mode 100644 capsl.h create mode 100644 cjet.h create mode 100644 config.h create mode 100644 fonts.c create mode 100644 function.c create mode 100644 header create mode 100644 io.c create mode 100644 macro.c create mode 100644 main.c create mode 100644 misc.c create mode 100644 msdos/cjets.rsp create mode 100644 msdos/make.bcc create mode 100644 msdos/make.dj create mode 100644 page.c create mode 100644 parse.c create mode 100644 pcl.h create mode 100644 pjl.c create mode 100644 raster.c create mode 100644 samples/README create mode 100644 samples/desktops.pcl create mode 100644 samples/latin1s.pcl create mode 100644 samples/legalp.pcl create mode 100644 samples/legals.pcl create mode 100644 samples/mctexts.pcl create mode 100644 samples/roman8s.pcl create mode 100644 samples/vintls.pcl create mode 100644 samples/vmaths.pcl create mode 100644 samples/vuss.pcl create mode 100644 symbol.c create mode 100644 symbol.h diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..a43ea21 --- /dev/null +++ b/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..b7e7228 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,42 @@ +Thu Feb 22 12:37:46 1996 Michael + +* cjet version 0.8.9, 22.02.1996 +* symbol.h, symbol.c: new PCL symbol sets: Desktop, MCText, VenturaUS, + Ventura International, Ventura Math, PSText, PSMath. (Questionable + usefulness :)) + symbol set handling fixups: allow selection of characters from + more graphic sets to fill in missing characters. Characters in control + code positions (not all, of course) are forceprinted as characters. + +Fri Jan 26 14:30:03 1996 Michael + +* cjet version 0.8.8 +* symbol.c: translate() +* fonts.c: ignore selection of nonexistent download fonts instead of + terminating abruptly +* misc.c: PrintControlChar() +* fixed(?) a download font problem: force printing of characters in control + code areas; CaPSL can't always make up its little mind and loses some + download characters on the first page; they started to appear somewhere + in the middle of the page or else on the next page. + +* cjet version 0.8.7, 17.01.1996 + +* pjl.c: new file: parse and ignore PJL sequences + +* fonts.c: removed (obsolete?) PCL font descriptor warning + +* function.c: added ESC &u # D (Set Units per Inch (PCL5e), added + appropriate parsing structure in parse.c + +* added ESC % # X Universal language exit (no-op) + +Mon May 15 19:35:05 1995 mike + +* cjet version 0.8.6 doc fix + +* cjet version 0.8.5 + +* raster.c: fixed mode 3 decompression; garbage was left in the + decompression buffer. + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..d920a1e --- /dev/null +++ b/INSTALL @@ -0,0 +1,30 @@ +CJET - HP Laserjet Emulation for Canon CaPSL (level III+) laser printers +Copyright (c) 1996 Michael Huijsmans mgh@sbox.tu-graz.ac.at +-------------------------------------------------------------------------- + +Compilation & "installation": + +0. Makefiles: + +- `Makefile' is for any UNIX system. Executable is `cjet'. + +- `make.dj' is for MSDOS and djgpp. Resulting program name is `cjetx.exe'. + +- `make.bcc' and `cjets.rsp' are for use with Borland C++ 3.1. Resulting + program name is `cjets.exe'. + + +1. Edit the appropriate Makefile for your system (CC etc.) + Defaults are for gcc. + +2. Edit "config.h" to #define your printer paper cassette size and default + symbol set. Defaults are European A4 paper and Roman-8. + +3. type `make -f ' for DOS or just `make' for UNIX + +4. Copy the executable to somewhere in your PATH. + + + + + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5220873 --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +# Makefile for CJet - LaserJet Emulation for CaPSL printers +# Copyright (C) 1996 Michael Huijsmans mgh@sbox.tu-graz.ac.at +# +# Makefile for UNIX systems +# + +# compiler, compiler and linker options +CC = gcc +OPT = -O2 -Wall +LINKOPT = -s + +# you should not need to change anything below + +SHELL = /bin/sh + +EXECNAME = cjet + +CFLAGS = $(OPT) +LDFLAGS = $(LINKOPT) + +OBJ = main.o parse.o function.o raster.o fonts.o misc.o symbol.o\ + page.o pjl.o macro.o io.o + + +cjet: $(OBJ) + $(CC) $(LDFLAGS) -o $(EXECNAME) $(OBJ) + +clean: + rm -f *.o $(EXECNAME) + + +$(OBJ): pcl.h cjet.h capsl.h +symbol.o: symbol.h + + + diff --git a/README b/README new file mode 100644 index 0000000..6a5adf7 --- /dev/null +++ b/README @@ -0,0 +1,160 @@ +CJET - HP Laserjet Emulation for Canon CaPSL (level III+) laser printers +Copyright (c) 1996 Michael Huijsmans + +email: mgh@sbox.tu-graz.ac.at + +-------------------------------------------------------------------------- +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should also have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +-------------------------------------------------------------------------- +Contents of this file: + +0. What is Cjet? +1. Supported machines +2. Usage +3. Features +4. Notes & Bugs + +See file INSTALL for compilation instructions. + +See file TODO for missing features + + +0. What is it? +-------------- + +CJET filters printer data from stdin to stdout, converting HP PCL +(Printer Command Language) escape sequences and data structures, +e.g. font headers, to their CaPSL equivalents. CaPSL is short for +`Canon Printing Systems Language'. Whereas PCL is a de-facto +world-wide standard as a laser and inkjet printer control language (if +you can call a bunch of escape sequences a `language'), CaPSL is +limited to Canon laser printers. Newer laser printers from Canon come +with PCL emulation, so CaPSL may well be facing extinction. + + + +1. Supported machines: +---------------------- + +The program itself should compile on any UNIX or UNIX-like system. +It even compiles under MS-DOS. (BC 3.1 and DJGPP). + +A Canon laser printer with CaPSL level III is required. + + +2. Current usage: +----------------- + + cjet [options] CaPSL-output + + Current options: + ---------------- + + -f set CaPSL paint mode to 'full'. Default is 'partial'. + Full paint mode requires at least 1.5MB printer memory. + Not very useful right now. + + -p ignore paper size commands. Useful for printing files + formatted for paper size X on printers with paper size Y. + + -q quiet mode. Suppresses all warning messages + + -x X shift output on paper by X dots horizontally. Positive values + of X shift to the right; negative values to the left. + Dots are 1/300 in. + + -y Y shift output on paper by Y dots vertically. Positive values + of Y shift downwards; negative values shift upwards. + + +3. Features: +------------ + +Cjet currently `emulates' a LaserJet II and supports some PCL features +found on later LaserJet models like the LaserJet IIp, IIIp, 4l. Not all +PCL commands are supported or fully functional; see the Missing / TODO +file TODO. The emulation is fairly complete; I emphasized the font +download and raster graphics stuff in favor of the plain text stuff +because I needed a TeX DVI driver ASAP. Among other things, Cjet +supports the following: + +- PCL Laserjet download fonts: auto-rotating and old-style landscape + types + +- PCL 5 raster compression modes 1, 2 and 3 + +- Roman-8, ISO Latin 1, Windows, PC-8, PC-850, PC-8D/N, and various other + symbol sets for text - mode printing + +- PJL sequences for newer LaserJet models are parsed and ignored (dvilj4l) + + +Cjet was "tested" with: + +- PCL output from dvilj, dvilj2p, dvilj4l: TeX DVI drivers for various + LaserJet models: LJII / LJIIp / LJ4l + +- PCL output from misc. software, e.g. the ljet3 driver in GhostScript + version 3.12, the LJIIIP driver in Windoze 3.1 (Note: see TODO on this) + + + +4. Notes: +--------- + +PJL (Printer job language) sequences (in output from dvilj4l) are now ignored. + +I mainly use `cjet' under Linux to convert PCL output from dvilj2p, a +TeX DVI driver for various flavours of LaserJet printers. It seems to work +(I can read what the Canon prints), at least for the 128-character fonts. +The newer 256-character fonts shouldn't pose any problems, except for the +fact that then only 16 download fonts are possible. This leads to +unpredictable results when more fonts get downloaded. +A workaround for this of course is to split the printing job into +smaller chunks. +I also prefer using GhostScript with the ljet3 driver and cjet instead +of the lbp8 driver because the lbp8 output gets shifted down and to +the right for some reason; with cjet I can shift it right back... +Caution: PCL mode 3 compressed raster data usually produces HUGE +amounts of CaPSL raster data, as CaPSL level III does not support any +compression. + +My printer is a Canon LBP-8 III+ with 1.5Mb memory. `Cjet' should(?) +also work for other Canon printers with less memory (LBP-4, LBP-4U), +except for full-page raster graphics, but I couldn't test this. +Anyway, enough paper was wasted already... + +The printers must support CaPSL level III or higher. + + +Bugs: +----- +Version 0.8.9: +A quasi-bug involving missing download characters in control code positions +has been fixed. +Selection of nonexistent download fonts (dvilj) is now ignored. + + +---- +Email bug reports, suggestions, remarks etc. to me at: + + mgh@sbox.tu-graz.ac.at + +However, I can't promise prompt reaction, as I *really* have other +things to do... + + + + diff --git a/TODO b/TODO new file mode 100644 index 0000000..24c78b3 --- /dev/null +++ b/TODO @@ -0,0 +1,37 @@ +Missing / TODO: + +- The character table for Ventura Math is probably not correct + +- rearrange PCL font downloads in the middle of pages so that CaPSL doesn't + eject the page in panic + +- better page stuff handling ( sizes and such ) + +- PCL 5 text attribute stuff - ESC (s # S + +- Macro and overlay stuff + +- HPGL support (some time) + +- some sort of init file to set cassette paper size, default font, font + catridges etc. + +What won't work : + +- some PCL files (e.g. at least one file created by the Ljet3p driver + in Windoze 3.1) download single characters in the middle of the page; + CaPSL will eject the current page at that point + +- Newer LaserJet models have more internal scalable fonts, the selection + of which will be at best ignored. + +- Reverse portrait / reverse landscape printing - ESC &l # O and ESC &a # P + +- Some lesser known or obsolete symbol sets or sets supplied with external + cartridges (which ones are obsolete ?) will not print correctly. + +- download symbol sets - ESC*c # R, ESC*c # S, ESC (t or (f # W (?) + (neither PCL nor CaPSL manuals available) + +- PCL 5 transparency mode pattern stuff (Is it useful ? Does anybody use it ?) + diff --git a/capsl.h b/capsl.h new file mode 100644 index 0000000..a7d5a2e --- /dev/null +++ b/capsl.h @@ -0,0 +1,122 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * capsl.h - CaPSL defines + * includes configuration file "config.h" + */ + +/* + * constant to convert PCL 4*dot pitch to CaPSL 100*pts pitch values + * canval = (300 / (pclval / 4)) * 100 => (300 * 4 * 100) /pclval + */ + +#define DOT2PTS 120000 + + +/* + * CaPSL typefaces + */ + +#define C_COURIER 3 /* Courier is Courier is Courier */ +#define C_SWISS 4 /* Swiss 721 - Univers / Helvetica */ +#define C_DUTCH 5 /* Dutch 801 - CG Times */ +#define C_SYMBOL 137 /* Symbol */ + + +/* + * some CaPSL graphic sets, the user manual doesn't list all of them (sigh) + * found by trial-and-error: + * IBM Portugal + * IBM CP 860 Portugal + * IBM CP 863 Canadian French + * IBM CP 865 Norway + */ + +#define C_IBML "'$2" /* 742 IBM L */ +#define C_IBMR1 "' 1" /* 701 IBM R1 - Codepage 437 */ +#define C_IBMR2 "' 2" /* 702 IBM R2 - Danish / Norwegian */ +#define C_IBM850 "' 3" /* 703 Codepage 850 Multilingual */ +#define C_IBM865 "'!6" /* 716 Codepage 865 */ +#define C_IBM863 "'!4" /* 714 Codepage 863 */ +#define C_IBM860 "'!1" /* 711 Codepage 860 - Portugal */ +#define C_IBMP "'!0" /* 710 IBM Portugal */ +#define C_PSR "\042! 1" /* 2101 PostScript right */ +#define C_SYML "\042!!0" /* 2110 Symbol left */ +#define C_SYMR "\042!!1" /* 2111 Symbol right */ +#define C_TURKISH "\042!\0421" /* 2121 Turkish */ +#define C_PSL "'!$2" /* 7142 PostScript left */ + + +/* + * CaPSL movement modes and submodes: line/column or size unit; + * units in size unit mode are either dots or decipoints + * dots are 1/300 in; decipts are 1/720 in. + */ + +#define LINECOL 0 +#define SIZEUNIT 1 +#define DOTS 7 +#define DECIPTS 2 + + +/* + * CaPSL portrait page size ids, add 1 to portrait id for landscape id + */ + +#define C_A4 14 +#define C_LETTER 30 +#define C_LEGAL 32 +#define C_EXEC 40 + + +/* + * Memorized Position stuff. PCL stores up to 20 positions in a stack, + * CaPSL saves up to 50 in a random access mode. Define some indices. + */ + +#define STACKBEGIN 10 /* Bottom of stack */ +#define STACKLIMIT 29 /* 20 Positions */ +#define PATTERNINDEX 30 /* saved position for patterns */ +#define RASTERINDEX 31 /* save position for Raster Graphics */ +#define MARGININDEX 32 /* save position for margin setting */ +#define S_LEFTMARGIN 33 /* save initial (adjusted) left margin */ +#define S_RIGHTMARGIN 34 /* save initial (adjusted) right margin */ +#define S_BOTMARGIN 35 /* save current bottom margin */ +#define S_TOPMARGIN 36 /* save initial (adjusted) top margin */ +#define S_CURRENTLEFT 37 /* save current left margin */ +#define S_CURRENTTOP 38 /* save current top margin */ + + + + + + + + + + + + + + + + + + diff --git a/cjet.h b/cjet.h new file mode 100644 index 0000000..75fd42f --- /dev/null +++ b/cjet.h @@ -0,0 +1,436 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * cjet.h - common defines, typedefs, global vars etc. + * includes configuration file "config.h" + */ + +#define VERSION "0.8.9" + +#ifdef MAIN +#define EXTERN +#else +#define EXTERN extern +#endif + +#ifdef MSDOS +#ifdef BCC +#include +#endif +#endif + +#include +#include +#include +#include + + +typedef short int WORD; +typedef unsigned int UINT; +typedef unsigned char BYTE; +typedef char BOOL ; + + + +#define UNIMPLEMENTED(a) if(verbose)\ + fprintf(stderr,"%s not yet implemented.\n",a) + +#define get_next_char() fgetc(infile) +#define unget_char(a) ungetc(a,infile) + +#include "pcl.h" +#include "capsl.h" + + +/* + * printer resolution + */ + +#define DPI 300 + +/* + * some control codes common to all(?) civilized printers + */ + +#define BEL 0x07 /* the bell */ +#define CR 0x0d /* carriage return */ +#define FF 0x0c /* form feed */ +#define LF 0x0a /* line feed */ +#define VTAB 0x0b /* vertical tab */ +#define ESC 0x1b /* escape character */ +#define SPACE 0x20 /* space character */ +#define BS 0x08 /* backspace */ +#define SI 0x0f /* shift in */ +#define SO 0x0e /* shift out */ +#define HTAB 0x09 /* horizontal tab */ + +/* various */ +#ifndef NULL +#define NULL 0 +#endif +#define TRUE 1 +#define FALSE 0 +#define PRIMARY 0 +#define SECONDARY 1 +#define LEFT 0 +#define RIGHT 1 +#define PORTRAIT 0 +#define LANDSCAPE 1 + + +/* homegrown error codes */ +#define UN_CLASS -300 /* unknown PCL command class */ +#define UN_CMD -301 /* unknown PCL command */ +#define UN_PARAM -302 /* mangled PCL parameter string */ +#define UN_OTHER -303 /* some other error */ +#define UN_OTHER1 -304 +#define UN_NOMEM -305 /* generic out of memory */ +#define UN_WFILE -306 /* file error on write */ +#define UN_RFILE -307 /* file error on read */ + + + +/* + * Doubly linked list of download font descriptors. These contain PCL to + * CaPSL id number assignments and various fields not actually used in a + * CaPSL font descriptor, but perhaps in some command later on. + */ + +typedef struct FONT_DESC FontDesc; +typedef FontDesc* Fptr; + +struct FONT_DESC { + int pcl_id; /* PCL font ID number */ + BYTE pcl_type; /* font size: 7- or 8-bit font */ + BYTE pcl_temp; /* status: temporary / permanent */ + char pcl_ul_dist; /* underline dist: + above, - below baseline */ + BYTE pcl_ul_height; /* Underline height, default 3 */ + int c_id_p; /* font id primary */ + int c_id_s; /* font id secondary */ + int c_orient; /* orientation */ + int c_gs; /* graphic set number */ + int c_flag; /* spacing flag */ + int c_pitch; /* character pitch */ + int c_csize; /* character size */ + int c_style; /* character style */ + int c_stroke; /* character stroke */ + int c_tface; /* typeface */ + int c_cwidth; /* Cell width */ + int c_cheight; /* Cell height */ + int c_bline; /* baseline distance */ + Fptr fd_next; /* next descriptor in list */ + Fptr fd_prev; /* previous fd */ +}; + +#define DOWNLD -1 /* flag: indicates download font */ + +EXTERN BOOL ignore; /* flag: ignore very small dl fonts */ +EXTERN BOOL ignorepaper; /* flag: ignore paper size setting commands */ +EXTERN BOOL verbose; /* flag: message output yes / no */ +EXTERN int paintmode; /* CaPSL paint mode: partial / full */ +EXTERN FILE *infile; +EXTERN FILE *outfile; +EXTERN char *prog_name; + + +/* variables to keep track of PCL & CaPSL printer states */ +EXTERN BOOL landscape; /* current page orientation */ +EXTERN int CR_status; /* CR / LF status, default 0 */ +EXTERN int left_margin; /* in DECIPTS, default 0 */ +EXTERN int right_margin; /* default max right pos on current page */ +EXTERN int top_margin; /* current top margin in DECIPTS */ +EXTERN int bottom_margin; /* in DECIPTS, set by text_length */ +EXTERN int last_top; /* last set top margin in DECIPTS */ +EXTERN int last_bot; /* last set bottom margin in DECIPTS */ +EXTERN int page_length; /* current page length in DECIPTS */ +EXTERN int paper_size; /* paper size as CaPSL ID */ +EXTERN int text_length; /* current text length in DECIPTS */ + +EXTERN int resolution; /* current graphics resolution in dpi */ +EXTERN int line_spacing; /* in LPI; default 6lpi */ +EXTERN int line_VMI; /* current VMI in decipoints */ +EXTERN int print_pitch; /* in CPI; default 10 cpi */ +EXTERN int print_HMI; /* current HMI in CPI * 100 */ +EXTERN int char_size; /* default 120 decipoints */ +EXTERN int shift_state; /* CaPSL: SI or SO ? */ +EXTERN int pos_unit; /* movement mode: line/Col or size unit */ +EXTERN int pos_sub_unit; /* movement submode: dots or decipoints */ +EXTERN int tface_p; /* current primary typeface */ +EXTERN int tface_s; /* current secondary typeface */ +EXTERN int set_p; /* current PCL primary symbol set */ +EXTERN int set_s; /* current PCL secondary symbol set */ +EXTERN int save_p; /* saved PCL primary symbol set */ +EXTERN int save_s; /* saved PCL secondary symbol set */ +EXTERN int macro_id; /* current macro id */ +EXTERN BOOL recording; /* macro registration in progress */ +EXTERN long macro_free; /* remaining space in macro buffer */ +EXTERN int pos_index; /* current memorized position index */ +EXTERN int page_y_offset; /* shift printout in y direction */ +EXTERN int page_x_offset; /* shift printout in x direction */ + +/* misc buffer stuff (raster & font download) */ + +#define M_BUFFER_SIZE 16384 /* initial buffer size */ +#define M_DEC_SIZE 2048 /* decompression buffer size */ +#define M_RASTER_SIZE 16384 /* raster buffer size */ +#define M_MACRO_SIZE 2048 /* macro buffer size */ + +typedef struct BUF_DESC bdesc; + +struct BUF_DESC { + long size; /* current size */ + BYTE *p; /* where it is */ +}; + +EXTERN bdesc buffer; /* the 'main' buffer */ +EXTERN bdesc aux_buffer; /* the 'aux' buffer */ +EXTERN bdesc dec_buffer; /* the 'decompression' buffer */ +EXTERN bdesc mac_buffer; /* macro defs here */ + +EXTERN BYTE *bufptr; /* global buffer.p */ +EXTERN BYTE *macroptr; /* current mac_buffer ptr */ + + +/* Raster Graphics stuff */ +EXTERN int old_usize; /* last raster data line size (bytes) */ +EXTERN int r_start; /* flag: Raster transfer in progress */ +EXTERN int r_width; /* current raster line width (bytes) */ +EXTERN int r_lines; /* current raster line count */ +EXTERN int r_mode; /* flag: PCL begin raster mode */ +EXTERN long r_free; /* free buffer size */ +EXTERN int r_compress; /* Compression Mode */ + + + +/* + * MAX_FONTS is max. number of fonts which can be printed per page, + * which also appears to be the max. number of downloadable fonts on + * the LBP 8. The CaPSL fonts are 7 bit, so only (MAX_FONTS / 2) 8-bit + * fonts can be downloaded. + */ + +#define MAX_FONTS 32 /* max. fonts per page */ + +EXTERN Fptr FontList; /* root of font descriptor list */ +EXTERN int c_font_used; /* number of used fonts (CaPSL) */ +EXTERN int pcl_font_id; /* current PCL download Font ID */ +EXTERN int c_font_id; /* next free CaPSL dl Font ID */ +EXTERN int char_code; /* current download character code */ +EXTERN int font_type; /* current dl Fonttype fixed / proport. */ +EXTERN int select_id; /* current CaPSL DownLoad Font ID */ +EXTERN int c_dl_prim; /* current CaPSL dl font id - primary */ +EXTERN int c_dl_sec; /* and secondary */ + + +/* Pattern Stuff */ +EXTERN int last_pattern; /* PCL or grey scale pattern id */ +EXTERN int patt_width; +EXTERN int patt_height; + +/* include printer defaults */ +#include "config.h" + +/* prototypes */ +void CheckPJL( void ); +void put_next_char( int ); +void PutString( char *, ... ); +void InitCaPSL( void ); +void init_side_margin( void ); +void init_top_margin( void ); +void cold_init( void ); +void terminate( void ); +int Parse(param *p); +void MorePanic( int, char* , ... ); +void SetModes( int, int ); +void SetShiftState( int ); +void CSSelect( int ); +void PutWord( int ); +void PurgeRaster( int ); +void clear_decompress_buffer( void); +void kill_descriptors( void ); +int FindFont (int ); +BYTE *get_buffer( int, bdesc * ); +void pipe_read( BYTE *, int ); +void pipe_write( BYTE * , int ); +void translate( int ); +void ReallyPrint( int ); +void paperwork( void ); +void paperinit( void ); + +void ClearSideMargins( void ); +void DisplayFunctions( void ); +void HalfLineFeed( void ); +void Reset( void ); +void SelfTest( void ); + +/* ESC ( */ +void Paren( int ); +void SetDefaultFont( int, int); +void SetDownLoadFont( int, int); +void SetSymbolSet( int, int ); + +/* ESC ( s */ +void Paren_S( int ); +void SetSpacing( int, int ); +void SetPitch( int, double ); +void SetHeight( int, double ); +void SetStyle( int, int ); +void SetStroke( int, param *); +void SetTypeface( int, int); +void DownLoadChar( int ); +void CreateFont( int ); + +/* ESC ( f */ +void Paren_F( int ); +void LoadSymbol( int ); + +/* ESC & */ +void Ampersand( void ); + +/* ESC & a */ +void Amp_a(void); +void SetLeftMargin(int); +void SetRightMargin(int); +void MoveHoriz( int, int, param *); +void MoveVert( int, int, param *); +void logical_page( int ); +void logical_rotate( int ); + +/* ESC & d */ +void Amp_d(void); +void SetUnderLineMode( int ); +void DisableUnderLine( void ); + +/* ESC & f */ +void Amp_f(void); +void PushPopPos( int ); +void MacroControl( int ); +void MacroID( int ); + +/* ESC & k */ +void Amp_k(void); +void SetHMI( double ); +void SetPrintPitch( int ); +void LineTermination( int ); + +/* ESC & p */ +void Amp_p(void); +void TransparentPrint( int ); + +/* ESC & l */ +void Amp_l(void); +void SetPageLength( int ); +void SetTopMargin( int ); +void SetTextLength( int ); +void SetLinesPerIn( int); +void SetVMI( double ); +void SetPageOrient( int ); +void PerfSkipMode( int ); +void NumCopies( int ); +void PaperControl( int ); +void SetPageSize( int ); +void paper_tray( int ); +void log_position( param *); + +/* ESC &r */ +void ClearPages(int); + +/* ESC & s */ +void Amp_s(void); +void SetWrapMode( int ); + +/* ESC & u */ +void Amp_u(void); +void SetUnitsPerInch( int ); + +/* ESC * */ +void Asterisk( void ); + +/* ESC * t */ +void Ast_t(void); +void RasterRez( int ); + +/* ESC * b */ +void Ast_b(void); +void TransferData( int ); +void Compression( int ); +void y_offset( int ); + +/* ESC * r */ +void Ast_r(void); +void StartRaster( int ); +void EndRaster ( void ); +void rotate_raster( int); +void raster_height( int ); +void raster_width( int ); + +/* ESC * c */ +void Ast_c(void); +void SetFontID( int ); +void SetCharCode( int ); +void FontControl( int ); +void HorizRuleSize( int, int ); +void VertRuleSize( int, int ); +void PatternID( int ); +void PrintRule( int ); +void SetSymbolID( int ); +void SymbolControl( int ); +void DefPattern( int ); +void PatternControl( int ); + +/* ESC *p */ +void Ast_p(void); +void MacroRef( int ); + +/* ESC *s */ +void StatusMessageType(int); +void StatusMessageUnit(int); +void StatusMessage(int); +void FreePrinterMemory(int); +void EchoValue(int value); + +/* ESC *v */ +void Ast_v( void); +void TPattern( int ); +void TSourceMode( int ); +void TDestMode( int ); + +/* ESC % */ +void percent( void ); +void UnivLangExit( int ); + + + + + + + + + + + + + + + + + + + diff --git a/config.h b/config.h new file mode 100644 index 0000000..be76be5 --- /dev/null +++ b/config.h @@ -0,0 +1,73 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * config.h : setup printer defaults: + * - paper size + * - symbol set + * - typeface + * - top and bottom margins + */ + +/* + * Cassette paper size: Select one of these: + * C_A4 for European A4 + * C_LETTER for US Letter size + * C_LEGAL for US Legal size + * C_EXEC for US Executive size + */ + +#define DEF_PAPER C_A4 + + +/* + * Default symbol set: (select one of the following) + * HP_ROMAN + * HP_PC_8 + * HP_ISOLATIN1 + * HP_PC850 + */ + +#define DEF_SET HP_ROMAN + + +/* + * Default Typeface: select one: + * C_COURIER + */ + +#define DEF_TFACE C_COURIER + + +/* + * default top and bottom margins in decipoints + * default 0.5 inch margins => 0.5in * 720 dpts = 360 + */ + +#define DEF_TOP_MARGIN 360 +#define DEF_BOT_MARGIN 360 + + +/* end */ + + + + + + diff --git a/fonts.c b/fonts.c new file mode 100644 index 0000000..3964d97 --- /dev/null +++ b/fonts.c @@ -0,0 +1,606 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * module : fonts.c - download font stuff + * + * Specify Font ID - ESC *c # D + * Specify Character Code - ESC *c # E + * Font and character control - ESC *c # F + * Set download font - ESC ( / ) # X + * download a character - ESC (s # W + * Create Font Descriptor - ESC )s # W + */ + + +#include "cjet.h" + + +/* + * create a new font descriptor and add it to the list + */ + +Fptr new_descriptor( void ) +{ + Fptr p,q; + + q = (Fptr) malloc(sizeof(FontDesc)); + if(q == 0){ + MorePanic(UN_NOMEM," malloc() font descriptor failed"); + exit(1); + } + if(FontList == 0) /* empty list */ + { + FontList = q; + q->fd_prev = 0; + q->fd_next = 0; + } + else + { + p = FontList; /* insert at head of list */ + p->fd_prev = q; + q->fd_next = p; + q->fd_prev = 0; + FontList = q; + } + return(q); +} + + +/* + * kill_descriptors + * walk through the list and free() each entry + */ + +void kill_descriptors( void ) +{ + Fptr p,q; + + p = FontList; + while(p != NULL) { + q = p->fd_next; + free(p); + p = q; + } + FontList = NULL; +} + + +/* + * Specify Font ID - ESC *c # D + * pcl_font_id is current PCL font id for download font ops + */ + +void SetFontID( int id ) +{ + pcl_font_id = id; +} + + +/* + * Specify Character Code - ESC *c # E + * char_code is current download op code + */ + +void SetCharCode( int code ) +{ + char_code = code; +} + + +/* + * search the PCL->CaPSL font id list and return pointer to the font + * descriptor matching the PCL id ; + * return NULL if no match was found; in this case no selection will + * take place. This "fixes" (dvilj) PCL code which selects a non-existing + * download font and then prints raster graphic characters + * + */ + +Fptr get_handle(int fontid) +{ + Fptr p; + + p = FontList; + while (p!=0) { + if(p->pcl_id == fontid) + return(p); + else + p = p->fd_next; + } + MorePanic(UN_OTHER, "Unknown PCL font descriptor %d ignored", fontid); + return(NULL); +} + + + +/* + * Font and character control - ESC *c [op] F + * delete downloaded character sets + * make dl sets temp or permanent - slightly bogus as all CaPSL dl fonts + * are sent as temporary fonts + */ + +void FontControl( int op ) +{ + int kill; + Fptr p, q, r; + + kill = PERMANENT; /* TEMP < PERM < TEMPERM */ + switch(op) + { + case 0 : /* delete temporary and permanent dl fonts */ + kill = TEMPERM; + case 1 : /* delete temporary dl fonts */ + { + p = FontList; + while (p!=0) { + q = p->fd_next; + if( kill > p->pcl_temp ) + { + PutString("\033[%d;1&p", p->c_id_p); + c_font_used--; + if(p->c_id_s > -1) { + PutString("\033[%d;1&p", p->c_id_s); + c_font_used--; + } + free(p); + } + p = q; + } + break; + } + case 2 : /* delete last specified dl font */ + { + p = get_handle(pcl_font_id); + if(p) { + q = p->fd_prev; + r = p->fd_next; + r->fd_prev = q; + q->fd_next = r; + PutString("\033[%d;1&p", p->c_id_p); + c_font_used--; + if(p->c_id_s > -1) { + PutString("\033[%d;1&p", p->c_id_s); + c_font_used--; + } + free(p); + } /* don't do anything if no match PCL->CaPSL was found */ + break; + } + case 4 : /* make last specified dl font temporary */ + { + p = get_handle(pcl_font_id); + if(p) + p->pcl_temp = TEMPORARY; + break; + } + case 5: /* make last specified dl font permanent */ + { + p = get_handle(pcl_font_id); + if(p) + p->pcl_temp = PERMANENT; + break; + } + case 6: /* copy current font as specified dl font id */ + { + break; + } + } +} + + + +/* + * set a download font and adjust current symbol set to avoid + * translate() translating incorrectly + */ + +void set_stuff( int id, int *set, int *save) +{ + CSSelect(id); /* select CaPSL font */ + if ( *set != DOWNLD) /* if prev selection was not dl font... */ + { + *save = *set; /* save prev. symbol set id */ + *set = DOWNLD; /* turn off translate() */ + } +} + + +/* + * Set download font as font - ESC( # X + * + * + * setting a PCL 8-bit download font sets the primary CaPSL font and + * - if available - the secondary CaPSL font + */ + +void SetDownLoadFont( int which, int fontid) +{ + int type, old; + + old = shift_state; /* get current shift state */ + type = FindFont( fontid ); /* get CaPSL assign numbers */ + + if(which == PRIMARY) /* set as primary font */ + { + SetShiftState(SI); + set_stuff(c_dl_prim, &set_p, &save_p); + if (c_dl_sec != -1) /* set secondary font because it's there */ + { + SetShiftState(SO); + set_stuff(c_dl_sec, &set_s, &save_s); + } + } + else /* use primary id to set secondary font */ + { /* useful only with 7-bit fonts... */ + SetShiftState(SO); + set_stuff(c_dl_prim, &set_s, &save_s); + } + SetShiftState(old); +} + + +/* + * select a CaPSL download character set by a number which is assigned + * at download font creation time. Also seems correct + */ + +void CSSelect(int ID) +{ + if(ID != select_id) { + PutString("\033[%d%%v", ID); + select_id = ID; + } + /* else was already selected */ +} + + +/* + * find the corresponding CaPSL font ids to a PCL font id + * there is no one-to-one correspondence as a possible PCL 8-bit set + * has to be `approximated' by two CaPSL 7-bit sets + */ + +int FindFont(int pclid) +{ + Fptr p; + + p = get_handle(pclid); + if(p) { + c_dl_prim = p->c_id_p; + c_dl_sec = p->c_id_s; + return(p->pcl_type); + } + else + return(0); +} + + +/* + * create a CaPSL font using a font descriptor generated from a PCL + * font descriptor and an id number + * control character flag '1 means control characters retain their control + * functions even if characters have been downloaded at their positions; + * this requires some trickery as to when to print control chars and when + * printable chars. + * flag '0' causes other problems: all characters are printable, some + * control codes (e.g. FF) are printed even when a real FF was wanted... + * (dvilj2p output) + */ + +void create_canon_font( int id, Fptr f ) +{ + PutString("\033P%dxFont%c.SET\033\\", id, id+65); + PutString("\033[0;0;0;"); /* 0 bytes, 0 chars reg'd, no priority */ + PutString("%d;%d;", f->c_orient, f->c_gs); + PutString("%d;%d;%d;", f->c_flag, f->c_pitch, f->c_csize); + PutString("%d;%d;%d;%d;%d;", f->c_style, f->c_stroke, f->c_tface, f->c_cwidth, f->c_cheight); + PutString("%d;0;0;0;0;1.p", f->c_bline); /* control char flag is 1 */ + c_font_id++; + c_font_used++; +} + + + +/* + * download a character of bytes - ESC (s # W + * uses current character code in global var 'CharCode'. + * + * Font Orientation: if the PCL download font header specifies Landscape, + * assume an old-style (?) landscape font definition and rotate the character + * pattern; else check the current page orientation ('landscape') and set + * the dl font orientation accordingly. + */ + +void DownLoadChar( int in_size) +{ + UINT Assign, csize; + WORD dummy; + int orient; + long pitch; + Fptr f; + + BYTE *out_buf = 0, *out_line, *out_copy, *p; + BYTE *in_line, *in_copy; + WORD in_top, in_left, out_top, out_left; + UINT out_w, out_h; + int in_bpr, out_bpr, out_size, in_bits; + int ls_lines, i, j; + BYTE in_mask, out_mask; + + p = get_buffer(in_size, &buffer); + + pipe_read(p, in_size); + orient = p[4]; /* character orientation */ + pitch = (p[14]*256+p[15])/4; + if(orient == LANDSCAPE) /* rotate a landscape character */ + { + in_left = p[6]*256 + p[7]; /* raw left offset */ + in_top = p[8]*256 + p[9]; /* raw top offset */ + + out_w = p[12]*256 + p[13]; /* portrait width is ls height */ + out_h = p[10]*256 + p[11]; /* portrait height is ls width */ + in_bpr = ( out_h + 7 ) / 8; /* in bytes per row */ + out_bpr = ( out_w + 7 ) / 8; /* out bytes per row */ + out_size = out_bpr * out_h; /* size of output raster in bytes */ + +#ifdef FDEBUG +fprintf(stderr, "Rotate: in_bpr %d, out_bpr %d ow %d, oh %d, size %d\n", + in_bpr, out_bpr, out_w, out_h, out_size); +#endif + out_buf = get_buffer(out_size, &aux_buffer); + for(i=0;i 8) + in_bits = 8; + for(j=0;j>= 1; + } + } + in_copy -= in_bpr; + in_line = in_copy; + out_mask >>= 1; + if( out_mask == 0) + { + out_mask = 0x80; + out_copy++; + out_line = out_copy; + } + } + out_top = - in_left; /* new top offset */ + out_left = in_top - out_w; /* new left offset */ + } + else + { /* portrait characters */ + out_w = p[10]*256 + p[11]; /* pattern width */ + out_h = p[12]*256 + p[13]; /* pattern height */ + out_left = p[6]*256 + p[7]; /* left offset */ + out_top = p[8]*256 + p[9]; /* top offset */ + out_size = in_size -16; /* subtract header info size */ + } + +#ifdef FDEBUG +fprintf(stderr,"..HP: char %d, left %d, top %d, ",char_code, out_left, out_top); +#endif + /* convert PCL values to CaPSL values */ + + out_top = out_top - out_h; + out_top = - out_top; + + dummy = FindFont( pcl_font_id ); + if (char_code >127){ + if (c_dl_sec == -1) { /* now we need a new CaPSL font */ + f = get_handle(pcl_font_id); /* get primary font descriptor */ + if(f == NULL) { /* trouble... */ + MorePanic(UN_OTHER,"Fatal: Missing PCL font descriptor %d",pcl_font_id); + exit(1); /* this really is bad - should not happen, to coin a phrase */ + } + c_dl_sec = c_font_id; /* add secondary id */ + f->c_id_s = c_dl_sec; + create_canon_font(c_dl_sec,f); /* and create font */ + } + Assign = c_dl_sec; + char_code -= 128; + } else { + Assign = c_dl_prim; + } + /* Assign = Canon assign number */ + if(font_type==8) + { + if( out_left < 0 ) /* Canon doesn't allow negative offsets */ + out_left = 0; /* in fixed pitch characters */ + csize = out_size + 9; /* Fixed Pitch character header size */ + } + else + { + csize = out_size + 11; /* Proportional character header size */ + } + +#ifdef FDEBUG + fprintf(stderr,"..dl char %d, pwidth %d, pheight %d, left %d, top %d, pitch %ld\n",char_code, out_w, out_h, out_left, out_top, pitch ); +#endif + + PutString("\033[%d;%d;%d.q", csize, Assign, font_type); + put_next_char(char_code); + if(font_type == 9) + PutWord(pitch); + PutWord(out_w); + PutWord(out_left); + PutWord(out_h); + PutWord(out_top); + if(orient == LANDSCAPE) + pipe_write(out_buf,out_size); + else + pipe_write( &p[16],out_size); +} + + +#ifdef FDEBUG + +void fnt_hdr( BYTE *p ) +/* print out HP font header info */ +{ + UINT CHeight, BLine, CWidth, Orient, SpFlag, pitch, CSize; + UINT Style, Stroke, TFace, Bitsize; + + CHeight = p[10]*256 + p[11]; /* cell height */ + BLine = p[6]*256 + p[7]; /* Baseline position */ + CWidth = p[8]*256 + p[9]; /* cell width */ + Orient = p[12]; + SpFlag = p[13]; /* spacing Flag */ + pitch = p[16]*256 + p[17]; + CSize = p[18]*256 + p[19]; + Style = p[23]; + Stroke = p[24]; + TFace = p[25]; + Bitsize = p[3]; + fprintf(stderr, "Fnthdr(HP): Size %d, Cellh %d, Cellw %d, pitch %d, Csize %d, BaseLine %d, Orient %d\n", + Bitsize, CHeight,CWidth,pitch,CSize,BLine,Orient); +} + + +#endif + + + + +/* + * Create Font Descriptor of bytes - ESC )s # W + * + * Apparently not all PCL 8-bit fonts use the code positions >127. + * I assume those sets are defined as PC8 sets to enable character + * printing in control code areas. + * Therefore the PCL 7- and 8- bit font types generate one CaPSL + * 7-bit font. An additional 7-bit CaPSL font is created only when + * necessary, i.e. when a PCL 8-bit font actually uses 8 bits. + * + * The font is created in the orientation given by the PCL orientation + * flag, or in the current page orientation in case of disagreement. + * + */ + +void CreateFont ( int size ) +{ + long temp; + int cs; + Fptr q; + BYTE *p; + + if (c_font_used >= MAX_FONTS) { + MorePanic(UN_OTHER, "Warning: Maximum CaPSL fonts per page reached"); + } + + p = get_buffer(size, &buffer); + pipe_read(p, size); /* read header */ + +/* + if(p[2] != 0) + MorePanic(UN_OTHER,"Warning: Download font is not a LJ font"); +*/ + +#ifdef FDEBUG + fnt_hdr(p); +#endif + + q = new_descriptor(); + q->pcl_id = pcl_font_id; + q->pcl_temp = TEMPORARY; /* default: temp */ + q->c_cwidth = p[8]*256 + p[9]; /* cell width */ + q->c_orient = p[12]; /* orientation */ + q->pcl_type = p[3]; /* bit size */ + q->c_cheight = p[10]*256 + p[11]; /* cell height */ + q->c_bline = q->c_cheight - (p[6]*256 + p[7]); /* Baseline position */ + +/* + * The CaPSL 'Orient' field is used when selecting char sets by + * attribute. If PCL dl fonts are always selected by some + * preassigned font id, then the corresponding CaPSL font will + * always be found. There may be problems if a PCL dl font is + * selected by attribute: depending on whether 'Orient' was set + * correctly the CaPSL dl font may or may not be found. + * Dvi2xx for example downloads fonts for landscape printing in + * portrait format. I suppose downloading landscape data is obsolete +*/ + + if (landscape == TRUE) /* page is currently lscaped... */ + q->c_orient = LANDSCAPE; + + q->c_flag = p[13] + 8; /* spacing Flag */ + q->c_gs = 3840; /* FIXME */ + temp = p[16]*256 + p[17]; + q->c_pitch = (UINT) (DOT2PTS / temp); + temp = p[18]*256 + p[19]; + q->c_csize = (UINT) ((25 * temp) / 4.1666667); /* dots to points */ + q->c_style = p[23]; + cs = p[24]; /* Strokeweight */ + if(cs < 0) + { + q->c_stroke = 20 - cs; + } + else if (cs > 0) + { + q->c_stroke = cs + 10; + } + else q->c_stroke = 0; + + q->c_tface = p[25]; + font_type = q->c_flag; /* fixed or prop., don't confuse with FType */ + q->c_id_p = c_font_id; + q->c_id_s = -1; /* no secondary font (yet) */ + create_canon_font(c_font_id, q); +} + + + + + + + + + diff --git a/function.c b/function.c new file mode 100644 index 0000000..20ec558 --- /dev/null +++ b/function.c @@ -0,0 +1,845 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * function.c - misc functions + * + * Clear Side Margins - ESC 9 + * Enter Display Functions Mode - ESC Y + * Exit Display Functions Mode - ESC Z + * Half Line Feed - ESC = + * Reset Printer - ESC E + * Self Test - ESC z + * set default fonts - ESC ( # @ + * select symbol set - ESC ( # ID + * Set fixed/proportional set - ESC (s # P + * Set Pitch in cpi - ESC (s # H + * Set character height in pts - ESC (s # V + * Set character style - ESC (s # S + * set character strokeweight - ESC (s # B + * select a typeface - ESC (s # T + * set left margin - ESC &a # L + * set right margin - ESC &a # M + * transparent print - ESC &p # X + * Set underline mode - ESC &d # d + * Disable underline - ESC &d @ + * Push / Pop position - ESC &f # S + * Set HMI value in 1/120in units - ESC &k # H + * Set Print Pitch - ESC &k # S + * Line Termination mode - ESC &k # G + * Set Lines per Inch - ESC &l # D + * Set VMI in 1/48 in units - ESC &l # C + * Select Perforation Skip Mode - ESC &l # L + * Set number of copies - ESC &l # X + * Set word wrap mode - ESC &s # C + * Set units per inch - ESC &u # D (PCL 5 - LJ4l) + * Universal language exit - ESC %-12345X (PCL 5) + * + * UNIMPLEMENTED("Print test page"); + * UNIMPLEMENTED("Macro Reference point"); + * UNIMPLEMENTED("ESC *s T\n"); + * UNIMPLEMENTED("ESC *s U\n"); + * UNIMPLEMENTED("ESC *s I\n"); + * UNIMPLEMENTED("ESC *s M\n"); + * UNIMPLEMENTED("ESC *s X\n"); + * UNIMPLEMENTED("ESC &r F\n"); + */ + +#include "cjet.h" + + +/* + * orientation of user defined pattern ? + */ + +void MacroRef( int op ) +{ + UNIMPLEMENTED("Macro Reference point"); +} + + +/* + * Set new movement modes, if and only if necessary. + */ + +void SetModes( int mode, int submode) +{ + if(mode != pos_unit){ /* if new mode != current mode */ + pos_unit = mode; /* set a new mode */ + if(mode == LINECOL) + PutString("\033[11l"); /* set line/col mode */ + else + PutString("\033[11h"); /* set Size Unit Mode */ + } + if(mode == SIZEUNIT) { /* change submode only if in size */ + if (submode != pos_sub_unit) { /* unit mode */ + pos_sub_unit = submode; + PutString("\033[%d I",submode); + } + } +} + + +/* + * Clear Side Margins - ESC 9 + * Sets the left margin saved in init_side_margin() as the new left margin. + * Sets the right margin saved in init_side_margin() as the new right margin. + * saved positions are adjusted for page_x_offset + */ + +void ClearSideMargins( void ) +{ + PutString("\033[0u"); /* clear side margins */ + PutString("\033[1;%d;0x", MARGININDEX); /* save CAP */ + PutString("\033[0;%d;1x", S_LEFTMARGIN); /* restore init left margin */ + PutString("\033[1;%d;1x", S_CURRENTLEFT); /* save left margin */ + PutString("\033[0t"); /* set left margin */ + PutString("\033[0;%d;1x", S_RIGHTMARGIN); /* restore init right marg. */ + PutString("\033[1t"); /* set right margin */ + PutString("\033[0;%d;0x", MARGININDEX); /* restore CAP */ + left_margin = 0; + right_margin = 0; +} + + + +/* + * set a new Shift state (SI or SO), if necessary + */ + +void SetShiftState( int mode ) +{ + if (mode != shift_state){ + put_next_char(mode); + shift_state = mode; + } +} + + + +/* + * Enter Display Functions Mode - ESC Y + * waits for ESC Z - Exit DF Mode, ignoring data + */ + +void DisplayFunctions( void ) +{ + BYTE c; + do { + while((c=get_next_char())!=ESC); + } while ((c=get_next_char())!='Z'); +} + + +/* + * Half Line Feed - ESC = + */ + +void HalfLineFeed( void ) +{ + PutString("\033K"); +} + + +/* + * Reset Printer - ESC E + */ + +void Reset( void ) +{ + InitCaPSL(); +} + + +/* + * Self Test - ESC z + * prints a test page some day + */ + +void SelfTest( void ) +{ + UNIMPLEMENTED("Print test page"); +} + + + +/* + * set default fonts - ESC ( # @ + * : 0,1 ... set default symbol set as symbol set (PCL 4) + * 2 ... Reselect current font (PCL 4) + * 3 ... Select default font as font (PCL 5) + * + * Ignore action 0-2 for symbol set selections other than to default, which + * is HP-ROMAN (older PCL behaviour ?). + * The Laserjet IIIp manual only lists action 3 - set default fonts. + */ + +void SetDefaultFont( int which, int action ) +{ + switch(action) + { + case 0 : + case 1 : SetSymbolSet( PRIMARY, HP_ROMAN ); break; + case 2 : break; + case 3 : SetTypeface( which, HP_COURIER ); break; + } +} + + + +/* + * select symbol set - ESC ( # ID + * Some PCL symbol sets have matching CaPSL graphic sets. Others are + * emulated by printing available characters from other graphic sets. + * (PC850 Multilingual, PostScript) This is done in symbol.c:translate() + * + * PCL symbol set ids consist of 'val' and 'terminator', e.g. '8U' + * Setnum is calculated as (val * 32) + (terminator - 64). + * + * Setting 8-bit symbol sets as secondary sets: + * set secondary set of 8-bit symbol set as new secondary set; + * leave primary set as is + */ + +void SetSymbolSet( int which, int setnum ) +{ + char sw; + + if(which == PRIMARY) { /* only relevant for 7-bit symbol sets */ + set_p = setnum; + sw = '('; + } + else { + set_s = setnum; + sw = ')'; + } + switch(setnum) { + case HP_LEGLSET : PutString("\033%cB",sw); break; /* ASCII + subst */ + case HP_NORWEG : PutString("\033%cE",sw); break; /* Norwegian */ + case HP_ITAL : PutString("\033%cY",sw); break; /* Italian */ + case HP_SWED : PutString("\033%cC",sw); break; /* Swedish */ + case HP_ASCII : PutString("\033%cB",sw); break; /* US ASCII */ + case HP_UKENG : PutString("\033%cA",sw); break; /* UK ASCII */ + case HP_FRENCH : PutString("\033%cR",sw); break; /* French */ + case HP_GERMAN : PutString("\033%cK",sw); break; /* German */ + case HP_SPANISH : PutString("\033%cZ",sw); break; /* Spanish */ + + case HP_PSTEXT : { if(which == PRIMARY) { + PutString("\033(%s\033)%s",C_PSL, C_PSR); + set_s = setnum; + } else + PutString("\033)%s", C_PSR); + break; + } + /* these two can be emulated using the Symbol typeface and graphic set */ + case HP_VMATH : + case HP_PSMATH : { if ( which == PRIMARY ) { + PutString("\033(%s\033)%s",C_SYML, C_SYMR); + set_s = setnum; + } else + PutString("\033)%s", C_SYMR); + break; + } + /* the next are emulated by IBML and PC850, PSR, Symbol(?) set(s) */ + case HP_ROMAN : /* Roman-8 */ + case HP_DESKTOP : /* Desktop */ + case HP_ISOLATIN1 : /* ISO 8859-1 Latin 1 */ + case HP_WIN30 : /* Win 3.0 Latin 1 */ + case HP_WIN31 : /* Win 3.1 Latin 1 */ + case HP_MCTEXT : /* MC Text */ + case HP_VINTL : /* Ventura International */ + case HP_VUS : /* Ventura US */ + case HP_PC850 : { if(which == PRIMARY) { + PutString("\033(%s\033)%s", C_IBML, C_IBM850); + set_s = setnum; + } else + PutString("\033)%s", C_IBM850); + break; + } + case HP_PCDN : { if(which == PRIMARY) { + PutString("\033(%s\033)%s", C_IBML, C_IBMR2); + set_s = setnum; + } else + PutString("\033)%s", C_IBMR2); + break; + } + case HP_PC_8 : { if(which == PRIMARY) { + PutString("\033(%s\033)%s", C_IBML, C_IBMR1); + set_s = setnum; + } else + PutString("\033)%s", C_IBMR1); + break; + } + case HP_PC_TRK : { if(which == PRIMARY) { + PutString("\033(%s\033)%s", C_IBML, C_TURKISH); + set_s = setnum; + } else + PutString("\033)%s", C_TURKISH); + break; + } + default : MorePanic(UN_OTHER,"Unknown symbol set: %d", setnum); break; + } +} + + +/* + * Set fixed/proportional for character set - ESC ( s # P + * UNKNOWN if the Canon command works for both sets or for any set separately + * value: 0 fixed, 1 proportional + */ + +void SetSpacing(int which, int value) +{ + int old; + + old = shift_state; + if(which == PRIMARY) + SetShiftState(SI); + else + SetShiftState(SO); + if (value == 0) + PutString("\033[?8h"); /* disable proportional spacing */ + else + /* enable proportional spacing and set proportional pitch */ + PutString("\033[?8l\033[?0 K"); + SetShiftState(old); +} + + +/* + * Set Pitch in cpi - ESC (s # H + */ + +void SetPitch( int which, double value) +{ + int old, pitch; + + old = shift_state; + value *= 100; + pitch = (int) (value); + + if(which == PRIMARY) + SetShiftState(SI); + else + SetShiftState(SO); + PutString("\033[?%d K",pitch); /* select character pitch */ + SetShiftState(old); + print_HMI = pitch; +} + + +/* + * Set character height in pts (1/72 in) - ESC (s # V + * Set Canon size in decipts, so multiply by 10 + */ + +void SetHeight(int which, double value) +{ + int old, size; + + old = shift_state; + value *=10; + size = (int) value; + SetModes(SIZEUNIT,DECIPTS); + if(which == PRIMARY) + SetShiftState(SI); + else + SetShiftState(SO); + PutString("\033[%d C",size); /* select character size */ + SetShiftState(old); + char_size = size; +} + + +/* + * Set character style - ESC (s # S + * FIXME: PCL 5 allows more effects + */ + +void SetStyle(int which, int value) +{ + int old; + + old = shift_state; + if(which == PRIMARY) + SetShiftState(SI); + else + SetShiftState(SO); + if (value == 0) + PutString("\033[23m"); /* upright characters */ + else + PutString("\033[3m"); /* italic characters */ + SetShiftState(old); +} + + +/* + * set character strokeweight - ESC (s # B + */ + +void SetStroke(int which, param *p) +{ + int old, weight; + + old = shift_state; + + if(which == PRIMARY) + SetShiftState(SI); + else + SetShiftState(SO); + + weight = p->i; + if (p->rel == NEGATIVE) + weight = -weight; + /* isn't this grotty ? */ + switch(weight) { + case -7 : PutString("\033[2;2;2;2;2;2;2m"); break; + case -6 : PutString("\033[2;2;2;2;2;2m"); break; + case -5 : PutString("\033[2;2;2;2;2m"); break; + case -4 : PutString("\033[2;2;2;2m"); break; + case -3 : PutString("\033[2;2;2m"); break; + case -2 : PutString("\033[2;2m"); break; + case -1 : PutString("\033[2m"); break; + case 0 : PutString("\033[22m"); break; + case 1 : PutString("\033[1m"); break; + case 2 : PutString("\033[1;1m"); break; + case 3 : PutString("\033[1;1;1m"); break; + case 4 : PutString("\033[1;1;1;1m"); break; + case 5 : PutString("\033[1;1;1;1;1m"); break; + case 6 : PutString("\033[1;1;1;1;1;1m"); break; + case 7 : PutString("\033[1;1;1;1;1;1;1m"); break; + } + SetShiftState(old); +} + + +/* + * set left margin in columns in current pitch - ESC &a # L + * adjust for page_x_offset + */ + +void SetLeftMargin( int pos) +{ + int x = page_x_offset; + + if(pos == 0) /* clear left ( and right... ) margins */ + ClearSideMargins(); + else { + PutString("\033[1;%d;0x",MARGININDEX); /* save CAP */ + SetModes(LINECOL,0); /* set line mode */ + PutString("\033[%d`",pos ); /* move absolute horizontal */ + if(x != 0) { + SetModes(SIZEUNIT,DECIPTS); /* adjust for page_x_offset */ + if (x > 0) + PutString("\033[%da",x); /* move right */ + else + PutString("\033[%dj", -x); /* move left */ + } + PutString("\033[0t"); /* set left margin */ + PutString("\033[1;%d;1x",S_CURRENTLEFT); /* save left margin */ + PutString("\033[0;%d;0x",MARGININDEX); /* restore CAP */ + left_margin = pos; + } +} + + +/* + * set right margin in columns in current pitch - ESC &a # M + * adjust for page_x_offset + */ + +void SetRightMargin( int pos) +{ + int x = page_x_offset; + + if(pos == 0) /* clear left ( and right... ) margins */ + ClearSideMargins(); + else { + PutString("\033[1;%d;0x",MARGININDEX); /* save CAP */ + SetModes(LINECOL,0); /* set line mode */ + PutString("\033[%d`",pos); /* move absolute horizontal */ + if(x != 0) { + SetModes(SIZEUNIT,DECIPTS); /* adjust for page_x_offset */ + if (x > 0) + PutString("\033[%da",x); /* move right */ + else + PutString("\033[%dj", -x); /* move left */ + } + PutString("\033[1t"); /* set right margin */ + PutString("\033[0;%d;0x",MARGININDEX); /* restore CAP */ + right_margin = pos; + } +} + + +/* + * MoveHoriz - move CAP horizontal, absolute or relative. + * when moving absolutely, adjust by page_x_offset + * + * MoveVert - move CAP vertically + * when moving absolutely, adjust by page_y_offset + */ + +void MoveHoriz(int mode, int submode, param *p) +{ + int x = page_x_offset; + + SetModes(mode, submode); /* set correct movement mode */ + if(r_start == TRUE ) { /* we have to print any graphics */ + PurgeRaster(0); /* before moving about the page */ + if( r_compress == 3 ) + clear_decompress_buffer(); + } + switch( p->rel ) { + case NONE : { + PutString("\033[%ld`", p->i); /* do the move */ + if(x != 0) { /* if there's an offset */ + SetModes(SIZEUNIT,DECIPTS); + if (x > 0) /* going right */ + PutString("\033[%da", x); + else + PutString("\033[%dj", -x); /* going left */ + } + break; + } + case POSITIVE : PutString("\033[%lda",p->i); break; /* right */ + case NEGATIVE : PutString("\033[%ldj",p->i); break; /* left */ + default : MorePanic(UN_PARAM, "Movement"); + } +} + + +void MoveVert(int mode, int submode, param *p) +{ + int y = page_y_offset; + + SetModes(mode, submode); /* set correct movement mode */ + if(r_start == TRUE ) { /* to avoid strange results, we have to print */ + PurgeRaster(0); /* any graphics before moving about the page */ + if( r_compress == 3 ) + clear_decompress_buffer(); + } + switch( p->rel ) { + case NONE : { + PutString("\033[%ldd", p->i); /* do the move */ + if( y != 0) { /* if there's an offset ... */ + SetModes(SIZEUNIT, DECIPTS); + if (y > 0) /* going down */ + PutString("\033[%de", y); + else /* going up */ + PutString("\033[%dk", -y); + } + break; + } + case POSITIVE : PutString("\033[%lde",p->i); break; /* down */ + case NEGATIVE : PutString("\033[%ldk",p->i); break; /* up */ + default : MorePanic(UN_PARAM, "Movement" ); + } +} + + +/* + * transparent print - ESC &p [count] X + * print the next count bytes directly to the printer + */ + +void TransparentPrint( int count ) +{ + BYTE *p; + + PutString("\033[%d.v",count); + get_buffer(count, &aux_buffer); + p = aux_buffer.p; + pipe_read(p, count); + pipe_write(p, count); +} + + + +/* + * Set underline mode - ESC &d # d + * ...0 Enable auto underline + * ...1 Single underline + * ...2 Double underline + * ...3 Single floating underline + * ...4 Double floating underline + * LJ IIIp manual only lists modes 0 and 3. + */ + +void SetUnderLineMode( int mode ) +{ + switch (mode) { + case 0 : + case 1 : PutString("\033[4m"); break; /* Single UL on */ + case 2 : PutString("\033[21m"); break; /* Double UL on */ + +/* FIXME: This has to change to use the UL_... values or something... */ + + case 3 : PutString("\033[4m"); break; /* Single UL on */ + case 4 : PutString("\033[21m"); break; /* Double UL on */ + default : break; + } +} + + + +/* + * Disable underline - ESC &d @ + */ + +void DisableUnderLine ( void ) +{ + PutString("\033[24m"); +} + + + +/* + * Push / Pop position - ESC &f # S + * Uses CaPSL memorized position CSI x and simulates a stack - will (perhaps) + * be changed by also using a CaPSL stack system - push pop environment CSI %y + * and CSI %z + */ + +void PushPopPos( int op ) +{ + if(op == 0) { /* Push current position */ + PutString("\033[1;%d;0x",pos_index++); /* memorize position */ + if( pos_index>STACKLIMIT ) /* what if stack overruns */ + pos_index = STACKLIMIT; /* who cares ? */ + } else { + PutString("\033[0;%d;0x",pos_index--); /* pop current position */ + if( pos_index T\n"); +} + + +void StatusMessageUnit(int id) +{ + UNIMPLEMENTED("ESC *s U\n"); +} + + +void StatusMessage(int id) +{ + UNIMPLEMENTED("ESC *s I\n"); +} + + +void FreePrinterMemory(int op) +{ + UNIMPLEMENTED("ESC *s M\n"); +} + + +void EchoValue(int value) +{ + UNIMPLEMENTED("ESC *s X\n"); +} + + +void ClearPages(int op) +{ + UNIMPLEMENTED("ESC &r F\n"); +} + + diff --git a/header b/header new file mode 100644 index 0000000..fb1553a --- /dev/null +++ b/header @@ -0,0 +1,19 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1995 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ diff --git a/io.c b/io.c new file mode 100644 index 0000000..c7b16cf --- /dev/null +++ b/io.c @@ -0,0 +1,100 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * io.c - input/output + * + * #define get_next_char() fgetc(infile) + * #define unget_char(a) ungetc(a,infile) + */ + +#include "cjet.h" + + +/* + * output a string, either directly to the printer or to the + * macro recording buffer + */ + +void PutString(char *format, ... ) +{ + va_list stuff; + va_start(stuff, format); + vfprintf(outfile, format, stuff); + va_end(stuff); +} + + +void put_next_char( int c) +{ + if(recording == TRUE) { + /* record in macro buffer */ + } + else + fputc (c,outfile); +} + + +/* + * read file/pipe routine with `helpful' error message + */ + +void pipe_read( BYTE *p, int size) +{ + if ( fread(p,1,size,infile) != size) { + MorePanic(UN_RFILE, "input", 0); + exit(1); /* yes, a bit abrupt */ + } +} + + + +/* + * file/pipe write routine with `helpful' error message + */ + +void pipe_write( BYTE *p, int size) +{ + if(recording == TRUE) { + /* macro recording */ + } else { + if (fwrite(p, 1, size, outfile) != size) { + MorePanic(UN_WFILE, "output", 0); + exit(1); /* yes, a bit abrupt */ + } + } +} + + + +void PutWord(int a) +/* the stupid way */ +{ + WORD hi, lo; + hi = (char) ((a>>8) & 0xff); + lo = (char) (a & 0xff); + put_next_char(hi); + put_next_char(lo); +} + + + + + + diff --git a/macro.c b/macro.c new file mode 100644 index 0000000..8604eb1 --- /dev/null +++ b/macro.c @@ -0,0 +1,69 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * macro.c - macro and overlay stuff (under construction) + * + * EXTERN int macro_id; current macro id + * EXTERN BOOL recording; macro registration in progress + * EXTERN long macro_free; remaining space in macro buffer + * EXTERN bdesc mac_buffer; macro defs here + * EXTERN BYTE *macroptr; current mac_buffer ptr + * + * UNIMPLEMENTED("MacroControl"); + * UNIMPLEMENTED("MacroID"); + * UNIMPLEMENTED("MacroRef"); + */ + + +#include "cjet.h" + + +/* + * macro control - ESC &f X + * + */ + +void MacroControl( int op ) +{ + switch(op) { + case 0 : /* start macro recording */ + case 1 : /* stop macro recording */ + case 2 : /* execute macro */ + case 3 : /* call macro */ + case 4 : /* enable macro for automatic overlay */ + case 5 : /* disable automatic overlay */ + case 6 : /* delete all macros */ + case 7 : /* delete all temporary macros */ + case 8 : /* delete current macro */ + case 9 : /* make macro temporary */ + case 10 : /* make macro permanent */ + default: break; + } + UNIMPLEMENTED("MacroControl"); +} + + +/* + * assign macro ID number - ESC &f Y + */ + +void MacroID( int id ) +{ + macro_id = id; +} diff --git a/main.c b/main.c new file mode 100644 index 0000000..ebcd108 --- /dev/null +++ b/main.c @@ -0,0 +1,189 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * main.c - main loop + * + */ + + +#define MAIN +#include "cjet.h" + + +#ifdef MSDOS +#include +#include +#ifdef BCC /* for Borland C 3.1 */ +#define fileno(f) ((f)->fd) +#endif +#endif + + +void usage( char c ) +{ + fprintf(stderr,"%s: unrecognized option -- %c\n",prog_name, c); + fprintf(stderr,"\n Usage: %s [options] CaPSL\n\n",prog_name); +/* fprintf(stderr," Options:\n");*/ + fprintf(stderr," -f full paint mode\n"); + fprintf(stderr," -p ignore paper size commands\n"); + fprintf(stderr," -q quiet mode\n"); + fprintf(stderr," -x shift output horizontally by dots\n"); + fprintf(stderr," -y shift output vertically by dots\n"); + fprintf(stderr," (dots are 1/300 inch)\n"); +/* fprintf(stderr," -i replace very small download fonts with internal scaled fonts\n\n");*/ + exit(0); +} + + +/* + * get program options: + * FIXME: use getopt() sometime + * + * -p ignore paper size commands; use this for example if a text is formatted + * for letter paper size, but the cassette paper size is A4 + * + * -q quiet mode, don't print anything + * + * -i ignore download fonts with point size < 8, + * substitute internal scaled font (not implemented yet) + * + * -f full paint mode for vector graphics; this requires >= 1.5 MB + * printer memory... + * + * -y arg shift output by arg dots in y direction + = up, - = down + * values entered as dots, save in DECIPOINTS + * + * -x arg shift output by arg dots in x direction + = right, - = left + * values entered as dots, save in DECIPOINTS + * + */ + +void parse_args(int argc, char **argv) +{ + char *s, *o, c = 0; + int err = 0; + int argi = 1; + + /* get program name */ + if(*argv[0] != '\0') + prog_name = argv[0]; + else + { + prog_name = (char *) malloc(5); + strcpy(prog_name,"CJet"); + } + + while(argi < argc ) { + s = argv[argi]; + argi++; + if (*s++ == '-') { + while(*s != 0) { + switch(c = (*s++) ) { + case 'f' : paintmode = 2; break; /* full paint mode */ + case 'p' : ignorepaper = TRUE; break; + case 'q' : verbose = FALSE; break; + case 'i' : ignore = TRUE; break; + case 'y' : { + o = argv[argi]; + page_y_offset = (int) (strtol(o, NULL, 10) * 2.4); + argi++; + break; + } + case 'x' : { + o = argv[argi]; + page_x_offset = (int) (strtol(o, NULL, 10) * 2.4); + argi++; + break; + } + default : err++; break; + } + } + } + } + if(verbose) { + fprintf(stderr,"%s version %s - LaserJet emulation for CaPSL printers\n", + prog_name, VERSION); + if(err > 0) + usage(c); + } +} + + + +int main(int argc, char **argv) +{ + int c; + +#ifdef MSDOS + setmode( ( fileno(stdin)) , O_BINARY); + setmode( ( fileno(stdout)) , O_BINARY); +#endif + + infile = stdin; + outfile = stdout; + + atexit(terminate); + cold_init(); + parse_args(argc, argv); + InitCaPSL(); + + while (( c = get_next_char())!= EOF) { + switch(c) { + case ESC: { + c = get_next_char(); + switch(c) { /* single character ESC codes */ + case '9' : ClearSideMargins(); break; + case 'Y' : DisplayFunctions(); break; + case 'Z' : break; /* dummy; is handled by ESC Y */ + case '=' : HalfLineFeed(); break; + case 'E' : Reset(); break; + case 'z' : SelfTest(); break; + case '(' : Paren(LEFT); break; + case ')' : Paren(RIGHT); break; + case '&' : Ampersand(); break; + case '*' : Asterisk(); break; + case '%' : percent(); break; + default : MorePanic( UN_CMD, "ESC %c", c); break; + } + break; + } + case BEL : /* REAL control characters */ + case BS : + case HTAB : + case LF : + case FF : + case CR : + case VTAB : put_next_char(c); break; + case '@' : CheckPJL(); break; + case SI : SetShiftState(SI); break; + case SO : SetShiftState(SO); break; + default : translate(c); break; + } + } + exit(0); /* ...made it to the bitter end */ +} + + + + + + + + diff --git a/misc.c b/misc.c new file mode 100644 index 0000000..8fdec32 --- /dev/null +++ b/misc.c @@ -0,0 +1,205 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * misc.c - misc / aux functions and initialization + * + */ + + +#include "cjet.h" + + +/* + * Requests for temporary buffers (raster data decompression, dumps + * and font downloads) pass or die here. Allocates a buffer once and + * realloc() to grow on request. Avoids excessive malloc()ing. + * bdesc structure has to be initialized with initial block size ! + * + * reqsize = new required size + * bdesc *f = pointer to buffer descriptor with current size + * returns pointer to block + * + */ + +BYTE *get_buffer( int reqsize, bdesc *f) +{ + if(f->p == NULL) { /* buffer is unallocated */ + f->p = (BYTE *) malloc(f->size); /* allocate a block */ + if(f->p == NULL) { /* that went wrong... */ + MorePanic(UN_NOMEM,"malloc() of temporary storage buffer failed"); + exit(1); /* ... and die. */ + } + } + /* if we get to here, the buffer exists. Check for size */ + if(reqsize > f->size) { + reqsize *= 2; /* make it larger for the future */ + f->p = (BYTE *) realloc( f->p, reqsize); + f->size = reqsize; + if(f->p == NULL) { + MorePanic(UN_NOMEM," realloc() of storage buffer failed"); + exit(1); + } + } + return (f->p); +} + + +/* + * program startup initialisation + * FIXME: do printer hard reset here; download new startup macro + */ + +void cold_init( void ) +{ + buffer.p = NULL; /* no main buffer yet */ + buffer.size = M_BUFFER_SIZE; /* initial size */ + aux_buffer.p = NULL; /* no aux buffer yet */ + aux_buffer.size = M_BUFFER_SIZE; + dec_buffer.p = NULL; /* no decompression buffer */ + dec_buffer.size = M_DEC_SIZE; + mac_buffer.p = NULL; /* no macro buffer */ + mac_buffer.size = M_MACRO_SIZE; + + verbose = TRUE; /* noisy running */ + ignorepaper = FALSE; /* don't ignore this */ + ignore = FALSE; /* don't ignore download fonts */ + paintmode = 0; /* use CaPSL partial paint mode */ + page_x_offset = 0; + page_y_offset = 0; +} + + +/* + * reset printer defaults + * As this function can be called during execution, make sure no options + * from the command line are 'overruled' + * FIXME: let fonts registered as permanent survive + * FIXME: call startup macro defined by cold_init() + */ + +void InitCaPSL(void) +{ + paper_size = DEF_PAPER; /* default paper size is set in config.h */ + landscape = FALSE; + line_spacing = 6; /* 6 lines per inch */ + line_VMI = 120; /* 120/720 inch per line */ + print_pitch = 10; /* 10 cpi */ + print_HMI = 1000; /* 10 cpi * 100 */ + top_margin = DEF_TOP_MARGIN; + bottom_margin = DEF_BOT_MARGIN; + last_top = -1; /* CaPSL: no margins are set on power up */ + last_bot = -1; + left_margin = 0; + right_margin = 0; /* i.e. rightmost position */ + shift_state = SI; + + resolution = 75; /* startup resolution */ + r_start = FALSE; /* no raster graphics */ + r_compress = 0; /* no compression */ + + tface_p = DEF_TFACE; /* primary typeface; default Courier */ + tface_s = DEF_TFACE; /* secondary typeface; default Courier */ + set_p = DEF_SET; /* default symbol set */ + set_s = DEF_SET; + char_size = 120; /* default font is 12pt */ + CR_status = 0; /* CR=CR LF=LF FF=FF */ + + pos_unit = LINECOL; /* CaPSL default movement mode */ + pos_sub_unit = DECIPTS; /* CaPSL default submode */ + + r_free = 0; + pos_index = STACKBEGIN; /* memorized position stack */ + pcl_font_id = 0; /* PCL download font numbering begins here */ + c_font_id = 0; /* CaPSL download font numbering */ + c_font_used = 0; /* CaPSL number of used fonts */ + + kill_descriptors(); /* remove any font descriptor entries */ + select_id = -1; /* no selected character set */ + recording = FALSE; /* no macro recording in progress */ + macro_id = -1; /* no current macro id */ + + /* + * Begin ISO mode; soft reset; paint mode; disable auto ff; + * enable scalable fonts + * select default symbol set + */ + + PutString("\033;\033<\033[%d&z\033[?2h\033[?32h", paintmode); + SetSymbolSet( PRIMARY, DEF_SET); + paperinit(); /* init paper defaults */ + + /* + * move to new (adjusted) origin: + */ + PutString("\033[0;%d;2x", S_CURRENTTOP); /* restore top margin */ + PutString("\033[0;%d;1x", S_CURRENTLEFT); /* restore left margin */ +} + + +/* + * called at program termination: + * free lists and any used malloc()ed blocks. + */ + +void terminate( void ) +{ + kill_descriptors(); + if(buffer.p != NULL) { + MorePanic(UN_OTHER, "Buffer used: %d kB", (buffer.size / 1024)); + free(buffer.p); + } + if(aux_buffer.p != NULL) { + MorePanic(UN_OTHER, "Aux buffer used: %d kB", (aux_buffer.size / 1024)); + free(aux_buffer.p); + } + if(dec_buffer.p != NULL) { + MorePanic(UN_OTHER, "Dec buffer used: %d kB", (dec_buffer.size / 1024)); + free(dec_buffer.p); + } + if(mac_buffer.p != NULL) { + MorePanic(UN_OTHER, "Macro buffer used: %d kB", (mac_buffer.size / 1024)); + free(mac_buffer.p); + } +} + + +void MorePanic( int errtype, char *format, ...) +{ + va_list stuff; + va_start(stuff, format); + + if (verbose) { + fprintf(stderr, "%s: ", prog_name); + switch(errtype) { + case UN_CMD: fprintf(stderr, "Unrecognized command: "); break; + case UN_CLASS: fprintf(stderr, "Unrecognized class: "); break; + case UN_PARAM: fprintf(stderr, "Garbage in command parameter: "); break; + case UN_OTHER: break; + case UN_NOMEM: fprintf(stderr, "Out of memory: "); break; + case UN_RFILE: fprintf(stderr, "File read error: "); break; + case UN_WFILE: fprintf(stderr, "File write error: "); break; + } + vfprintf(stderr, format, stuff); + fprintf(stderr,"\n"); + } + va_end(stuff); +} + + diff --git a/msdos/cjets.rsp b/msdos/cjets.rsp new file mode 100644 index 0000000..f2ff944 --- /dev/null +++ b/msdos/cjets.rsp @@ -0,0 +1,11 @@ +main.obj +parse.obj +function.obj +page.obj +raster.obj +misc.obj +pjl.obj +fonts.obj +symbol.obj +io.obj +macro.obj diff --git a/msdos/make.bcc b/msdos/make.bcc new file mode 100644 index 0000000..247eb92 --- /dev/null +++ b/msdos/make.bcc @@ -0,0 +1,33 @@ +# Makefile for CJet - LaserJet Emulation for CaPSL printers +# Copyright (C) 1994-1996 Michael Huijsmans +# mgh@sbox.tu-graz.ac.at +# +# Borland C++ 3.1, small model + + +EXECNAME = cjets.exe + + +CC = bcc +OPT = -A -a -ms -N -k -DMSDOS -DBCC + +# define this for your site +#LIB=D:\BC\LIB + +CFLAGS = $(OPT) + +OBJ1 = main.obj parse.obj function.obj raster.obj fonts.obj misc.obj +OBJ2 = symbol.obj pjl.obj page.obj macro.obj io.obj + +cjet: $(OBJ1) $(OBJ2) + $(CC) -a -L$(LIB) -e$(EXECNAME) @cjets.rsp + +$(OBJ1): pcl.h cjet.h capsl.h symbol.h +$(OBJ2): pcl.h cjet.h capsl.h symbol.h + + +clean: + del *.obj + del $(EXECNAME) + + diff --git a/msdos/make.dj b/msdos/make.dj new file mode 100644 index 0000000..9929ad2 --- /dev/null +++ b/msdos/make.dj @@ -0,0 +1,24 @@ +# Makefile for CJet - LaserJet Emulation for CaPSL printers +# Copyright (C) 1994-1996 Michael Huijsmans mgh@sbox.tu-graz.ac.at +# +# Makefile for DJGPP +# make -f make.dj +# + +EXECNAME = cjetx +CC = gcc +OPT = -O2 -Wall + +CFLAGS = $(OPT) + +OBJ = main.o parse.o function.o raster.o fonts.o misc.o symbol.o pjl.o page.o macro.o io.o + +cjet: $(OBJ) + $(CC) -s -o $(EXECNAME) $(OBJ) + coff2exe $(EXECNAME) + +clean: + del *.o $(EXECNAME) + + +$(OBJ): pcl.h cjet.h capsl.h diff --git a/page.c b/page.c new file mode 100644 index 0000000..70f9241 --- /dev/null +++ b/page.c @@ -0,0 +1,509 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * page.c - tedious page stuff + * + * Set Text length - ESC &l # F + * select output paper tray - ESC &l # G + * Select Page Orientation - ESC &l # O + * Set Page Length - ESC &l # P + * Set Top Margin - ESC &l # E + * logical_page - ESC &a # W [data] + * Log. position across ? - ESC &l # U + * Log. position down ? - ESC &l # Z + * Logical page rotate - ESC &a # P + * Paper Input Control - ESC &l # H + * SetPageSize - ESC &l # A + * UNIMPLEMENTED("Logical page positioning"); + */ + + + +#include "cjet.h" + +/* page stuff debugging */ +/* #define PDEBUG */ + + +struct PAPER { + int p_length; /* page length in decipoints, portrait */ + int l_length; /* page length in decipoints, landscape */ +}; + +typedef struct PAPER paper; + + +/* + * Define some common (physical) paper lengths in DECIPTS for portrait and + * landscape orientations. Dubious. + * + * A4 : 210mm x 297mm (width x height) + * letter : 8.5in x 11in + * legal : 8.5in x 14in + * exec : 7.25in x 10.5 in + * B5 : 180mm x 257mm ? + * + */ + +paper A4_size = { 8418, 5950 }; +paper letter_size = { 7920, 6120 }; +paper legal_size = { 10080, 6120 }; +paper exec_size = { 7560, 5220 }; +paper B5_size = { 7284, 5157 }; + + +#ifdef PDEBUG +void paper_state( void ) +{ + fprintf(stderr,"papersize = %d, orientation = %d, page length = %d\n", + paper_size, landscape, page_length); + fprintf(stderr,"text length = %d, topmargin = %d, bottom margin = %d ", + text_length, top_margin, bottom_margin); + if((text_length + top_margin + bottom_margin) == page_length) + fprintf(stderr,"\n"); + else + fprintf(stderr,"diffs!\n"); +} +#endif + + + +/* + * initialize left and right margins; + * consider page_x_offset + */ + +void init_side_margin( void ) +{ + int x = page_x_offset; + + PutString("\033[1;%d;0x",MARGININDEX); /* save CAP */ + PutString("\033[0;1;0x"); /* move to physical 0,0 */ + SetModes(SIZEUNIT,DECIPTS); + if (x != 0) { + if (x > 0) + PutString("\033[%da", x); /* move to margin */ + else + PutString("\033[%dj", -x); /* move left to margin */ + } + PutString("\033[0t"); /* set left margin */ + PutString("\033[1;%d;1x",S_LEFTMARGIN); /* save left margin */ + PutString("\033[1;%d;1x",S_CURRENTLEFT); /* save left margin */ + PutString("\033[0;2;0x"); /* move to right corner */ + if (x != 0) { + if (x > 0) + PutString("\033[%da", x); /* move right to margin */ + else + PutString("\033[%dj", -x); /* move left to margin */ + } + PutString("\033[1t"); /* set right margin */ + PutString("\033[1;%d;1x", S_RIGHTMARGIN); /* save right margin */ + PutString("\033[0;%d;0x", MARGININDEX); /* restore CAP */ +} + + + +/* + * initialize top margin; + * consider page_y_offset, but don't set the margin yet + */ + +void init_top_margin( void ) +{ + int y = page_y_offset; + + PutString("\033[1;%d;0x", MARGININDEX); /* save CAP */ + PutString("\033[0;1;0x"); /* move to physical 0,0 */ + SetModes(SIZEUNIT,DECIPTS); + if( y!= 0 ) + if (y > 0) + PutString("\033[%de", y); /* move down */ + else + PutString("\033[%dk", -y); /* move up */ + PutString("\033[1;%d;2x", S_TOPMARGIN); /* save init top margin */ + PutString("\033[0;%d;0x", MARGININDEX); /* restore CAP */ +} + + + +/* + * CaPSL: Set current top_margin as the top margin in decipts + * If the top margin was already set to the same amount, ignore. + * set: restore top of (physical) page position and move down from there + * page_y_adjust has been considered in init_top_margin() + */ + +void +C_set_top_margin( void ) +{ + if (top_margin != last_top) { + PutString("\033[1;%d;0x", MARGININDEX); /* save CAP */ + PutString("\033[0;%d;2x", S_TOPMARGIN); /* restore top edge */ + SetModes(SIZEUNIT,DECIPTS); /* set DECIPTS mode */ + PutString("\033[%de", top_margin); /* move down vertical */ + PutString("\033[2t"); /* set top margin */ + PutString("\033[1;%d;2x", S_CURRENTTOP); /* save curr. top margin */ + PutString("\033[0;%d;0x", MARGININDEX); /* restore CAP */ + last_top = top_margin; + } +} + + + +/* + * CaPSL: Set the current bottom_margin in decipts + * Calculate position from top_margin and text_length + * pos = top_margin + text_length + 1(?) + * as page_length = top_margin + text_length + bottom_margin + */ + +void +C_set_bot_margin( void ) +{ + int pos; + if(bottom_margin != last_bot) + { + pos = top_margin + text_length + 1; + PutString("\033[1;%d;0x", MARGININDEX); /* save CAP */ + PutString("\033[0;%d;2x", S_TOPMARGIN); /* restore top edge */ + SetModes(SIZEUNIT,DECIPTS); /* set DECIPTS mode */ + PutString("\033[%de", pos); /* move down vertical */ + PutString("\033[3t"); /* set bottom margin */ + PutString("\033[0;%d;0x", MARGININDEX); /* restore CAP */ + last_bot = bottom_margin; + } +} + + +/* + * Set default text length from page_length and top_margin. The bottom_margin + * is set to the default value. The top_margin value is either the default + * value or has been set previously + */ + +void +C_default_text_length( void ) +{ + bottom_margin = DEF_BOT_MARGIN; + text_length = page_length - bottom_margin - top_margin; + C_set_bot_margin(); +} + + +/* + * sets the top margin to default + */ + +void +C_default_top_margin( void ) +{ + top_margin = DEF_TOP_MARGIN; + C_set_top_margin(); +} + + +/* + * Get page length in decipoints for given CaPSL page size parameter and + * current orientation + */ + +void +C_default_page_length( void ) +{ + paper *p; + + switch(paper_size) + { + case C_LETTER : p = &letter_size; break; + case C_LEGAL : p = &legal_size; break; + case C_EXEC : p = &exec_size; break; + case C_A4 : + default : p = &A4_size; break; + } + page_length = (landscape ? p->l_length : p->p_length); + C_default_top_margin(); + C_default_text_length(); +} + + +/* + * Set Text length - ESC &l # F + * + * Set number of printable lines in the current line spacing. This + * implicitly sets the bottom margin. + * bottom margin = pagelength - topmargin - textlength + */ + +void +SetTextLength( int lines ) +{ + if (lines == 0) + C_default_text_length(); + else + { + text_length = lines * line_VMI; /* convert to decipoints */ + bottom_margin = page_length - text_length - top_margin; + if (bottom_margin < 0) { + bottom_margin = 0; + MorePanic(UN_OTHER,"SetTextLength(): Bottom Margin exceeds page"); + } else + C_set_bot_margin(); + } +#ifdef PDEBUG + fprintf(stderr,"SetTextlength():\n"); + paper_state(); +#endif +} + + +/* + * Select Page Orientation - ESC &l # O + * 0...select Portrait mode + * 1...select Landscape Mode + * 2...select reverse Portrait (PCL 5) + * 3...select reverse Landscape (PCL 5) + * CaPSL: select current paper size command for portrait (paper size x) + * or landscape (paper size x + 1) + * The PCL SetPageOrientation command is usually (?) sent after the + * SetPageSize command. If the -p command line option was set, only the + * CaPSL Orientation will be changed. Otherwise the Page Size will also + * be set. + */ + +void +SetPageOrient( int mode ) +{ + switch(mode) { + case 0: + case 2: landscape = FALSE; break; + case 1: + case 3: landscape = TRUE; break; + default: break; + } + mode = paper_size + landscape; + PutString("\033[%dp", mode); + last_top = 0; + last_bot = 0; + C_default_page_length(); +#ifdef PDEBUG + fprintf(stderr,"SetPageOrient():\n"); + paper_state(); +#endif +} + + +/* + * Set Page Length - ESC &l # P + * set number of lines in the current line spacing + * calculate length in decipts + */ + +void +SetPageLength( int lines ) +{ + page_length = lines * line_VMI; + C_default_top_margin(); + C_default_text_length(); +#ifdef PDEBUG + fprintf(stderr,"SetPageLength():\n"); + paper_state(); +#endif + +} + + + +/* + * Set Top Margin - ESC &l # E + * convert top margin in #lines in current line spacing to decipts + * + */ + +void +SetTopMargin( int lines ) +{ + if(lines == 0) /* clear top ( and bottom ...) margins */ + { + PutString("\033[1u"); + bottom_margin = 0; + last_top = -1; /* will be set in C_set_top_margin */ + last_bot = -1; + text_length = page_length; + } + top_margin = lines * line_VMI; /* convert margin to decipts */ + C_set_top_margin(); + C_default_text_length(); + +#ifdef PDEBUG + fprintf(stderr,"SetTopMargin():\n"); + paper_state(); +#endif + +} + + +/* + * select output paper tray - ESC &l # G + * 1..upper output tray; 2..rear output tray + */ + +void +paper_tray( int sel ) +{ + if((sel==2) && (verbose)) + MorePanic(UN_OTHER,"Open rear paper output tray..."); + /* or plain ignore it */ +} + + +/* + * Set Page Size - ESC &l # A + * FIXME for other page and envelope sizes + * + */ + +void +SetPageSize( int size ) +{ + paper_size = DEF_PAPER; + if(ignorepaper == FALSE) { + switch(size) { + case HP_LETTER : paper_size = C_LETTER; break; + case HP_EXEC : paper_size = C_EXEC; break; + case HP_A4 : paper_size = C_A4; break; + case HP_LEGAL : paper_size = C_LEGAL; break; + default: MorePanic(UN_OTHER,"Ignored SetPageSize(): Unknown size %d",size); + break; + } + /* FIXME ignore ? (This is also set in SetPageOrientation())*/ + /* PutString("\033[%dp", csize); */ + } /* ignorepaper */ + C_default_page_length(); + +#ifdef PDEBUG + fprintf(stderr,"SetTopMargin():\n"); + paper_state(); +#endif + +} + + +/* + * Paper Input Control - ESC &l # H + */ + +void +PaperControl( int op ) +{ + switch(op) { + case 0 : put_next_char(FF); break; /* eject the current page */ + case 2 : PutString("\033[1q"); break; /* manual feed */ + case 1 : /* feed paper from cassette */ + case 3 : /* manual envelope feed */ + case 4 : /* lower slot ? */ + case 5 : /* lower cassette */ + default : PutString("\033[0q"); break; + } +} + + +/* + * logical_page - ESC &a # W [data] + * specify user defined logical page data + * FIXME (unknown) + * read binary data and ignore for now + */ + +void +logical_page( int size ) +{ + BYTE *p; + p = get_buffer(size, &buffer); + pipe_read(p,size); +} + + +/* + * position the logical page by some amount in decipts in some direction. + * *if* this is: position the logical page over the physical page, then + * approximate the effects like the -x and -y command line switches. + * FIXME + * + * ESC &l # U - position across the page (?) + * ESC &l # Z - position down the page (?) + */ + +void +log_position( param *p) +{ + UNIMPLEMENTED("Logical page positioning"); +} + + +/* + * Logical rotate ESC &a # P - rotate page about + * CaPSL: use Page rotation command CSI %r to approximate this function; + * PCL allows multiples of 90 degrees + */ + +void +logical_rotate( int deg ) +{ + switch(deg) { + case 90 : + case 270 : { PutString("\033[1%%r"); /* enable Landscape */ + landscape = TRUE; + break; + } + case 0 : + case 180 : { PutString("\033[0%%r"); /* enable Portrait */ + landscape = FALSE; + break; + } + default : break; + } + top_margin = 0; /* rotate command clears all margins */ + bottom_margin = 0; + last_top = 0; + last_bot = 0; + text_length = page_length; + +#ifdef PDEBUG + fprintf(stderr,"SetPageRotation():\n"); + paper_state(); +#endif + +} + + +void +paperinit( void ) +{ + init_top_margin(); + init_side_margin(); + C_default_page_length(); + +#ifdef PDEBUG + fprintf(stderr,"paperinit():\n"); + paper_state(); +#endif + +} + diff --git a/parse.c b/parse.c new file mode 100644 index 0000000..eb55867 --- /dev/null +++ b/parse.c @@ -0,0 +1,586 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * parse.c - disassemble PCL sequences + * + */ + + +#include "cjet.h" + + +/* + * extended isalpha() to include the character '@' + */ + +int isxalpha( int c) +{ + if (c == '@') + return(TRUE); + else + return(isalpha(c)); +} + + +/* + * extended isupper() to include '@' + */ + +int isxupper( int c ) +{ + if (c == '@') + return(TRUE); + else + return (isupper(c)); +} + + +/* + * A PCL escape sequence has the form: + * ESC `command class character(s)' `value field' `command letter' + * Example: `ESC &a 123.456 B' + * + * Sequences of the same class, e.g. `&a' can be combined by printing the + * `command letter' (aka `terminator') in lowercase; the last command should + * be uppercase. + * Example: `ESC &a 123 b 456 c 789 D' + * + * Parse() scans a PCL escape sequence, extracts its argument and command + * letter and returns a flag to indicate whether more commands of the + * same class will follow. + * + * The `value field' (aka `parameter') may be a decimal fraction, e.g. + * '16.666'. Parse() keeps track of the decimal point and then divides + * the resulting integer value (ignoring the decimal point) by the + * correct factor. In the above example, 16666 / 1000 = 16.666. + */ + +int Parse(param *p) +{ + long current; + BOOL real; /* flag: parameter value is a real value */ + long len; + int c, d, more; + + p->rel = NONE; + p->i = 0; + p->f = 0.0; + current = 0; + real = FALSE; + len = 0; + + while (!isxalpha(c = get_next_char())) { + switch(c) { + case '+' : p->rel = POSITIVE; break; + case '-' : p->rel = NEGATIVE; break; + case '0' : + case '1' : + case '2' : + case '3' : + case '4' : + case '5' : + case '6' : + case '7' : + case '8' : + case '9' : { + current = current*10 + (c-48); + len *= 10; + break; + } + case '.' : { /* after decimal point, keep track of number of*/ + len = 1; /* digits we have to divide by later in 'len' */ + real = TRUE; + break; + } + default : MorePanic(UN_PARAM, "in Parse()"); break; + } + if(real == TRUE) { /* value is too large by factor 'len' */ + p->f = (double) current / (double) len; + p->i = (int) p->f; + } + else { + p->i = current; + p->f = (double) current; + } + } + + /* + * Some programs create files with PCL sequences in which the + * terminating character is LOWER case; check for this here: + * If an ESC or EOF character follows a lowercase terminator, + * then that letter should have been uppercase - end of command. + * Assume valid continuation for any other following stuff + */ + + more = FALSE; + p->letter = toupper(c); + if (islower(c)) { /* either continuation or special case */ + d = get_next_char(); /* peek at next character */ + unget_char(d); /* put it back before it's missed */ + if (d != ESC) /* ESC means a new command */ + if (d != EOF) /* EOF means just that */ + more = TRUE; /* else to be continued... */ + } + return(more); +} + + +/* + * Download symbol set - ESC (f sequence (PCL5) + * FIXME - no manual + */ + +void Paren_F(int gset) +{ + int more; + param p; + + do { + more = Parse (&p); + switch(p.letter) { + case 'W' : LoadSymbol( p.i); break; + default : MorePanic( UN_CMD,"ESC (f %c or ESC )f %c", p.letter, p.letter); + break; + } + }while(more); +} + + + +/* + * 'ESC (s' or 'ESC )s' sequence ... + */ + +void Paren_S(int gset) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter){ + case 'P' : SetSpacing(gset, p.i); break; + case 'H' : SetPitch(gset, p.f); break; + case 'V' : SetHeight(gset, p.f); break; + case 'S' : SetStyle(gset, p.i); break; + case 'B' : SetStroke(gset, &p); break; + case 'T' : SetTypeface(gset, p.i); break; + case 'W' : { if (gset == PRIMARY) + DownLoadChar( p.i); + else + CreateFont( p.i ); + break; + } + default : MorePanic(UN_CMD, "ESC (s %c or ESC )s %c", p.letter, p.letter); + break; + } + }while (more); +} + + +/* + * 'ESC (' or 'ESC )' sequence ... + */ + +void Paren( int direction ) +{ + int c, more, setnum, gset; + param p; + + if(direction == LEFT) + gset = PRIMARY; + else + gset = SECONDARY; + c = get_next_char(); + if(c == 's') /* ESC (s or ESC )s... */ + Paren_S(gset); + else if(c == 'f') /* ESC (f or ESC )f... */ + Paren_F(gset); + else { /* ESC ( or ESC )... */ + unget_char(c); + do { + more = Parse(&p); + switch(p.letter) { + case '@' : SetDefaultFont(gset, p.i); break; + case 'X' : SetDownLoadFont(gset,p.i); break; + default : { /* select symbol set */ + setnum = p.i*32 + (p.letter-64); + SetSymbolSet(gset, setnum); + break; + } + } + } while(more); + } + } + + +void Amp_a( void ) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'L' : SetLeftMargin(p.i); break; + case 'M' : SetRightMargin(p.i); break; + case 'C' : MoveHoriz(LINECOL, 0 ,&p); break; + case 'R' : MoveVert(LINECOL, 0, &p); break; + case 'H' : MoveHoriz(SIZEUNIT, DECIPTS, &p); break; + case 'V' : MoveVert(SIZEUNIT, DECIPTS, &p); break; + case 'P' : logical_rotate(p.i); break; + case 'W' : logical_page(p.i); break; + default : MorePanic( UN_CMD, "ESC &a %c", p.letter); break; + } + } while(more); +} + + +void Amp_d( void ) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'D' : SetUnderLineMode(p.i); break; + case '@' : DisableUnderLine(); break; + default : MorePanic(UN_CMD, "ESC &d %c", p.letter); break; + } + } while(more); +} + + +void +Amp_f( void ) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'S' : PushPopPos(p.i); break; + case 'X' : MacroControl(p.i); break; + case 'Y' : MacroID(p.i); break; + default : MorePanic(UN_CMD, "ESC &f %c", p.letter); break; + } + } while(more); +} + + +void Amp_k( void ) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'H' : SetHMI(p.f); break; + case 'S' : SetPrintPitch(p.i); break; + case 'G' : LineTermination(p.i); break; + default : MorePanic(UN_CMD, "ESC &k %c", p.letter); break; + } + } while(more); +} + + +void Amp_p( void ) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'X' : TransparentPrint(p.i); break; + default : MorePanic(UN_CMD,"ESC &p %c", p.letter); break; + } + } while(more); +} + + +void Amp_l( void ) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'P' : SetPageLength(p.i); break; + case 'E' : SetTopMargin(p.i); break; + case 'F' : SetTextLength(p.i); break; + case 'D' : SetLinesPerIn(p.i); break; + case 'C' : SetVMI(p.f); break; + case 'O' : SetPageOrient(p.i); break; + case 'L' : PerfSkipMode(p.i); break; + case 'X' : NumCopies(p.i); break; + case 'H' : PaperControl( p.i); break; + case 'A' : SetPageSize(p.i); break; + case 'G' : paper_tray(p.i); break; + case 'U' : log_position(&p); break; + case 'Z' : log_position(&p); break; + default : MorePanic(UN_CMD,"ESC &l %c", p.letter); break; + } + } while(more); +} + + +void Amp_s( void ) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'C' : SetWrapMode(p.i); break; + default : MorePanic(UN_CMD,"ESC &s %c", p.letter); break; + } + } while(more); +} + + +void Amp_u( void ) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'D' : SetUnitsPerInch(p.i); break; + default : MorePanic(UN_CMD,"ESC &u %c", p.letter); break; + } + } while(more); +} + + +void Amp_r( void ) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'F' : ClearPages(p.i); break; + default : MorePanic(UN_CMD,"ESC &r %c", p.letter); break; + } + } while(more); +} + + +void Ampersand( void ) +/* 'ESC &' sequence ... */ +{ + char c; + /* get command class letter ... */ + c = get_next_char(); + switch(c){ + case 'a' : Amp_a(); break; + case 'd' : Amp_d(); break; + case 'f' : Amp_f(); break; + case 'k' : Amp_k(); break; + case 'l' : Amp_l(); break; + case 'p' : Amp_p(); break; + case 'r' : Amp_r(); break; + case 's' : Amp_s(); break; + case 'u' : Amp_u(); break; + default : MorePanic( UN_CLASS, "ESC &%c", c); break; + } +} + + +void Ast_t(void) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'R' : RasterRez(p.i); break; + default : MorePanic(UN_CMD,"ESC *t %c", p.letter); break; + } + }while(more); +} + + +void Ast_b(void) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'W' : TransferData(p.i); break; + case 'M' : Compression(p.i); break; + case 'Y' : y_offset(p.i); break; + default : MorePanic(UN_CMD,"ESC *b %c", p.letter); break; + } + }while(more); +} + + +void Ast_r(void) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'A' : StartRaster(p.i); break; + case 'B' : EndRaster(); break; + case 'C' : EndRaster(); break; + case 'F' : rotate_raster(p.i); break; + case 'T' : raster_height(p.i); break; + case 'S' : raster_width(p.i); break; + default : MorePanic(UN_CMD,"ESC *r %c", p.letter); break; + } + }while(more); +} + + +void Ast_p(void) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'X' : MoveHoriz(SIZEUNIT, DOTS, &p); break; + case 'Y' : MoveVert(SIZEUNIT, DOTS, &p); break; + case 'R' : MacroRef(p.i); break; + default : MorePanic(UN_CMD, "ESC *p %c", p.letter); break; + } + }while(more); +} + + +void Ast_v(void) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'T' : TPattern(p.i); break; + case 'N' : TSourceMode(p.i); break; + case 'O' : TDestMode(p.i); break; + default : MorePanic(UN_CMD, "ESC *v %c", p.letter); break; + } + }while(more); +} + + +void Ast_s(void) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'T' : StatusMessageType(p.i); break; + case 'U' : StatusMessageUnit(p.i); break; + case 'I' : StatusMessage(p.i); break; + case 'M' : FreePrinterMemory(p.i); break; + case 'X' : EchoValue(p.i); break; + default : MorePanic(UN_CMD, "ESC *s %c", p.letter); break; + } + }while(more); +} + + +void Ast_c(void) +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'D' : SetFontID( p.i); break; + case 'E' : SetCharCode( p.i); break; + case 'F' : FontControl(p.i); break; + case 'A' : HorizRuleSize(DOTS, p.i); break; + case 'H' : HorizRuleSize(DECIPTS, p.i); break; + case 'B' : VertRuleSize(DOTS, p.i); break; + case 'V' : VertRuleSize(DECIPTS, p.i); break; + case 'G' : PatternID(p.i); break; + case 'W' : DefPattern(p.i); break; + case 'Q' : PatternControl(p.i); break; + case 'P' : PrintRule(p.i); break; + case 'R' : SetSymbolID(p.i); break; + case 'S' : SymbolControl(p.i); break; + default : MorePanic(UN_CMD,"ESC *c %c", p.letter); break; + } + }while(more); +} + + +/* + * 'ESC *' sequences + */ + +void Asterisk( void ) +{ + int c; + + c = get_next_char(); /* get command class letter ... */ + switch(c){ + case 't' : Ast_t(); break; + case 'b' : Ast_b(); break; + case 'r' : Ast_r(); break; + case 'p' : Ast_p(); break; + case 'c' : Ast_c(); break; + case 'v' : Ast_v(); break; + case 's' : Ast_s(); break; + default : MorePanic( UN_CLASS, "ESC *%c", c); break; + } +} + + +void percent( void ) +/* no second command class letter; parameters/terminators follow immediately */ +{ + int more; + param p; + + do { + more = Parse(&p); + switch(p.letter) { + case 'A' : UNIMPLEMENTED("Use Cursor position"); break; + case 'X' : UnivLangExit(p.i); break; + default : MorePanic(UN_CLASS, "ESC %%%c", p.letter); break; + } + }while(more); +} + + + diff --git a/pcl.h b/pcl.h new file mode 100644 index 0000000..635c464 --- /dev/null +++ b/pcl.h @@ -0,0 +1,137 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * + * pcl.h - PCL defines + */ + + +/* + * PCL symbol set numbers, number= value*32 + terminator-64 + */ + +/* 7-bit sets */ +#define HP_NORWEG 4 /* ISO 60 Norwegian 0D */ +#define HP_ITAL 9 /* ISO 15 Italian 0I */ +#define HP_UKENG 37 /* ISO 4 UK 1E */ +#define HP_FRENCH 38 /* ISO 69 French 1F */ +#define HP_GERMAN 39 /* ISO 21 German 1G */ +#define HP_SWED 19 /* ISO 11 Swedish 0S */ +#define HP_ASCII 21 /* ISO 6 ASCII 0U */ +#define HP_SPANISH 83 /* ISO 17 Spanish 2S */ +#define HP_LEGLSET 53 /* HP Legal 1U */ + +/* 8-bit sets * = equiv. CaPSL sets exist */ +#define HP_ROMAN 277 /* Roman-8 8U */ +#define HP_DESKTOP 234 /* Desktop 7J */ +#define HP_WIN30 309 /* Windows 3.0 Latin 1 9U */ +#define HP_WIN31 629 /* Windows 3.1 Latin 1 19U */ +#define HP_ISOLATIN1 14 /* ISO 8859-1 Latin 1 0N */ +#define HP_PC_8 341 /* * PC-8 CP 437 10U */ +#define HP_PCDN 373 /* * PC Dan/Nor 11U */ +#define HP_PC850 405 /* * PC-850 12U */ +#define HP_PC_TRK 308 /* * PC Turkish 9T */ +#define HP_PSTEXT 330 /* * PS TEXT 10J */ +#define HP_MCTEXT 394 /* MC Text 12J */ +#define HP_VMATH 205 /* Ventura Math 6M */ +#define HP_PSMATH 173 /* * PS Math 5M */ +#define HP_VINTL 426 /* Ventura Int'l 13J */ +#define HP_VUS 458 /* Ventura US 14J */ + + +/* + * PCL typefaces for which CaPSL equivalents exist + * PCL 4 typeface numbers 0-5 match CaPSL numbers: + * 0 Line Printer + * 1 Pica + * 2 Elite + * 3 Courier + * 4 Helvetica (Swiss) + * 5 Times Roman (Dutch) + */ + +#define HP_COURIER 3 /* default typeface is 3 (Courier) */ +#define HP_UNIVERS 4148 /* PCL CG Univers is CaPSL Swiss */ +#define HP_CGTIMES 4101 /* PCL CG Times is CaPSL Dutch */ + +/* various other PCL typefaces */ +#define HP_COURIER2 4099 /* PCL5 code for Courier */ +#define HP_ALBERTUS 4362 /* Albertus */ +#define HP_ANOLIVE 4168 /* Antique Olive */ +#define HP_CORONET 4116 /* Coronet */ +#define HP_LGOTHIC 4102 /* Letter Gothic */ +#define HP_WDINGS 6826 /* Intellifont Wingdings */ + + +/* PCL Page Sizes */ +#define HP_A4 26 +#define HP_LETTER 2 +#define HP_EXEC 1 +#define HP_LEGAL 3 + + +/* defines for PCL relative positioning */ +#define NONE 0 +#define POSITIVE 1 +#define NEGATIVE 2 + + +/* PCL Font Header - Font Type field */ +#define SEVENBIT 0 +#define EIGHTBIT 1 +#define IBMFONT 2 + + +/* defines for font / macro registration modes */ +#define TEMPORARY 0 +#define PERMANENT 1 +#define TEMPERM 2 + + +/* PCL Escape value & command letter struct */ + +struct PARAM{ + long i; /* parameter value as integer */ + double f; /* parameter value as real*/ + BOOL rel; /* relative coordinate flag */ + int letter; /* command letter */ +}; + +typedef struct PARAM param; + + + + + + + + + + + + + + + + + + + + diff --git a/pjl.c b/pjl.c new file mode 100644 index 0000000..08a2750 --- /dev/null +++ b/pjl.c @@ -0,0 +1,71 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * pjl.c - check for and ignore (for now) PJL sequences + * + */ + + +#include "cjet.h" + +/* + * later model HP printers add a "Printer Job Language" + * PJL commands are of the form "@PJL bla bla bla [CR]LF" + */ + + +/* + * A '@' was detected in the input stream. Check for the string "PJL": + * if "PJL" was found, ignore everything up to the next LF + * else print the pending '@' and any read characters. + */ + +void CheckPJL(void) +{ + + int p, j, l; + + p = get_next_char(); + + if (p == 'P') { + j = get_next_char(); + if (j == 'J') { + l = get_next_char(); + if (l == 'L') { /* yes. @PJL found. now ignore it */ + do { + p = get_next_char(); + } while (p != LF); + } else { /* print "@PJ" */ + translate('@'); + translate('P'); + translate('J'); + unget_char(l); /* put back last character */ + } + } else { /* print "@P" */ + translate('@'); + translate('P'); + unget_char(j); /* put back last character */ + } + } + else { + translate('@'); + unget_char(p); /* put back last character */ + } +} diff --git a/raster.c b/raster.c new file mode 100644 index 0000000..ce93860 --- /dev/null +++ b/raster.c @@ -0,0 +1,576 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * + * raster.c - raster graphics stuff + * + * rotate raster - ESC *r # F + * Set Raster pattern height - ESC *r # T + * set raster width - ESC *r # S + * raster y offset in raster lines - ESC *b # Y + * Set Compression mode - ESC *b # M + * set Raster Resolution - ESC *r # R + * Transfer Raster Graphics - ESC *b # W [data] + * Start Raster Graphics - ESC *r # A + * End Raster Graphics - ESC *r B + * End Raster Graphics - ESC *r C + * Horizontal Rule Size - ESC *c # H + * Vertical Rule Size - ESC *c # B + * Specify Pattern ID - ESC *c # G + * Print Rule / Pattern - ESC *c # P + * + * UNIMPLEMENTED("Rotate raster method 3") - ESC *r F + * UNIMPLEMENTED("Set raster height") - ESC *r T + * UNIMPLEMENTED("Set Raster width") - ESC *r S + * UNIMPLEMENTED("User defined pattern"); - ESC *c W + * UNIMPLEMENTED("Pattern control"); - ESC *c Q + * UNIMPLEMENTED("Transparency pattern"); - ESC *v T + * UNIMPLEMENTED("Transparency source mode"); - ESC *v N + * UNIMPLEMENTED("Transparency destination mode");- ESC *v O + */ + +#include +#include "cjet.h" + +/*#define RDEBUG */ + +/* + * clear the decompression buffer; + */ + +void clear_decompress_buffer() +{ + BYTE *p; + p = get_buffer(0, &dec_buffer); + memset(p, 0, dec_buffer.size); + old_usize = 0; +} + + + +/* + * rotate raster - ESC *r # F + * method 0 : rotate portrait data for landscape printing + * method 3 : old PCL landscape data format + */ + +void +rotate_raster(int method) +{ + switch(method){ + case 0 : break; /* CaPSL rotates automatically */ + case 3 : UNIMPLEMENTED("Rotate raster method 3"); break; + } +} + + +/* + * Set Raster pattern height - ESC *r # T + * + */ + +void +raster_height( int height) +{ + UNIMPLEMENTED("Set raster height"); +} + + +/* + * set raster width - ESC *r # S + */ + +void +raster_width( int width) +{ + UNIMPLEMENTED("Set Raster width"); +} + + +/* + * raster y offset in raster lines - ESC *b # Y + * print pending raster data and move CAP by #lines downwards + * FIXME for different transparency modes ? + */ + +void y_offset( int lines) +{ +#ifdef RDEBUG + fprintf(stderr,"Y Offset %d lines\n",lines); +#endif + PurgeRaster(0); + if(lines > 0) { + SetModes(SIZEUNIT,DOTS); + PutString("\033[%de",lines); + } + clear_decompress_buffer(); +} + + + +/* + * Set Compression mode - ESC *b # M + * 0...no compression + * 1...run length encoding + * 2...TIFF encoding + * 3...delta row compression + */ + +void +Compression( int mode ) +{ +#ifdef RDEBUG + fprintf(stderr,"Compression mode set from %d to %d\n",r_compress, mode); +#endif + + r_compress = mode; + + if (mode > 3) + MorePanic(UN_OTHER,"Unsupported data compression mode %d",mode); + /* FIXME: now what ? */ +} + + +/* + * set Raster Resolution - ESC *r # R + * value res is 75, 100, 150, or 300 dpi. In the CaPSL scheme of things, + * the raster resolution is sent along with the actual graphics command. + */ + +void +RasterRez(int res) +{ + resolution = res; +} + + +/* + * dump raster graphics collected in the buffer to the printer; + * move printer CAP past last line; + * + */ +void +PurgeRaster( int size ) +{ + long count; + + count = buffer.size - r_free; + +#ifdef RDEBUG + fprintf(stderr,"PurgeRaster() %ld count, %d lines, %d oldsize, %d size\n",count, r_lines, old_usize, size); +#endif + + if(count > 0) { + PutString("\033[%ld;%d;%d.r", count, r_width, resolution); + pipe_write(buffer.p, count); + } + r_free = buffer.size; + bufptr = buffer.p; + r_width = size; + if(r_lines > 0) { + SetModes(SIZEUNIT,DOTS); + PutString("\033[%de",r_lines); /* move down */ + } + r_lines = 0; +} + + + + +/* + * Transfer_ModeX: + * - reads a mode X compressed raster data row into dec_buffer + * - returns uncompressed length + * - size is always > 0 except for mode 3 + * + */ + +int Transfer_Mode0( int size ) +{ + pipe_read(dec_buffer.p, size); + return(size); +} + + +int Transfer_Mode1( int size ) +{ + BYTE *dec; + int usize, count, i, j, db, rep; + + usize = 0; + dec = dec_buffer.p; + count = size / 2; /* this had better be even */ + for(i=0;i 128) { /* determine sub mode */ + rep = 256 - rep; /* sub mode 1: real rep count */ + for(j=0;j0); + return (usize); +} + + +int Transfer_Mode3( int size ) +{ + BYTE *dec; + int usize, count, i, j, db, rep; + + usize = 0; + dec = dec_buffer.p; + if(size > 0) { + count = size; + while (count > 0) { + db = get_next_char(); count--; /* get command byte */ + rep = (db >> 5) + 1; /* replace count */ + i = db & 0x1f; /* offset */ + dec += i; /* move pointer */ + usize += i; /* keep track of length */ + if( i == 31 ) + do { + i = get_next_char(); count--; + dec += i; + usize += i; + } while( i == 255 ); + for(j=0;j copy previous row */ + usize = old_usize; + return(usize); +} + + +/* + * Transfer Raster Graphics ESC *b # W [data] + * PCL raster data rows are first read/decompressed into dec_buffer. + * Then the resulting rows with the same width are collected into + * CaPSL raster data chunks. + * For mode 3 (delta row) compression, the previous raster row (regardless + * of any previous compression mode) is still in dec_buffer[] and can be + * used as the seed row for the current row. + * + */ + +void +TransferData( int size ) +{ + BYTE *dec; + int newsize, i; + + newsize = 0; + + if(size == 0) { /* check for 0 raster data size */ + if (r_compress != 3) { /* for modes 0..2 move down */ + y_offset(1); + return; + } + if ((r_compress == 3) && (old_usize == 0)) { /* move down for mode 3 */ + y_offset(1); /* if seed row is empty */ + return; + } + } + + switch (r_compress) + { + case 0: /* no compression */ + newsize = Transfer_Mode0(size); + break; + + case 1: /* run length encoding */ + newsize = Transfer_Mode1(size); + break; + /* mode 1 */ + + case 2: /* TIFF mode */ + newsize = Transfer_Mode2(size); + break; + /* case 2 */ + + case 3: /* delta row compression */ + newsize = Transfer_Mode3(size); + break; + /* case 3 */ + } + + /* + * modes 0-2: if the new line is shorter: zero previous size of buffer + * mode 3: newsize is always >= old_usize: no effect + */ + for(i = newsize;i < old_usize; i++) dec_buffer.p[i] = 0; + + /* + * zero strip + */ + + dec = dec_buffer.p + newsize -1; + while ((*dec-- == 0) && (dec != dec_buffer.p)) newsize--; + + /* + * if r_width is 0 => init: set r_width to newsize + */ + if (r_width == 0) r_width = newsize; + + /* if buffer is full or new raster data has a different width, purge */ + if((newsize > r_free) || (newsize != r_width)) + PurgeRaster( newsize ); + + /* add new data to buffer: row size is the same or new */ + dec = dec_buffer.p; + for(i=0;i*p2000X?*p299X*p1046Y@*p411XA*p523XB*p635XC*p747XD*p859XE*p965XF*p1085XG*p1200XH*p1312XI*p1424XJ*p1536XK*p1662XL*p1780XM*p1892XN*p2007XO*p299X*p1123YP*p412XQ*p523XR*p635XS*p747XT*p859XU*p971XV*p1077XW*p1195XX*p1308XY*p1420XZ*p1532X[*p1650X\*p1770X]*p1884X^*p1998X_*p304X*p1201Y`*p416Xa*p528Xb*p640Xc*p752Xd*p864Xe*p969Xf*p1089Xg*p1201Xh*p1313Xi*p1425Xj*p1537Xk*p1663Xl*p1781Xm*p1893Xn*p2008Xo*p303X*p1279Yp*p415Xq*p527Xr*p639Xs*p751Xt*p863Xu*p975Xv*p1077Xw*p1200Xx*p1312Xy*p1424Xz*p1536X{*p1654X|*p1773X}*p1884X~*p1999X*p257X*p676Y*c2A*c635B*c0P*c1824A*c2B*c0P*p2079X*c2A*c635B*c0P*p257X*p1309Y*c1824A*c2B*c0P(8U(s3ts10hbP E \ No newline at end of file diff --git a/samples/legals.pcl b/samples/legals.pcl new file mode 100644 index 0000000..81944dd --- /dev/null +++ b/samples/legals.pcl @@ -0,0 +1 @@ +E&l1X&l0o26a4d1e45F&l1H*t300R(9U(s4148t3b0s20.0v1P*p736X*p116Y CJet Test Page(9U(s4148t0b0s12.0v1P*p182X*p304YTypeface: Univers*p182X*p364YSymbol Set: HP Legal (9U(s4148t3b0s12.0v1P*p182X*p604YHP Legal (secondary):)1U(s4148t0b0s12.0v1P*p309X*p735Y*p421X*p533X*p645X*p757X*p869X*p982X*p1094X*p1206X*p1318X*p1430X*p1542X*p1660X*p1778X*p1890X*p2005X*p309X*p813Y*p421X*p533X*p645X*p757X*p869X*p982X*p1094X*p1206X*p1318X*p1430X*p1542X*p1660X*p1778X*p1890X*p2005X*p309X*p890Y*p421X*p526X*p638X*p750X*p862X*p978X*p1087X*p1199X*p1314X*p1428X*p1537X*p1644X*p1778X*p1886X*p1998X*p302X*p968Y*p405X*p532X*p644X*p750X*p864X*p974X*p1099X*p1199X*p1317X*p1428X*p1537X*p1644X*p1762X*p1874X*p2000X*p299X*p1046Y*p411X*p523X*p635X*p747X*p859X*p965X*p1085X*p1200X*p1312X*p1424X*p1536X*p1662X*p1780X*p1892X*p2007X*p299X*p1123Y*p412X*p523X*p635X*p747X*p859X*p971X*p1077X*p1195X*p1308X*p1420X*p1532X*p1650X*p1770X*p1884X*p1998X*p304X*p1201Y*p416X*p528X*p640X*p752X*p864X*p969X*p1089X*p1201X*p1313X*p1425X*p1537X*p1663X*p1781X*p1893X*p2008X*p303X*p1279Y*p415X*p527X*p639X*p751X*p863X*p975X*p1077X*p1200X*p1312X*p1424X*p1536X*p1654X*p1773X*p1884X*p1999X*p257X*p676Y*c2A*c635B*c0P*c1824A*c2B*c0P*p2079X*c2A*c635B*c0P*p257X*p1309Y*c1824A*c2B*c0P(8U(s3ts10hbP E \ No newline at end of file diff --git a/samples/mctexts.pcl b/samples/mctexts.pcl new file mode 100644 index 0000000..ca08572 --- /dev/null +++ b/samples/mctexts.pcl @@ -0,0 +1 @@ +E&l1X&l0o26a4d1e45F&l1H*t300R(9U(s4148t3b0s20.0v1P*p736X*p116Y CJet Test Page(9U(s4148t0b0s12.0v1P*p182X*p304YTypeface: Univers*p182X*p364YSymbol Set: MC Text(9U(s4148t3b0s12.0v1P*p182X*p604YMC Text (secondary):(12J(s4148t0b0s12.0v1P*p309X*p735Y*p421X*p533X*p645X*p757X*p869X*p982X*p1094X*p1206X*p1318X*p1430X*p1542X*p1660X*p1778X*p1890X*p2005X*p309X*p813Y*p421X*p533X*p645X*p757X*p869X*p982X*p1094X*p1206X*p1318X*p1430X*p1542X*p1660X*p1778X*p1890X*p2005X*p309X*p890Y*p421X*p526X*p638X*p750X*p862X*p978X*p1087X*p1199X*p1314X*p1428X*p1537X*p1644X*p1778X*p1886X*p1998X*p302X*p968Y*p405X*p532X*p644X*p750X*p864X*p974X*p1099X*p1199X*p1317X*p1428X*p1537X*p1644X*p1762X*p1874X*p2000X*p299X*p1046Y*p411X*p523X*p635X*p747X*p859X*p965X*p1085X*p1200X*p1312X*p1424X*p1536X*p1662X*p1780X*p1892X*p2007X*p299X*p1123Y*p412X*p523X*p635X*p747X*p859X*p971X*p1077X*p1195X*p1308X*p1420X*p1532X*p1650X*p1770X*p1884X*p1998X*p304X*p1201Y*p416X*p528X*p640X*p752X*p864X*p969X*p1089X*p1201X*p1313X*p1425X*p1537X*p1663X*p1781X*p1893X*p2008X*p303X*p1279Y*p415X*p527X*p639X*p751X*p863X*p975X*p1077X*p1200X*p1312X*p1424X*p1536X*p1654X*p1773X*p1884X*p1999X*p257X*p676Y*c2A*c635B*c0P*c1824A*c2B*c0P*p2079X*c2A*c635B*c0P*p257X*p1309Y*c1824A*c2B*c0P(8U(s3ts10hbP E \ No newline at end of file diff --git a/samples/roman8s.pcl b/samples/roman8s.pcl new file mode 100644 index 0000000..db5cc62 --- /dev/null +++ b/samples/roman8s.pcl @@ -0,0 +1 @@ +E&l1X&l0o26a4d1e45F&l1H*t300R(9U(s4148t3b0s20.0v1P*p736X*p116Y CJet Test Page(9U(s4148t0b0s12.0v1P*p182X*p304YTypeface: Univers*p182X*p364YSymbol Set: HP Roman-8(9U(s4148t3b0s12.0v1P*p182X*p604YRoman-8 (secondary):(8U(s4148t0b0s12.0v1P*p309X*p735Y*p421X*p533X*p645X*p757X*p869X*p982X*p1094X*p1206X*p1318X*p1430X*p1542X*p1660X*p1778X*p1890X*p2005X*p309X*p813Y*p421X*p533X*p645X*p757X*p869X*p982X*p1094X*p1206X*p1318X*p1430X*p1542X*p1660X*p1778X*p1890X*p2005X*p309X*p890Y*p421X*p526X*p638X*p750X*p862X*p978X*p1087X*p1199X*p1314X*p1428X*p1537X*p1644X*p1778X*p1886X*p1998X*p302X*p968Y*p405X*p532X*p644X*p750X*p864X*p974X*p1099X*p1199X*p1317X*p1428X*p1537X*p1644X*p1762X*p1874X*p2000X*p299X*p1046Y*p411X*p523X*p635X*p747X*p859X*p965X*p1085X*p1200X*p1312X*p1424X*p1536X*p1662X*p1780X*p1892X*p2007X*p299X*p1123Y*p412X*p523X*p635X*p747X*p859X*p971X*p1077X*p1195X*p1308X*p1420X*p1532X*p1650X*p1770X*p1884X*p1998X*p304X*p1201Y*p416X*p528X*p640X*p752X*p864X*p969X*p1089X*p1201X*p1313X*p1425X*p1537X*p1663X*p1781X*p1893X*p2008X*p303X*p1279Y*p415X*p527X*p639X*p751X*p863X*p975X*p1077X*p1200X*p1312X*p1424X*p1536X*p1654X*p1773X*p1884X*p1999X*p257X*p676Y*c2A*c635B*c0P*c1824A*c2B*c0P*p2079X*c2A*c635B*c0P*p257X*p1309Y*c1824A*c2B*c0P(8U(s3ts10hbP E \ No newline at end of file diff --git a/samples/vintls.pcl b/samples/vintls.pcl new file mode 100644 index 0000000..4dba2ed --- /dev/null +++ b/samples/vintls.pcl @@ -0,0 +1 @@ +E&l1X&l0o26a4d1e45F&l1H*t300R(9U(s4148t3b0s20.0v1P*p736X*p116Y CJet Test Page(9U(s4148t0b0s12.0v1P*p182X*p304YTypeface: Univers*p182X*p364YSymbol Set: Ventura International (9U(s4148t3b0s12.0v1P*p182X*p604YVentura International (secondary):(13J(s4148t0b0s12.0v1P*p309X*p735Y*p421X*p533X*p645X*p757X*p869X*p982X*p1094X*p1206X*p1318X*p1430X*p1542X*p1660X*p1778X*p1890X*p2005X*p309X*p813Y*p421X*p533X*p645X*p757X*p869X*p982X*p1094X*p1206X*p1318X*p1430X*p1542X*p1660X*p1778X*p1890X*p2005X*p309X*p890Y*p421X*p526X*p638X*p750X*p862X*p978X*p1087X*p1199X*p1314X*p1428X*p1537X*p1644X*p1778X*p1886X*p1998X*p302X*p968Y*p405X*p532X*p644X*p750X*p864X*p974X*p1099X*p1199X*p1317X*p1428X*p1537X*p1644X*p1762X*p1874X*p2000X*p299X*p1046Y*p411X*p523X*p635X*p747X*p859X*p965X*p1085X*p1200X*p1312X*p1424X*p1536X*p1662X*p1780X*p1892X*p2007X*p299X*p1123Y*p412X*p523X*p635X*p747X*p859X*p971X*p1077X*p1195X*p1308X*p1420X*p1532X*p1650X*p1770X*p1884X*p1998X*p304X*p1201Y*p416X*p528X*p640X*p752X*p864X*p969X*p1089X*p1201X*p1313X*p1425X*p1537X*p1663X*p1781X*p1893X*p2008X*p303X*p1279Y*p415X*p527X*p639X*p751X*p863X*p975X*p1077X*p1200X*p1312X*p1424X*p1536X*p1654X*p1773X*p1884X*p1999X*p257X*p676Y*c2A*c635B*c0P*c1824A*c2B*c0P*p2079X*c2A*c635B*c0P*p257X*p1309Y*c1824A*c2B*c0P(8U(s3ts10hbP E \ No newline at end of file diff --git a/samples/vmaths.pcl b/samples/vmaths.pcl new file mode 100644 index 0000000..e2c0665 --- /dev/null +++ b/samples/vmaths.pcl @@ -0,0 +1 @@ +E&l1X&l0o26a4d1e45F&l1H*t300R(9U(s4148t3b0s20.0v1P*p736X*p116Y CJet Test Page(9U(s4148t0b0s12.0v1P*p182X*p304YTypeface: Univers*p182X*p364YSymbol Set: Ventura Math (9U(s4148t3b0s12.0v1P*p182X*p604YVentura Math (secondary):(6M(s4148t0b0s12.0v1P*p309X*p735Y*p421X*p533X*p645X*p757X*p869X*p982X*p1094X*p1206X*p1318X*p1430X*p1542X*p1660X*p1778X*p1890X*p2005X*p309X*p813Y*p421X*p533X*p645X*p757X*p869X*p982X*p1094X*p1206X*p1318X*p1430X*p1542X*p1660X*p1778X*p1890X*p2005X*p309X*p890Y*p421X*p526X*p638X*p750X*p862X*p978X*p1087X*p1199X*p1314X*p1428X*p1537X*p1644X*p1778X*p1886X*p1998X*p302X*p968Y*p405X*p532X*p644X*p750X*p864X*p974X*p1099X*p1199X*p1317X*p1428X*p1537X*p1644X*p1762X*p1874X*p2000X*p299X*p1046Y*p411X*p523X*p635X*p747X*p859X*p965X*p1085X*p1200X*p1312X*p1424X*p1536X*p1662X*p1780X*p1892X*p2007X*p299X*p1123Y*p412X*p523X*p635X*p747X*p859X*p971X*p1077X*p1195X*p1308X*p1420X*p1532X*p1650X*p1770X*p1884X*p1998X*p304X*p1201Y*p416X*p528X*p640X*p752X*p864X*p969X*p1089X*p1201X*p1313X*p1425X*p1537X*p1663X*p1781X*p1893X*p2008X*p303X*p1279Y*p415X*p527X*p639X*p751X*p863X*p975X*p1077X*p1200X*p1312X*p1424X*p1536X*p1654X*p1773X*p1884X*p1999X*p257X*p676Y*c2A*c635B*c0P*c1824A*c2B*c0P*p2079X*c2A*c635B*c0P*p257X*p1309Y*c1824A*c2B*c0P(8U(s3ts10hbP E \ No newline at end of file diff --git a/samples/vuss.pcl b/samples/vuss.pcl new file mode 100644 index 0000000..429e400 --- /dev/null +++ b/samples/vuss.pcl @@ -0,0 +1 @@ +E&l1X&l0o26a4d1e45F&l1H*t300R(9U(s4148t3b0s20.0v1P*p736X*p116Y CJet Test Page(9U(s4148t0b0s12.0v1P*p182X*p304YTypeface: Univers*p182X*p364YSymbol Set: Ventura US (9U(s4148t3b0s12.0v1P*p182X*p604YVentura US (secondary):(14J(s4148t0b0s12.0v1P*p309X*p735Y*p421X*p533X*p645X*p757X*p869X*p982X*p1094X*p1206X*p1318X*p1430X*p1542X*p1660X*p1778X*p1890X*p2005X*p309X*p813Y*p421X*p533X*p645X*p757X*p869X*p982X*p1094X*p1206X*p1318X*p1430X*p1542X*p1660X*p1778X*p1890X*p2005X*p309X*p890Y*p421X*p526X*p638X*p750X*p862X*p978X*p1087X*p1199X*p1314X*p1428X*p1537X*p1644X*p1778X*p1886X*p1998X*p302X*p968Y*p405X*p532X*p644X*p750X*p864X*p974X*p1099X*p1199X*p1317X*p1428X*p1537X*p1644X*p1762X*p1874X*p2000X*p299X*p1046Y*p411X*p523X*p635X*p747X*p859X*p965X*p1085X*p1200X*p1312X*p1424X*p1536X*p1662X*p1780X*p1892X*p2007X*p299X*p1123Y*p412X*p523X*p635X*p747X*p859X*p971X*p1077X*p1195X*p1308X*p1420X*p1532X*p1650X*p1770X*p1884X*p1998X*p304X*p1201Y*p416X*p528X*p640X*p752X*p864X*p969X*p1089X*p1201X*p1313X*p1425X*p1537X*p1663X*p1781X*p1893X*p2008X*p303X*p1279Y*p415X*p527X*p639X*p751X*p863X*p975X*p1077X*p1200X*p1312X*p1424X*p1536X*p1654X*p1773X*p1884X*p1999X*p257X*p676Y*c2A*c635B*c0P*c1824A*c2B*c0P*p2079X*c2A*c635B*c0P*p257X*p1309Y*c1824A*c2B*c0P(8U(s3ts10hbP E \ No newline at end of file diff --git a/symbol.c b/symbol.c new file mode 100644 index 0000000..e72aa51 --- /dev/null +++ b/symbol.c @@ -0,0 +1,335 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * symbol.c - symbol set stuff + * + * + */ + +#include "cjet.h" +#include "symbol.h" + + +/* + * print ed + * Calculate amount to move accent right and over the letter. + * The movement amounts depend on current character size, typeface + * and type style. Fudge factors found by trial-and-error and some + * simplistic calculations...FIXME + * + */ + +void letter_accent( int letter , int accent ) +{ + long x,y; + long c = char_size; + + x = 0; /* offset to the right */ + y = 0; /* offset upwards */ + + /* + * save current graphic set and position and + * select PSR as secondary graphic set + */ + PutString("\033[0;5;6%%y\033)\042! 1"); + SetModes(SIZEUNIT,DECIPTS); + switch(letter) { + case 'S' : { + y = ( c * 175) / 1000; + if( tface_p == C_DUTCH ) + x = y / 2; + else + x = y; + break; + } + case 'Y' : { + y = ( c * 175) / 1000; + if( tface_p == C_DUTCH ) + x = (c * 200) / 1000; + else + x = y; + break; + } + case 's' : { + if( tface_p == C_SWISS ) + x = (c * 90) / 1000; + } + default: break; + } + /* + * move right, move up, print accent, pop previous state, print letter + */ + PutString("\033[%lda\033[%ldk%c\033[0;5;6%%z%c", x, y, accent, letter); +} + + + +/* + * Finally, really print a character + * Characters have been translated, symbol sets selected etc. + */ + +void ReallyPrint( int what ) +{ + + /* + * force printing of control characters 0x00 - 0x20: any control + * characters which should actually function as control codes are + * trapped in the main parsing loop in main() + */ + if(what < 0x20) + PutString("\033[1.v%c", what); + else { + switch(what) { + case 0x7f : /* DEL is normally ignored by CaPSL */ + case 0x85 : /* 8-bit control characters. According to the manual, */ + case 0x88 : /* these control characters are printed as characters */ + case 0x8a : /* if any IBM secondary set or PSR is selected. To */ + case 0x8b : /* ensure correct printing, esp. with download fonts, */ + case 0x8c : /* force printing of characters anyway */ + case 0x8d : + case 0x90 : + case 0x9b : + case 0x9c : + case 0xff : PutString("\033[1.v%c", what); break; + default : put_next_char(what); break; + } + } +} + + +/* + * print a character from another graphic set: + * push current environment, select the new graphic set, + * print the character and pop the previous state. + * flag indicates primary or secondary set + */ + +void print_alt_char( int c, BOOL flag, char *set ) +{ + char which; + + if(flag == PRIMARY) + which = '('; + else + which = ')'; + PutString("\033[0%%y\033%c%s", which, set); /* push & select */ + ReallyPrint(c); + PutString("\033[0%%z"); /* pop previous state */ +} + + +/* + * Print Trademark symbol from symbol typeface + * Check current typeface to print correct TM symbol (Dutch or Swiss typeface) + */ + +void PrintTM(void) +{ + if (tface_s == C_DUTCH) + print_alt_char( 212, SECONDARY, C_SYMR); + else + print_alt_char( 228, SECONDARY, C_SYMR); +} + + + +/* + * hack to print c/o character + * select smaller font size and print c o slash + * FIXME + */ + +void PrintCO(void) +{ + int newsize, x, y; + + SetModes(SIZEUNIT,DECIPTS); + PutString("\033[0;2;5;6%%y"); /* save current environment */ + newsize = (char_size * 3) / 4; /* new char size in decipoints */ + y = newsize / 2; + x = newsize / 3; + PutString("\033[%d C",newsize); + /* move left, move up, print c, move down, print o */ + PutString("\033[%dj\033[%dkc\033[%deo", x, y, y ); + PutString("\033[0;2;5;6%%z"); /* pop previous environment */ + print_alt_char(164, SECONDARY, C_PSR); +} + + + +/* + * various hacks to print characters not normally existent + * in CaPSL symbol sets; some can be constructed by printing two + * characters, some can only be replaced by more or less adequate + * characters + */ + +void PrintSpecial( int what ) +{ + switch (what) { + case HACEK_SMALL_S : letter_accent('s', PSR_HACEK); break; + case HACEK_CAP_S : letter_accent('S', PSR_HACEK); break; + case DIAERESIS_CAP_Y : letter_accent('Y', PSR_DIAERESIS); break; + case SINGLE_QUOTE_OPEN : print_alt_char( 169, SECONDARY, C_PSR); break; + case SINGLE_QUOTE_CLOSE: print_alt_char( 169, SECONDARY, C_PSR); break; + case TRADEMARK : PrintTM(); break; + case CEE_OH : PrintCO(); break; + case IGREK_SMALL : print_alt_char(0x40, PRIMARY, "\042#2"); break; + case IGREK_CAP : { SetModes(SIZEUNIT,DECIPTS); + PutString("I\033[%djJ", (print_HMI / 300 )); + break; + } +/* + * Note: this assumes IBML is selected as primary set + */ + case FILLCIRCLE : PutString("\033[1.v%c", 7); break; + case OPENCIRCLE : PutString("\033[1.v%c", 9); break; + } +} + + + +/* + * PrintThrough: print a character, check if it's from another + * symbol set or has the TSPECIAL flag + */ + +void PrintThrough(int what) +{ + int c, flags; + + c = what & 0x00ff; + flags = what & 0xffffff00; + + switch( flags) { + case TSPECIAL : PrintSpecial(what); break; + case TPSR : print_alt_char( c, SECONDARY, C_PSR); break; + case TIBMR1 : print_alt_char( c, SECONDARY, C_IBMR1); break; + case TIBMR2 : print_alt_char( c, SECONDARY, C_IBMR2); break; + case TSYML : print_alt_char( c, PRIMARY, C_SYML); break; + case TSYMR : print_alt_char( c, SECONDARY, C_SYMR); break; + default : ReallyPrint(c); break; + } +} + + + +/* + * HP Legal is a 7-bit set. + * When characters 128-255 are printed then this set + * is a secondary set; the characters are mapped to 0..127 to + * check for the special characters. + */ + +void translate_legal( int c ) +{ + int what; + + if (c > 127) + what = c - 128; + else + what = c; + + switch(what) { + case 60 : print_alt_char( 242, SECONDARY, C_IBM850); break; /* dbl underl */ + case 62 : print_alt_char( 189, SECONDARY, C_IBM850); break; /* cents */ + case 92 : print_alt_char( 169, SECONDARY, C_IBM850); break; /* r circle */ + case 94 : print_alt_char( 184, SECONDARY, C_IBM850); break; /* copyright */ + case 96 : print_alt_char( 248, SECONDARY, C_IBM850); break; /* circle */ + case 123 : print_alt_char( 245, SECONDARY, C_IBM850); break; /* paragraph */ + case 124 : print_alt_char( 244, SECONDARY, C_IBM850); break; /* thingy */ + case 125 : print_alt_char( 178, SECONDARY, C_PSR); break; /* dagger */ + case 126 : PrintTM(); break; /* trademark */ + default : ReallyPrint( c ); break; + } +} + + +/* + * Translate PCL symbol set character positions to CaPSL positions. + * + * PCL characters 0..127 generally match CaPSL characters 0..127 (ASCII + * and national variants). Current Exceptions are: + * HP Legal: + * + * PCL characters 128..255 are matched to CaPSL characters + * by lookup tables + * or directly, e.g. for IBM and PS symbol sets + * + * Things to look out for: + * shift state + * don't translate for download fonts + * + * Changes: + * let ISOLATIN1 and WIN30 table equal WIN31 table + */ + +void translate( int c) +{ + int set; + + if(c < 128) { /* print from primary set if the */ + if( shift_state == SI ) { /* character codes are 0..127 and */ + set = set_p; /* shift mode is SI (Shift In) */ + switch(set) { + case HP_LEGLSET : translate_legal(c); break; + default : ReallyPrint(c); break; + } + return; + } /* shift mode is Shift Out: */ + c += 128; /* map 0..127 to 128..255 */ + } /* fall through to: */ + set = set_s; /* print from secondary set */ + switch(set) { + case HP_ROMAN : PrintThrough( roman_table [c-128] ); break; + case HP_ISOLATIN1 : + case HP_WIN30 : + case HP_WIN31 : PrintThrough( latin_table [c-128] ); break; + case HP_DESKTOP : PrintThrough( desktop_table[c-128] ); break; + case HP_MCTEXT : PrintThrough( mctext_table [c-128] ); break; + case HP_VINTL : PrintThrough( v_intl_table [c-128] ); break; + case HP_VMATH : PrintThrough( vmath_table [c-128] ); break; + case HP_VUS : PrintThrough( vus_table [c-128] ); break; + case HP_LEGLSET : translate_legal(c); break; + case DOWNLD : + default : ReallyPrint(c); break; + } +} + + + +void SetSymbolID( int id) +{ + UNIMPLEMENTED("Symbol set ID"); +} + +void LoadSymbol( int count ) +{ + UNIMPLEMENTED("Download symbol set"); +} + +void SymbolControl( int op ) +{ + UNIMPLEMENTED("Symbol set control"); +} + + + diff --git a/symbol.h b/symbol.h new file mode 100644 index 0000000..22f3b16 --- /dev/null +++ b/symbol.h @@ -0,0 +1,286 @@ +/* + * CJet: LaserJet emulation for Canon CaPSL III+ laser printers + * Copyright (C) 1996 Michael Huijsmans + * Email: mgh@sbox.tu-graz.ac.at + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * symbol.h : PCL -> CaPSL graphic set tables + * + * X_table[] entry value: prints a char from: + * + * 0x00XX : C_IBM850 + * 0x00XX + TPSR : C_PSR + * etc. + * + * example: N tilde: + * is Roman-8 char 182 -> roman_table[182-160] = 165 C_IBM850 + * + * TSPECIAL flags nonexistent characters built from existing ones + */ + +#define TPSR 0x0100 +#define TIBMR1 0x0200 +#define TIBMR2 0x0400 +#define TSYML 0x0800 +#define TSYMR 0x1000 +#define TSPECIAL 0x2000 + + +/* + * some characters do not exist in CaPSL sets; these are "built" from + * available characters + */ + +#define HACEK_SMALL_S TSPECIAL + 1 +#define HACEK_CAP_S TSPECIAL + 2 +#define DIAERESIS_CAP_Y TSPECIAL + 3 +#define SINGLE_QUOTE_OPEN TSPECIAL + 4 +#define SINGLE_QUOTE_CLOSE TSPECIAL + 5 +#define TRADEMARK TSPECIAL + 6 +#define CEE_OH TSPECIAL + 7 /* c/o character */ +#define IGREK_SMALL TSPECIAL + 8 /* ij ligature */ +#define IGREK_CAP TSPECIAL + 9 /* IJ ligature */ +#define FILLCIRCLE TSPECIAL + 10 /* IBML 07 */ +#define OPENCIRCLE TSPECIAL + 11 /* IBML 09 */ + +/* + * define some PSR diacritics used to construct nonexistent characters + */ + +#define PSR_HACEK 207 +#define PSR_DIAERESIS 200 + + +/* + * HP Roman-8: + * Table has 128 entries; the upper 96 characters are the actual + * Roman-8 characters, + */ + +WORD roman_table[128] = +{ + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 183, 182, 212, 210, 211, 215, 216, + TPSR+194, TPSR+193, TPSR+195, 249, TPSR+196, 235, 234, 156, + TPSR+197, 237, 236, 248, 128, 135, 165, 164, + 173, 168, 207, 156, 190, 245, 159, 189, + 131, 136, 147, 150, 160, 130, 162, 163, + 133, 138, 149, 151, 132, 137, 148, 129, + 143, 140, 157, 146, 134, 161, 155, 145, + 142, 141, 153, 154, 144, 139, TPSR+251, 226, + 181, 199, 198, 209, 208, 214, 222, 224, + 227, 229, 228, HACEK_CAP_S, + HACEK_SMALL_S, 233, DIAERESIS_CAP_Y, 152, + 232, 231, 250, 230, 244, 243, TPSR+208, 172, + 171, 166, 167, 174, 254, 175, 241, 255 +}; + + +/* + * ISO 8859-1 (ECMA-94) Latin 1: + * Windoze 3.0 Latin 1: + * Windoze 3.1 Latin 1: + * + * (Almost) all ISO characters are available in code page 850 + * Exceptions: + * character 223 ( German sharp s) replaced by PSR 251 + * (CaPSL PC850 character 225 is a Greek Beta) + */ + +WORD latin_table[128] = +{ + 255, 255, TPSR+184, 159, + TPSR+185, TPSR+188, TPSR+178, TPSR+179, + TPSR+195, TPSR+189, HACEK_CAP_S, TPSR+172, + TPSR+234, 255, 255, 255, + 255, SINGLE_QUOTE_OPEN, SINGLE_QUOTE_CLOSE, TPSR+170, + TPSR+186, TPSR+183, TPSR+177, TPSR+208, + TPSR+196, TRADEMARK, HACEK_SMALL_S, TPSR+173, + TPSR+250, 255, 255, DIAERESIS_CAP_Y, + 255, 173, 189, 156, 207, 190, 221, 245, + 249, 184, 166, 174, 170, 240, 169, TPSR+197, + 248, 241, 253, 252, 239, 230, 244, 250, + 247, 251, 167, 175, 172, 171, 243, 168, + 183, 181, 182, 199, 142, 143, 146, 128, + 212, 144, 210, 211, 222, 214, 215, 216, + 209, 165, 227, 224, 226, 229, 153, 158, + 157, 235, 233, 234, 154, 237, 232, TPSR+251, + 133, 160, 131, 198, 132, 134, 145, 135, + 138, 130, 136, 137, 141, 161, 140, 139, + 208, 164, 149, 162, 147, 228, 148, 246, + 155, 151, 163, 150, 129, 236, 231, 152 +}; + + + +/* + * Desktop character set + * 128-159 blank spaces, actual character set is from 160 to 255 + */ + +WORD desktop_table[128] = { + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 244, 245, TPSR+178, + TPSR+179, 184, 169, TRADEMARK, + CEE_OH, 189, 240, 196, + TPSR+188, TPSR+174, TPSR+175, 255, + TPSR+170, TPSR+186, 230, TPSR+189, + TPSR+183, FILLCIRCLE, OPENCIRCLE, OPENCIRCLE, + 254, 254, 30, 31, + TPSR+169, 170, 221, 242, + TPSR+177, 241, 158, 246, + 248, TSYMR+162, TSYMR+178, 172, + 171, 243, 251, 253, + 252, TPSR+164, 255, 255, + TPSR+172, TPSR+173, 174, 175, + TPSR+184, TPSR+185, 250, 173, + 168, TIBMR1+158, TIBMR2+171, 156, + 190, 207, 159, TPSR+251, + 166, 167, 145, 146, + 208, 209, IGREK_SMALL, IGREK_CAP, + TPSR+248, TPSR+232, TPSR+250, TPSR+234, + 155, 157, 231, 232, + TPSR+194, TPSR+193, TPSR+195, 249, + TPSR+196, TPSR+207, TPSR+198, TPSR+205, + TPSR+202, TPSR+199, TPSR+197, TPSR+203, + TPSR+206, 250, TPSR+245, 255 +}; + + +/* + * Ventura International + * spaces from 128 - 159 + * actual characters 160 - 255 + */ + +WORD v_intl_table[128] = { + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + TPSR+185, 183, 182, 212, + 210, 211, 215, 216, + 184, 169, TRADEMARK, TPSR+172, + TPSR+173, 235, 234, 255, + TPSR+189, TPSR+170, TPSR+186, 248, + 128, 135, 165, 164, + 173, 168, 207, 156, + 190, 245, 159, 189, + 131, 136, 147, 150, + 160, 130, 162, 163, + 133, 138, 149, 151, + 132, 137, 148, 129, + 143, 140, 157, 146, + 134, 161, 155, 145, + 142, 141, 153, 154, + 144, 139, TPSR+251, 226, + 181, 199, 198, 255, + 255, 214, 222, 224, + 227, 229, 228, HACEK_CAP_S, + HACEK_SMALL_S, 233, DIAERESIS_CAP_Y, 152, + TPSR+234, TPSR+250, 244, TPSR+178, + TPSR+179, TPSR+208, TPSR+177, 255, + 255, 166, 167, 174, + TPSR+183, 175, 255, TPSR+188 +}; + + + +/* + * Ventura US: + */ + +WORD vus_table[128] = { + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, +TPSR+185, 255, 255, 255, 255, 255, 255, 255, + 184, 169, TRADEMARK, 255, 255, 255, 255, 255, +TPSR+189, TPSR+170, TPSR+186, 248, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 245, 255, 189, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 244, TPSR+178, TPSR+179, TPSR+208,TPSR+177, 255, + 255, 255, 255, 255, TPSR+183, 255, 255, TPSR+188, +}; + + +/* HP Legal : no table */ + + +/* + * MC Text + * 128 characters + */ + +WORD mctext_table[128] = { + 142, 143, 128, 144, 165, 153, 154, 160, + 133, 131, 132, 198, 134, 135, 130, 138, + 136, 137, 161, 141, 140, 139, 164, 162, + 149, 147, 148, 228, 163, 151, 150, 129, + TPSR+178, 248, 189, 156, 245, TPSR+183, 244, TPSR+251, + 169, 184, TRADEMARK, 239, 249, TSYMR+185, 146, 157, + TSYMR+165, 241, TIBMR1+243, TIBMR1+242, 190, 230, TSYMR+182, TSYMR+229, + TSYMR+213, TIBMR1+227, TSYMR+242, 166, 167, TIBMR1+234, 145, 155, + 168, 173, 170, TIBMR1+251, 159, TIBMR1+247, TSYML+68, 174, + 175, TPSR+188, 255, 183, 199, 229, TPSR+234, TPSR+250, + TPSR+177, TPSR+208, TPSR+170, TPSR+186, + SINGLE_QUOTE_OPEN, SINGLE_QUOTE_CLOSE, 246, TSYMR+224, + 152, DIAERESIS_CAP_Y, TPSR+164, 207, + TPSR+172, TPSR+173, TPSR+174, TPSR+175, + TPSR+179, 250, TPSR+184, TPSR+185, TPSR+189, 182, 210, 181, + 211, 212, 214, 215, 216, 222, 224, 226, + 255, 227, 233, 234, 235, 213, TPSR+195, TPSR+196, + TPSR+197, TPSR+198, TPSR+199, TPSR+202, 247, TPSR+205, TPSR+206, TPSR+207 +}; + + +/* + * Ventura Math : 128 entries + * Ventura Math characters 160 - 255 + * table entries are from C_SYMR i.e. PS_MATH! + */ + +WORD vmath_table[128] = { + 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, + 224, 214, 232, 233, 234, 235, 238, 231, + 221, 222, 223, 203, 204, 245, 244, 253, + 226, 201, 202, 230, 160, 167, 197, 196, + 205, 200, 190, 188, 189, 217, 191, 187, + 163, 168, 179, 182, 192, 162, 194, 195, + 165, 170, 181, 183, 164, 169, 180, 161, + 175, 172, 210, 178, 166, 193, 211, 177, + 174, 173, 185, 186, 176, 171, 249, 242, + 247, 215, 208, 248, 240, 237, 236, 241, + 255, 216, 209, 243, 244, 252, 254, 184, + 213, 212, 220, 219, 218, 229, 228, 250, + 251, 198, 199, 206, 227, 207, 246, 225 +}; -- cgit v1.2.3 From 300bba8fc0804f35bd2526556ee8be67fe8939db Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Fri, 1 Aug 2014 15:36:24 +0200 Subject: Import cjet_0.8.9-6.debian.tar.xz [dgit import tarball cjet 0.8.9-6 cjet_0.8.9-6.debian.tar.xz] --- changelog | 58 ++++++++++++++++++++++++++++++++++++ cjet.1 | 63 ++++++++++++++++++++++++++++++++++++++++ compat | 1 + control | 27 +++++++++++++++++ copyright | 34 ++++++++++++++++++++++ dirs | 0 patches/series | 1 + patches/use_exported_flags.patch | 27 +++++++++++++++++ printer-driver-cjet.docs | 2 ++ printer-driver-cjet.install | 1 + printer-driver-cjet.manpages | 1 + rules | 4 +++ source/format | 1 + tests/control | 3 ++ tests/printer-driver-cjet | 5 ++++ watch | 4 +++ 16 files changed, 232 insertions(+) create mode 100644 changelog create mode 100644 cjet.1 create mode 100644 compat create mode 100644 control create mode 100644 copyright create mode 100644 dirs create mode 100644 patches/series create mode 100644 patches/use_exported_flags.patch create mode 100644 printer-driver-cjet.docs create mode 100644 printer-driver-cjet.install create mode 100644 printer-driver-cjet.manpages create mode 100755 rules create mode 100644 source/format create mode 100644 tests/control create mode 100755 tests/printer-driver-cjet create mode 100644 watch diff --git a/changelog b/changelog new file mode 100644 index 0000000..0bea13b --- /dev/null +++ b/changelog @@ -0,0 +1,58 @@ +cjet (0.8.9-6) unstable; urgency=medium + + * Add autopkgtest suite + + -- Didier Raboud Fri, 01 Aug 2014 15:36:24 +0200 + +cjet (0.8.9-5) unstable; urgency=medium + + [ Bart Martens ] + * Add debian/watch + + [ Didier Raboud ] + * Move the repository from collab-maint to printing; update the VCS-* + fields accordingly + + -- Didier Raboud Wed, 05 Mar 2014 16:26:23 +0100 + +cjet (0.8.9-4) unstable; urgency=low + + * Drop cjet transitional package which reached stable + * Bump Standards-Version to 3.9.5 without changes needed + + -- Didier Raboud Fri, 29 Nov 2013 12:08:39 +0100 + +cjet (0.8.9-3) unstable; urgency=low + + [ Didier Raboud ] + * Put under Debian Printing Team umbrella and add myself as Uploader. + * Rename cjet to printer-driver-cjet, add transitional package. + (Closes: #647531) + * Promote printer-driver-cjet to optional priority. + * Rewrite short description. + * Add missing comma between Depends. + * Change source format to 3.0 (quilt). + * Convert debian/rules to tiny dh style, bump compat to 9 for auto- + buildflags. + * Patch the upstream Makefile to use exported flags. (Closes: #436629) + * Rewrite debian/copyright using the copyright-format 1.0. + * Bump Standards-Version to 3.9.3 without changes needed. + * Add Vcs-* fields as this will be maintained on Alioth's collab- + maint. + + [ Osamu Aoki ] + * Rewrite long description to be more inclusive. (Closes: #272016) + + -- Didier Raboud Wed, 21 Mar 2012 12:55:27 +0100 + +cjet (0.8.9-2) unstable; urgency=low + + * Rebuild package to update ElGamal signature. (Closes: #494854) + + -- Chris Lawrence Wed, 13 Aug 2008 14:00:36 -0500 + +cjet (0.8.9-1) unstable; urgency=low + + * Initial Release. (Closes: #199631) + + -- Chris Lawrence Wed, 2 Jul 2003 10:11:13 -0500 diff --git a/cjet.1 b/cjet.1 new file mode 100644 index 0000000..02dbc25 --- /dev/null +++ b/cjet.1 @@ -0,0 +1,63 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH CJET 1 "July 2, 2003" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +cjet \- converts HP PCL to Canon CaPSL format +.SH SYNOPSIS +.B cjet +.RI [ options ] < input.pcl > output +.SH DESCRIPTION +This manual page documents briefly the +.B cjet +command. +This manual page was written for the Debian distribution +because the original program does not have a manual page. +.PP +\fBcjet\fP converts the common HP PCL page description language to +Canon's CaPSL, which was used in the mid-1990s by some Canon laser +printers. It is normally used as part of a printer filter script, +like the \fBFoomatic\fP system. +.SH OPTIONS +.TP +.B \-h +Show summary of options. +.TP +.B \-f +Use full paint mode instead of partial paint mode. This requires the +printer to have at least 1.5 MB of memory to work correctly. +.TP +.B \-p +Ignore paper size commands. Useful for printing files formatted for +paper size X on printers with paper size Y. +.TP +.B \-q +Quiet mode. Suppresses all warning messages. +.TP +.B \-x X +Shift output on paper by X dots horizontally. Positive values +of X shift to the right; negative values to the left. Dots are 1/300 +inch (0.085 mm). +.TP +.B \-y Y +Shift output on paper by Y dots vertically. Positive values of Y shift +downwards; negative values shift upwards. +.SH SEE ALSO +.BR /usr/share/doc/printer-driver-cjet/README +.SH AUTHOR +This manual page was written by Chris Lawrence +based on the original README file by Michael Huijsmans for the Debian +project (but may be used by others). diff --git a/compat b/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/compat @@ -0,0 +1 @@ +9 diff --git a/control b/control new file mode 100644 index 0000000..4c13ba5 --- /dev/null +++ b/control @@ -0,0 +1,27 @@ +Source: cjet +Section: text +Priority: optional +Maintainer: Debian Printing Team +Uploaders: Didier Raboud , Chris Lawrence +Build-Depends: debhelper (>= 9~) +Vcs-Git: https://alioth.debian.org/anonscm/git/printing/cjet.git +Vcs-Browser: http://anonscm.debian.org/gitweb/?p=printing/cjet.git +XS-Testsuite: autopkgtest +Standards-Version: 3.9.5 + +Package: printer-driver-cjet +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Suggests: foomatic-db-engine | apsfilter +Replaces: cjet (<< 0.8.9-3~) +Breaks: cjet (<< 0.8.9-3~) +Description: printer driver for Canon LBP laser printers + CJET filters printer data from stdin to stdout, converting HP PCL + (Printer Command Language) escape sequences and data structures, + e.g. font headers, to their CaPSL equivalents. + . + CaPSL stands for Canon Printing System Language. It is a set of + control command developed for the Canon European Language Printer. + CaPSL was used in Canon Export Models such as LBP-8markIII series and + LBP-4series. Canon's older Japanese models (LBP-A404 GII etc. LIPS-III + as default command) usually have CaPSL emulation mode. diff --git a/copyright b/copyright new file mode 100644 index 0000000..fdf4430 --- /dev/null +++ b/copyright @@ -0,0 +1,34 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: cjet +Source: ftp://metalab.unc.edu/pub/Linux/system/printing/ + +Files: * +Copyright: 1996, Michael Huijsmans +License: GPL-2+ + +Files: debian/* +Copyright: 2003, Chris Lawrence + 2012, Didier Raboud +License: GPL-2+ + +License: GPL-2+ + This program is free software; you can redistribute it + and/or modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later + version. + . + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more + details. + . + You should have received a copy of the GNU General Public + License along with this package; if not, write to the Free + Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301 USA + . + On Debian systems, the full text of the GNU General Public + License version 2 can be found in the file + `/usr/share/common-licenses/GPL-2'. diff --git a/dirs b/dirs new file mode 100644 index 0000000..e69de29 diff --git a/patches/series b/patches/series new file mode 100644 index 0000000..fbfb42b --- /dev/null +++ b/patches/series @@ -0,0 +1 @@ +use_exported_flags.patch diff --git a/patches/use_exported_flags.patch b/patches/use_exported_flags.patch new file mode 100644 index 0000000..a9620b3 --- /dev/null +++ b/patches/use_exported_flags.patch @@ -0,0 +1,27 @@ +Description: Don't hardcode compiler/linker options. + This allows the Debian build options set by dpkg-buildflags to be used. +Author: Didier Raboud +Last-Update: 2012-03-13 +--- a/Makefile ++++ b/Makefile +@@ -4,20 +4,12 @@ + # Makefile for UNIX systems + # + +-# compiler, compiler and linker options +-CC = gcc +-OPT = -O2 -Wall +-LINKOPT = -s +- + # you should not need to change anything below + + SHELL = /bin/sh + + EXECNAME = cjet + +-CFLAGS = $(OPT) +-LDFLAGS = $(LINKOPT) +- + OBJ = main.o parse.o function.o raster.o fonts.o misc.o symbol.o\ + page.o pjl.o macro.o io.o + diff --git a/printer-driver-cjet.docs b/printer-driver-cjet.docs new file mode 100644 index 0000000..724e084 --- /dev/null +++ b/printer-driver-cjet.docs @@ -0,0 +1,2 @@ +README +TODO diff --git a/printer-driver-cjet.install b/printer-driver-cjet.install new file mode 100644 index 0000000..8475687 --- /dev/null +++ b/printer-driver-cjet.install @@ -0,0 +1 @@ +cjet usr/bin/ diff --git a/printer-driver-cjet.manpages b/printer-driver-cjet.manpages new file mode 100644 index 0000000..7424431 --- /dev/null +++ b/printer-driver-cjet.manpages @@ -0,0 +1 @@ +debian/cjet.1 diff --git a/rules b/rules new file mode 100755 index 0000000..2d33f6a --- /dev/null +++ b/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: + dh $@ diff --git a/source/format b/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/tests/control b/tests/control new file mode 100644 index 0000000..7a95cde --- /dev/null +++ b/tests/control @@ -0,0 +1,3 @@ +Tests: printer-driver-cjet +Restrictions: needs-root +Depends: printer-driver-cjet, foomatic-db-compressed-ppds, cups, cups-client (>= 1.7.3-5~) diff --git a/tests/printer-driver-cjet b/tests/printer-driver-cjet new file mode 100755 index 0000000..df42449 --- /dev/null +++ b/tests/printer-driver-cjet @@ -0,0 +1,5 @@ +#!/bin/sh + +set -e + +/usr/share/cups/test-drivers -n adt-test-cjet-0 -r '^foomatic-db-compressed-ppds.*\-cjet' diff --git a/watch b/watch new file mode 100644 index 0000000..c6ca9f4 --- /dev/null +++ b/watch @@ -0,0 +1,4 @@ +version=3 +opts=uversionmangle=s/^(0)(\d)(\d)$/$1.$2.$3/ \ +ftp://metalab.unc.edu/pub/Linux/system/printing/ \ +(?:|.*/)cjet(?:[_\-]v?|)(\d[^\s/]*)\.(?:tar\.xz|txz|tar\.bz2|tbz2|tar\.gz|tgz) -- cgit v1.2.3 From 4ad9df571e2bce35c04960c6ed9cbf601e9dbd54 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Fri, 1 Aug 2014 15:36:24 +0200 Subject: Don't hardcode compiler/linker options. This allows the Debian build options set by dpkg-buildflags to be used. Last-Update: 2012-03-13 Gbp-Pq: Name use_exported_flags.patch --- Makefile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Makefile b/Makefile index 5220873..419a634 100644 --- a/Makefile +++ b/Makefile @@ -4,20 +4,12 @@ # Makefile for UNIX systems # -# compiler, compiler and linker options -CC = gcc -OPT = -O2 -Wall -LINKOPT = -s - # you should not need to change anything below SHELL = /bin/sh EXECNAME = cjet -CFLAGS = $(OPT) -LDFLAGS = $(LINKOPT) - OBJ = main.o parse.o function.o raster.o fonts.o misc.o symbol.o\ page.o pjl.o macro.o io.o -- cgit v1.2.3