I have installed non standard font (ISOCPEUR.TTF) whiсh respond to \showfont command like this:
\newcommand{\showfont}{encoding: \f@encoding{},
family: \f@family{},
series: \f@series{},
shape: \f@shape{},
size: \f@size{}
}
The command \newcommand{\iso}{\fontfamily{iso}\selectfont}
set "iso" font, but if such is not installed switch to computern modern.
I want to create a command which set "iso" font, but if such font is not installed, the command must set \sffamily font.
I tried but my efforts have not been successful
\newcommand\f@family@iso{iso}
\newcommand{\iso}{\fontfamily{iso}\selectfont%
\ifx\f@family\f@family@iso%
%it's ok, do nothing
\else
\sffamily\slshape\selectfont
\fi
}
In any case such code set \sffamily
font even if "iso" font is installed.
Best Answer
On second thought, maybe you are just looking for a simple solution like the following:
Addition: Run-time check for the presence of a TFM file
I’m adding the answer I had originally devised for this problem, because I think that, after all, it illustrates an interesting technique. This solution doesn’t rely on the presence of a
.fd
file that describes how to implement a given font family (in principle, this is not mandatory in order to be able to use a font), but checks directly for the existence of the external font, or, more exactly, of its TFM (TeX Font Metric) file.The following source file should be compiled with the
--restricted-shell-escape
command-line option. Among other things, it implements a command with three mandatory arguments named\IfTFMFileExists
, which queries (via the piped input feature) the system for the existence of the TFM file whose basename is passed in the first argument, and executes the code contained in the second argument if the file is found, and the code contained in the third argument if it is not. This command is subsequently used to choose between two\DeclareFontShape
declarations, one that binds the given font shape to its intended external font (if the latter is present on the system), and the other that substitutes for it another font shape.Note that the first time you compile this code, it will probably invoke
mktextfm
to build thelasi1000.tfm
TFM file, that is necessary for the font used as a substitute for theiso
family, that is, Computer Modern Sans in the T2A encoding, and which is not installed by default in the standard TeXLive distribution.Obviously, you can avoid warnings about the substitution of Computer Modern Sans for the
iso
family by replacing thesub
size function withssub
.The code could also be packaged in the form of a
.fd
file, of course: you would need to include only the defintion of the\IfTFMFileExists
command and the (conditional) font declarations themselves.