Given two co-ordinates say, X.south east and X.south west, is it possible to determine the length or the vector between the two?
In the MWE the width, has been calculated using traditional TeX techniques, but is obviously a bit of a wasted effort as PGF probably did all these calculations already.

\documentclass{article}
\usepackage{pgf,tikz}
\makeatletter
\begin{document}
\def\convert@cx#1{\the#1}
\newlength\xheight@cx
\newlength\xlength@cx
\newlength\xdepth@cx
\newlength\xtotal@cx
\newsavebox{\fontbox}
%
\def\drawfontbox#1{%
{\upshape\Huge
\savebox{\fontbox}{#1}
\pgfmathsetlength{\xheight@cx}{\ht\fontbox}
\pgfmathsetlength{\xlength@cx}{\wd\fontbox}
\pgfmathsetlength{\xdepth@cx}{\dp\fontbox}
\pgfmathsetlength{\xtotal@cx}{\xdepth@cx+\xheight@cx}
\begin{tikzpicture}[scale=1]
\node[rectangle,draw,inner sep=0pt,outer sep=0pt] (X){#1};
\draw[red, line width=0.4pt] (X.text) circle(1pt)[fill=red] -- (X.base east);
\draw[|<->|,>=latex] ([yshift=5pt] X.north west)
--([yshift=5pt] X.north east) node [above=-5pt,midway,
font={\tiny}]{width = \convert@cx{\xlength@cx}};
% draw the xheight
\draw[|<->|,>=latex]([xshift=-5pt]X.base west)
--([xshift=-5pt] X.north west)
node [left,midway,font={\tiny}] {x-height=\convert@cx{\xheight@cx}};
% draw depth
\draw[-|,>=latex]([xshift=-5pt]X.base west)
--([xshift=-5pt] X.south west)
node [left,midway,font={\tiny}] {depth=\convert@cx{\xdepth@cx}};
\draw[<-,>=latex]([xshift=-5pt]X.south west)
--++(0,-8pt);
% draw total height
%
\draw[|<->|,>=latex]([xshift=5pt]X.north east)
--([xshift=5pt] X.south east)
node [right,midway,font={\tiny}] {height=\convert@cx{\xtotal@cx}};
\end{tikzpicture}}
}
\drawfontbox{QWERTY}
\end{document}



\veclenmight or might not work, but currently it is neither in my memory nor in my vocabulary. Maybe you can provide an answer? – yannisl Jun 02 '12 at 15:38\veclengives the "length" of the vector. You get the coordinates of the vector with TeX :\pgfpointdiff{\pgfpointanchor{A}{anchor}}{\pgfpointanchor{B}{anchor}}in\pgf@xand\pgf@y. Another possibility is($(b)-(a)$)for example\node (c) at ($(b)-(a)$) {c};– Alain Matthes Jun 02 '12 at 15:43\pgfpointdiff{⟨start ⟩}{⟨end ⟩}Returns the difference vector ⟨end⟩ − ⟨start⟩. – Alain Matthes Jun 02 '12 at 15:47