diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2023-04-10 11:49:59 +0100 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2023-04-10 11:49:59 +0100 |
commit | 7fc1b376bba20c5a207f07c0222827705a2c8fa5 (patch) | |
tree | a48ea6ac69e2961871d13d3620f3c669898b821c | |
parent | dd3a13d7a1f5d22df2ceb958d262393965a99a7e (diff) | |
download | ghostpdl-7fc1b376bba20c5a207f07c0222827705a2c8fa5.tar.gz |
PostScript interpreter - don't rotate content onto square media
Bug #706563 "PagSize Policy 3 can inappropriately rotate content"
As noted, if the medium is square, and the requested medium is portrait,
then we would end up rotating the content.
To avoid this, just check if the medium or request is square, and if so
set rotate to 0.
-rw-r--r-- | psi/zmedia2.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/psi/zmedia2.c b/psi/zmedia2.c index 33fd4977b..667547b3d 100644 --- a/psi/zmedia2.c +++ b/psi/zmedia2.c @@ -391,15 +391,21 @@ match_page_size(const gs_point * request, const gs_rect * medium, int policy, fabs((medium->p.x - ry) * (medium->q.x - ry)) + (pmat->xx == 0.0 || (rotate & 1) == 1 ? 0.01 : 0); /* rotated */ } else { - int rotate = - (orient >= 0 ? orient : - (rx < ry) ^ (medium->q.x < medium->q.y)); - bool larger = (policy == 13) ? 0 : - (rotate & 1 ? medium->q.y >= rx && medium->q.x >= ry : - medium->q.x >= rx && medium->q.y >= ry); + int rotate = 0; + bool larger = 0; bool adjust = false; float mismatch = medium->q.x * medium->q.y - rx * ry; + rotate = orient >= 0 ? orient : (rx < ry) ^ (medium->q.x < medium->q.y); + + /* If either the request or the media is square, there is no point in rotating */ + if (rx == ry || medium->q.x == medium->q.y) + rotate = 0; + + larger = (policy == 13) ? 0 : + (rotate & 1 ? medium->q.y >= rx && medium->q.x >= ry : + medium->q.x >= rx && medium->q.y >= ry); + switch (policy) { default: /* exact match only */ return 0; |