%! <> setpagedevice %-------------------------XXX***XXX------------------------ %The idea of the following definition of PostScript routines is %to get tree basic lay out concept for my book. %Top text with Drop Capitals this is a three step procedure: %1. (capital ) dc %2. (longer text string ) p %3. viewing with "Ghostview" and adjusting to bring the forth line %back to the left margin with '0 LM' and make: %(the rest of longer text string is made like this ) pl %Top text plan which is simple: %(Longer text string ) pl %Bottom text which is %(Longer text string ) bt %More over there will be two simple text setting concepts %That does not do automatic string breaking (Line Wrap) %(Show text string, go to new line ) n %(Center the string, go to new line ) c %And one that does just an empty line L %-------------------------XXX***XXX------------------------ %The definition of routines grow in complexity as the text advances %Any line beginning with -> % %is beaning ignored by the PostScript interpreter, in that way %I can comment the program inside the program source. %Before any new step I will sum up on the new operators being %used in the following so one can cape track of what is definitions %and what is operators. Most of this routines comes from %David Byram-Wigfields book Practical PostScript but the %examples in the book has errors so I found better codes %in his minidict %http://www.cappella.demon.co.uk/division/minidict.html/ %-------------------------XXX***XXX------------------------ %------------START DEFINING ROUTINES (DEFINITIONS) -------- %-------------------------XXX***XXX------------------------ %..Variables..TM, BM, LM and RM are just variables containing numbers %that can be changed along the way, but in a refined manner they %will serve as margins in a text box. %Operators: exch, def. /TM { /tm exch def } def 491 TM %Top margin /BM { /bm exch def } def 0 BM %Bottom margin /LM { /lm exch def } def 0 LM %Left margin /RM { /rm exch def } def 384 RM %Right margin /LG { /lg exch def } def 16 LG %Line hight %-------------------------XXX***XXX------------------------ %..Definition.. The 'textbox' routine can be used to recall %the original setting of the above variables when ever you %need it. For instance when you start a new page. %(No new operators used) /textbox { 491 TM 0 BM 0 LM 384 RM 16 LG } def %-------------------------XXX***XXX------------------------ %..Definition.. Sins the format of my book pages is smaller then %A4. I place my book pages on an A4 page horizontal centered %and vertically placed towards the top of the paper. % __________ %| | | | %| | | | %| |______| | %| | %|__________| % %This routine should be called to begin the text setting of any %any pages. That means that if you want text on top of image %you first have the images and then after that you put in %'text_go' to start the typesetting section on that same page. % %(No new operators used). /text_go { textbox gsave 104 253 translate } def %-------------------------XXX***XXX------------------------ %..Abbreviation.. A shortening of the name of an often %used operator. New operators used: show, load. /s /show load def %-------------------------XXX***XXX------------------------ %..Definitions.. New operators used: sub, moveto. /newline { tm lg sub /tm exch def lm tm moveto } def /L { newline } def /n { s L } def %-------------------------XXX***XXX------------------------ %..Definitions.. Two routines for measuring. %New operators used: currentpoint, stringwidth, pop, dup /cpp { currentpoint pop } def % where are we? /dsp { dup stringwidth pop } def % how long is the chosen text? %-------------------------XXX***XXX------------------------ %..Definitions.. Routines for centering text within the textbox. %New operators used: div, exch, add /center { dsp 2 div %measure length of text: pop the vertical y: halve % rm lm sub 2 div %linewidth: subtract left from right margin: halve % exch sub lm add tm moveto %swap round: subtract: add left margin: move % } def %complete definition % /c { center n } def %abbreviated 'center' command: print: move to next line % %-------------------------XXX***XXX------------------------ %..Definitions.. Routines for Drop Capitals.. my own hack, %(No new operators used). /dc { /Times-Bolt-Italic findfont 65 scalefont setfont tm 32 sub /tm exch def lm tm moveto dup s /Times-Bolt-Italic findfont 16 scalefont setfont cpp 10 sub LM tm 32 add TM lm tm moveto } def %-------------------------XXX***XXX------------------------ %..Definitions.. Routines for bottom aligned text.. my own hack. %New operators used: floor = (get rid of decimal numbers) /btinn { dsp dup rm lm sub div lg 2 mul mul add rm lm sub div floor 1 sub lg mul TM } def %-------------------------XXX***XXX------------------------ %..Definitions.. Routines for Line Wrap. Here the complexity is %growing much and I actually am not able to analyze all that is %happening, but I need this so "Thank you David Byram-Wigfields." %New operators used: search, roll, exit, ifelse, loop, copy, %string, index, putinterval, gt /space ( ) def /ssp { space search pop } def % look for spaces /find { search { pop 3 -1 roll 1 add 3 1 roll } { pop exit } ifelse } bind def /spacecount { 0 exch ( ) { find } loop } def /glue { 2 copy length exch length add string dup 4 2 roll 2 index 0 3 index putinterval exch length exch putinterval } bind def /rejoin { ssp exch glue } def /toofar? { rejoin dsp cpp add rm gt } def /p { dup spacecount { toofar? { L s } { s } ifelse } repeat pop L } bind def /pl { lm tm moveto p } def /bt { btinn pl } def %-------------------------XXX***XXX------------------------ %----------- END OF DEFINING ROUTINES (DEFINITIONS) ------- %-------------------------XXX***XXX------------------------ text_go /Times-Bolt-Italic findfont 16 scalefont setfont 0.07 0.03 0.29 setrgbcolor L L L /Times-Bolt-Italic findfont 36 scalefont setfont (Direct ) c L (PostScript ) c L /Times-Bolt-Italic findfont 16 scalefont setfont (A nice way of expressing one self ) c L L L L (Partly home made and partly put togther from ) c (David Byram-Wigfields book ) c L (by ) c L /Times-Bolt-Italic findfont 24 scalefont setfont (Mikkel Meinike Nielsen ) c /Times-Bolt-Italic findfont 16 scalefont setfont L L L L (Thanks to the deferent people from deferent mailing lists ) c (who have bin helping me along the way of making this ) c 0 TM (FORLAG ) c grestore showpage %-------------------- *** New Page *** ------------------ text_go (S ) dc (o far, we have constructed a textbox to place the text on the page and made commands for centering text. In order to typeset properly, we will obviously need ) p 0 LM (some form of linewrap to break paragraphed text into lines that suit the textbox width ) pl ( The minidict page command moves the textbox to the place chosen by the translation values. You can change your typeface and pointsize as you wish, but sins I don't need that for my book I left out the routines needed for doing in-line font changes in this program. The paragraph is typed between parentheses, otherwise known as brackets. ) bt grestore showpage