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

fonts not working on Linux #138

Open
jmodlis opened this issue Jun 6, 2023 · 9 comments
Open

fonts not working on Linux #138

jmodlis opened this issue Jun 6, 2023 · 9 comments

Comments

@jmodlis
Copy link

jmodlis commented Jun 6, 2023

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
Copy link

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

@nx10
Copy link
Owner

nx10 commented Jul 15, 2023

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
Copy link

grst commented Jul 23, 2023

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

@nx10
Copy link
Owner

nx10 commented Jul 23, 2023

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
Copy link

jimjam-slam commented Aug 23, 2023

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
Copy link

jimjam-slam commented Aug 23, 2023

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
Copy link

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.

@agilly
Copy link

agilly commented Nov 11, 2024

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

This works, to be clear, you have to go to the URL (in vscode there's an icon with a square and an arrow pointing to the top right above the plot), then inspect the page or otherwise access the SVG that you see displayed there. Open it in a text editor, you'll see a bunch of font-family attributes, which in my case were "DejaVu Sans" or "Nimbus Sans" (seemingly at random). I installed these fonts on my Mac, then rebooted, and it worked.

My setup: MacBook running VSCode, remote server with R extension running on remote with latest httpgd.

@nx10 I do not know if you are involved with the VS Code integration, but it would be nice to somehow expose the system_fonts argument to allow for some kind of mapping between sans and a font that already exists on the host.

@jmodlis
Copy link
Author

jmodlis commented Nov 20, 2024

I'm coming here to second @agilly's comment, which somehow was written in a way such that I finally understood... I tried for many hours to do all sorts of fancy things with system fonts, VS-Code settings, etc. In the end the solution for me was simple:

  1. Download the DejaVu Sans font or whatever is in the SVG if it's diferent for you) to my laptop, I downloaded the font from: https://www.fontsquirrel.com/fonts/dejavu-sans
  2. Install the DejaVu Sans font on my personal computer/laptop using the Font Book application (instructions: https://support.apple.com/guide/font-book/install-and-validate-fonts-fntbk1000/mac)
  3. Re-open the VSCode Instance.

I am utilizing a CodeServer instance via Open OnDemand. The job is handled via a slurm scheduler, the OS is Rocky9. My laptop/local computer is an Apple M1 operating under the Monterey OS.

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

7 participants