I would like to be able to measure some dimensions while in the tikzpicture environment.
Here is the MWE to demonstrate my intentions:
\documentclass {article}
\RequirePackage [utf8] {inputenc}
\RequirePackage {tikz}
\RequirePackage {expl3}
\begin {document}
%\begin {tikzpicture}
\ExplSyntaxOn
\dim_new:N \height
\settoheight {\height} {\fontsize {18} {21.6} \selectfont something}
\dim_log:N \height
\ExplSyntaxOff
%\end {tikzpicture}
\end {document}
When tikzpicture is commented out, the height is properly measured.
However, once the tikzpicture environment is enabled, the height has the value 0.0pt.
Judging by the log and similar questions on the internet, this is happening because tikzpicture environment sets the font to nullfont, which doesn't have any character in it.
Therefore, it's impossible to measure the dimensions of the glyphs.
I have tried to change the font inside the tikzpicture environment by adding:
\renewcommand {\encodingdefault} {OT1}
\renewcommand {\familydefault} {\rmdefault}
\renewcommand {\rmdefault} {cmr}
\renewcommand {\seriesdefault} {m}
\renewcommand {\shapedefault} {n}
\fontencoding {\encodingdefault}
\fontfamily {\familydefault}
\fontseries {\seriesdefault}
\fontshape {\shapedefault}
\selectfont
Unfortunately, this didn't change the outcome.
The only thing, that did change the outcome, was adding \font\nullfont=cmr18.
But this approach has downsides:
- It really looks like a bad and unsecure code.
heightdiffers between disabledtikzpictureand enabledtikzpicture+ newnullfont.- Looks like redefinition of
nullfontand also ignores this part of code:\fontsize {18} {21.6}.
How can I change the font to global one, only when performing these measurements inside tikzpicture and change it back to nullfont afterwards?

tikzpicturethe text is gobbled (\nullflont) unless you put in in a node, where you can usefontornode font. See here for a very related question. – Jun 09 '19 at 18:20\begin{advertizing}See https://tex.stackexchange.com/a/459858/121799\end{advertizing}. ;-) ? – Jun 09 '19 at 18:25tikzpicture. I don't want to draw a node with that value. That value will be used later just for calculating the position of next drawing. Is that even possible? I thought font changing will be easy enough, but it doesn't look like it now :D – Iskustvo Jun 09 '19 at 18:47\begin{pgfinterruptpicture}%before you define the box and\end{pgfinterruptpicture}%afterwards.\begin{tikzpicture} \begin{pgfinterruptpicture}% \ExplSyntaxOn \dim_new:N \height \settoheight{\height}{\fontsize{18}{21.6} \selectfont something} \global\height=\height \dim_log:N \height \ExplSyntaxOff \end{pgfinterruptpicture}% \end{tikzpicture} \typeout{\the\height}– Jun 09 '19 at 18:56