ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Gerben Wierda <gerben.wierda@rna.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Would it be possible in LMTX to do something like variable font/lineheight to fit a fixed frame?
Date: Sun, 10 May 2020 20:34:31 +0200	[thread overview]
Message-ID: <BE6805D3-45AE-4895-8FA7-1FA01F5B4AB1@rna.nl> (raw)


[-- 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
___________________________________________________________________________________

                 reply	other threads:[~2020-05-10 18:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BE6805D3-45AE-4895-8FA7-1FA01F5B4AB1@rna.nl \
    --to=gerben.wierda@rna.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).