I'm trying to produce a document to compare a bunch of fontfaces. I'd like to parse an array to load and try them all.
This is what I have done:
\documentclass{article}
\usepackage{lipsum}
\usepackage{pgffor}
\usepackage{fontspec}
\def\LoadFont#1{\expandafter\newfontface\csname#1\endcsname{#1}}
\def\UseFont#1{\csname#1\endcsname}
\def\FontList{Charter,Lato,Linux Libertine O}
% these work just fine
%\LoadFont{Charter}
%\LoadFont{Lato}
%\LoadFont{Linux Libertine O}
% THIS DOES NOT WORK
\foreach \FontName in \FontList {\LoadFont\FontName}
\begin{document}
\foreach \FontName in \FontList {\UseFont\FontName\lipsum[1]}
\end{document}
While the cycle with \UseFont
works fine, the one with \LoadFont
does not. On its own, \LoadFont
does what's expected.
I think this could be an expansion problem, but I'm not sure where it stands exactly; blind attempts led nowhere.
What's wrong with the loading cycle?