nx10 / httpgd

Asynchronous http server graphics device for R.
https://nx10.github.io/httpgd
GNU General Public License v2.0
368 stars 19 forks source link

fonts not working on Linux #138

Open jmodlis opened 1 year ago

jmodlis commented 1 year ago

Hello,

I have been testing out R in VSCode and the fonts don't appear to be working properly (and appear to be a serifed font). I have seen #85, but unlike in that post, it does appear that the fonts are installed on the machine. The exported plots (I checked pdf and png) have the correct font, but Vscode/R/httpgd plot display does not. The problem occurs in both a "normal" R environment and a conda environment in Linux.

I have been through the httpgd documents, the svglite documentation, and systemfonts documentation (like the commenter in #85), but I'm not really sure where to start with this issue. Do you have any suggestions?

Editing to add that the plots are working properly locally (Mac), and that when I don't use httpgd when I'm working remotely (linux) the X window also displays the proper font.

Thanks! Jen

DogDaodao commented 1 year ago

I have a same problem when using httpgd in a remote vscode server, but works fine in native vscode on windows/linux

nx10 commented 1 year ago

Thanks for trying out httpgd and opening the issue!

Fonts are not embedded in the SVG so they have to be installed both on the server as well as locally.

If they are and it still does not work let us know

grst commented 1 year ago

How can I find out what's the font that is missing? 🙈

nx10 commented 1 year ago

You can look it up in the .SVG if you open it in a text editor. Otherwise you can attach it here then I will have a look.

jimjam-slam commented 11 months ago

I should maybe open a separate issue for this, but given {svglite} supports passing a URL for a @font-face declaration to the device's web_fonts argument, it would be great it we could supply that string to {httpgd} too.

I'm running a workshop using a VSCode dev container that will run in Codespaces, and I'd love to be able to supply a font that works as well in {httpgd}'s viewer as it does in rendered raster plots. Like the other commenters, I can't get fonts to appear in the viewer even if they're installed on both the container and my own system (they work great in the viewer if I use it on macOS natively).

jimjam-slam commented 11 months ago

The container I have set up is here: https://github.com/jimjam-slam/icuc11-workshop-dataviz/tree/main (you can launch it in Codespaces here).

The fonts are kept in .devcontainer and transfered to /usr/local/share/fonts in the container. .Rprofile then registers them with systemfonts::register_font to overwrite sans. I'm assuming I also need to add something like this block in the VSCode-R Wiki (nope, that's to open the web page in VSCode instead!).

I find that font support is unchanged even if I manually call hgd() with system_fonts or user_fonts supplied. It doesn't take the web_fonts argument, though, so maybe that's not surprising!

memeplex commented 4 months ago

I'm running the VSCode R extension, which uses httpgd, and e.g:

r$> hist(c(1,2,3,1,2,3))
Warning message:
No fonts detected on your system. Using an empty font. 

This doesn't happen when running the same line from a non-attached R repl.

This is macOS Sonoma, but I guess it's the same issue.