Fonts: Difference between revisions

Fix solutions for tufo fonts problem in flatpak applications
Flatpak font probem
Line 124: Line 124:
</syntaxhighlight>
</syntaxhighlight>


==== Best Solution: Copy all your fonts to $HOME and allow flatpak applications to access ====
==== Best Solution: Just copy necessary fonts to <code>$HOME/.local/share/fonts</code> ====
Create fonts directory <code>$HOME/.local/share/fonts</code> and copy system fonts with option <code>-L, --dereference</code>  .<syntaxhighlight lang="bash">
Create fonts directory <code>$HOME/.local/share/fonts</code> and copy system fonts with option <code>-L, --dereference</code>  .<syntaxhighlight lang="bash">
mkdir $HOME/.local/share/fonts && cp -L /run/current-system/sw/share/X11/fonts/* $HOME/.local/share/fonts/
mkdir $HOME/.local/share/fonts && cp -L /run/current-system/sw/share/X11/fonts/* $HOME/.local/share/fonts/
</syntaxhighlight>Grant flatpak applications access to your fonts directory.<syntaxhighlight lang="bash">
</syntaxhighlight>Note: There is '''no need''' to grant flatpak applications access to <code>$HOME/.local/share/fonts</code>.
flatpak --user override --filesystem=$HOME/.local/share/fonts:ro
</syntaxhighlight>


==== Possible Method: Create symlink to system fonts at  <code>$HOME/.local/share/fonts</code> ====
Instead, if you do that, some applications (for example, steam) won't work.<blockquote>Internals: How it works?
 
Flatpak applications run in sandboxes. When you start a flatpak application, flatpak builds a rootfs for it with bubblewrap.
 
With <code>findmnt --task {PID of flatpak app}</code> , you can explore the details of its rootfs.
 
By default, flatpak mounts <code>$HOME/.local/share/fonts</code> to <code>/run/host/user-fonts</code> in rootfs of an flatpak application.<syntaxhighlight lang="json">
{
  "target": "/run/host/user-fonts",
  "source": "/dev/disk/by-uuid/b2e1e6b5-738b-410b-b736-6d5c3dbbe31f[/home/username/.local/share/fonts]",
  "fstype": "ext4",
  "options": "ro,nosuid,nodev,relatime"
}
</syntaxhighlight>Then flatpak application can read fonts from that to display contents correctly.</blockquote>
 
==== Another Method: Create symlink to system fonts at  <code>$HOME/.local/share/fonts</code> ====
<blockquote>'''Note:''' this method doesn't work for some flatpak applications (for example, steam)!
<blockquote>'''Note:''' this method doesn't work for some flatpak applications (for example, steam)!