OpTeX icon indicating copy to clipboard operation
OpTeX copied to clipboard

\magscale and PDF paper size

Open mattiasmarka opened this issue 2 years ago • 2 comments

Consider the following example:

\fontfam[LMfonts]
\margins/ b5 (,,,)mm
\magscale[1193]\margins/ a4 (,,,)mm

\input knuth

\bye

If I comment out the first or second line with the \margins command, the output does not change visually. This is to expected as the dimensions of a4 paper are roughly 1.193 times that of b5 paper.

Now, what is curious is that, the example above produces a PDF for which the page dimensions listed in the metadata are those of b5 paper. For the example above, shouldn't the paper dimensions of the PDF be those of a4 paper?

This behavior is not specific to one PDF reader. I tested Gnome Document Viewer, Firefox and Okular.

Also, it does not seem to make a difference if one of the lines with the \margins command is commented out.

As I said the output is visually the same in any case. That being said, I haven't tried printing the PDF produced by the example above to see if the paper size listed in the metadata is actually correct.

Perhaps I just don't understand what \magscale is supposed to do. What do you think?

I'm on version 1.09.

mattiasmarka avatar May 27 '23 16:05 mattiasmarka

It's not entirely clear to me either.

The magnification of all dimensions used in the document was implemented in the classical TeX as a constant (so called MAG value) saved to the header of the DVI output. All dimensions were unchanged inside DVI output and the DVI driver was responsible to scale all dimensions from DVI by MAG when the printing was processed. If a user wanted to specify a real dimension (which was printed), then he used the truept, truemm, truecm etc. units and TeX saved to the DVI the desired dimension divided by MAG. DVI driver scaled all dimensions by MAG, so these "true" dimensions were printed in desired size. The MAG value can be saved to the DVI using \mag primitive before first \shipout.

What happens when the output is PDF, not DVI and \mag primitive is used? Try this:

\fontfam[lm]
\mag= 1193
\input knuth
\bye

I see no difference between the output when \mag is used/unused. The two PDF's differs only by the creation date and the checksum. It seems that MAG value isn't provided in PDF. On the other hands, PDF provides the paper size, but DVI doesn't do this. We must re-set the paper size registers after \mag is used using "true" dimensions unit, because we want to scale all dimensions but not the paper size. This work is done by the macro \magscale: is sets \mag primitive register and resets paper sizes by "true" dimensions, i.e. the internal values of these registers are divided by MAG. The result, which you observed, is the scaled paper size dimensions by 1/MAG in the PDF.

I understand that this is not optimal, but the desired aim: "to keep the paper dimensions unscaled and scale all dimensions used in the PDF" is not trivial to reach. So, let's this \magscale "feature" as an attractiveness referring to the time of the DVI format.

olsak avatar Jun 05 '23 16:06 olsak

(Sorry for the late reply.)

What happens when the output is PDF, not DVI and \mag primitive is used?

Last I checked, it was visually exactly equivalent to using \magscale. Should this be?

I understand that this is not optimal, but the desired aim: "to keep the paper dimensions unscaled and scale all dimensions used in the PDF" is not trivial to reach. So, let's this \magscale "feature" as an attractiveness referring to the time of the DVI format.

Can I ask why is it that paper dimensions are defined in terms of mm not truemm? For example: \_sdef{_pgs:a4}{(210,297)mm} vs \_sdef{_pgs:a4}{(210,297)truemm}

Thanks.

mattiasmarka avatar Sep 04 '23 12:09 mattiasmarka