This generates the figure, shown below, with the mismatched fonts. Is it possible to change the default Latex font (on the x-axis) to match the y-axis font?
As far as I understand, @Kolaru took the care to pick settings for Computer Modern manually, like where to put letters next to the integral sign, etc. Also the glyph indices for the special symbols. All this would need to be redone for any other font to work well, it’s not just a matter of picking one. If any of you is motivated enough to do it, I’m sure @Kolaru would have some tips how it’s done.
If the problem is consistency, I have just put out a new patch where you can do the following:
using CairoMakie
using MathTeXEngine
fig = Figure()
fig[1, 1] = Label(fig, "Here is a label", font=texfont())
fig[2, 1] = Label(fig, L"Here is another label $x$")
The problem is that if we want to support them, someone has to go through all constructs and make sure they render correctly. I did that manually for NewComputerModern, and hardcoded a lot of the placement values.
I suspect the necessary information for all these fonts is available somewhere, but I don’t know where and I don’t understand the structure or magic of LaTeX packages. So I don’t plan to go further in this direction myself, for the forseeable future.
Just mentioning in passing that the same problem has been (is being) tackled by Mathjax, so there’s probably useful information to obtain from that side: MathJax Font Support — MathJax 3.2 documentation
In particular, since the glyph positioning is handled completely independently of TeX, they may have more readable information that could be reused here. (I briefly interacted with one of the devs, for a project replacing glyphs with custom SVG paths, and it seems most of the machinery is already in place and will become much easier in v3)
Since I had the same problem a few days ago, I thought I’d share the theme snippet I ended up with, to make all non-latex text elements look similar to the latex ones:
using MathTeXEngine # required for texfont
textheme = Theme(fonts=(; regular=texfont(:text),
bold=texfont(:bold),
italic=texfont(:italic),
bold_italic=texfont(:bolditalic)))
with_theme(textheme) do
fig = Figure(resolution=(400,300))
ax = Axis(fig[1,1],
title="foo",
xlabel="whatever",
ylabel=L"$\mathcal{H_\infty}$ Norm",
xticks=(1:10, vcat(L"\sum i", repr.(2:10))))
scatter!(ax, rand(10))
fig
end