C.1. Introduction to the PostScript Language

PostScript is an interpreted programming language, in the sense that it does not involve a step for compilation: the printer or the rendering software reads the PostScript code and executes it at the same time. The goal of the PostScript language is to describe a page for the purpose of printing or display:[C-1] an abstract description of the page (made up of mathematical objects) is supplied to the PostScript interpreter. When an entire page has been described, it is then printed out, and execution continues with the following page.

[C-1] We have seen people use the PostScript language to do calculations, but that remains in the realm of the anecdotal.

The objects that can be manipulated are straight lines, cubic Bézier curves (see Appendix G), shapes whose outlines are made of straight lines or cubic Bézier curves, and, finally, fonts (whose glyphs are also made of—straight lines and cubic Bézier curves).

C.1.1. Syntax

PostScript may seem strange to those accustomed to languages such as C and Java. First of all, it is a language written in reverse Polish notation: to perform an operation, we first write the operands and then the operator ("2 2 +" instead of "2 + 2"). Next, it is a language based on a stack: we are not required to write declarations that end with a special character, as in other languages. In PostScript, we write data, and these data are automatically placed on a stack; then we write operators, and the operators pop ...

Get Fonts & Encodings now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.