\settoheight{\gnat}{text}
The \settoheight command sets the value of a length command equal to the height of the text argument.
\settoheight
length
text