4

I write a TeX-document on two PCs, the files are transferred via USB-Stick. The document should be printed with a specific font. For legal reaons the font is only available on one PC.

When I translate the document in the PC without the font, I get a fontspec error: "font-not-found". (same error in another question)

The finished document shows no characters.

Is there a mechanism to detect this problem and switch to another font?

Actually I change my font selection each time I change the computer. But I want to avoid to use two versions of my style. I would like to have one style for each computer.

A MWE:

\documentclass{article}
\usepackage{fontspec}
%This throws an error - I want to catch it and use another font
\setmainfont{My Font on other PC} 
%If error:
%\setmainfont{Arial} 
\begin{document}
Test
\end{document}

My wish: This document will be translated without an error with lualatex on a windows PC. If the font My Font on other PC is installed, it is used. If it is not installed, the alternative should be used.

1 Answer 1

2

Luatex may let you catch that I'm not sure, but a simpler method that would also work with classic TeX is to simply replace

\setmainfont{My Font on other PC} 

by

\input{setdefaultfont}

then anywhere on the tex input path on the two machines you have a setdefaultfont.tex which you do not transfer between the machines.

On one machine the file has the line

\setmainfont{My Font on other PC} 

and on the other it has the line

\setmainfont{Arial} 
2
  • +1 What I don't like with this solution: setdefaultfont.tex must be defined on each new PC and if I get the font on my 2nd PC, I have to adapt setdefaultfont.tex. Let's see, if another solution will come up.
    – knut
    Commented Mar 28, 2013 at 20:31
  • 1
    Instead You might prefer to have \InputIfFileExists{setdefaultfont}{}{\setmainfont{Arial}} then you only need the file on machines which are not going to use arial Commented Mar 28, 2013 at 20:33

You must log in to answer this question.

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