From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/107285 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Gerben Wierda Newsgroups: gmane.comp.tex.context 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 Message-ID: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="===============6040553418400902882==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="124513"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun May 10 20:35:14 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jXqnC-000WFT-EC for gctc-ntg-context-518@m.gmane-mx.org; Sun, 10 May 2020 20:35:14 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 8547E183C95; Sun, 10 May 2020 20:34:36 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Gkq5GrL0y-Tx; Sun, 10 May 2020 20:34:34 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 86FBD183CB3; Sun, 10 May 2020 20:34:34 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id C28A2183C52 for ; Sun, 10 May 2020 20:34:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dSNLC9V36-sg for ; Sun, 10 May 2020 20:34:32 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=213.125.118.53; helo=mail.rna.nl; envelope-from=gerben.wierda@rna.nl; receiver= Original-Received: from mail.rna.nl (mail.rna.nl [213.125.118.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 331EF183C49 for ; Sun, 10 May 2020 20:34:32 +0200 (CEST) Original-Received: from hermione.rna.nl (hermione.rna.nl [192.168.2.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.rna.nl (Postfix) with ESMTPSA id B5E043E6106B for ; Sun, 10 May 2020 20:34:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rna.nl; s=dkim_rsa2048; t=1589135671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=9ULaQYwqNeYBM5NimibWHBf1IGEzr38U1MV5rORGZrE=; b=QehKEgKMdPW86wndHJh0HF5y6/jvH7RMBPwRRqcIKxeskXeqm5+dS2qcIxe4oV6NoO/cVO d129/aEuNhUNKQOCR3g0uVbd5KhlYFmJF3AjSgh8Y1nC9n8+2TscHk/8OSAskQevsfKezr xHpK7BjxDSelQNB0wihVUC3pV71zreLcH4A/B4XRsUlEbwp0G81i7qryAwfS0Y7IK1jnQU LLCJcBSNRZMoKETomhX/A31oOA42urxlqtLEsstVlrETGC2Mr902Fah4VnpHJbLdESPTCG qPbDDOK+nGZBuCRNOha5cQJpUccNRm5TFDOFbSbQb23r3Q4/JA9DRjRHlHcd+g== X-Mailer: Apple Mail (2.3445.104.14) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:107285 Archived-At: --===============6040553418400902882== Content-Type: multipart/alternative; boundary="Apple-Mail=_21752363-5575-4BDE-A8A2-0E120DEEEEDC" --Apple-Mail=_21752363-5575-4BDE-A8A2-0E120DEEEEDC Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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=E2=80=99t = 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=E2=80=99t need to be perfect, a good approximation will do. I=E2=80=99= 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? =20 G= --Apple-Mail=_21752363-5575-4BDE-A8A2-0E120DEEEEDC Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 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=E2=80=99t 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=E2=80=99t need to be perfect, a good approximation will = do. I=E2=80=99ve 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
= --Apple-Mail=_21752363-5575-4BDE-A8A2-0E120DEEEEDC-- --===============6040553418400902882== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============6040553418400902882==--