Printing specific unicode character in otf file using MathTeXEngine

When using MathTeXEngine within Makie, I need to put a specific font for N in the graph. I am using \mathcal{N} within LaTeX, and would like an N which looks similar. I cannot change the font for the LaTeX font.

The mathcal{N} which MathTeXEngine chooses is shown below. I would like to use the N given by index 2775 in the same otf font file. Is there some way for me to accomplish this?

using MathTeXEngine
    1-element Vector{Any}:
     (TeXChar 'š“' [index 2823 in NewComputerModern Math - Regular], [0.0, 0.0], 1.0)

It looks like you can just add new Unicode characters to the font mapping in MathTeXEngine.jl and then use that Unicode directly in the LaTeX string (rather than \mathcal):

julia> MathTeXEngine._symbol_to_new_computer_modern['š“'] = ("NewComputerModern/NewCMMath-Regular.otf", 2775)
("NewComputerModern/NewCMMath-Regular.otf", 2775)

julia> generate_tex_elements("š“")
1-element Vector{Any}:
 (TeXChar 'š“' [index 2775 in NewComputerModern Math - Regular], Float32[0.0, 0.0], 1.0)

This is just a hack, of course, from looking into the source code. Iā€™m not sure if there is a documented/approved way to do this.

1 Like