This is not a satisfactory answer, but rather a framework:
The idea is that TikZ expects users to pass font commands using font = and node font =. Those commands are stored in \tikz@textfont and \tikz@node@textfont for later use. So at least this part can be automatized.
Once the desired offset is calculated, there are two ways to go
- shift the node by simply passing
xshift = -offset; this will affect the anchors for future positioning.
- add negative glues; this can be done by redefining
\tikz@text@action. In fact, this command is redefined if the user passes text ragged left or any text alignment style.
Now, wrapping everything you did into a style key. If you want different offsets for different initial letters, you can define a style with argument(s).
In the following example, I used twice the kerning between A and V as the offset. I am not saying that this is correct. But \XeTeXglyphbounds might not give you the correct result as well. The reason is the same as why we need overshoot).
\documentclass[tikz]{standalone}
\usepackage{fontspec}
\setmainfont{Futura}
\begin{document}
\makeatletter
\tikzset{
distil kerning/.code={%
\let\oldtempselectfont\pgfmath@selectfont%
\def\pgfmath@selectfont{\tikz@node@textfont\tikz@textfont\oldtempselectfont}
\pgfmathsetmacro\pgfkerningcorrection{width("V")+width("A")-width("VA")}
\xdef\pgfkerningcorrection{\pgfkerningcorrection}
\let\pgfmath@selectfont\oldtempselectfont
},
node correction by kerning/.style={
distil kerning,
xshift=-\pgfkerningcorrection*2
},
ncbk/.style=node correction by kerning
}
\makeatother
\tikz\draw foreach\A[count=\i]in{A,...,G}{(0,\i*\i/7)node[right,font=\fontsize{\i0}{0}\selectfont,ncbk]{\A: text of size \i0.}};
\tikz\draw foreach\A[count=\i]in{A,...,G}{(0,\i*\i/7)node[right,font=\fontsize{\i0}{0}\selectfont ]{\A: text of size \i0.}};
\end{document}

fontspec. But, on the bright side, there will only be a handful of such instances, and I can manually adjust the text without too much trouble. – jme Nov 17 '16 at 19:04scaleinstead of changing the font size, same results. An idea: maybe if there's a way to get a hold of the sidebearing size one canxshiftthe nodes that value... – Guilherme Zanotelli Nov 18 '16 at 06:02