Bug 173726 - mpage calculates page scaling incorrectly
mpage calculates page scaling incorrectly
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: mpage (Show other bugs)
4
All Linux
medium Severity medium
: ---
: ---
Assigned To: Radek Vokal
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-11-19 13:35 EST by redhat-bugs2eran
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version: 2.5.4-6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-02-09 05:52:54 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch to fix the reported problem (1.24 KB, patch)
2005-11-19 13:37 EST, redhat-bugs2eran
no flags Details | Diff

  None (edit)
Description redhat-bugs2eran 2005-11-19 13:35:33 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc4 Firefox/1.0.7

Description of problem:
The '-M' option of mpage allows for changing the paper magins, and scales the input PostScript to fill the new margins. This calculation is done incorrectly, as acknowledged in the mpage(1) manpage: 

  "Very large values have funny effects.
   This is left as an exercise to the user."

Well, this user found the error: it lies in post.c lines 730-731 and 867-868. These lines compute the scaling factor as (WIDTH-MARGIN)/WIDTH, which incorrect since the margins are given in logical units (i.e., units of the input page rather than the output page), as explained in the manpage. Moreover, the left and bottom margins are handled by translation in logical units, so the current code is inconsistent any way you look at it.

Attached is a patch which fixes this, by calculating the ratio as WIDTH/(WIDTH+MARGIN). 

As a sanity check, consider the case WIDTH=MARGIN, which should shrink by a factor of 2 (and does with my formula), but with the current code shrinks to the content to zero size.

Compatibility-wise this sould be OK, since the old and new code give similar results for small margins, and for large margins the old code was broken and inconsistent anyway (as warned in the manpage). But I suggest changing the version number (add a suffix?), in case some applications (like mike) need to check for a good version.

Version-Release number of selected component (if applicable):
mpage-2.5.4-5

How reproducible:
Always

Steps to Reproduce:
1. Run 
$ mpage -1 -M500r /usr/share/doc/bash-3.0/bash.ps > out.ps && evince out.ps
and observe that the content is shrunk too much (as if the right margin is given in physical units instead of logical unit)

2. Run 
$ mpage -1 -M500l /usr/share/doc/bash-3.0/bash.ps > out.ps && evince out.ps
and observe that the left margin is determined correctly in logical units, but again the content is shrunk too much.

3. Run
page -1 -M300l300r /usr/share/doc/bash-3.0/bash.ps > out.ps && evince out.ps
and observe that the result is nonsensical.


Additional info:
Comment 1 redhat-bugs2eran 2005-11-19 13:37:45 EST
Created attachment 121266 [details]
Patch to fix the reported problem

Note You need to log in before you can comment on or make changes to this bug.