=== 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 help, the BJ200 is pretty useless.  "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 access to advanced features
like not dropping the data.  Also page size, fonts, line spacing, and so on.

It probably works with compatible Canon printers, but will not work
with a vanilla Proprinter -- it uses Canon-only codes to download
360x360 characters.  In modes that use only resident fonts, it might
work with Proprinters.

The printer must be in Proprinter mode (DIP switch 12 off).  Epson mode
has more fonts and better ones, but does not have 360x360 resolution.

All characters print (using the IBM PC character set) except (only) these:

    \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.

Also note that linefeed is treated as Unix newline, which also works
for CRLF-delimited lines.  But a file that improbably depends on
linefeed not performing carriage return won't print correctly.

There are many flags, sorry.  A few of them are useless, provided only
to give access to some seldom-used escape sequence.


=== 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	 beauty?	flag

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

Resident fonts come in 4 widths, given in chars/inch.  The 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
that grew up around them, documents are sometimes formatted assuming that
a page is 66 lines high and that linefeeds 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 does 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 something equally strange, use the
flag -lpi to set the desired number of lines per inch.  This doesn't
change the size of the characters, of course, just the line spacing.
It too is floating point.

Resident fonts come in two code pages, 437 and 850.  Use -code-page to
say which.  The default is 437.  Code page 850 has some different
national characters in the high half of the chart, see your favorite IBM
documentation for details.

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 does not download arbitrary fonts, but has some built in tiny fonts
for special effects.

It can print two or four pages per side, or print sideways (landscape).

    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 device fonts.  The above maximums are for 11-inch
paper, 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 provision for changing
defaults in the makefile or other handy config utility.  Just specify
the necessary flags in the scripts.

   -width N positions the printout to center a line of length N chars.
     For proportional fonts, N is taken in 12 cpi units.  Long lines are
     truncated at the right edge of the print area, which may be more
     than N chars.

   -height N prints N lines per page, positioned to vertically center
     a full page of N lines.  -height 66 specifies the whole sheet, 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 using 66 lines/page instead of formfeeds.

   -cpi N, N in { 10 12 17 PS }, chooses a font of that pitch in chars/in.

   -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 N, N in { 437, 850 }, uses that code page.  Default 437.
     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 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 sheet. Conflicts with -font and -landscape.

   -odd prints every other sheet starting at the first.

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


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

    1    any   off = letter, on = A4  (sets width, -paper-length sets length)
    2    off
    3    ignored
    4    ignored        
    5    ignored
    6    ignored
    7    ignored
    8    ignored
    9    ignored
   10    on
   11    ignored
   12    off


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

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

I use printer names to encode useful flag combinations.  For example,
to print something two-up with ordinary margins, I would use

    lpr -P80x60x2 file.txt

My printcap defines a large number of these 'printers', like this:

    80x60:if=/usr/etc/bjf80x60:tc=raw:
    65x60:if=/usr/etc/bjf65x60:tc=raw:
    80x66:if=/usr/etc/bjf80x66:tc=raw:
    65x66:if=/usr/etc/bjf75x66:tc=raw:
    80x60x2:if=/usr/etc/bjf80x60x2:tc=raw:
    80x60x4:if=/usr/etc/bjf80x60x4:tc=raw:
    80x76x2:if=/usr/etc/bjf80x76x2:tc=raw:
    80x76x4:if=/usr/etc/bjf80x76x4:tc=raw:

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

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

The filter scripts /usr/etc/bjfxxxxx are all something like

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

You can bang out the filter scripts (and the printcap entries) by the
gross with a trivial Icon (or, if you insist, perl) program.  Just
come up with a consistent, memorable representation for the main
options: size, 1side/even/odd, draft/letter.

For occasional special cases, run it 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 IBMPC.
