4

While figuring out what fonts can be used to print what characters I wanted to come up with a fast and easy way to testing them. I know there are very useful answers for priting a character table of a font (see also here) or testing all fonts that are available, but I wanted to have a solution where I could quickly test a specific font (that I like) for specific characters (that I need). Here's what I've come up with:

\documentclass{article}
\usepackage{fontspec}
\newcommand{\fonttest}[1]{
\newfontfamily\myfont[Ligatures=TeX]{#1}
{\myfont
\textbf{#1} font test:
% here go all the characters that need to be tested, e.g.,
AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz? \par
\textit{AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz?} \par
More Characters: Åå Çç Øø
Uncommon Nasals: Ẽẽ Ĩĩ Ũũ Ỹỹ \par
IPA: ʔǝŋɲɾʧɨɔɛʃʤɸɣβɡɑɐɒʙðɕʑɻɚ\par
Greek: ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ αβγδεζηθικλμνξοπρσςτυφχψω \par
Ligatures: 
fluffier soufflé fisticuffs fb fh ffh fj ffj fk ffk ft fft tt Qu Th ch ck ct \par
\textsc{\ldots{} and testing some Small Caps}\par 
% whatever other characters you need to test for ... 
\vspace{1em}
}}

\begin{document}
Testing fonts in \LaTeX\ \par
\bigskip
% and here the fonts
\fonttest{Iowan Old Style}
\fonttest{Junicode}
\fonttest{Gentium Plus}
\fonttest{Minion Pro}
%\fonttest{Linux Libertine O}
%\fonttest{your favorite system font goes here}
\end{document}

This works with XeLaTeX and LuaLaTeX and for the fonts installed on the OS. Simply put the name of the system font as the argument for the fonttest macro and add whatever characters are needed to the command itself.

Now, (and here's why this is a question) maybe someone more experienced can modify it (or come up with a better solution) so that one can also test for fonts installed with the LaTeX distribution. The way it is now, it works in Lua for some LaTeX fonts but not for all.

I can do \fonttest{Linux Libertine O} but I cannot do \fonttest{Accanthis} although, I've tested, \usepackage{accanthis} in the preamble makes Accanthis the document font). I have no idea why that could be. And in XeTeX it doesn't work at all (since it's just a test this might not be that important). So I'm looking for a solution that let's me test all fonts, LaTeX and System, ideally with the same mechanism (at least for Lua, if someone comes up with a solution that works across engines that won't be rejected either, of course ;) ...).

BTW, for future reference, once you've figured out that a specific font is really pretty but doesn't have that one character that you need, you can use this solution to define a fallback font.

  • It will probably work if you use a font which exists such as AccanthisADFStdNo3. Also, where is Iowan Old Style available, since that apparently works OK? – cfr Sep 11 '16 at 2:04
  • 1
    @cfr I think Iowan Old Style is a font that comes (or came) with OS X. It is one of the few system fonts that has a very complete set of characters and looks a little nicer compared to TNR. – jan Sep 11 '16 at 21:02
4

It works fine provided you request fonts which exist. Since Accanthis does not exist, obviously that isn't an option. I guess you could argue that the test should, in that case, report that the font provides none of the requested characters rather than failing on the grounds that all possible fonts exist in the Platonic realm. However, I don't think you can expect beta software such as LuaTeX to deal with the metaphysics involved quite yet.

If you stick to existent fonts such as AccanthisADFStdNo3, it should work fine provided you have configured your system to know about the relevant TeX font directories. For example, these directories need to be included in fontconfig's configuration on GNU/Linux which use this font management.

\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{fontspec}
\newcommand{\fonttest}[1]{%
  \newfontfamily\myfont[Ligatures=TeX]{#1}%
  {\myfont
    \textbf{#1} font test:
    % here go all the characters that need to be tested, e.g.,
    AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz? \par
    \textit{AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz?} \par
    More Characters: Åå Çç Øø
    Uncommon Nasals: Ẽẽ Ĩĩ Ũũ Ỹỹ \par
    IPA: ʔǝŋɲɾʧɨɔɛʃʤɸɣβɡɑɐɒʙðɕʑɻɚ\par
    Greek: ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ αβγδεζηθικλμνξοπρσςτυφχψω \par
    Ligatures:
    fluffier soufflé fisticuffs fb fh ffh fj ffj fk ffk ft fft tt Qu Th ch ck ct \par
    \textsc{\ldots{} and testing some Small Caps}\par
    % whatever other characters you need to test for ...
    \vspace{1em}%
  }%
}
\begin{document}
Testing fonts in \LaTeX\ \par
\bigskip
% and here the fonts
\fonttest{Iwona}
\fonttest{Junicode}
\fonttest{Gentium Plus}
\fonttest{Minion Pro}
\fonttest{Linux Libertine O}
\fonttest{AccanthisADFStdNo3}
\end{document}

output

Note, however, that this output will not necessarily tell you everything you wish to know. Some fonts provide small-caps, for example, but you need to configure the small-caps for it to work. Or you might only see certain ligatures when certain font features are active. Moreover, different fonts may activate the same ligature as part of different font features.

And, of course, this will not tell you anything about type1 or MetaFont fonts installed in the traditional way.

  • Thank you for your reply. I'm glad I didn't do any major errors. So maybe my question should have been "Where do I find the exact font names for the LaTeX installed fonts?" Neither the LaTeX font catalogue nor CTAN gave me any clue how to call it. – jan Sep 11 '16 at 21:00
  • @jan otfinfo -i <path to font file> is what I use. Possibly Font Book could tell you but it might want to install the font somewhere else first. – cfr Sep 11 '16 at 21:19
  • And is there an easy way to get the file paths? AFAIK they can be installed in a number of places in a LaTeX distribution so I was hoping that it would be a bit easier. Sorry if I'm just not understanding some very basic things, but I was hoping that if font packages are found by LaTeX that there would also be some easy way to find the necessary information to include them in the above way, using the package name for example. Because somewhere in each (font-)package there must be the necessary font file, no? With its path and name etc. – jan Sep 14 '16 at 9:58
  • If you are using fonts from the TeX installation, you can use kpsewhich <filename>. If you are using system fonts, obviously that won't work. On a Unix-ish system, you can use locate or find. – cfr Sep 14 '16 at 12:29
  • And if I don't even know the filename? Sorry to be a pain, but so far I've relied on the font catalog to know which fonts are available and how the package is called. But I don't know how to either get the correct font name, file name or file path—and I need at least one of them to make it work as you describe. – jan Sep 14 '16 at 12:40
2

Just use better the options:

\documentclass{article}
\usepackage{fontspec}

\NewDocumentCommand{\fonttest}{O{}m}{{%
  \par\parindent=0pt
  \newfontfamily\myfont[#1]{#2}% limit the scope
  \myfont
  \textbf{#2} font test:
  % here go all the characters that need to be tested, e.g.,
  AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz? \par
  \textit{AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz?} \par
  More Characters: Åå Çç Øø
  Uncommon Nasals: Ẽẽ Ĩĩ Ũũ Ỹỹ \par
  IPA: ʔǝŋɲɾʧɨɔɛʃʤɸɣβɡɑɐɒʙðɕʑɻɚ\par
  Greek: ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ αβγδεζηθικλμνξοπρσςτυφχψω \par
  Ligatures: 
    fluffier soufflé fisticuffs fb fh ffh fj ffj fk ffk ft fft tt Qu Th ch ck ct \par
  \textsc{\ldots{} and testing some Small Caps}\par 
  % whatever other characters you need to test for ... 
  \vspace{1em}
}}

\begin{document}
Testing fonts in \LaTeX\ \par
\bigskip
% and here the fonts
\fonttest{Junicode}
\fonttest[Scale=1.5]{EB Garamond}
\fonttest[Path=/opt/X11/share/fonts/OTF/,Extension=.otf]{SyrCOMJerusalemBold}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.