(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}
\newcommand{\firstsymbol}{%
\begin{tikzpicture}[my style]
\draw (0, 0) circle;
\end{tikzpicture}%
}
\tikzpicturestructure inside the\newcommandentity ? – fpavogt Aug 17 '21 at 07:57\node{.}. Does matplotlib then show the dot and the circle? – Ulrike Fischer Aug 17 '21 at 08:01matplotlibonly shows (on-screen) the text of the node (if I save using thepgfbackend, it all works fine of course). If I ask the node to have (e.g.) a green circle around it withnode[circle, draw=green] {.}, it still only shows the text of the node. – fpavogt Aug 17 '21 at 09:02\baselineskip. – Davislor Aug 17 '21 at 17:23\mathchoice. – Davislor Aug 17 '21 at 17:43matplotlibrequires to display thetikzpicture) that way. For the scaling, I was already drawing the symbols the the correct text scale using ex units. Did you mean something different ? – fpavogt Aug 18 '21 at 06:35tikzwas ideal to draw them with no fuss, without having to deal with the whole "font" Universe ... But since I end up needing proper font metrics, I guess there's no by-passing this ... ? – fpavogt Aug 22 '21 at 19:06fontspecnow supports those. – Davislor Aug 22 '21 at 20:31