From: Aditya Mahajan <adityam@umich.edu>
To: ntg-context@ntg.nl
Subject: Re: How to calculate the height of text of a certain width?
Date: Tue, 24 Mar 2020 11:36:30 -0400 (EDT) [thread overview]
Message-ID: <nycvar.YAK.7.77.849.2003241131000.413538@nqv-guvaxcnq> (raw)
In-Reply-To: <20200324152934.GA6936@nan>
On Tue, 24 Mar 2020, Rudolf Bahr wrote:
> On Tue, Mar 24, 2020 at 03:56:18PM +0100, Wolfgang Schuster wrote:
>> Rudolf Bahr schrieb am 24.03.2020 um 12:19:
>> > Hello dear All,
>> >
>> > the following MWE works best:
>> >
>> >
>> > \definelayer[LAY]
>> > \starttext
>> >
>> > \setlayerframed[LAY]
>> > [x=0pt,y=20pt]
>> > [frame=on,
>> > width=300pt,
>> > align={right,}] % tolerant}]
>> > {\input ward }
>> > \flushlayer[LAY]
>> > \stoptext
>> >
>> >
>> > Now, it could have a favourable effect on designing a page if the height of a text
>> > of certain width could be calculated in advance, depending of the font.
>> > Is there a way?
>> >
>> > As I fear, TeX's means "\setbox" woun't work with aligned texts.
>>
>> Can you give more details, I have no idea what you mean with aligned texts
>> (layers?).
>>
>> Wolfgang
>
>
> Hi Wolfgang,
>
> With "aligned texts" I thought of "align={right,}]" in the above example or
> text which is "flushed right":
>
> \setbox0=\vbox{... somehow flushed text ...} wount work, i.e \wd0 or \ht0
> will both result in 0. With "unflushed" text this means will work perfectly.
You can do:
\definelayer[LAY]
\starttext
\setbox\scratchbox=\vbox{\framed[width=300pt, align=flushleft]{\input
ward\relax}}
The height of the box is \the\ht\scratchbox; the width is
\the\wd\scratchbox.
\unvbox\scratchbox
\setlayerframed[LAY][x=0pt, y=20pt][width=300pt, align=flushleft]{\input
ward\relax}
\flushlayer[LAY]
\stoptext
Aditya
___________________________________________________________________________________
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
___________________________________________________________________________________
next prev parent reply other threads:[~2020-03-24 15:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 11:19 Rudolf Bahr
2020-03-24 14:56 ` Wolfgang Schuster
2020-03-24 15:29 ` Rudolf Bahr
2020-03-24 15:36 ` Aditya Mahajan [this message]
2020-03-24 18:41 ` Rudolf Bahr
2020-03-24 15:43 ` Wolfgang Schuster
2020-03-24 18:04 ` Rudolf Bahr
2020-03-24 18:29 ` Wolfgang Schuster
2020-03-25 10:30 ` Rudolf Bahr
2020-03-25 11:00 ` Rudolf Bahr
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=nycvar.YAK.7.77.849.2003241131000.413538@nqv-guvaxcnq \
--to=adityam@umich.edu \
--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).