Setting font of minus sign in exponent in Makie

With the following code:

using CairoMakie
CairoMakie.activate!()

set_theme!()
set_theme!(font = "Arial",)

function log_tick_formatter(values)
    return map(v -> "10" * Makie.UnicodeFun.to_superscript(round(Int64, v)), values)
end


x = 10.0.^(-3:0.1:2)
y = -3:0.1:2
data = x .* ones(Float64, 1, length(y))

ticks = -3:1:2

fig = Figure(resolution = (243,216))

ax, hm = heatmap(fig[1, 1], x, y, log10.(data),
    axis=(;xscale=log10, xminorticksvisible=true, xminorticks=IntervalsBetween(9)))

cb = Colorbar(fig[1, 2], hm; ticks=ticks, tickformat=log_tick_formatter)

colgap!(fig.layout, Relative(0.05))

display(fig)
save("test_fig_1.pdf", fig, pt_per_unit=1)

I get this figure

test_fig

When I inspect the font in PDE viewer and Adobe Illustrator, I find that the font of the minus sign in the exponent (e.g. 10^{-2}) is DejaVuSans even though I specify the default font to Arial. Notice that the minus sign in the exponent appears longer than the minus sign in ‘-2’ in the y-axis. I have a couple questions:

  1. Are there ways to change the font of the minus sign in exponent to Arial or whatever I specify, so that it appears the same as the those not in exponents?
  2. If not, are there ways to make change the fonts of those scientific notations fonts to Latex font (default to computer modern, right?)
  3. Ultimately I would like to change the default font for everything (regular texts and numbers like those shown in this figure + Latex fonts). I know many special math symbols are not supported in a specific font like Arial, but at least from my experience for a simple figure like this one I can pretty much unify all the fonts to something like Arial.
1 Like

I believe the font wouldnt change if Arial had the glyph, the problem is that each of these exponent glyphs is its own thing completely separate from the normal version. I’ve been wanting to add some basic subscript superscript functionality to base Makie (not at the level of MathTeXEngine but also not limited to Computer Modern) for that reason, some numbers and the point can also look wonky in exponents. In that mode the superscripts would just be shifted and scaled normal glyphs, so you’d have the full glyph set available.

So I just looked up the unicode of superscript minus, which is 207B. Illustrator fails to display this character in Arial, so maybe the issues I had really has something to do with the glyph. I then try other fonts like Times New Roman, Helvetica, Calibri and Cambria, all of which should support superscript minus based on Illustrator (it manages to display superscript minus for these fonts). However, for Helvetica, Cairomakie again converts the font of the superscript minus back to DejaVuSans, so I’m not sure if the problem is entirely due to the lack of relevant glyph.

Old fonts like Helvetica (one of the original Postscript fonts from the 1980s, years before Unicode even existed) don’t have good unicode coverage, so probably Illustrator is not using a superscript glyph but is just drawing superscripts itself.

Basically, if you use old fonts with poor Unicode coverage, you will start to hit fallback fonts instead. (That’s also why math rendering in e.g. TeX is typically done in specialized fonts.)