# [Tex/LaTex] Change default font within all tikzpicture environments

fontstikz-pgf

I want to have all tikz graphics in \sffamily font. However, I cannot set a base font for tikz, as it will be overridden, whenever I user, e.g., font=\itshape, for a node locally.

I tried to set a prefix such as \tikzset{font/.prefix = {\sffamily}}, as well as to change de default font using \AtBeginEnvironment{tikzpicture}{\renewcommand*{\familydefault}{\sfdefault}} and \AtEndEnvironment, respectively.
Also, I tried \tikzset{execute at begin picture={\renewcommand*{\familydefault}{\sfdefault}}}. However, nothing helped.

I'm simply looking for a proper way to set the base font in all tikz environments to \sfdefault.

In the following MWE, the first node should be sans, oblique, the other two nodes should be similar:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node [font=\sffamily\itshape] {I should be in sans italic};
\node [font=\itshape,below] {I should be in sans italic};
\node [font=\bfseries,above] {I should be in sans oblique};
\end{tikzpicture}
\end{document}


Here is a simple solution (if you don't already use every picture style). Add the following line in your preamble:

\tikzset{every picture/.style={/utils/exec={\sffamily}}}


Example:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\tikzset{every picture/.style={/utils/exec={\sffamily}}}
\begin{document}
\begin{tikzpicture}
\node [font=\sffamily\itshape] {I should be in sans italic or sans oblique};
\node [font=\itshape,below] {I should be in sans italic or sans oblique};
\end{tikzpicture}
\end{document}