Yes the fonts have to be installed correctly for it to work. In my testing, the fonts have to be available from two places: inside the MathTEXEngine folder and from the system’s font folder (which depends on the OS, among other things). While it does work eventually (as you can see from the examples in the docs), it’s sometimes a struggle getting there. The problem is that successfully installing fonts on all OS combinations isn’t as easy as it should be.
I would recommend the Luxor GitHub page. If there is nothing about this in the documentation, add a comment on an issue if you find one or make an issue if you don’t.
It’s fair to describe LaTEX support as experimental at present. But if you don’t see the right fonts at all, then it might be something to do with how you installed them. Perhaps you could provide more details in a new issue …
Could you give an example of what you’d normally type in LaTeX? I can check the code to see if it’s possible. (Note that Latex support in Luxor is currently on hold, pending developments in Cairo.jl.)
For example, the figure below shows the text “coordinate” and the function name “sin” as regular text, while the variable “x” is shown in italics. The input for xlabel would be L"$x$ coordinate" and for ylabel L"$\sin(x^2)$".
I noticed that Makie can render this way using MathTexEngine; however, I could not figure out how they implemented that.
Haha, yes, I don’t think this is possible. The Makie folks have implemented a powerful font system that does all kind of things; Luxor isn’t in the same league…
There’s a possible workaround for text placement, an old experimental function which was kind of made obsolete when MathTeXEngine.jl came along: Luxor.textplace() . I had to use it once…
@drawsvg begin
background("black")
sethue("gold")
fontface("Cmr10")
textplace("sin x2", Point(-250, 0),
[
(face = "Cmr10", color = colorant"gold", size = 200,), # s
(), # i
(), # n
(), # ' '
(face = "Cmmi10",), #x
(size = 150, shift = 50,), #2
],
action=:fill
)
end
I managed to display regular and italic text in equations using Luxor, LaTeXStrings, and MathTexEngine. Thanks @cormullion, for the insights.
Below is an example figure and the code I used. The function setlatex is similar to the settext function but for latex strings. I believe that something like this can be easily added to Luxor.