Would it be possible in LMTX to do something like variable font/lineheight to fit a fixed frame?
Suppose I have a fixed sized frame, say 3 y 4 cm. And I have a variable-length text. Would it be possible to write a macro that scaled the font and line height such that the text will fit in the frame? What I have now is very basic: Fixed width Typeset (METAPOST textext()) If too high METAPOST: scale down so it fits in frame But the scaling wil scale both height and width so it doesn’t only go to the correct height, it also gets too narrow. Just scaling in the vertical direction squashes the text/font. What would be great is some way to have the font size and lineheight result from TeX trying to fit it inside a predetermined size. Doesn’t need to be perfect, a good approximation will do. I’ve been thinking about using the surface size difference between desired box size and the result of textext() as an approach to guess a right fontsize and line height. What could make it possible for me too is a way to do a typeset command from lua that gives me the box sizes of typesetting without actually typesetting it to the true output of the job. Something like typeset a piece of text without actually outputting it to the PDF output in a width (say 4) get the width and height of the result (say 4 x 6) Adapt front size and lineheight (from 4x6 to 4x3 means a 50% reduction, which may be too much as the result may have just a syllable on the last line) typeset for real in 50% size Is that doable? Or is there a better way? G
participants (1)
-
Gerben Wierda