I wish to define a mathematical symbol, similar to \odot, using TikZ. The symbol should thus scale appropriately in accordance with its context (e.g. inline math, footnotes, diagrams, etc.). As a template, I followed this related question. However, it doesn't appear to be scaling correctly in all contexts. Furthermore, the spacing around the symbol is subtly wrong.
Here is a minimal working example:
\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz-cd}
\newlength{\oh}
\newcommand{\ostar}{\mathbin{\vcenter{\hbox{\text{\settoheight{\oh}{$\odot$}\tikz[baseline=.45\oh]{\drawline width=.06\ohcircle[radius=.57\oh]node[overlay,yshift=-.025\oh]{\ensuremath{*}};}}}}}}
\begin{document}
\begin{align}
f \odot g \
f \ostar g \
x^{f \odot g} \
x^{f \ostar g} \
\end{align}
\vspace{-7ex}
[\begin{tikzcd}[column sep=large,row sep=tiny]
\cdot & \cdot \
\cdot & \cdot \
\arrow["{f \odot g}"{description}, from=1-1, to=1-2]
\arrow["{f \ostar g}"{description}, from=2-1, to=2-2]
\end{tikzcd}]
\end{document}
which produces:
As seen in the image, the size of \ostar is correct for normal size math and in the commutative diagram. However, it is too large in the superscript (with respect to \odot), even though it should be scaled proportionally to \odot (since all the dimensions are with respect to \oh). Furthermore, though it is a little hard to see in the image, there is less spacing around \ostar than around \odot in every place it is used.
I suspect there's a simple solution, but I haven't been able to figure it out. How can I fix the definition of \ostar so that it behaves the same as \odot?
(Note that I actually want to define more complicated symbols than \ostar using the same method, so alternative solutions like this one do not suffice for my purposes.)


\text{$\vcenter{...}$}in order to fix the size. But this won't work intikzcd, because you're nestingtikzpictureinsidetikzpicture. – egreg May 17 '23 at 10:52tikzcd, but it is perhaps close enough to be acceptable. – varkor May 17 '23 at 12:05