As stated in the topic title, saving a plot to a pdf when using the fontfamily “Palatino Roman” doesn’t show negative signs.
Here’s a MWE:
f(x) = x^2-3
pl = plot(f, -3, 3, fontfamily="Palatino Roman")
and these are the resulting plots:
First the plot as a png:
And now a screenshot of the plot as a pdf (a screenshot because I can’t upload pdfs):
I am using Plots v1.16.8
I’m posting here instead of submitting an issue because I don’t want to spam Github by submitting an issue that’s known. I searched but couldn’t find any issue similar. I also don’t know if I should submit an issue for Plots.jl or one of the backends.
What backend are you using?
It looks like the backend has text rendering that doesn’t support fallback fonts, and Palatino Roman is missing a glyph for the minus sign (U+2212).
I believe it’s GR (or the default). I created a new environment with Plots.jl as the only package added.
I’ve uploaded the Project.toml and Manifest.toml files here: Manifest.toml · GitHub
GR doesn’t support fallback fonts last I heard, which means that it won’t render any Unicode characters that aren’t present in your font, and hence you need to use a font with sufficient Unicode coverage. See also the discussion in Error with unicode labels in GR backend · Issue #791 · JuliaPlots/Plots.jl · GitHub
Thank you, @stevengj
In case anyone runs into this thread, there is a another issue submitted here: Error about savefig · Issue #2938 · JuliaPlots/Plots.jl · GitHub
GR can not embed fonts into the PDF output. You will have to provide a “Palatino” font with the corresponding UTF-8 glyphs (using the
GKS_FONT_DIRS environment) and use GR’s internal text renderer (using
GR.settextfontprec(..., GR.TEXT_PRECISION_OUTLINE)). I can try to provide an example next week …
ENV["GKS_FONT_DIRS"] = pwd()
font = loadfont("Rockness.ttf")
text(0.5, 0.5, "The quick brown fox jumps over the lazy dog")
font = loadfont("Palatino-Roman.ttf")
text(0.5, 0.4, "– The quick brown fox jumps over the lazy dog –")
You will find the above fonts here.