Scale .pgf image but preserve font size

You can scale the graphics by k using for example scalebox and scale the font by 1/k to compensate this. If you compile with XeLaTeX or LuaLaTeX you can use the scale features of fontspec.

Here is a simple example :

% to compile with XeLaTeX or LuaLaTeX
\documentclass[varwidth,border=50]{standalone}
\usepackage{fontspec}
\usepackage{pgf}

\begin{document}

% font scale = .25*4 = 1
\setsansfont{Latin Modern Sans}[Scale=.25]%
\scalebox{4}{
  \begin{pgfpicture}
    \pgfsetstrokecolor{red}%
    \pgfpathrectangle{\pgfpointorigin}{\pgfqpoint{5mm}{5mm}}%
    \pgfusepath{draw}%
    \pgftext[x=4,y=4]{{\sffamily\fontsize{12.000000}{14.400000}\selectfont 40}}%
  \end{pgfpicture}
}

% font scale = .5*2 = 1
\setsansfont{Latin Modern Sans}[Scale=.5]%
\scalebox{2}{
  \begin{pgfpicture}
    \pgfsetstrokecolor{red}%
    \pgfpathrectangle{\pgfpointorigin}{\pgfqpoint{5mm}{5mm}}%
    \pgfusepath{draw}%
    \pgftext[x=4,y=4]{{\sffamily\fontsize{12.000000}{14.400000}\selectfont 40}}%
  \end{pgfpicture}
}

\end{document}

enter image description here