fontslatexxelatex

Xelatex cannot find font path


I wanted to use the font QTLinostroke.otf from the apt package texlive-fonts-extra in Ubuntu using xelatex. I installed the apt package

sudo apt install texlive-fonts-extra

The font file by default is installed in the path /usr/share/texlive/texmf-dist/fonts/opentype/public/qualitype/QTLinostroke.otf Then I ran the following tex file using xelatex.

%!TeX program=xelatex
\documentclass[12pt]{article}

\usepackage[a4paper,margin=2.05cm]{geometry}
\usepackage{fontspec}

\setmainfont{QTLinostroke}

\begin{document}

The quick brown fox jumps over lazy the dog.

\end{document}

However, xelatex couldn't find the font file. However, if I copy the file QTLinostroke.otf to $HOME/.fonts/ folder then the tex file compiles without a hitch. So my questions are

  1. Why can't xelatex find the font system font file which is a part of the texlive package.
  2. The font size (once I managed to compile it) is too small for this particular font, even though I say 12pt in the documentclass.

Solution

  • The workaround that I have already mentioned in my question (when compiling with xelatex) is to copy the font file to ~/.fonts/ folder.

    # Get the fontpath. Usually it is
    # /usr/share/texlive/texmf-dist/fonts/opentype/public/qualitype/QTLinostroke.otf
    fontpath=$(apt-file list texlive-fonts-extra | grep QTLinostroke.otf \
        | cut -d" " -f2)
    
    # Create the ~/.fonts/ directory and copy the .otf file
    mkdir -p ~/.fonts/
    cp "${fontpath}" ~/.fonts/ 
    

    With this xelatex also finds the font and compiles it nicely.