Coder Social home page Coder Social logo

Add Inter Font Support about gr HOT 7 OPEN

EldarAgalarov avatar EldarAgalarov commented on August 16, 2024
Add Inter Font Support

from gr.

Comments (7)

IngoMeyer441 avatar IngoMeyer441 commented on August 16, 2024 1

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.

from gr.

jheinen avatar jheinen commented on August 16, 2024 1

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.

from gr.

danielkaiser avatar danielkaiser commented on August 16, 2024

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

from gr.

EldarAgalarov avatar EldarAgalarov commented on August 16, 2024

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

from gr.

danielkaiser avatar danielkaiser commented on August 16, 2024

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?

from gr.

EldarAgalarov avatar EldarAgalarov commented on August 16, 2024

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

from gr.

EldarAgalarov avatar EldarAgalarov commented on August 16, 2024

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

from gr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.