ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Rik Kabel <ConTeXt@rik.users.panix.com>
To: ntg-context@ntg.nl
Subject: Re: Getting width of text to be typeset
Date: Sat, 23 May 2020 09:52:47 -0400	[thread overview]
Message-ID: <f22072b2-8c86-53ea-b6d4-45bff5a58826@rik.users.panix.com> (raw)
In-Reply-To: <357d26e1-2571-b30c-2eb6-c787ed3bbf18@rik.users.panix.com>


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


On 5/22/2020 19:49, Rik Kabel wrote:
>
> If the OP simply wants the width of a string, one can use 
> \setwidthof#1\to#2.
>
>     \define\String{pqrs}
>     \setwidthof{\String}\to\Wdth
>     \String\ is \Wdth\ wide.
>
>     \setwidthof{{\tfb\em\String}}\to\Wdth
>     {\tfb\em\String} is \Wdth\ wide.
>
> I do not know if that is different from the width of the same string 
> unboxed from the paragraph. There may be some adjustments made in 
> justification, expansion, and such that are not treated.
>
>
Correcting my post (thank you, Floris), the format is a bit different 
than I had written. The following works:

    \starttext
    \define\String{pqrs}
    \setwidthof\String\to\WdthA
    {\String} is \WdthA\ wide.

    \define\String{\tfx\em pqrs}
    \setwidthof\String\to\WdthB
    {\String} is \WdthB\ wide.

    \define\String{\ss pqrs}
    \setwidthof\String\to\WdthC
    {\String} is \WdthC\ wide.
    \stoptext


Giving:

-- 
Rik


[-- Attachment #1.2.1: Type: text/html, Size: 1931 bytes --]

[-- Attachment #1.2.2: janpnilaphcbkjac.png --]
[-- Type: image/png, Size: 14894 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
___________________________________________________________________________________

      parent reply	other threads:[~2020-05-23 13:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22  9:22 context
2020-05-22 22:03 ` Hans Hagen
2020-05-22 22:18   ` Hans Hagen
2020-05-22 23:49     ` Rik Kabel
2020-05-23 11:04       ` Gerben Wierda
2020-05-23 13:52       ` Rik Kabel [this message]

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=f22072b2-8c86-53ea-b6d4-45bff5a58826@rik.users.panix.com \
    --to=context@rik.users.panix.com \
    --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).