Printer Control Codes:

In principle, what a computer user wants to see on paper is what they see on the screen but more of it. Computer screens tend to be "landscape" orientation and display 1280 x 1024 pixels. Paper is normally used "portrait" and can show much more information - even a crudely printed 300dpi A4 page is around 2400 x 3300 pixels.

Until very recently mapping what a user sees on screen to what they expect on paper has been difficult to achieve. Old computer screens were a poor reflection of anything that could be produced on paper. Paper printing includes fonts and typefaces, bold, underlining, superscript and subscript, symbols, graphics and borders. Old display screens could not achieve most of this.

Starting in the 1980s Apple Mac and Windows systems with VGA displays changed this by introducing graphical computing. Users began to expect  WYSIWYG - What You See Is What You Get. Screen and printed output have the same appearance. The problem is that printer control languages that used to work well for material from crude old displays are poor at handling complex graphics on screen or paper.

The basis of printer control was generally ASCII codes, which originated with printing telegraphs.  Each character is represented by a seven bit binary pattern, and most of the characters transferred are printed. Screen and printer each hold their own pattern for reproducing characters, so it is possible for the pattern seen on the screen and that output on paper to be ather different. There are also some control codes, for instance for Back Space (BS), Horizontal Tab(HT), Vertical Tab (VT), Form Feed (FF) and Carriage Return (CR).

Some manufacturers adopted other characters using the 8 bit codes common on computers. These could give special instructions to the printer on character spacing, bold printing, double height, underlining or colour selection, or to knock it into a graphics printing mode. There have been innumerable different standards for printer control. OKI printers obeyed one set, IBM another and Mannesman yet another still. Each new generation of printers has introduced new capabilities and new codes.

Epson Esc-P2

Control codes for dot matrix printers are often based on the Epson command set, the most recent version being ESC-P2. (There are a series of Epson Commands suited to dot-matrix printers MX100, FX1050, LQ850, LQ2050, LQ1170). Epson owns the copyright to the ESC-P2 command set - so only their printers might produce them. However Epson used to copy IBM printer codes, and they now find many other manufacturers copying them. There is even an ESC/P card for HP laserjets to give it backward compatability with dot-matrix printers.

Ordinary text passes as ordinary ASCII code and obeys the BS, HT, VT, FF and CR commands as usual. A whole new rich set of printer instructions can be accessed by passing an Escape character (ESC or Decimal code 27) to the printer fololowed by one or two characters that act as instructions; for instance:

ESC E (27 69) sets condensed mode - the characters are smaller and closer together

ESC F (27 70) cancels condensed mode

ESC G (27 71) sets bold mode - the characters are made blacker (perhaps by overprinting them)

ESC H( 27 72) cancels bold character mode

There are commands to select double height, change linespacing, produce shadowed characters, select different fonts or English and Asian scripts. Recent manuals contain several hundred pages detailing what each command should do.

While the computer is transferring character-oriented material from a word-processor or a database the interface between computer and printer is quite efficient. An A4 page can contain just over 5,000 characters, so the interface will need to carry 5,000 bytes of information. In principle it is possible for an EPP interface to handle this volume of data in less than 1000th of a second although it may take longer to print.

However with the growth of Windows applications the material to be printed can often only be expressed as a graphic. ESC/P allows for this. ESC * nm allows the computer to download a binary pattern with a length specified by the parameters n and m which are dot patterns applied directly to the printhead pins.

An A4 page will contain nearly 8 million dot positions, so nearly a million bytes of information will need to be transferred over the interface,(there is no grey scale, dots print or not).  This process of transfering the page a pixel at a time isn't nearly so fast as transfering the ASCII characters.

Dot matrix printers are often rather poor at handling graphics. To print a line of normal characters the printer needs to acquire 132 characters before the head sets off across the page. To print graphics at 300dpi it will need to store about 4000 bytes in its buffer. Quite a few old printers could not do this, they had to print part of a line at a time. 

This situation is made worse because Windows programs use so many fonts. Suppose that the printer’s internal character set is Courier, and the users screen shows Arial. In the worst case the printer must simply substitute one font for another - and the printed page looks nothing like its screen counterpart. An alternative is to build the equired font out of bit-mapped graphics to create the Arial characters. The computer therefore sends the whole text of the page as graphics. At least 10 times as much data will need to be moved, and the printhead will not be used in the most efficient way, so this will slow the print process down.

All recent printers have  a rather more efficient way to produce fonts, the required font can be downloaded into the printer where it will be used to produce non-native fonts much more efficiently. This process can work providing the computers printer-drivers know the facility exists and the memory space taken by the font is not too large. Downloadable fonts aren’t much help with graphics, but they can regain efficiency with text.

Epson updated their language to ESC/P2 and it is still widely used. Whether it should be called a language is questionable; it's more a set of control codes however it does the job of describing pages. HP PCL and Postscript are more common.

One way to ensure that screen and printer graphics are identical is to use a common language. The most widely respected is Adobe Postscript.

PostScript

PostScript is a full computer language particularly intended for graphics. It describes the page as coordinated and objets as vectors  together with instructions to fill in the shapes described. A picture like a JPEG can be given as a bitmap but positioned precisely. Like other vector graphic languages PostScript has a wide potential use, it has been used to drive screens as well as printers. Every character, line and dot on the page is described with an English token, so a typical excerpt  looks like this.

newpath
54.285713 49.505039 moveto
697.14283 49.505039 lineto
697.14283 329.50504 lineto
54.285713 329.50504 lineto
54.285713 49.505039 lineto
closepath
stroke
gsave

In a simple PostScript file text can be described as vectors as well. This does mean that the file is larger than it need be. PostScript Level 2 introduced composite fonts and PostScript 3  introduced colour handling adequate for pre-press production.

PostScript belongs to Adobe, indeed it is the founding technology for their business. The idea was created by John Warnock and Charles Geschke in 1982. Both had esperience with computer graphics, Warnock at Evans & Sutherland then working with Geschke at Xerox Parc where they had worked on the InterPress language. PostSript is similar to Interpress but simpler. Apple boss Steve Jobs urged them to adapt PostScript as a language for laser printers. The Apple LaserWriter  was the first to ship with  PostScript although doing this required it to have a more powerful processor than those used in Apples desktop computers at the time.

Apple have been great promoters of Adobe Postscript because of its reliability in producing page layout. PostScript files have been the de-facto standard for exchanging grapical information between sites as well as from computer to printer. PostScript's descendant the PDF (Portable Document Format) has largely taken over in document exchange and recent printers often come with direct PDF print.

Manufacturers of PostScript equipment pay per-unit  licence to Adobe to use their language. The language is proprietary and certain aspect of its' operation like the "hints" on Type 1 fonts were at one time secret although these days everything is open. The price of the licence is often a significant fraction of the cost of the printer. Many  manufacturers have tried to produce machines that will obey Adobe Postscript without legally infringing their copyright. Specialists in this field include

Zoran - often used by HP for their "emulation"
Global Graphics "Jaws" and Harlequin.

Postscript is complex, and its interpretation in the printer requires a powerful processor.

GDI

Windows largely created the graphics problem - before it became widespread graphics was a "ghetto" function carried on by people who had bought Apple Mac machines. Windows also provides a solution by providing a common Graphical Device Interface.

The Graphical Device Interface is a Windows software mechanism which treats screen, printer and any other output device that might be attached in the same way. A printer attached directly to the GDI can be entirely controlled by the main PC, and needs little in the way of logic itself and no control language - all of its controls are directly carried out from Windows. The disadvantage is that the user must be unning Windows, the advantage is that the user can spend money on a more powerful PC with the savings from not having to buy an expensive printer logic.

Clearly the GDI printer is no use to someone unning an Apple Mac (they have had their own equivalent overpriced machines for years). A GDI printer is also of little use to a DOS user - although some printers do come with a driver that will provide some DOS services. Microsoft have said that the GDI in Windows ‘95 will not be identical to that in Windows 3.1, so users will need to have a secure line to get the correct printer driver when they want to upgrade their version of Windows.
 
 

Standing somewhere between Epson codes and Postscript in effectiveness and widespread use is the Hewlett Packard code-set PCML..