Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #3504
| From | news@zzo38computer.org.invalid |
|---|---|
| Newsgroups | comp.lang.postscript |
| Subject | Some general purpose PostScript procedures - multiget scanpath straccum strfinish |
| Date | 2020-04-14 16:17 -0700 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <1586905414.bystand@zzo38computer.org> (permalink) |
As part of TeXnicard, I wrote many PostScript procedures. Many of them are
not usable outside of TeXnicard, but a few of them are. Maybe you might
find some of them useful; I don't know. But I found it useful.
The multiget procedure is used to retrieve multiple entries from a
dictionary, and put them into an array. It might be useful with
writeobject or with some other things too. (Unfortunately, this
implementation does not work with objects other than dictionaries, since
known is only compatible with dictionaries.)
/multiget { %( dict array -- array )
<< >> begin
exch /A exch def
/B 1 index length def
{
A 1 index known {
A exch get
} {
pop null
} ifelse
} forall
B array astore
end
} bind def
The straccum and strfinish procedures are used for string accumulation.
You can write data into the file to result a string with all of the data
that has been accumulated.
/_straccum [null] def
/straccum { %( -- file )
[<< /N 0 /T 0 >> {
begin {
dup length 0 eq {
pop
} {
/T 1 index length T add def
N exch def
/N N 1 add def
} ifelse
1024 string
} {
//_straccum 0 currentdict put
N exch def
()
} ifelse end
} //systemdict /exec get] cvx /NullEncode filter
} bind def
/strfinish { %( file -- string )
closefile //_straccum 0 get //_straccum 0 null put
begin
/S T N load length add string def 0
0 1 N {
load
S 2 index 2 index putinterval
length add
} for
pop S end
} bind def
currentdict /_straccum undef
The scanpath procedure is used to convert a monotone path into an array
to find the left and right boundary per scanline. Some algorithms may use
this for something, such as typesetting text into an area of some shape
that isn't rectangular.
/scanpath { %( -- array )
gsave [
matrix setmatrix initclip clip
pathbbox cvi exch pop exch cvi 3 -1 roll pop
dup 1 3 index {
clipsave
0 exch 65535 1 rectclip
clippath pathbbox pop exch pop
cvi exch cvi
cliprestore
} for
] grestore
} bind def
All of these codes are public domain.
You can also mention comment if you have a use for it, improvements of it,
complaints, questions, and/or other comments, please.
--
This signature intentionally left blank.
(But if it has these words, then actually it isn't blank, isn't it?)
Back to comp.lang.postscript | Previous | Next — Next in thread | Find similar
Some general purpose PostScript procedures - multiget scanpath straccum strfinish news@zzo38computer.org.invalid - 2020-04-14 16:17 -0700
Re: Some general purpose PostScript procedures - multiget scanpath straccum strfinish luser droog <luser.droog@gmail.com> - 2020-04-14 22:30 -0700
Re: Some general purpose PostScript procedures - multiget scanpath straccum strfinish luser droog <luser.droog@gmail.com> - 2020-04-16 23:02 -0700
csiph-web