[Tex/LaTex] Custom slice font style in pie chart

tikz-pgf

This question refers to the following post.

See below my implementation based on the answer of bordaigorl which is really great.

[
pie chart,
slice type={Baunternehmen}{blu},
slice type={Vermietung}{rosso},
slice type={Sonstiges}{giallo},
slice type={Geschäftsführung}{blu},
slice type={Disposition}{rosso},
slice type={ausführender Bereich}{giallo},
slice type={Kundenbetreuung}{viola},
slice type={Materialversorgung}{verde},
pie values/.style={font={\small}},
scale=3
]

\pie[values of Sonstiges/.style={pos=1.1}]{2008}{69/Baunternehmen,28/Vermietung, 3/Sonstiges}
\pie[xshift=3cm]%
{2009}{32/Geschäftsführung/,29/Disposition, 18/ausführender Bereich, 15/Kundenbetreuung, 6/Materialversorgung}

\legend[shift={(0cm,-1cm)}]{{Baunternehmen/Baunternehmen}, {Vermietung}/Vermietung, {Sonstiges}/Sonstiges}
\legend[shift={(3cm,-1cm)}]{{Geschäftsführung}/Geschäftsführung, {Disposition}/Disposition, {ausführender Bereich}/ausführender Bereich,{Kundenbetreuung}/Kundenbetreuung,{Materialversorgung}/Materialversorgung}

\end{tikzpicture}

I am using for my document a custom font (uarial). Thus, pie title and legend values are in uarial. The slice values are standard latex font.

enter image description here

How do I change here to uarial font. For standard implementation of tikzpicture I am therefore using

nodes near coords style={/pgf/number format/assume math mode},

Same approach? But where exactly in the macro?

The macros \pie and \legend and all the keys needed are defined as follows:

\definecolor{rosso}{RGB}{220,57,18}
\definecolor{giallo}{RGB}{255,153,0}
\definecolor{blu}{RGB}{102,140,217}
\definecolor{verde}{RGB}{16,150,24}
\definecolor{viola}{RGB}{153,0,153}

\makeatletter

\tikzstyle{chart}=[
    legend label/.style={font={\scriptsize},anchor=west,align=left},
    legend box/.style={rectangle, draw, minimum size=5pt},
    axis/.style={black,semithick,->},
    axis label/.style={anchor=east,font={\tiny}},
]

\tikzstyle{bar chart}=[
    chart,
    bar width/.code={
        \pgfmathparse{##1/2}
        \global\let\bar@w\pgfmathresult
    },
    bar/.style={very thick, draw=white},
    bar label/.style={font={\bf\small},anchor=north},
    bar value/.style={font={\footnotesize}},
    bar width=.75,
]

\tikzstyle{pie chart}=[
    chart,
    slice/.style={line cap=round, line join=round, very thick,draw=white},
    pie title/.style={font={\bf}},
    slice type/.style 2 args={
        ##1/.style={fill=##2},
        values of ##1/.style={}
    }
]

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}


\newcommand{\pie}[3][]{
    \begin{scope}[#1]
    \pgfmathsetmacro{\curA}{90}
    \pgfmathsetmacro{\r}{1}
    \def\c{(0,0)}
    \node[pie title] at (90:1.3) {#2};
    \foreach \v/\s in{#3}{
        \pgfmathsetmacro{\deltaA}{\v/100*360}
        \pgfmathsetmacro{\nextA}{\curA + \deltaA}
        \pgfmathsetmacro{\midA}{(\curA+\nextA)/2}

        \path[slice,\s] \c
            -- +(\curA:\r)
            arc (\curA:\nextA:\r)
            -- cycle;
        \pgfmathsetmacro{\d}{max((\deltaA * -(.5/50) + 1) , .5)}

        \begin{pgfonlayer}{foreground}
        \path \c -- node[pos=\d,pie values,values of \s]{$\v\%$} +(\midA:\r);
        \end{pgfonlayer}

        \global\let\curA\nextA
    }
    \end{scope}
}

\newcommand{\legend}[2][]{
    \begin{scope}[#1]
    \path
        \foreach \n/\s in {#2}
            {
                  ++(0,-10pt) node[\s,legend box] {} +(5pt,0) node[legend label] {\n}
            }
    ;
    \end{scope}
}

Thanks in advance.

Best Answer

The \pie macro does

\path \c -- node[pos=\d,pie values,values of \s]{$\v\%$} +(\midA:\r);

meaning that the numbers in the slices is set in math mode. Your font setup probably doesn't change the math font, so you get standard one.

Remove the dollar signs from the node text, and the numbers will be set in text mode instead:

\path \c -- node[pos=\d,pie values,values of \s]{\v\%} +(\midA:\r);