[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: why does ps->eps conversion reduce line thickness?

On Mon, Apr 23, 2001 at 01:08:30PM +1000, Mark Mackenzie wrote:
> I do ps->eps conversions using:
> echo -n '\004' | gs -q -dNOPAUSE -sDEVICE=epswrite \
> -sOutputFile=box.eps box.ps >/dev/null
> using box.ps below. When box.ps is printed, it comes out as a 1mm thick
> 1" box (quite dark). When box.eps is printed, the lines are very thin 
> (perhaps .2mm) and faint. 
> This is when printing to a postscript printer hp2100tn. I think if
> you are using gs via magicfilter for a non-ps printer, the printout is
> ok.
> Does anyone know why this is the case? The problem is that when I
> my ps files in a latex document most lines are too faint, and the
> thickness is varying as if I had an aliasing error.


in the postscript drawing model there is a clean seperation between
constructing the paths that define the shapes to draw, and the actual
rendering. The paths can be imagined as invisible descriptions of the
shapes, while the rendering process then puts some color onto the
virtual page. The rendering itself can basically be "stroking" (like
taking a pencil and moving/putting color along the path), or "filling"
the area circumscribed by a closed path.
Actually, there are three steps: (1) path construction, (2) rendering
and (3) transferring the internally built-up page image onto the
physical paper or some other media.

Now, how does that relate to your problem?  If you want to stroke the
path (the square in your case) you need to tell the postscript
interpreter which line width, line style, etc. you wish to use. In the
example below this didn't happen anywhere, so the interpreter uses
some built-in defaults. These are device-dependent, i.e. they can vary
from printer to printer. Typically the default line width is set to
the device resolution. So if you have a 600dpi printer, the lines will
be 1/600 inch wide, whereas, if you let ghostscript output the page
to the screen, the same line will usually be one pixel wide.
But these are just the defaults. You can of course set any desired line
width, and the postscript interpreter will try to approximate that
thickness as good as possible at the given device resolution.
The operator for setting the line width is, guess what, "setlinewidth" ;)
The units in which you specify the width is by default 1/72 inch, but
you can change that as well.
Thus to get a line width of, let's say, 5/72 inch, you simple put

  5 setlinewidth

somewhere before executing the "stroke" operator, as I've done in your
code below. The exact place is not so important as long as it's before
the "stroke", so putting it before the "newpath" would be equally fine,
for example. You can specify _any_ width, not just integer multiples of
the unit currently in effect. So, something like "1.35 setlinewidth" is
ok, too.

In case you'd rather wanted to use mm-units, you could put

  72 25.4 div dup scale

at the beginning of the postscript document, etc. etc. ...

So, if you write your (simple) documents from scratch, things are
basically quite easy and flexible. On the other hand, if you'd have to
manipulate some third-party postscript document, it can of course be
considerably harder to find the correct place to modify...

If you feel like doing more advanced things than drawing a simple square,
I'd recommend that you get the PostScript Language Reference Manual from
Adobe -- it's available for free:

http://partners.adobe.com/asn/developer/technotes/postscript.html  (overview)
http://partners.adobe.com/asn/developer/pdfs/tn/PLRM.pdf        (direct link)

(also available as a printed book)


> box.ps - from postscript.tar.gz on the net somewhere.
> %!
> %% Draws a one square inch box and inch in from the bottom left
> /inch {72 mul} def
> newpath                  |
> 1 inch 1 inch moveto     |
> 2 inch 1 inch lineto     |  this is the path construction
> 2 inch 2 inch lineto     |
> 1 inch 2 inch lineto     |
> closepath                |

  5 setlinewidth
> stroke                      this renders the square

> showpage                    this transfers it to the paper

Erdmut Pfeifer
science+computing ag

-- Bugs come in through open windows. Keep Windows shut! --

Reply to: