\settowidth{len-cmd}{text}
The \settowidth command sets the value of a length command, len-cmd, which is specified as the first argument, equal to the width of the text argument in the current font.
See Lengths Back to the Table of Contents