The RISC OS Printing System (part 1)

In this series of articles, I will endeavour to explain the intricacies of the printing system as used in RISC OS 3.1 onwards. This will require some detailed explanations of programming techniques as well as the structure of the system. I hope this won't put off those of you who don't produce your own programs. I will try to keep things as simple as possible. But first we need a little history lesson to help you understand how the different printing systems have evolved.

In the beginning...

In the good old days, when data was just text, things were quite simple.

The first type of printers were little more than electric typewriters without a keyboard. These had a wheel whose petals had all the required symbols and alphanumeric letters (see below). They accepted ASCII codes only. If a different font was required, a different wheel had to be used. These were slow and noisy - typically a few tens of characters per second.

For faster printing, line printers were used (see above right). These had a chain spinning at high speed and a set of hammers (80, 120, 160 etc) so that all the characters on one line could be printed at about the same time. Again, they only understood ASCII codes. These were fast, (pages/sec) very noisy and very large! If a new font was required, the chain needed changing. Neither of these printers could output any bit image type graphics.

The next type of printer to emerge was the dot matrix. This first consisted 8 or 9 pins arranged vertically in a printer head which moved across the page (see below). An internal CPU ran a program which produced the required pin firing patterns to produce the alphanumeric shapes and symbols. Most dot matrix printers had their own alphabet patterns stored in ROM, together with a set of instructions as to how to produce underlining, embolding etc, so all a computer program had to do was send down the correct codes and the printer produced the required results.

E.g. To produce a bold B, the codes used by most dot matrix printers were <27><69> <66><27><70>

Since character 27 had always been used for the Escape key these codes were known as Escape sequences. The above would be written as Esc 69 (switch on bold) 66 (ASCII code for B) Esc 70 (switch off bold).

Most dot matrix printers used the Epson escape codes and so writing software such as word-processors was straightforward. For those of you who remember WordWise or Interword, these codes should bring back happy memories.

As printer technology improved, different codes were included to switch the printer to different resolutions, and even to produce crude graphics by individual control over the firing of each pin in the printer head.

A typical graphic on a BBC computer was printed by reading a pixel on the screen, deciding its 'greyness' and firing the required pin at the right position with right force on the paper using an escape sequence. Later, more pins were squeezed into the head (16, 24 etc) to improve the quality. These required extra escape codes, then more codes were added when colour arrived.

Then there was PostScript...

All this was fine for dot matrix and, later, for inkjet printers, i.e. printers which produce output by dots on a page. The main disadvantages of these printers were speed and quality. The laser printer was used for high quality text.

These printers have a large electrically charged spinning belt which is scanned by a laser. Where the laser strikes, the charge is lost. Black powder is then applied to the belt and only sticks to the remaining charged areas. The belt then presses on a sheet of paper, transferring the powder. After heating the paper to fix the powder, it has the required output.

Since the laser scans at high speed, this method (similar to the electrons scanning in a TV tube producing an image) requires a large data bandwidth, i.e. your computer couldn't send the required data fast enough down the parallel port! Hence a language (invented by Adobe Systems Inc) called PostScript was invented to overcome this problem. PostScript data can be thought of as a simple program of commands which the laser printers CPU interprets to produce the required data for switching the laser on and off as it scans.

Now and in the future...

Inkjet printers have taken over from dot matrix; they produce higher quality and are quiet and reasonably quick. They use similar escape sequences although different manufacturers have 'muddied the water' by producing their own variations. Some inkjets use PostScript or near approximations.

Laser printers haven't changed much; they are now faster, have colour and increased resolutions but most, if not all, use a version of PostScript.

Plotters, using pens or inkjets, mostly use PostScript.

Daisywheel and line printers have died out, so the two main printing systems are:

Any printing system must therefore cater for at least the above.

For the escape sequence technique, the printer system must be able to cater for a large variation in standards. Hence, when you buy a new inkjet, it usually comes with its own 'driver' for Windows etc.

The computer's point of view...

In the early days when just text was required, all a computer had to deal with was ASCII codes 'wrapped up' in escape sequences or PostScript. This could be sent in one linear stream. With the advent of multitasking WIMP environments, the data has to be thought of as an image.

This means that the page of data, even if it is only text, is actually sent as a graphical type image to the printer (PostScript is the exception - see later!). Drawing text graphically means that the user can select any font style and use graphics and the printer will faithfully(!?) produce what is seen on the screen. The image can be sent in small chunks, hence multitasking can be catered for.

The printer system must therefore change this graphical information into escape sequence lines of graphical data for the printer to produce.

In PostScript, text is dealt with separately from graphics. A PostScript printer has some sets of fonts in ROM, so there is no need to send these shapes as graphics. A problem arises in that the font used in the document might not be in the printer ROM, so a table of nearest matches is used to convert any fonts. Graphics are held as bit images and are output one line at a time.

Here's the PostScript data to produce a bold B.

/RO_Trinity.Bold_ELatin1 192 192 Fn
(B)

For the programmer, the printer interface must have a common set of commands so that a program can be kept independent of any type of printer. In fact, the program shouldn't need to know what type of printer is connected. Any drawing, plotting, printing of text should use the same commands as for the screen, only redirected to the printer (modified actions to take account of printer limitations).

Well that's 'all' a printer system has to deal with! Next time, I will explain how the RISC OS printer system meets the above requirements.


Source: Archive Magazine 13.4
Publication: Archive Magazine
Contributor: Brian Pickard