Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #2253
| From | ken <ken@spamcop.net> |
|---|---|
| Newsgroups | comp.lang.postscript |
| Subject | Re: . bbox of a set of glyphs |
| Date | 2015-05-08 12:06 +0100 |
| Message-ID | <MPG.2fb6a8f514227b4d9898f6@usenet.plus.net> (permalink) |
| References | <e960544e-41e2-4c87-bda4-dca56daf7c41@googlegroups.com> <766aec49-0b07-4b3b-ad9d-2e6870d1587c@googlegroups.com> |
In article <766aec49-0b07-4b3b-ad9d-2e6870d1587c@googlegroups.com>,
jodun@mail.com says...
> Ken's approach - thanks kin for spending a lot of time - may be the
more accurate one, but it, in my newbish opinion,
> a: does not lend it self to a one-process solution
> b: has 4 arbitrary numbers, 4000 4000 1000 0
> N.B. As far as I can tell, to get the bbox, we need a separte run
> followed by manual arithmtic/trascriptin into a subsequent run.
> If, as I ambitiously intend, am gonna process a database of thousand of strings
> that manualisation would obviously not do.
OK so one of the things you can do is put all your marking code into a
form (or even a procedure!). Then you can rerun the form as many times
as you need, potentially under different conditions, to get the result
you want.
So you could (for example) run the file once with 'show' redefined so
that it did a 'currentpoint' after each show. That doesn't get you the
bounding box, but it quickly gives you an approximation to the extents
of the text.
You can then use that to translate the form completely onto the page
(and possibly alter the page size) and run the form again to get
accurate results for the bbox.
Here's your original example, suitably modified to use the charapth
approach and a procedure for the content rather than a form:
8<----------------------------8<-------------------------8<------------
%!
/Content {
/Times-Bold 111 selectfont 200 444 moveto (Sun) show
/Arial 44 selectfont 60 rotate (Moon) show
2 3 scale
/Courier-Italic 300 selectfont 45 rotate (Pluto)show
} def
save
/show {true charpath} bind def
matrix currentmatrix
/Content cvx exec
setmatrix
flattenpath pathbbox
5 -1 roll
restore
/ury exch def
/urx exch def
/lly exch def
/llx exch def
(llx ) print llx ==
(lly ) print lly ==
(urx ) print urx ==
(ury ) print ury == flush
<</PageSize [urx llx sub ury lly sub]>> setpagedevice
llx neg lly neg translate
/Content cvx exec
showpage
8<----------------------------8<-------------------------8<------------
Notice the use of flattenpath, that should preclude the inclusion of
control points in the path before we send it to pathbbox. It does,
however, convert true curves to a flattened approximatoin, so you will
need to run ths at a reasonable resolution to get correct results.
Observe that if you run this at different resolutions you will get
slightly different results, due to the difference in device space
(pathbbox converts the device space representation back into user space,
so obviously is affected by the user space->Ldevice space mapping, which
is affected by the resolution).
If I run that through Ghostscript I get a page tightly clipped to the
extent of the marks. Using the bbox device I get :
%%BoundingBox: 0 0 1290 2126
%%HiResBoundingBox: 0.000000 0.000000 1289.437554 2125.997935
Is that sufficient for your needs ? You shoud note that if you actually
intend to print ths, you will need to do the exact same translation of
the origin as done above, immediately after the setpagedevice. Otherwise
the marking operations will still take place off the page.
If you want a BoundingBox which accounts for that, well you have the
asnwer already in the box bounds.
I'm assuming, based on your requirement for one pass, that you intend to
do 'something' with the content and so translating the origin is the
right thing to do.
Ken
Back to comp.lang.postscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
. bbox of a set of glyphs jodun@mail.com - 2015-04-30 15:05 -0700
Re: . bbox of a set of glyphs ken <ken@spamcop.net> - 2015-05-01 07:48 +0100
Re: . bbox of a set of glyphs jdaw1 <jdawiseman@gmail.com> - 2015-05-01 01:50 -0700
Re: . bbox of a set of glyphs jodun@mail.com - 2015-05-02 06:48 -0700
Re: . bbox of a set of glyphs jdaw1 <jdawiseman@gmail.com> - 2015-05-02 14:13 -0700
Re: . bbox of a set of glyphs ken <ken@spamcop.net> - 2015-05-04 08:00 +0100
Re: . bbox of a set of glyphs jdaw1 <jdawiseman@gmail.com> - 2015-05-08 01:34 -0700
Re: . bbox of a set of glyphs ken <ken@spamcop.net> - 2015-05-08 10:44 +0100
Re: . bbox of a set of glyphs jdaw1 <jdawiseman@gmail.com> - 2015-05-08 05:06 -0700
Re: . bbox of a set of glyphs SaGS <sags5495@gmail.com> - 2015-05-11 01:40 -0700
Re: . bbox of a set of glyphs jdaw1 <jdawiseman@gmail.com> - 2015-05-11 02:58 -0700
Re: . bbox of a set of glyphs ken <ken@spamcop.net> - 2015-05-04 08:50 +0100
Re: . bbox of a set of glyphs jodun@mail.com - 2015-05-04 11:22 -0700
Re: . bbox of a set of glyphs jodun@mail.com - 2015-05-07 14:01 -0700
Re: . bbox of a set of glyphs luser- -droog <mijoryx@yahoo.com> - 2015-05-07 21:19 -0700
Re: . bbox of a set of glyphs ken <ken@spamcop.net> - 2015-05-08 08:21 +0100
Re: . bbox of a set of glyphs ken <ken@spamcop.net> - 2015-05-08 12:06 +0100
Re: . bbox of a set of glyphs jodun@mail.com - 2015-05-12 07:44 -0700
Re: . bbox of a set of glyphs ken <ken@spamcop.net> - 2015-05-12 16:36 +0100
Re: . bbox of a set of glyphs jodun@mail.com - 2015-05-14 08:18 -0700
Re: . bbox of a set of glyphs ken <ken@spamcop.net> - 2015-05-14 17:31 +0100
csiph-web