| PostScript | |
|---|---|
| Paradigm | multi-paradigm: stack-based, procedural |
| Appeared in | 1982 |
| Designed by | John Warnock & Chuck Geschke |
| Developer | Adobe Systems |
| Typing discipline | dynamic, strong |
| Major implementations | Adobe PostScript, TrueImage, Ghostscript |
| Influenced by | Forth, Lisp |
| Influenced | |
| PostScript | |
|---|---|
| File name extension | . A programming paradigm is a fundamental style of Computer programming. A multi-paradigm programming language is a Programming language that supports more than one Programming paradigm. A stack-oriented programming language is one that relies on a Stack machine model for passing parameters Procedural programming can sometimes be used as a synonym for Imperative programming (specifying the steps the program must take to reach the desired state but can also John Warnock (b October 6, 1940) is an American Computer scientist best known as the co-founder with Charles Geschke of Adobe Systems Charles M "Chuck" Geschke (born 1939 is best known as the co-founder with John Warnock of Adobe Systems Inc A software developer is a person or organization concerned with facets of the software development process wider than design and coding a somewhat broader scope of Adobe Systems Incorporated (pronounced a-DOE-bee əˈdoʊbiː ( is an American Computer software company headquartered in San Jose California In Computer science, a type system defines how a Programming language classifies values and expressions into '''types''', how it can Implementation is the realization of an application or execution of a Plan, idea Model, Design, Specification, standard, Algorithm PostScript ( PS) is a dynamically typed concatenative Programming language created by John Warnock and Charles Geschke in 1982 TrueImage is a PostScript -compatible interpreter (clone originally developed by Cal Bauer and Bauer Enterprises and sold to Microsoft in 1989 Ghostscript is a suite of Software based on an interpreter for Adobe Systems ' PostScript and Portable Document Format (PDF Page description Forth is a structured, imperative, stack-based, computer Programming language and programming environment Lisp (or LISP) is a family of Computer Programming languages with a long history and a distinctive fully parenthesized syntax A filename extension is a suffix to the name of a Computer file applied to indicate the encoding convention ( File format) of its contents ps |
| Internet media type | application/postscript |
| Uniform Type Identifier | com. An Internet media type, originally called a MIME type after MIME and sometimes a Content-type after the name of a header in several protocols whose value A Uniform Type Identifier ( UTI) is a string defined by Apple Inc adobe. postscript |
| Magic number | %! |
| Developed by | Adobe Systems |
| Type of format | printing file format |
| Extended to | Encapsulated PostScript |
PostScript (PS) is a page description language and programming language used primarily in the electronic and desktop publishing areas. A file format is a particular way to encode information for storage in a Computer file. Adobe Systems Incorporated (pronounced a-DOE-bee əˈdoʊbiː ( is an American Computer software company headquartered in San Jose California Encapsulated PostScript, or EPS, is a DSC -conforming PostScript document with additional restrictions intended to make EPS files usable as a Graphics A page description language (PDL is a language that describes the appearance of a printed page in a higher level than an actual output Bitmap. A programming language is an Artificial language that can be used to write programs which control the behavior of a machine particularly a Computer. Desktop publishing (also known as DTP) combines a Personal computer and WYSIWYG page layout Software to create Publication Documents
Contents |
The concepts of the PostScript language were seeded in 1976 when John Warnock was working at Evans & Sutherland, a famous computer graphics company. John Warnock (b October 6, 1940) is an American Computer scientist best known as the co-founder with Charles Geschke of Adobe Systems Evans & Sutherland ( is a Computer firm involved in the Computer graphics field Computer graphics are Graphics created by Computers and more generally the Representation and Manipulation of Pictorial Data At that time John Warnock was developing an interpreter for a large three-dimensional graphics database of New York harbor. New York ( is a state in the Mid-Atlantic and Northeastern regions of the United States and is the nation's third most populous Warnock conceived the Design System language to process the graphics, very similar to the Forth programming language. Forth is a structured, imperative, stack-based, computer Programming language and programming environment
Concurrently, researchers at Xerox PARC had developed the first laser printer and had recognized the need for a standard means of defining page images. PARC (Palo Alto Research Center Inc formerly Xerox PARC, is a Research and development company in Palo Alto California that began as a division of A laser printer is a common type of Computer printer that rapidly produces high quality text and graphics on plain paper In 1975-76 a team led by Bob Sproull developed the Press format, which was eventually used in the Xerox Star system to drive laser printers. Dr Robert F Sproull works for Sun Microsystems where he is a Sun Fellow and Vice President at Sun Labs Massachusetts in Burlington The Star Workstation, officially known as the Xerox 8010 Information System, was introduced But Press, a data format rather than a language, lacked flexibility, and PARC mounted the InterPress effort to create a successor. PARC (Palo Alto Research Center Inc formerly Xerox PARC, is a Research and development company in Palo Alto California that began as a division of InterPress is a Page description language developed at Xerox PARC, based on the Forth programming language and an earlier graphics language called JaM
In 1978 Evans and Sutherland asked Warnock to move from the San Francisco Bay Area to their main headquarters in Utah, but he was not interested in moving. Evans & Sutherland ( is a Computer firm involved in the Computer graphics field John Warnock (b October 6, 1940) is an American Computer scientist best known as the co-founder with Charles Geschke of Adobe Systems The San Francisco Bay Area, commonly known as the Bay Area, or the Bay, is a geographically and ethnically diverse metropolitan region that surrounds the The State of Utah (ˈjuːtɔː or) is a western state of the United States. He then joined Xerox PARC to work with Martin Newell. PARC (Palo Alto Research Center Inc formerly Xerox PARC, is a Research and development company in Palo Alto California that began as a division of Martin Newell is a British-born Computer scientist specializing in Computer graphics and is perhaps best known as the creator of the Utah teapot. They rewrote Design System to create JaM (for "John and Martin") which was used for VLSI design and the investigation of type and graphics printing. This work later evolved and expanded into the InterPress language. InterPress is a Page description language developed at Xerox PARC, based on the Forth programming language and an earlier graphics language called JaM
Warnock left with Chuck Geschke and founded Adobe Systems in December 1982. Charles M "Chuck" Geschke (born 1939 is best known as the co-founder with John Warnock of Adobe Systems Inc Adobe Systems Incorporated (pronounced a-DOE-bee əˈdoʊbiː ( is an American Computer software company headquartered in San Jose California They created a simpler language, similar to InterPress, called PostScript, which went on the market in 1984. At about this time they were visited by Steve Jobs, who urged them to adapt PostScript to be used as the language for driving laser printers. Steven Paul Jobs (born February 24 1955 is the Co-founder, Chairman, and CEO of Apple Inc and former CEO of Pixar Animation A laser printer is a common type of Computer printer that rapidly produces high quality text and graphics on plain paper
In March of 1985, the Apple LaserWriter was the first printer to ship with PostScript, sparking the desktop publishing (DTP) revolution in the mid-1980s. Apple Inc, ( formerly Apple Computer Inc, is an American Multinational corporation with a focus on designing and manufacturing Consumer electronics The Apple LaserWriter was one of the first Laser printers available to the mass market Desktop publishing (also known as DTP) combines a Personal computer and WYSIWYG page layout Software to create Publication Documents The combination of technical merits and widespread availability made PostScript a language of choice for graphical output for printing applications. For a time an interpreter (sometimes referred to as a RIP -for Raster Image Processor) for the PostScript language was a common component of laser printers, into the 1990s. In Computer science, an interpreter normally means a Computer program that executes, i A raster image processor (RIP is a component used in a Printing system which produces a raster image also know as a Bitmap. A laser printer is a common type of Computer printer that rapidly produces high quality text and graphics on plain paper
Once the de facto standard for electronic distribution of final documents meant for publication, PostScript is steadily being supplanted in this area by one of its own descendants, the Portable Document Format or PDF. By 2001 there were fewer printer models which came with support for PostScript, largely due to the growing competition from much cheaper non-PostScript ink jet printers (PostScript interpreters added significantly to printer cost), and new software-based methods to render PostScript images on the computer, making them suitable for any printer (PDF provided one such method). The use of a PostScript laser printer still can, however, significantly reduce the CPU workload involved in printing documents, transferring the work of rendering PostScript images from the computer to the printer.
The PostScript language has had two major upgrades. The first version, known as PostScript Level 1, was introduced in 1984.
PostScript Level 2 was introduced in 1991, and included several improvements: improved speed and reliability, support for in-RIP separations, image decompression (for example, JPEG images could be rendered by a PostScript program), support for composite fonts, and the form mechanism for caching reusable content. Image compression is the application of Data compression on Digital images In effect the objective is to reduce redundancy of the image data in order to be able to In typography a font (also fount) is traditionally defined as a complete character set of a single size and style of a particular Typeface.
PostScript 3 (Adobe dropped the "level" terminology in favor of simple versioning) came at the end of 1997, and along with many new dictionary-based versions of older operators, introduced better color handling, and new filters (which allow in-program compression/decompression, program chunking, and advanced error-handling).
PostScript 3 was significant in terms of replacing the existing proprietary color electronic prepress systems, then widely used for magazine production, through the introduction of smooth shading operations with up to 4096 shades of grey (rather than the 256 available in PostScript 2), as well as DeviceN, a color space that allowed the addition of additional ink colors (called spot colors) into composite color pages. In Offset printing, a spot color is any color generated by an Ink (pure or mixed that is printed using a single run.
Prior to the introduction of PostScript, printers were designed to print character output given the text—typically in ASCII—as input. American Standard Code for Information Interchange ( ASCII) There were a number of technologies for this task, but most shared the property that the glyphs were physically difficult to change, as they were stamped onto typewriter keys, bands of metal, or optical plates. A glyph is an element of writing Two or more glyphs representing the same symbol whether interchangeable or context-dependent are called Allographs the abstract unit they A typewriter is a mechanical or Electromechanical device with a set of "keys" that when pressed cause characters to be printed on a medium
This changed to some degree with the increasing popularity of dot matrix printers. A dot matrix printer or impact matrix printer refers to a type of Computer printer with a print head that runs back and forth on the page and prints by impact striking The characters on these systems were drawn as a series of dots, the proper dots to use defined as a font table inside the printer. In Typography, a typeface is a set of one or more Fonts designed with stylistic unity each comprising a coordinated set of Glyphs A typeface usually comprises As they grew in sophistication, dot matrix printers started including several built-in fonts from which the user could select, and some models allowed users to upload their own custom glyphs into the printer.
Dot matrix printers also introduced the ability to print raster graphics. In Computer graphics, a raster graphics image or bitmap, is a Data structure representing a generally rectangular grid of Pixels The graphics were interpreted by the computer and sent as a series of dots to the printer using a series of escape sequences. This article refers to codes used as commands for computing devices These printer control languages varied from printer to printer, requiring program authors to create numerous drivers. A page description language (PDL is a language that describes the appearance of a printed page in a higher level than an actual output Bitmap. In computing a device driver or software driver is a Computer program allowing higher-level computer programs to interact with a Hardware device
Vector graphics printing was left to special-purpose devices, called plotters. A plotter is a Vector graphics printing device that connects to a Computer. Plotters did share a common command language, HPGL, but were of limited use for anything other than printing graphics. HPGL, sometimes hyphenated as HP-GL, is the primary Printer control language used by Hewlett-Packard Plotters The name is an Initialism In addition, they tended to be expensive and slow, and thus rare.
Laser printers combine the best features of both printers and plotters. Like plotters, laser printers offer high quality line art, and like dot-matrix printers, they are able to generate pages of text and raster graphics. Unlike either printers or plotters, however, a laser printer makes it possible to position high-quality graphics and text on the same page. PostScript made it possible to fully exploit these characteristics, by offering a single control language that could be used on any brand of printer.
PostScript went beyond the typical printer control language and was a complete programming language of its own. Many applications can transform a document into a PostScript program whose execution will result in the original document. This program can be sent to an interpreter in a printer, which results in a printed document, or to one inside another application, which will display the document on-screen. In Computer science, an interpreter normally means a Computer program that executes, i Since the document-program is the same regardless of its destination, it is called device-independent.
PostScript is noteworthy for implementing on-the fly rasterization; everything, even text, is specified in terms of straight lines and cubic Bézier curves (previously found only in CAD applications), which allows arbitrary scaling, rotating and other transformations. Rasterization or Rasterisation is the task of taking an image described in a Vector graphics format (shapes and converting it into a Raster image ( In the mathematical field of Numerical analysis, a Bézier curve is a Parametric curve important in Computer graphics and related fields When the PostScript program is interpreted, the interpreter converts these instructions into the dots needed to form the output. For this reason PostScript interpreters are also sometimes called PostScript Raster Image Processors, or RIPs. A raster image processor (RIP is a component used in a Printing system which produces a raster image also know as a Bitmap.
Almost as complex as PostScript itself was its handling of fonts. In Typography, a typeface is a set of one or more Fonts designed with stylistic unity each comprising a coordinated set of Glyphs A typeface usually comprises The rich font system used the PS graphics primitives to draw glyphs as line art, which could then be rendered at any resolution. Printmaking art techniques such as Engraving, Etching, Woodcut and Lithography are covered more fully in their respective articles Image resolution describes the detail an Image holds The term applies equally to Digital images film images and other types of images Though this sounds like a reasonably straightforward concept, there were a number of typographic issues that had to be considered. Typography is the art and techniques of arranging type, Type design, and modifying type Glyphs Type glyphs are created and modified using a variety
One issue is that fonts do not actually scale linearly at small sizes; features of the glyphs will become proportionally too large or small and they start to look wrong. PostScript avoided this problem with the inclusion of hints which could be saved along with the font outlines. Font hinting is the use of mathematical instructions to adjust the display of an Outline font so that it lines up with a rasterized grid Basically they are additional information in horizontal or vertical bands that help identify the features in each letter that are important for the rasterizer to maintain. The result was significantly better-looking fonts even at low resolution; it had formerly been believed that hand-tuned bitmap fonts were required for this task.
At the time, the technology for including these hints in fonts was carefully guarded, and the hinted fonts were compressed and encrypted into what Adobe called a Type 1 Font (also known as PostScript Type 1 Font, PS1, T1 or Adobe Type 1). PostScript fonts are Outline font specifications developed by Adobe for professional digital typesetting, which uses PostScript file format to Type 1 was effectively a simplification of the PS system to store outline information only, as opposed to being a complete language (PDF is similar in this regard). Adobe would then sell licenses to the Type 1 technology to those wanting to add hints to their own fonts. Those who did not license the technology were left with the Type 3 Font (also known as, PostScript Type 3 Font, PS3 or T3). PostScript fonts are Outline font specifications developed by Adobe for professional digital typesetting, which uses PostScript file format to Type 3 fonts allowed for all the sophistication of the PostScript language, but without the standardized approach to hinting. Other differences further added to the confusion.
Type 2 was designed to be used with the Compact Font Format (CFF), and were implemented for a compact representation of the glyph description procedures to reduce the overall font file size. PostScript fonts are Outline font specifications developed by Adobe for professional digital typesetting, which uses PostScript file format to PostScript fonts are Outline font specifications developed by Adobe for professional digital typesetting, which uses PostScript file format to The CFF/Type2 format later became the basis for Type 1 OpenType fonts. PostScript fonts are Outline font specifications developed by Adobe for professional digital typesetting, which uses PostScript file format to OpenType is a scalable format for Computer fonts initially developed by Microsoft, later joined by Adobe Systems.
CID-keyed font format was also designed, to solve the problems in the OCF/Type 0 fonts, for addressing the complex Asian-language (CJK) encoding and very large character set issues. PostScript fonts are Outline font specifications developed by Adobe for professional digital typesetting, which uses PostScript file format to CJK is a collective term for Chinese, Japanese, and Korean, which constitute the main East Asian languages. CID-keyed font format can be used with the Type 1 font format for standard CID-keyed fonts, or Type 2 for CID-keyed OpenType fonts.
Adobe's rates were widely considered to be prohibitively high, and it was this issue that led Apple to design their own system, TrueType, around 1991. TrueType is an Outline font standard originally developed by Apple Computer in the late 1980s as a competitor to Adobe 's Type 1 fonts Immediately following the announcement of TrueType, Adobe published the specification for the Type 1 font format. Retail tools such as Altsys Fontographer (acquired by Macromedia in January 1995, owned by FontLab since May 2005) added the ability to create Type 1 fonts. Fontographer, sometimes abbreviated to FOG, is a software application used to design fonts available for both Microsoft Windows and Apple Macintosh platforms Macromedia was a North American graphics and Web development Software house headquartered in San Francisco, California producing such products FontLab is both the name of a company FontLab Ltd and the former name of their flagship Font editor product now called FontLab Studio. Since then, many free Type 1 fonts have been released; for instance, the fonts used with the TeX typesetting system are available in this format. TeX (ˈtɛx as in Greek, often /ˈtɛk/ in English; written with a lowercase 'e' in imitation of the logo is a Typesetting system designed and mostly
In the early 1990s there were several other systems for storing outline-based fonts, developed by Bitstream and METAFONT for instance, but none included a general-purpose printing solution and they were therefore not widely used as a result. Bitstream Inc (NASDAQBITS is a Type foundry that produces digital Typefaces (fonts Metafont is a Programming language used to define vector fonts.
In the late 1990s, Adobe joined Microsoft in developing OpenType, essentially a functional superset of the Type 1 and TrueType formats. OpenType is a scalable format for Computer fonts initially developed by Microsoft, later joined by Adobe Systems. When printed to a PostScript output device, the unneeded parts of the OpenType font are omitted, and what is sent to the device by the driver is the same as it would be for a TrueType or Type 1 font, depending on which kind of outlines were present in the OpenType font.
In the 1980s, Adobe got most of their revenue from the licensing fees for their implementation of PostScript for printers, known as a raster image processor or RIP. A raster image processor (RIP is a component used in a Printing system which produces a raster image also know as a Bitmap. As a number of new RISC-based platforms became available in the mid 1980s, some found Adobe's support of the new machines to be lacking.
This and issues of cost led to third-party implementations of PostScript becoming common, particularly in low-cost printers (where the licensing fee was the sticking point) or in high-end typesetting equipment (where the quest for speed demanded support for new platforms faster than Adobe could provide). At one point, Microsoft and Apple teamed up to try to unseat Adobe's laser printer monopoly, Microsoft licensing to Apple a PostScript-compatible interpreter it had bought called TrueImage, and Apple licensing to Microsoft its new font format, TrueType (Apple ended up reaching an accord with Adobe and licensed genuine PostScript for its printers, but TrueType became the standard outline font technology for both Windows and the Macintosh). TrueImage is a PostScript -compatible interpreter (clone originally developed by Cal Bauer and Bauer Enterprises and sold to Microsoft in 1989 TrueType is an Outline font standard originally developed by Apple Computer in the late 1980s as a competitor to Adobe 's Type 1 fonts This article is about font technology For information about the typographic appearance of individual font sets see Typefaces A computer font (or Some third-party PostScript-compatible interpreters are still widely used in printers, particularly PhoenixPage, which is standard in black-and-white Hewlett-Packard laser printers (as of 2006). Year 2006 ( MMVI) was a Common year starting on Sunday of the Gregorian calendar.
Many basic, inexpensive laser printers don't support PostScript, instead coming with drivers that simply rasterize the platform's native graphics formats rather than converting them to PostScript first. When PostScript support is needed for such a printer, a free PostScript-compatible interpreter called Ghostscript can be used. Free software or software libre is Software that can be used studied and modified without restriction and which can be copied and redistributed in modified or unmodified Ghostscript is a suite of Software based on an interpreter for Adobe Systems ' PostScript and Portable Document Format (PDF Page description Ghostscript prints PostScript documents on non-PostScript printers using the CPU of the host computer to do the rasterization, sending the result as a single large bitmap to the printer. Ghostscript can also be used to preview PostScript documents on a computer monitor and to convert PostScript pages into raster graphics such as TIFF and PNG, and vector formats such as PDF. Portable Network Graphics ( PNG) is a bitmapped image format that employs Lossless data compression.
Very high-resolution devices, such as imagesetters or CTP platesetters, in which resolutions exceeding 2500 dpi are common, still require external RIPs with large amounts of memory and hard drive space. An imagesetter is an ultra-high resolution large-format computer output device Computer to plate (CTP is an Imaging technology used in modern printing processes. A platesetter is a machine which receives a raster image from a Raster image processor and in turn creates a lithographic plate suitable for use on an Offset Very high-end laser printer systems (known as digital presses) also use an external RIP to separate the more readily-upgradable computer from the specialized printing hardware. Companies such as EFI and Xitron specialize in such RIP software.
With PostScript becoming a de facto standard for printed output, it was natural to consider using the same language for describing the screen output as well. The rapid increase in CPU power in the late 1980s, combined with an interest in windowing systems, led to several attempts to create a display system that used PostScript as its primary display technology.
There are a number of advantages to using PS as the display system. One is that the fonts on other systems required the user to keep not only bitmaps for the screen, but also Type 1 for the printer. Using PS on the display would eliminate this and require only one set. Another advantage is that it allows for the dumbing down of printers. The term "dumb-down" was coined by Ken E Smith of Colorado according to the Oxford English Dictionary, which has the official definition of the term as used by Mr When the LaserWriter was released it was the most powerful (and expensive) machine in Apple's lineup, a result of needing considerable processing power and memory to render the page at a resolution of 300 dpi in a reasonable amount of time. Dots per inch ( DPI) is a measure of spatial Printing or Video dot density in particular the number of individual dots that can be placed within the span In contrast, the 400-dpi printer that shipped with the NeXT platform contained no image renderer at all, instead using the computer's CPU to do the rendering and passing the rendered page as a bitmap to the printer. NeXT Computer Inc (later NeXT Software Inc) was an American Computer company headquartered in Redwood City, California that In Computer graphics, a bitmap or pixmap is a type of memory organization or Image file format used to store Digital images The (See also GDI printer. The Graphics Device Interface (GDI is one of the three core components or "subsystems" together with the kernel and the Windows API for the user interface )
The main advantage in using PostScript as a windowing system is that it allows one to write desktop publishing (DTP) and other graphically-intensive applications with a single set of graphics routines. Desktop publishing (also known as DTP) combines a Personal computer and WYSIWYG page layout Software to create Publication Documents The same code that generates bitmaps for the window can be used to generate bitmaps for the printer without any translation. DTP applications on traditional systems require the programmer to construct the GUI editor in the platform's own graphics system (for example, QuickDraw on the Macintosh, or Graphics Device Interface (GDI) on Microsoft Windows) and then write additional code to translate the graphics into proper PostScript for printing. Quickdraw also refers to equipment used for Rock climbing. QuickDraw is the 2D graphics library and associated Macintosh, commonly nicknamed Mac is a Brand name which covers several lines of Personal computers designed developed and marketed by Apple Inc The Graphics Device Interface (GDI is one of the three core components or "subsystems" together with the kernel and the Windows API for the user interface Microsoft Windows is a series of Software Operating systems and Graphical user interfaces produced by Microsoft. This often takes up most of the programming effort on such projects and is a major source of bugs.
The two main examples of PostScript as a display technology are Display PostScript (DPS) and NeWS. Display PostScript (or DPS) is an on-screen display system As the name implies DPS uses the PostScript (PS imaging model and language to generate on-screen graphics News is any new information or information on Current events which is presented by print, broadcast, Internet, or Word of mouth They differed dramatically in terms of where the display logic was applied; in DPS the view system was left to the hosting OS, whereas under NeWS the entire display was written in PS and ran in a single complex interpreter.
PostScript is a Turing-complete programming language. In computability theory, several closely-related terms are used to describe the "computational power" of a computational system (such as an Abstract machine or Typically, PostScript programs are not produced by humans, but by other programs. However, it is possible to produce graphics or to perform calculations by hand-crafting PostScript programs.
PostScript is an interpreted, stack-based language similar to Forth but with strong dynamic typing, data structures inspired by those found in Lisp, scoped memory and, since language level 2, garbage collection. A stack-oriented programming language is one that relies on a Stack machine model for passing parameters Forth is a structured, imperative, stack-based, computer Programming language and programming environment In Computer science, a type system defines how a Programming language classifies values and expressions into '''types''', how it can Lisp (or LISP) is a family of Computer Programming languages with a long history and a distinctive fully parenthesized syntax In Computer science, garbage collection ( GC) is a form of automatic Memory management. The language syntax uses reverse Polish notation, which makes parentheses unnecessary, but reading a program requires some practice, because one has to keep the layout of the stack in mind. Reverse Polish notation (or just RPN) by analogy with the related Polish notation, a prefix notation introduced in 1920 by the Polish mathematician Most operators (what other languages term functions) take their arguments from the stack, and place their results onto the stack. Literals (for example numbers) have the effect of placing a copy of themselves on the stack. Sophisticated data structures can be built on the array and dictionary types, but cannot be declared to the type system, which sees them all only as arrays and dictionaries, so any further typing discipline to be applied to such user-defined "types" is left to the code that implements them.
Example:
3 4 add 5 1 sub mul
will compute (3 + 4) × (5 − 1). Reverse Polish notation (or just RPN) by analogy with the related Polish notation, a prefix notation introduced in 1920 by the Polish mathematician
PostScript variables are placed on a dictionary stack where everything that is not a literal is looked up. On a match, the current value stored under the name is pushed (or rather, executed — see below). If a variable that is not in the dictionary stack is searched for, it is termed a mismatch, resulting in an error. To place something in the current dictionary (i. e. the topmost dictionary on the dictionary stack) one needs the def operator, which takes a name and a value as its arguments. Names are constructed by prefixing (or quoting) with a slash. So
/x1 15 def
will first push the name "x1" on the stack, then the value 15, then execute def which will take both from the stack, and write 15 into the current dictionary under the name "x1". Later occurrences of "x1" (not to be confused with "/x1") will push 15 onto the stack as long as the variable is unchanged. This code will increment the content of x1 by 2, assuming x1 is already present in the current dictionary:
/x1 x1 2 add def
Several Postscript operators rearrange or manipulate the stack: duplicate (dup), discard (pop) and exchange (exch) operate on elements at the top of the stack, whereas roll rotates a specified section of the stack, copy duplicates a specified portion, and index lets you access the stack like an array.
Some programming utility is offered by { and }. The opening brace puts the interpreter in deferred execution mode, so that everything is just placed on the stack, even operators and other executable objects. The one exception is the closing brace, which takes everything put on the stack since the opening brace, bundles it up into an (anonymous) procedure, and places that on the stack.
This construct is used in various ways, for subroutine definition (the anonymous procedure is assigned to a variable), loops, conditionals, etc. Example:
x1 0 eq { 0 } { 1 x1 div } ifelse
This code first uses the eq operator to test whether the value of x1 is equal to 0; depending on the outcome eq will push true or false onto the stack. After that, two procedures are pushed onto the stack. Then ifelse is executed, which takes three arguments from the stack, and will execute either the second (if the third is true) or first (if the third is false). In summary, 0 results if x1 is 0, 1/x1 is the result for all other cases.
/inc3 { 3 add } def
Here def is used to place something in the current dictionary, only this time it is a procedure instead of a simple integer. This works because the values coming from the dictionary are executed, not just pushed (as simplistically stated above). Since executing a literal amounts to pushing it, that did not make a difference before. Now executing "inc3" will first look it up in the dictionary, find the procedure object representing "{ 3 add }" and execute that. One value must reside on the stack for this to work, since add needs two arguments, only one of which is given in the procedure itself. Naturally, one passes arguments to procedures by placing them on the stack, so we can simply view "inc3" as a procedure that takes one argument. Example call:
71 inc3
will put 71 on the stack, which inc3 will increment by three, for a final result of 74.
Procedures are simply executable arrays, so they can also be created 'manually':
/inc3 [ 3 /add load ] cvx def
Warning: the above will only work if add is still an operator. If it had been redefined as a procedure an additional exec would be required. However, the exec operator may similarly have been redefined. . . the solution of which is left as an exercise for the reader!
To produce graphics, PostScript uses an ordinary cartesian coordinate system. In Mathematics, the Cartesian coordinate system (also called rectangular coordinate system) is used to determine each point uniquely in a plane
100 200 moveto 300 400 lineto stroke
moves the "cursor" to the point with coordinates (100, 200) and then draws a line to the point (300, 400).
50 70 moveto 100 200 50 80 100 100 curveto stroke
produces a cubic Bézier curve from (50, 70) to (100, 100) with control points (100, 200) and (50, 80). In the mathematical field of Numerical analysis, a Bézier curve is a Parametric curve important in Computer graphics and related fields
250 250 moveto (Wikipedia) show
will create the text "Wikipedia" at coordinate location (250, 250), rendered in a preselected font (using a possible command string such as /Courier findfont 12 scalefont setfont)
Graphics are initially specified in the "user coordinate system". These are then passed through a 2D transformation matrix in order to translate them into the final "device coordinate system". In Linear algebra, Linear transformations can be represented by matrices. Postscript offers commands to manipulate the transformation matrix in useful ways.
200 300 translate 45 rotate
will manipulate the transformation matrix to add a translation of the user coordinate system 200 units upwards, 300 units to the right and rotate it 45 degrees. This is cumulative to any transformations previously specified.
The default transformation is specified as providing units that are 1/72 inch long, with the origin located at the bottom left of the output device. [1]
The character "%" is used to introduce comments in PostScript programs. As a general convention, every PostScript program should start with the characters "%!" so that all devices will properly interpret it as PostScript.
A Hello World program, the customary way to show a small example of a complete program in a given language, might look like this in Postscript:
%!PS /Courier findfont 20 scalefont setfont 72 500 moveto (Hello world!) show showpage
or if the output device has a console
%!PS (Hello world!) =
This article was originally based on material from the Free On-line Dictionary of Computing, which is licensed under the GFDL. The Free On-line Dictionary of Computing ( FOLDOC) is an online searchable encyclopedic Dictionary of Computing subjects The GNU Free Documentation License ( GNU FDL or simply GFDL) is a Copyleft License for free documentation designed by the Free Software