=== NOTICE OF INCOMPATIBLE CHANGE ==============================

The default character set is now Latin 1, not IBM PC.

It would have been this way from the first but I didn't realize at the time
that code page 850 contains all the chars of Latin-1.  (In fact, that's 
what 850 is -- 437 changed to accommodate the missing Latin-1 chars.)

You can get the old behavior by adding -code-page 437 to your filter scripts.


=== Intro ==============================

bjf is a filter for Canon BJ-200 printers.  It does:

  1-sided or manual 2-sided
  1-up, 2-up or 4-up, or landscape
  draft or letter quality (i.e., gray or black)
  resident font selection (courier,gothic,prestige) x (10,12,17,proportional)
  vertical & horizontal margins

More specifically:

Without some software, the BJ200 is pretty unpolished.  "lpr file.txt"
produces pages in reverse order, prints over page breaks (omitting 3
lines every time), positions the output over the holes in 3-hole paper
(getting ink all over the platen and smudging subsequent sheets), etc, etc.

bjf shoves in escape sequences to provide centering, page breaks, even/odd
printing, and so on.  It also provides methods to use all of the printer's
built-in features, even the useless ones.

The printer must be in Proprinter mode (DIP switch 12 off on the
original BJ200).

Most control characters are taken as printing characters -- the only 
exceptions are

    \r  carriage return
    \n  newline
    \t  tab
    \f  formfeed
    \b  backspace	

Note particularly that escape \033 is NOT in this list, so preformatted files
containing escape sequences will have their escape sequences printed out.


=== Basic usage ==============================

bjf is meant to be run automatically by lpd as an input filter, but
it can be run by hand to try out the various flags.  For example

  bjf -width 80 -height 60 -font courier -cpi 12 < some.file > /dev/lp1

will copy some.file to the printer, with 80-column lines, 60-line pages,
using the built-in Courier font at size 12 chars/inch.  The next few
sections describe the available bjf flags.  A discussion of how to set
up automatic printing is at the end.


=== About 1-sided and 2-sided printing ==============================

By default bjf prints 1-sided.  It prints the last page first so the
output ends up with the first page on top.

For 2-sided printing, there are two flags, -even and -odd.  First
print the file with -odd.  Put the output back into the printer, top
edge down with the blank side forward.  Print the file again with
-even.  [ Mnemonic: first print page 1 etc, then print page 2 etc. ]

-even and -odd can be used with all other options.


=== About draft mode ==============================

Use -draft to get gray instead of black printing.  This saves ink and
prints faster.  By default, output is letter quality, i.e., black.

-draft can be used with all other options except -font.


=== About resident fonts ==============================

Resident fonts come in 3 faces.  The default is Courier.

    face	 beautiful?	flag

    courier	  pass		-font courier
    prestige	  not		-font prestige
    sans	  not		-font gothic

Resident fonts come in 4 widths, given in chars/inch.  
The max number of chars per line depends on this character pitch.

    pitch	max width	typical width   flag
	
    10 cpi	   80		    65		-cpi 10
    12 cpi	   96		    80		-cpi 12
    17 cpi	  137		   132		-cpi 17
 proportional	 varies		    80		-cpi ps

Resident fonts all are the same height, designed to print 6 lines per inch,
so an 11-inch page is 66 lines high.  The top line and bottom two lines
can't be printed.

Horizontal and vertical margins are not specified directly, instead
the page width and height are given.  Margins are chosen to center the
printable area on the paper.

So, for example, -width 80 -height 60 -cpi 12 is a normal setting, producing
pages 80 cols wide, 60 lines high, with about 1-inch margins left and right
and about 1/2 inch top and bottom.

Lines longer than -width are truncated.  Pages taller than -height are
continued on the next page.

Owing to the extreme weirdness of old line printers and the conventions
adopted by Unix, documents are sometimes formatted assuming that
a page is 66 lines high and that newlines should be used to advance the
paper to the next page.  -height 66 accommodates this.  Pages of 66 lines
are centered on the paper, meaning that the top and bottom margins are
zero.  Note that the BJ-200 cannot not print the top line and bottom two
lines on the paper -- my original reason for writing this -- so use
-height 66 only when the document has been formatted by a utility that
insures those lines are always blank.  (Like pr(1).)

To vertically center the output on the paper, bjf must know how long
the paper is.  If it is not 11 inches, use the -paper-length flag
to give the length in inches.  (It's floating point, i.e. it can
have a fractional part.)

To get double-spaced output or to squeeze the lines closer together,
use the flag -lpi to set the desired number of lines per inch.  This
doesn't change the size of the characters, just the line spacing.  
It too is floating point.

Three character sets are available: Latin-1 and code pages 437 and 850.  
Use -code-page to say which.  The default is latin1.

All the flags in this section can be used freely with each other, but
not with the flags in the next section.


=== About downloaded fonts ==============================

bjf can print two pages side by side on a single sheet of paper, or
four pages on a single page.  It can also print 132-wide landscape
pages.

It uses downloaded fonts to do this, so the flags like -cpi, -lpi,
and -font are not available.

    flag       width          height
            default max    default max

 -two-up      80    83       60	   77
 -four-up     80    82       60    76
 -landscape  132   137       60    64

The flags -width, -height, and -paper-length control the page size and
centering, as with the built-in fonts.  The above maximums are for
11-inch paper, using other lengths will change the max width or height.

Since these fonts are so small, bjf prints two lines at a time.  This
means sending vast amounts of data to the printer.  Print speed is
limited by the data rate -- there will be some pauses in printing, but
it is still printing faster than if it only did one line at a time.


=== Man page ==============================

Usage is
    bjf -flags < infile > outfile

bjf is an lpd input filter -- it only reads from stdin, which must be
a disk file.

It's meant to be run from scripts, so there is no attempt to make the
user interface nifty or interactive.  Just specify the necessary flags
in the scripts.

   -width N sets the left margin to center a line of N chars.
     For proportional fonts, N is taken in 12 cpi units.  
     Long lines are truncated at the right edge of the print area,
     rather than after than N chars.

   -height N sets the top margin to vertically center a page of N lines,
     and also inserts page breaks after N lines.  -height 66 specifies
     the whole page, and the printout is positioned accordingly, but
     lines 1,65,66 are not printable and are not sent.  This is what is
     needed for pr and nroff output that uses 66 newlines instead of
     formfeeds.

   -cpi N, N in { 10 12 17 PS }, chooses a font of that pitch in chars/in.
     PS means 'proportional spacing', i.e. variable width chars.

   -lpi N.N sets the interline spacing to N.N lines/in.  Default 6.

   -font X, X in { courier, gothic, prestige }, uses that resident font.
     courier is the default, and best.  Can't be used with -draft,
     -landscape, -two-up, -four-up.

   -code-page X, X in { latin1, 437, 850 }, uses that code page.  
     Default latin1.  Conflicts with -landscape, -two-up, -four-up.

   -paper-length N.N gives the height of the physical paper in inches.

   -draft uses draft mode (light ink, high speed) output.
     There's only one built-in draft font, so -draft and -font conflict.

   -landscape downloads a sideways font and rotates the page.  
     Size is typically 132x60.  Conflicts with -font but not -draft.

   -two-up prints two pages side by side.  Implies -landscape.
     Size is typically 80x60.  (WIDTH is the width of one of the two pages.)

   -four-up prints four pages per page. Conflicts with -font and -landscape.

   -odd prints every other page starting at the first.

   -even prints every other page starting at the second, followed by
     a blank page if the last sheet was not even.


=== DIP switch settings ==============================

For BJ200:

    1    as apprpriate	off = letter width, on = A4 width
    2    off		reduce vertical scale by 63/66
    3    ignored	not used
    4    ignored        page length
    5    ignored	char set 1 or 2
    6    ignored	lf->crlf
    7    ignored	alternate graphics mode
    8    ignored	not used
    9    ignored	437 or 850
   10    on		download font storage enabled
   11    ignored	not used
   12    off		BJ-10 mode

For Bj200e and BJ200ex:

Set them up the same way, but the specific DIP switch numbers are different.


=== /etc/printcap ==============================

I am no expert, and will offer no advice to people contemplating
complicated setups.  But I will tell you what I did.

The basic idea is to set up a lot of printer names to produce the
needed formats.  For example, to print something two-up with 
ordinary margins, I would use

    lpr -P80x60-2 file.txt

The file /etc/printcap defines a large number of these 'printers', like this:

    80x60:if=/usr/sbin/bjf/bjf-80x60:tc=bj
    80x60-e:if=/usr/sbin/bjf/bjf-80x60-e:tc=bj
    80x60-o:if=/usr/sbin/bjf/bjf-80x60-o:tc=bj
    80x60-2:if=/usr/sbin/bjf/bjf-80x60-2:tc=bj
    80x60-2e:if=/usr/sbin/bjf/bjf-80x60-2e:tc=bj
    80x60-2o:if=/usr/sbin/bjf/bjf-80x60-2o:tc=bj
    80x60-4:if=/usr/sbin/bjf/bjf-80x60-4:tc=bj
    80x60-4e:if=/usr/sbin/bjf/bjf-80x60-4e:tc=bj
    80x60-4o:if=/usr/sbin/bjf/bjf-80x60-4o:tc=bj
    132x60:if=/usr/sbin/bjf/bjf-132x60:tc=bj
    132x60-e:if=/usr/sbin/bjf/bjf-132x60-e:tc=bj
    132x60-o:if=/usr/sbin/bjf/bjf-132x60-o:tc=bj
    ... etc etc ...

'bj' is the real printer, which just passes the data straight through:

    bj:lp=/dev/lp1:sd=/usr/spool/lp/bj:sh:mx#0:

The filter scripts /usr/sbin/bjf/bjfxxxxx are all something like

    #!/bin/sh
    exec /usr/sbin/bjf/bjf -width 80 -height 60 -two-up -draft

I've included the setup I use in etc-printcap.tar.gz as an example.
Just look at it, or untar it into a temp directory and manually
integrate the filter scripts and printcap entries.

If you want to use more, better, or different conventions, you can
eawily bang out the filter scripts and printcap entries by the gross
with a simple script.  There's an example one in etc-printcap.tar.gz.

(Note: the example printcap uses the a single spool directory for all
the formats.  This way, a simple 'lpq' shows you what's printing
and what's waiting.  But it is not correct to do this, and it bites
you if any waiting jobs want a different format than the one printing
-- everything will get printed with the format of the first job.
On a single-user system, it's no big problem to wait for the job(s)
to finish before printing new ones in a different format.
To set it up properly, use a separate spool directory for each queue,
but then you have to say e.g. lpq -P80x60 to look at those jobs,
and lpq -P80x60-2 to look at those jobs, and it can become quite 
tedious.)

For occasional special cases, you can run bjf by hand with

      bjf -flags < file | lpr
or    bjf -flags < file > /dev/lp1


=== BUGS ==============================

The lancscape font is missing some chars.  It's basically ASCII-7, not Latin-1.
