Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #2246

Re: . bbox of a set of glyphs

From ken <ken@spamcop.net>
Newsgroups comp.lang.postscript
Subject Re: . bbox of a set of glyphs
Date 2015-05-04 08:50 +0100
Message-ID <MPG.2fb1352154c267489898f3@usenet.plus.net> (permalink)
References <e960544e-41e2-4c87-bda4-dca56daf7c41@googlegroups.com> <fb3c69b4-2c5a-404a-acfa-dbf5a3e25765@googlegroups.com>

Show all headers | View raw


In article <fb3c69b4-2c5a-404a-acfa-dbf5a3e25765@googlegroups.com>, 
jodun@mail.com says...

> > I think I need to compute the *overall* bounding box
> > But if I use the bbox device, I get an utterly wrong answer.
> > 
> > Help

Well, you still haven't opened a bug report.....

Assuming the file below is an example of the sort of problem you are 
seeing, the problem is that the bbox device is limited (clipped) by the 
initial page. So if your output extends off the page, it will be clipped 
to it.

> -------------------------------- code ----------------------
> 
> 0 setgray
> 
> /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
> -----------------------------end code -----------------
> 
> Now, how can I get the overall/cumulative  bounding box ?
> and  how to clip the margins out ?


The Ghostscript bbox device (which is clipped to the page) says that the 
BBOX is 0 441 439 1301.

The code supplied by jdaw1, again using Ghostscript, comes out at -404 
398 383 1214, Acrobat Distiller says -420 396 385 1214 (Bear in mind the 
fonts used are probably slightly different since they are not embedded).

I have no idea which is correct, I presume you know. However, if you 
accept the fact that the bbox device clips to the page, then these are 
all in reasonably close agreement, I certainly don't see the bbox device 
answer as 'utterly wrong'.

So, I then modified the iput file to move the entire conetnt onto the 
page (and made the page size large enogh to hold the content. I did ths 
by modifying your code:

%!
<</PageSize [4000 4000]>> setpagedevice
1000 0 translate

/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
showpage

Running this through the bbox device gives me:

%%BoundingBox: 127 441 1439 2575
%%HiResBoundingBox: 127.964809 441.897737 1438.657550 2574.422078

So, the modified file has its lower left at 127,441 and its upper right 
at 1439,2575.

As to clipping out the margins, you use 'rectclip'. Howeever, what I 
assume you *actually* mean is 'how do I draw this so it fills the page 
with no white space'. In which case the answer is that you set the 
PageSize to be the width and height, and translate the bottom left 
corner of the content to 0,0.

So I modified your original file thus:

%!
<</PageSize [1312 2134]>> setpagedevice
873 -441 translate

/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
showpage

So how did I arrive at those figures ? Easy, the width is given by urx - 
llx = 1439 - 127 = 1312. Heiht is given by ury - lly = 2575 - 441 = 
2134.

We know that when we offset the content by x=1000, y=0 that the content 
started at llx = 127, lly = 441. So we need to translate the content by 
that amount. 1000 - 127 = 873, and 0 -441 = -441.
 

If I run this through Ghostscript then the result is ver close to a 
tight clip to the text. Differences in resolution, and rounding errors, 
will mean that there are always likely to be a few pixels difference. 
You can probably get even closer by using the high resolution bbox. For 
confirmation I ran the file through acrobat distiller and, given the 
caveats about fonts, the result is close to the Ghostscript display.

In any event, the Ghostscript bbox device's result is certainly not 
'utterly wrong', and gives a result better than that proposed by use of 
charpath.


			Ken

Back to comp.lang.postscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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