ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Would it be possible in LMTX to do something like variable font/lineheight to fit a fixed frame?
@ 2020-05-10 18:34 Gerben Wierda
  0 siblings, 0 replies; only message in thread
From: Gerben Wierda @ 2020-05-10 18:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1479 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 2540 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-10 18:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-10 18:34 Would it be possible in LMTX to do something like variable font/lineheight to fit a fixed frame? Gerben Wierda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).