收藏 分享(赏)

postscript语言教程与手册-DAddison-Wesley.PDF

上传人:weiwoduzun 文档编号:4034742 上传时间:2018-12-05 格式:PDF 页数:242 大小:847.07KB
下载 相关 举报
postscript语言教程与手册-DAddison-Wesley.PDF_第1页
第1页 / 共242页
postscript语言教程与手册-DAddison-Wesley.PDF_第2页
第2页 / 共242页
postscript语言教程与手册-DAddison-Wesley.PDF_第3页
第3页 / 共242页
postscript语言教程与手册-DAddison-Wesley.PDF_第4页
第4页 / 共242页
postscript语言教程与手册-DAddison-Wesley.PDF_第5页
第5页 / 共242页
点击查看更多>>
资源描述

1、 LANGUAGETUTORIALandCOOKBOOKADOBE SYSTEMSINCORPORATEDAddison-Wesley Publishing Company, Inc.Reading, Massachusetts Menlo Park, CaliforniaDon Mills, Ontario Wokingham, England AmsterdamSydney Singapore Tokyo MadridBogot Santiago San JuanLibrary of Congress Cataloging in Publication DataMain entry und

2、er title:Postscript language tutorial and cookbook.Includes index.1. PostScript (Computer program language)I. Adobe Systems.QA76.73.P67P68 1985 005.133 85-15694ISBN 0-201-10179-3Copyright 1985 by Adobe Systems Incorporated.All rights reserved. No part of this publication may bereproduced, stored in

3、a retrieval system, or transmitted, in anyform or by any means, electronic, mechanical, photocopying,recording, or otherwise, without the prior written permissionof the publisher.Printed in the United States of America.Published simultaneously in Canada.POSTSCRIPT is a trademark of Adobe Systems Inc

4、orporated.Times is a trademark and Helvetica is a registered trademark ofAllied Corporation.Linotron 101 is a registered trademark of Allied Corporation.Scribe and UNILOGIC are registered trademarks of UNILOGIC, Ltd.Apple, AppleTalk, and MacTerminal are trademarks ofApple Computer, Inc.Macintosh is

5、a trademark licensed to Apple Computer, Inc.The information in this book is furnished for informational use only, issubject to change without notice, and should not be construed as acommitment by Adobe Systems Incorporated. Adobe SystemsIncorporated assumes no responsibility or liability for any err

6、ors orinaccuracies that may appear in this book. The software described inthis book is furnished under license and may only be used or copied inaccordance with the terms of such license.ABCDEFGHIJ-HA-898765Second printing: December 1985ivContentsPREFACE ixPOSTSCRIPT LANGUAGETUTORIALCHAPTER 1 INTRODU

7、CTION1.1 POSTSCRIPT as a Page Description Language 11.2 POSTSCRIPT as a Programming Language 4CHAPTER 2 STACK AND ARITHMETIC2.1 The POSTSCRIPT Stack 72.2 Arithmetic 82.3 Interactive Stack Operators 122.4 New Operator Summaries 142.5 Operator Summary 15CHAPTER 3 BEGINNING GRAPHICS3.1 Drawing Lines 18

8、3.2 Filled Shapes 223.3 Operator Summary 25CHAPTER 4 PROCEDURES AND VARIABLES4.1 POSTSCRIPT Dictionaries 274.2 Defining Variables and Procedures 284.3 Using Procedures and Variables 304.4 Operator Summary 33CHAPTER 5 PRINTING TEXT5.1 POSTSCRIPT Fonts 355.2 Printing Variety 385.3 Operator Summary 46v

9、CHAPTER 6 MORE GRAPHICS6.1 Coordinate Systems 476.2 Graphics State 506.3 Curves 536.4 Operator Summary 60CHAPTER 7 LOOPS AND CONDITIONALS7.1 Conditional Execution 627.2 Loops 677.3 Operator Summary 76CHAPTER 8 ARRAYS8.1 POSTSCRIPT Arrays 778.2 Array Operators 788.3 Operator Summary 86CHAPTER 9 MORE

10、FONTS9.1 Different Shows 879.2 Character Encoding 919.3 Font Transformations 949.4 Character Outlines 979.5 Operator Summary 100CHAPTER 10 CLIPPING AND LINE DETAILS10.1 Clipping Path 10110.2 Line-Drawing Details 10410.3 Operator Summary 110CHAPTER 11 IMAGES11.1 The image Operator 11111.2 Operator Su

11、mmary 117CHAPTER 12 POSTSCRIPT PRINTERS12.1 Apple LaserWriter 119viPOSTSCRIPT LANGUAGECOOKBOOKINTRODUCTIONFORMAT OF THE EXAMPLES 125HOW TO USE THE COOKBOOK 126BASIC GRAPHICSABOUT THE PROGRAMS 129DICTIONARIES AND LOCAL VARIABLES 130Program 1 / Repeated Shapes 135Program 2 / Expanded and Constant Widt

12、h Lines 137Program 3 / Elliptical Arcs 139Program 4 / Drawing Arrows 143Program 5 / Centered Dash Patterns 147Program 6 / Printing Images 151PRINTING TEXTABOUT THE PROGRAMS 155Program 7 / Printing with Small Caps 159Program 8 / Setting Fractions 163Program 9 / Vertical Text 167Program 10 / Circular

13、Text 169Program 11 / Placing Text Along an Arbitrary Path 173APPLICATIONSABOUT THE PROGRAMS 177Program 12 / A Simple Line Breaking Algorithm 181Program 13 / Making a Poster 185Program 14 / Drawing a Pie Chart 189Program 15 / Filling an Area with a Pattern 193MODIFYING AND CREATING FONTSMODIFYING EXI

14、STING FONTS 199CREATING NEW FONTS 200ABOUT THE PROGRAMS 201Program 16 / Making an Outline Font 205Program 17 / Re-encoding an Entire Font 209Program 18 / Making Small Changes to Encoding Vectors 213Program 19 / Changing the Character Widths of a Font 217Program 20 / Creating an Analytic Font 221Prog

15、ram 21 / Creating a Bitmap Font 225viiFOR FURTHER REFERENCE 229QUOTATIONS 231APPENDIX OPERATOR SUMMARYINDEX 241viiiPrefaceThe POSTSCRIPT page description language provides a device in-dependent standard for representing the printed page. This bookis designed to be a companion piece to the POSTSCRIPT

16、 Lan-guage Reference Manual. It presents illustrative material to aidin understanding the POSTSCRIPT language. The tutorial infor-mation presented here has been deliberately separated from thereference manual to help ensure that the defining document of-fers a precise, unambiguous definition of the

17、language and asso-ciated graphics imaging model. In all cases, when questions ofdefinition or precise specification are raised, the POSTSCRIPTLanguage Reference Manual is the final word.This book actually contains two documents: the POSTSCRIPTLanguage Tutorial and the POSTSCRIPT Language Cookbook.Th

18、e tutorial provides an easy, informal introduction to thePOSTSCRIPT language and its graphics primitives. The tutorialsstyle and level of presentation is aimed at programmers whowish to design and implement applications, such as wordprocessing packages, graphics illustrators, and CAD/CAM draw-ing sy

19、stems. It is interactively oriented, and written with the as-sumption that you, the reader, already know how to program.You are encouraged to try variations of the examples presentedin the tutorial on a POSTSCRIPT printer as you work your waythrough the book.The cookbook is, as its name suggests, a

20、collection of programsthat are offered as examples of POSTSCRIPT usage. Thesesamples have been chosen both as illustrations of the functionalrange of POSTSCRIPT and as useful ingredients for inclusion inapplication packages that you design. The cookbook samplesdemonstrate techniques for rendering qu

21、ality graphics, achievingeffective typography with digital fonts, and maintaining truedevice independence. Again, you are encouraged to experimentwith variations of these samples on a POSTSCRIPT printer as youdevelop your own applications.ixThe principal authors of this material are Linda Gass and J

22、ohnDeubert. The final organization and the majority of the materialfor the POSTSCRIPT Language Tutorial is due to John Deubert.Ed Taft reviewed and proofread the material during the laterstages of its production. Linda Gass designed and developed thePOSTSCRIPT Language Cookbook and she is the princi

23、pal authorof both the examples and the explanatory text. The seminal ideaof the cookbook is due to Doug Brotz and several of the illustra-tions in the cookbook are due to John Warnock. Andy Shoreproofread the text and POSTSCRIPT sample programs. The bookdesign was specified by Bob Ishi and was imple

24、mented by AndyShore and Brian Reid. The index was compiled by StevenSorensen.The art of printing is rich in tradition, and the technology forproducing the printed page has evolved over centuries. We atAdobe Systems are pleased to offer POSTSCRIPT as a tool forprinting in the electronic age. I believ

25、e that this tutorial materialwill significantly enhance your ability to explore this excitingtechnology and help you enjoy the process of discovering theworld of electronic printing.Charles GeschkeAugust 1985xCHAPTER 1INTRODUCTIONABACBACABDCEABDCEFABDThe POSTSCRIPT language is a programming language

26、 designedto convey a description of virtually any desired page to a printer.It possesses a wide range of graphic operators that may be com-bined in any manner. It contains variables and allows the com-bining of operators into more complex procedures and functions.POSTSCRIPT page descriptions are pro

27、grams to be run by an in-terpreter. POSTSCRIPT programs are usually generated by appli-cation programs running on other computers. However, manyPOSTSCRIPT printers, including the Apple LaserWriter, have aninteractive state in which the user may program directly inPOSTSCRIPT (see section 12.1).1.1 PO

28、STSCRIPT AS A PAGE DESCRIPTION LANGUAGEPOSTSCRIPT has a large selection of graphics operators that al-low it to precisely describe a desired page. These operators con-trol the placement of three types of graphics objects: Text in a wide variety of typefaces can be placed on a pagein any position, or

29、ientation, and scale. Geometric figures can be constructed using POSTSCRIPTgraphics operators. These describe the locations of straight1lines and curves of any size, orientation, and width, as wellas filled spaces of any size, shape, and color. Sampled Images of digitized photographs, free-handsketc

30、hes, or any other image may be placed on a page inany scale or orientation.All graphic objects may be easily rotated, scaled, and clipped toa specified portion of the output page.POSTSCRIPT Imaging ModelAn imaging model is the set of rules that are incorporated intothe design of a graphics system. T

31、he POSTSCRIPT imaging modelis very similar to the model we instinctively adopt when we drawby hand.The POSTSCRIPT model considers an image to be built up byplacing ink on a page in selected areas. The ink may form letters,lines, filled shapes, or halftone representations of photographs.The ink itsel

32、f may be black, white, colored, or any shade of gray.These elements may be cropped to a boundary of any shape asthey are placed on the page. Once the page has been built up tothe desired form, it may be printed on an output device.Three concepts are central to the implementation of thePOSTSCRIPT ima

33、ging model:Current Page: The current page is the “ideal page” on whichPOSTSCRIPT draws. It is independent of the capabilities of theprinter being used.When a program begins, the current page is completely empty.POSTSCRIPT painting operators place marks on the current page,each of which completely ob

34、scures marks that they may overlay.Once the current page is completely described, it is sent to theprinter, which reproduces the page as well as it can.It is important to remember that no matter what color a markhas white, gray, black, or color it is put onto the currentpage as if it were applied wi

35、th opaque paint.Current Path: The current path is a set of connected and dis-2 Chapter 1: INTRODUCTIONconnected points, lines, and curves that together describe shapesand their positions. There is no restriction to the shapes that maybe defined by the current path; they may be convex or concave,even

36、 self-intersecting. The elements of the current path arespecified in terms of their positions on the current page. Theresolution of the printer in use in no way constrains the defini-tion of the path.The current path is not itself a mark on the current page.POSTSCRIPT path operators define the curre

37、nt path, but do notmark the page. Once a path has been defined, it can be strokedonto the current page (resulting in a line drawn along the path),filled (yielding solid regions of ink), or used as a clipping bound-ary.Clipping Path: The current clipping path is the boundary ofthe area that may be dr

38、awn upon. Initially, the clipping pathmatches the printers default paper size. The clipping path maybe changed to any size and shape desired. If an imaging operatortries to mark the current page outside of the current clippingpath, only those parts of the mark that fall within the clippingpath will

39、actually be drawn onto the current page.Coordinate SystemsPositions on a page are described as x and y pairs in a coordinatesystem imposed on the page.Every output device has a built-in coordinate system by which itaddresses points on a page. We call this built-in coordinate sys-tem, idiosyncratic t

40、o each device, device space. Device spacevaries widely from printer to printer; there is no uniformity in theplacement of coordinate origins or in horizontal and verticalscaling.Positions on the POSTSCRIPT current page are described in termsof a user coordinate system or user space. This coordinate

41、sys-tem is independent of the printers device space. Coordinates in aPOSTSCRIPT program are automatically transformed from userspace into the printers device space before printing the currentpage. User space thus provides a coordinate system within whicha page may be described without regard for the

42、 particularmachine on which the page is to be printed.1.1 POSTSCRIPT AS A PAGE DESCRIPTION LANGUAGE 3The POSTSCRIPT user space can be altered in three ways. Thecoordinate systems origin may be translated, moved to anypoint in user space. The axes may be rotated to any orientation.The axes may be sca

43、led to any degree desired; the scaling maybe different in the x and y directions. A sophisticated user mayspecify any linear transformation from user space to devicespace. Thus, coordinates in a POSTSCRIPT program are change-able with respect to the current page, since they are describedfrom within

44、a coordinate system that may slide around, turn,shrink, or expand.1.2 POSTSCRIPT AS A PROGRAMMING LANGUAGEAbout one-third of the POSTSCRIPT language is devoted tographics. The remainder makes up an entirely general computerprogramming language. The POSTSCRIPT language contains ele-ments of many othe

45、r programming languages, but most closelyresembles the FORTH language.POSTSCRIPT StackPOSTSCRIPT reserves a piece of memory called a stack for thedata with which it is working. The stack behaves like a stack ofbooks. The last book placed on the stack is the first book thatwill later be removed. Simi

46、larly, numbers, strings, and otherpieces of data placed on the stack will be removed in reverseorder, the last item added to the stack being the first retrieved.Postfix NotationPOSTSCRIPT operators that require numbers or other data, suchas add and sub, retrieve that data from the stack. To use anop

47、erator, one must first place the data it requires, its operands,on the stack, and then call the operator. The operator will placeits own results on the stack. This style of programming, in whichthe operands are specified before the operator, is referred to aspostfix notation.4 Chapter 1: INTRODUCTIO

48、NPOSTSCRIPT Data TypesPOSTSCRIPT supports many data types common to other lan-guages, including reals, booleans, arrays, and strings. ThePOSTSCRIPT language also defines object types such asdictionary and mark. For descriptions of all the POSTSCRIPT dataand object types, refer to the POSTSCRIPT Lang

49、uage ReferenceManual.POSTSCRIPT FlexibilityPOSTSCRIPT is an extremely flexible language. Functions that donot exist, but which would be useful for an application, can bedefined and then used like other POSTSCRIPT operators. Thus,POSTSCRIPT is not a fixed tool within whose limits an appli-cation must be written, but is an environment that can bechanged to match the task at hand. Pieces of one page descrip-tion can be used to compose other, more complicated pages.Such pieces can be used in their original form or translated,rotated, and scaled to form a myriad of

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 实用文档 > 简明教程

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报