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