Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Inter Font Support #171

Open
EldarAgalarov opened this issue Feb 16, 2023 · 7 comments
Open

Add Inter Font Support #171

EldarAgalarov opened this issue Feb 16, 2023 · 7 comments

Comments

@EldarAgalarov
Copy link

EldarAgalarov commented Feb 16, 2023

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 :(

@danielkaiser
Copy link
Contributor

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);
}

@EldarAgalarov
Copy link
Author

Hi @danielkaiser
Can I load Inter font into GR using Julia? I'm using GR Framework as backend of the Julian's Plots library.

@IngoMeyer441
Copy link
Member

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.

@danielkaiser
Copy link
Contributor

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?

@EldarAgalarov
Copy link
Author

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

@jheinen
Copy link
Collaborator

jheinen commented Mar 10, 2023

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")

Screenshot 2023-03-10 at 07 14 42

This plot was created using a symbolic link Inter.ttf => Inter-Regular.ttf.

@EldarAgalarov
Copy link
Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants