blue-build / modules

BlueBuild standard modules used for building your Atomic Images
Apache License 2.0
24 stars 25 forks source link

Font module: Nested font in /usr/share/fonts/nerd-fonts and /usr/share/fonts/google-fonts not recognized by vscode running in distrobox #58

Closed nhubaotruong closed 10 months ago

nhubaotruong commented 10 months ago

Hi, I'd like to report that nested font in /usr/share/fonts/nerd-fonts/* and /usr/share/fonts/google-fonts/* not recognized by vscode running in distrobox.

I tried to manual install the fonts using script modules, which only put the fonts in /usr/share/fonts/$font and it does get picked up

Ex: /usr/share/fonts/nerd-fonts/Meslo/* doesn't get picked up by vscode

/usr/share/fonts/Meslo/* does get picked up by vscode

lucasvsr commented 10 months ago

This happens because distrobox does not see the fonts installed on the host. To do this, it is necessary to load the fonts that are in /run/host/usr/share/fonts, which is where the distrobox loads the fonts available on the host. Use the command fc-cache -f /run/host/usr/share/fonts

nhubaotruong commented 10 months ago

Distrobox auto mounts the system font in /usr/local/share/fonts inside the container, I'm not sure why it didn't get picked up if the font is nested in 2 layers or more

lucasvsr commented 10 months ago

I'm using version 1.5.0.2 of distrobox and it only mounts the following directories/files:

/tmp:/tmp /var/home/:/var/home/ /:/run/host /sys:/sys /dev:/dev /etc/hosts:/etc/hosts /etc/resolv.conf:/etc/resolv.conf /usr/bin/distrobox-host-exec:/usr/bin/distrobox-host-exec /usr/bin/distrobox-export:/usr/bin/distrobox-export

But apparently, the problem is vscode. I tried to use a font that was in /run/host/usr/share/fonts and it didn't recognize it. When I used gnome-text-editor (installed in container) it worked.

It looks like the solution at the moment is what you implemented in the PR.

nhubaotruong commented 10 months ago

I won't be at the computer for the next 4 days, please take your time to review if necessary

nhubaotruong commented 10 months ago

@lucasvsr Hi, I've been doing some testing on my machine for a few days, it seems that this situation was caused by fontconfig cache, which isn't compatible across many distros as mentioned here

A simple fix was just to run fc-cache -f in the distrobox container after adding the font module

I'll close this issue and the PR, thanks for your time

nhubaotruong commented 10 months ago

Expanding on my explaination in case someone reads this thread.

Vscode installed in arch container are from aur, which uses the source from static build of vscode (.tar.gz file), which doesn't use system fontconfig, therefore it doesn't picked up the nested font like other applications.

Vscode installed in ubuntu container (deb) and fedora container (rpm) picks up the font just fine

trevnels commented 7 months ago

I'm currently seeing what I believe to be the same issue with a Fedora 39 host and Fedora 39 container, even after clearing the font cache. Even though the font is recognized by name through fc-match inside the distrobox, VSCode is still not able to use it.

rm -rf'ing ~/.cache/fontconfig does seem to fix it temporarily, but it regresses after a while. I'm wondering if this has to do with flatpak runtimes bumping fontconfig to 2.15 while Fedora and my distrobox are still on 2.14.2, and there's some incompatibility between the caches.