[Tex/LaTex] Use dimensions \totalheight \depth for inline TikZ drawing

dimensionslengthstikz-pgf

I want to use the current text's dimensional properties for constructing an inline TikZ image, such as an icon.
The properties I have in mind for use are

\height
\depth
\totalheight

as described here.

What I want to achieve is something like the following, but instead of using ex units, want to be sure the drawing fits into the line exactly.
bad rendering

\tikz[baseline={1ex}] \draw[draw=black, fill=blue, rounded corners] (0,0) rectangle (5ex,3ex) ;
Signal

Please observe that this code lets the drawing start too low (below the "g" in "Signal") and end too high (above the "S" in Signal).

Best Answer

You can use node and control its dimensions.

\documentclass{article}
\usepackage{tikz,calc}
\begin{document}
\fboxsep=0pt
\fbox{
\tikz[baseline=(a.base)] \node[draw=black, fill=blue, rectangle, rounded corners,inner sep=0, outer sep=0,minimum width=5ex] (a) {\vphantom{Sg}} ;
Signal}
\end{document}

enter image description here

Here \vphantom adds the total height (i.e., height of S and depth of g)

PS \fbox is there just to show the heights.

Related Question