(Note: this question is similar to quite a few others on SO (e.g. this one, that one, that other one, ... but I could find none discussing the explicit need for the new symbols to have proper font metrics attached.)

Dear Hive Mind,

I need/want to use LaTeX to include custom symbols in Python (matplotlib) plots.

I initially used metafont to create the symbols, but ended up using tikz instead to get vector quality symbols, and packed them up in a dedicated LaTeX package. This works perfectly from the LaTeX perspective. However, I eventually learned that matplotlib requires proper font metrics for elements to be displayed correctly in the figure text elements.

Hence this question: what would be the proper/cleanest way to create new LaTeX symbols with full font metric ?

Can I still use tikz and add the font metric info to it ? Do I need to create a full vector font instead ? What would be the 2021 best tool to do so ? Is pict2e what I am looking for ?

Edit 23.08.2021: pict2e (as suggested here) does not solve the problem with the font metrics.

Note 23.08.2021: I have started looking closely at FontForge, but have encountered some issues.

For the record, here's a simplified excerpt of my tikz code inside the .dtx file:

%    \begin{macrocode}
\tikzset{my style/.style={line width=0.2ex, radius=1ex, baseline=-0.6ex}}

%    \end{macrocode}
% \noindent Next, each symbol is being defined individually.
% \begin{macro}{\firstsymbol}
% The first symbol:
%    \begin{macrocode}
   \begin{tikzpicture}[my style]
   \draw  (0, 0) circle;
  • what happens if you add some text to the circle, e.g. tiny periods at the bottom left and the top right of the circle? Commented Aug 17, 2021 at 7:39
  • @UlrikeFischer: do you mean around the \tikzpicture structure inside the \newcommand entity ?
    – fpavogt
    Commented Aug 17, 2021 at 7:57
  • I mean inside the tikzpicture, add some \node{.}. Does matplotlib then show the dot and the circle? Commented Aug 17, 2021 at 8:01
  • No, matplotlib only shows (on-screen) the text of the node (if I save using the pgf backend, it all works fine of course). If I ask the node to have (e.g.) a green circle around it with node[circle, draw=green] {.}, it still only shows the text of the node.
    – fpavogt
    Commented Aug 17, 2021 at 9:02
  • that sounds as if you will have to create a proper font, e.g. with fontforge. Commented Aug 17, 2021 at 9:05

1 Answer 1


Two years down the line, and the solution has taken the following form.

Essentially, I draw the symbols using TikZ, then create an OpenType font with the resulting SVGs using FontForge, before bundling it into a LaTeX package.

The resulting package was uploaded to CTAN.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .