Open EldarAgalarov opened 1 year ago
Hi,
we only bundle a very limited amount of fonts to keep the GR runtime downloads small. For this reason we even removed existing fonts and instead added the gr_loadfont
function, with the help of which you can load arbitrary fonts.
This function also searches the default font directories of the operating system, so if you presumably have Inter
installed, this snippet should be sufficient to use the Inter
font in GR:
int font;
gr_loadfont("Inter-Regular.ttf", &font);
if (font >= 0) {
gr_settextfontprec(font, 3);
}
Hi @danielkaiser Can I load Inter font into GR using Julia? I'm using GR Framework as backend of the Julian's Plots library.
Hey @EldarAgalarov,
the direct GR wrapper GR.jl has support for custom user fonts, see the user_fonts.jl
example as a reference. However, I don't know if GR.jl and Plots can be mixed together. Probably @jheinen can tell more about this.
Hi @EldarAgalarov,
with this commit by @jheinen in Plots.jl (included since version 1.38.6) loading of custom fonts with the GR backend should be supported there as well.
Does this solve your issue?
Hi @danielkaiser Tried without success:
using Plots
ENV["GKS_FONT_DIRS"] = joinpath(pwd(), "Documents", "inter") # Inter.ttf
p = plot(1:10, rand(10), title = "Title", label = "Label", xguide = "xGuide", yguide = "yGuide")
f = font("Inter")
Plots.gr_set_font(f, p[1])
p
Could you please try:
ENV["GKS_FONT_DIRS"] = joinpath(pwd(), "Documents", "inter") # Inter.ttf
using Plots
default(fontfamily="Inter")
p = plot(1:10, rand(10), title = "Title", label = "Label", xguide = "xGuide", yguide = "yGuide")
This plot was created using a symbolic link Inter.ttf => Inter-Regular.ttf
.
Hi @jheinen Your code works!
PS. It would be nice to add support for variable fonts (all styles are packed into one file) and for OpenType fonts (.otf).
Hi. It would be great if Inter font will be supported by GR. Ugly and scary fonts like Courier are supported, but not beautiful fonts like Inter :(