How can I resize (anamorphically) the contents of a box in plain TeX, that is, give it new width, height and depth?
\setbox0=\hbox{Hello!}
\copy0 % output at orig. size
%
% code which resizes box 0
% ...
%
\box0 % output with altered dimensions
\bye
Best Answer
Just to get a hand on the problem, here's what one has to do with
pdftex
.You can change the “current matrix” that tells
pdftex
how to resize the material it's going to print. Just save the current settings, change the matrix and restore.Do you see the problem? Between
\pdfsave
and\pdfrestore
there should be no horizontal movement, so you need to compute the apparent dimension of the text you're transforming. Some trigonometry is needed in case of rotations, while scaling in either direction is easier. You'd use something likefor doubling in the x-direction and tripling in the y-direction and typeset an empty box with the apparent dimensions:
Note that proper space is reserved for the entire construction.
If you want to support also XeTeX, you'd have to use a completely different method, issuing suitable
\special
commands. Different\special
commands would be needed forlatex+dvips
.