Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #129
| From | luser- -droog <mijoryx@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.postscript |
| Subject | yet another prototype document formatting engine |
| Date | 2011-04-24 23:09 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <4c697d14-fab4-4e0f-addb-cf2d48f9cf2c@p23g2000vbl.googlegroups.com> (permalink) |
This implements a very bare-bones text-with-embedded-
control-codes processor. I'm hoping the 'clippath pathbbox'
will eliminate all that letter/a4 gibberish.
Comments welcome.
504(0)12:54 AM:ps 0> cat ibis.ps
%!
/show { dup print show } bind def
/inch {72 mul} def
/pagesize [ clippath pathbbox ] def
%/letter {/pagesize [8.5 inch 11 inch] def} def
/setbounds {
/Y exch def
/X exch def
/y exch def
/x exch def
} def
/savebounds {
/bnds [ x y X Y ] def
} def
/resetbounds {
bnds aload pop setbounds
} def
% n margin -
% set margin to n points from edges
/margin {
clippath pathbbox
4 index sub 4 1 roll
4 index sub 4 1 roll
4 index add 4 1 roll
4 index add 4 1 roll
setbounds savebounds
pop
} def
/eol {
(\n) print
x
Y lead sub
dup /Y exch def
moveto
Y y lt { showpage startpage } if
} def
/blank {
eol
} def
/startpage {
resetbounds
eol
} def
% str part -
% show the string
/part {
show
} def
% show a space
/space {
( ) part
} def
/escape (\\) def
% str scan -
% scan a string for the escape sequence
% execute pre part
% pull token from
%
/scan {
dup length 0 eq {
pop blank
}{
escape search {
part
space
pop
token {
exec scan
} if
}{
part eol
} ifelse
} ifelse
} def
/buf 500 string def
% file|string ibis -
% process a source file (by name if string)
/ibis {
dup type /stringtype eq { (r) file } if
dup type /filetype ne { /ibis cvx /typecheck cvx .error } if
/src exch def
{
src buf readline exch
scan
not { exit } if
} loop
} def
/r { /Palatino-Roman 15 selectfont
lead 20 lt { /lead 20 def } if
} def
/i { /Palatino-Italic 15 selectfont
lead 20 lt { /lead 20 def } if
} def
%letter
1 inch margin savebounds
/lead 0 def
r
startpage
currentfile ibis
Lorem ipsum dolor sit amet, consectataur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim\i ad minim\r veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur.
\exit
pop pop
/escape <abcdef00> def
% To run this program upon itself, we must redefine the
% escape string in such a manner that the semantic
% content does not match the syntactic structure
% (so it doesn't choke upon reading this very
% definition), ie. an encoded form.
% Otherwise, it would attempt to execute the name '\',
% and probably won't find such a thing defined.
(ibis.ps)(r)file ibis
Back to comp.lang.postscript | Previous | Next — Next in thread | Find similar
yet another prototype document formatting engine luser- -droog <mijoryx@yahoo.com> - 2011-04-24 23:09 -0700
Re: yet another prototype document formatting engine luser- -droog <mijoryx@yahoo.com> - 2011-04-25 09:00 -0700
Re: yet another prototype document formatting engine luser- -droog <mijoryx@yahoo.com> - 2011-04-26 21:59 -0700
Re: yet another prototype document formatting engine luser- -droog <mijoryx@yahoo.com> - 2011-04-28 01:28 -0700
document formatting engine - broken luser- -droog <mijoryx@yahoo.com> - 2011-05-12 23:19 -0700
csiph-web