[Tex/LaTex] How to scale Tikz drawings and text together

fontspecscalingtikz-pgf

I'm trying to build a diagram (a logo, actually) that I can scale easily through a parameter. I'd like to be able to scale both drawing and fonts through a single parameter.

Here's my current MWE, which I hope will illustrate my difficulties:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{fontspec}
\begin{document}
\begin{tikzpicture}[scale=1.0]
\node [draw=black] at (0,0)
{\fontspec[Scale=2.0]{Bookman Old Style Bold}B}; 
\node [draw=none] at (0,-0.5)
{\fontspec[Scale=1.0]{Bookman Old Style} This is a B}; 
\end{tikzpicture}
~
\begin{tikzpicture}[scale=2.0]
\node [draw=black] at (0,0)
{\fontspec[Scale=4.0]{Bookman Old Style Bold}B}; 
\node [draw=none] at (0,-0.5)
{\fontspec[Scale=2.0]{Bookman Old Style} This is a B}; 
\end{tikzpicture}
\end{document}

which gives me this:

two sizes of logo

I have two problems:

  1. How can I derive the scale=1/2/4s from a single parameter?

  2. Why is there proportionally less space between the box and the dot on the "i" of "is".


Update:

Thank you all for the answers and comments so far.

The consensual approach seems to be "transform everything", which I am happy with, although it seems to me to be (somewhat) a second-best solution. Why?

Well, as I understand it, scaling fonts isn't strictly linear point-by point. In other words, I believe that a 10pt font scaled by x2 is not the same as the same font at 20pt.

As well as this, global scaling will also scale the line thicknesses; this may well limit just how far I can scale up or down.

Clearly I was assuming that fontspec scale= does a proper "font upsizing". Otherwise my code is just as "second-best" as everyone else's.

I'll leave things alone for a bit more time, then accept and vote on the answers.

BTW, for those who don't have the font family installed, that's not an important part of the question. "Any font will do, except Comic Sans".

Best Answer

To scale everything together you might want to wrap everything in a \scalebox{<factor>}{...} (graphic/x package, already loaded by tikz). The scale option of tikz works differently: it only scales coordinates. The inner sep value which determines the border will not be scaled by it, which results in the i being further away from the border. You would need to adjust this value with the scale factor as well if you don't use \scalebox.

Alternatively you can try to use drawing units which are relative to the font size, measured in either ex or em. The default you use at the moment is in cm. Even better would be to use anchors for the positioning instead, i.e. try this:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{fontspec}
\begin{document}
\begin{tikzpicture}[scale=1.0,inner sep=4pt]
\node [draw=black] (B)
{\fontspec[Scale=2.0]{Bookman Old Style Bold}B}; 
\node [draw=none,anchor=north] at (B.south)
{\fontspec[Scale=1.0]{Bookman Old Style} This is a B}; 
\end{tikzpicture}
~
\begin{tikzpicture}[scale=2.0,inner sep=8pt]
\node [draw=black] (B)
{\fontspec[Scale=4.0]{Bookman Old Style Bold}B}; 
\node [draw=none,anchor=north] at (B.south)
{\fontspec[Scale=2.0]{Bookman Old Style} This is a B}; 
\end{tikzpicture}
\end{document}

I can't compile it by myself due to the missing fonts.