2

My setup consists of a Windows 10 installation with the Windows Subsystem for Linux (WSL). Within WSL, I use Debian 10. I do not have any LaTeX distribution installed on Windows. Instead, I use the TeXlive distribution that comes in Debian 10's repositories. If it is of any relevance, I use Visual Studio Code with the LaTeX Workshop and Remote - WSL extensions.

For my slides, I use the Metropolis theme. The theme is supposed to be used in conjuction with XeLaTeX, because it searches for the Fira Sans font family among the system fonts. I already have the Fira Sans font family in C:\Windows\Fonts, and I know I could copy the ttf files into /usr/local/share/fonts/ within WSL (this is how I am rolling at the moment, and it works). However, this duplicates files and doubles the required disk space.

Can I permanently instruct xelatex in WSL to use fonts in C:\Windows\Fonts? If yes, how? I know I can use the suggestions in this question to tell each individual document where to look for fonts. Instead, I ask whether I can permanently change the font default search path for xelatex in WSL, so that it would search in /mnt/c/Windows/Fonts.

Side question: would the answer to my question be desirable in terms of performance? By design, WSL has worse IO performance when accessing files in /mnt/c compared to using files "locally" within WSL (i.e., /usr and ~). Here is an account on the issue. So maybe telling /usr/bin/xelatex to use fonts in /mnt/c/Windows/Fonts is a bad idea, because it would negatively impact compilation times in a significant and noticeable way.

1 Answer 1

5

I will assume that there is no real reason why you would only want to add the paths to xelatex, so the easiest way is probably to add the Windows font path to fontspec such that the fonts get picked up by all WSL programs:

Under WSL, create a new fontconfig configuration file under the name ~/.config/fontconfig/fonts.conf. In this file, write

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <dir>/mnt/c/Windows/Fonts/</dir>
</fontconfig>

After changing the configuration you should execute fc-cache to update font caches from fontconfig. You might have to run fc-cache again after installing a new font in the windows directories in order to pick it up.

The advantage of this caching is that most documents will not even have to access the Windows font folder if the cached data shows that the font in question is not in the windows directory, so the bad IO performance will only affect you if you actually use one of your Windows fonts.

2
  • Most documents will not even have to access the Windows font folder if the cached data shows that the font in question is not in the windows directory. This does not apply to my case, where I'd use Fira Sans from C:\Windows\Fonts, right? Everytime I'd run xelatex, it would have to pick up the font from the Windows folder. So performance considerations do apply to this specific use-case. Am I understanding correctly? Apr 21, 2020 at 15:05
  • 1
    @apsql You are understanding that correctly, but the slow access to the windows directory only occurs for the font files and there is no full tree search done in every run. Therefore it shouldn't be a problem. Apr 21, 2020 at 15:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .