TROFF(ID:2589/tro001)Typesetter Runofffor Typesetter ROFF or Times ROFF Text formatting language/interpreter - extension of NROFF to output to CAT Typesetter Related languages
References: Introduction Troff and nroff are text processors that format text for typesetter- and typewriter-like terminals, respectively. They accept lines of text interspersed with lines of format control information and format the text into a printable, paginated document having a user-designed style. Troff and nroff offer unusual freedom in document styling: arbitrary style headers and footers; arbitrary style footnotes; multiple automatic sequence numbering for paragraphs, sections, etc; multiple column output; dynamic font and point-size control; arbitrary horizontal and vertical local motions at any point; and a family of automatic overstriking, bracket construction, and line-drawing functions. Troff produces its output in a device-independent form, although parameterized for a specific device; troff output must be processed by a driver for that device to produce printed output. Troff and nroff are highly compatible with each other and it is almost always possible to prepare input acceptable to both. Conditional input is provided that enables the user to embed input expressly destined for either program. Nroff can prepare output directly for a variety of terminal types and is capable of utilizing the full resolution of each terminal. A warning, however: nroff necessarily cannot support all features of troff. Within that limitation, it is the same as troff, and in fact there is only a single program, invoked by two different names. Extract: Background to the Second Edition Background to the Second Edition Troff was originally written by the late Joe Ossanna in about 1973, in assembly language for the PDP-11, to drive the Graphic Systems CAT typesetter. It was rewritten in C around 1975, and underwent slow but steady evolution until Ossanna's death late in 1977. In 1979, Brian Kernighan modified troff so that it would produce output for a variety of typesetters, while retaining its input specifications. Over the decade from 1979 to 1989, the internals have been modestly revised, though much of the code remains as it was when Ossanna wrote it. Troff reads parameter files each time it is invoked, to set values for machine resolution, legal type sizes and fonts, and character names, character widths and the like. Troff output is ASCII characters in a simple language that describes where each character is to be placed and in what size and font. A post-processor must be written for each device to convert this typesetter-independent language into specific instructions for that device. The output language contains information that was not readily identifiable in the older output. Most notably, the beginning of each page and line is marked, so post-processors can do device-specific optimizations such as sorting the data vertically or printing it boustrophedonically, independent of troff. Capabilities for graphics have been added. troff now recognizes commands for drawing diagonal lines, circles, ellipses, circular arcs, and quadratic B-splines; there are also ways to pass arbitrary information to the output unprocessed by troff. A number of limitations have been eased or eliminated. A document may have an arbitrary number of fonts on any page (if the output device permits it, of course). Fonts may be accessed merely by naming them; "mounting'' is no longer necessary. There are no limits on the number of characters. Character height and slant may be set independently of width. The remainder of this document contains a description of usage and command-line options; a summary of requests, escape sequences, and pre-defined number registers; a reference manual; tutorial examples; and a list of commonly-available characters. Extract: Acknowledgements Acknowledgements Joe Ossanna's troff remains a remarkable accomplishment. For fifteen years, it has proven a robust tool, taking unbelievable abuse from a variety of preprocessors and being forced into uses that were never conceived of in the original design, all with considerable grace under fire. The current version of troff has profited from significant code improvements by Jaap Akkerhuis, Dennis Ritchie, Ken Thompson, and Molly Wagner. Andrew Hume, Doug McIlroy, and Ravi Sethi made valuable suggestions on the manual. I fear that the remaining bugs are my fault. ps Extract: History The TROFF text formatter 2 was originally written by the late Joe Ossanna in about 1973, in assembly language for the PDP-11. (NROFF, which drives terminals instead of a typesetter, is essentially identical to TROFF; we will use "TROFF'' as a generic term henceforth.) It was rewritten in C around 1975, and underwent slow but steady evolution until Ossanna's death late in 1977. In spite of some obvious deficiencies - a rebarbative input syntax, mysterious and undocumented properties in some areas, and a voracious appetite for computer resources (especially when used with macro packages and preprocessors like EQN and TBL) - TROFF has been the basis of document preparation at Bell Labs for some years, and is likely to remain so for years to come. Early in 1979, the Computing Science Research Center decided to acquire a new typesetter, primarily because of our interests in typesetting graphics. At the same time, the Murray Hill Computer Center began to investigate the possibility of replacing their family of aging CAT's with a new, high-performance typesetter, simply to keep up with their rapidly expanding load. My first thought (a thought shared by many others) was that this would be a glorious opportunity to replace TROFF with a new formatting language: better designed, easier to work with, and of course much faster. This remains a desirable goal, but, after quite a bit of thought spread over several years, I am still not really much closer to a better design, let alone an implementation. Furthermore, a great deal of software depends on TROFF - the preprocessors, the macro packages, and of course all of their documentation and our accumulated expertise. Tossing this aside is not something to be done lightly. Accordingly, in the spring of 1979, I set about to modify TROFF so that it would run henceforth without change on a variety of typesetters. The ground rule was that TROFF should retain its current specifications, so that existing software like EQN, TBL and the macro packages would continue to work with it. [...] TROFF is highly dependent on the Graphic Systems CAT typesetter, not just in details of code but also in many aspects of its design. The language design issues have been largely ignored (few are truly fundamental), while the code has been modified so that dependencies are either eliminated or at least parameterized. TROFF originally had parameters of the typesetter compiled into the code, often in non-obvious ways. The new version reads a parameter file each time it is invoked, to set values for machine resolution, legal sizes, fonts and characters, character widths and the like. TROFF output used to be binary device codes specific to the CAT and arcane beyond description. The output of the new version is ASCII characters in a simple and (I hope) universal language that describes where each character is to be placed and in what size and font. A post-processor must be written for each typesetter to convert this typesetter-independent language into specific codes for that typesetter. Post-processors currently exist for the CAT, the Mergenthaler Linotron 202, the Autologic APS-5, the Tektronix 4014 terminal, The Imagen Canon laser printer, Versatec printers, and a bit-map terminal. New ones can generally be written in less than a day; they share much of their code with previous ones. The new output language contains information that is not readily identifiable in the older output. Most notably, the beginning of each page and line is marked, so post-processors can do device-specific optimizations such as sorting the data vertically or printing it boustrophedonically, independently of TROFF. Since actual output is done by a post-processor, not TROFF, new capabilities for graphics have been easy to add. TROFF now recognizes commands for drawing diagonal lines, circles, ellipses, circular arcs, and quadratic B-splines; these are used in the PIC 3 and IDEAL 4 languages. A number of limitations have been eased or eliminated. A document may have an arbitrary number of fonts on any page (if the output device permits it, of course). Fonts may be accessed merely by naming them; "mounting'' is no longer necessary. Character height and slant may be set independently of width. The new TROFF is about 1000 bytes larger in instruction space and 13000 bytes larger in data space (thus guaranteeing that it will not run on PDP-11/40 style machines). It runs about as fast as the original version, though a simple improvement that I made could be retrofitted into the earlier version to keep it about 20% faster. The post-processors are not included in these time comparisons; they typically take 10-20% of the TROFF time. |