How to ensure line widths are the same vertically and horizontally in PostScript?

Viewed 64

The width of a line in PostScript is defined in terms of distances in the user space. In my use case, the aspect ratio of the device space (e.g. 4:3) is different from the aspect ratio of the user space (e.g. 1:1), which causes the line widths in the device space to be different in vertical and horizontal directions.

How to make line widths the same regardless of the line orientation? The PostScript Language Reference Manual for setlinewidth mentions that if the current transformation matrix (CTM) in effect at the time of the stroke specifies scaling by different factors in the x and y dimensions, then thickness of the lines can vary.

Does this mean that if I set a CTM with the same scaling factor in x and y dimensions before calling stroke and then reset the CTM to the value used elsewhere in the PostScript file, the line widths will be the same without affecting anything else?

1 Answers

Yes. stroke will generate an outline of the path corresponding to a pen shape transformed by the CTM. You can use setmatrix to establish a consistent uniform matrix for the pen.

matrix currentmatrix
  matrix identmatrix setmatrix
  stroke
setmatrix
Related