# fontspec Font not Found (AlegreyaSans package)

This is a common problem, but none of the several links I've followed address my issue. An MWE:

%XeLaTeX
\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage[sfdefault]{AlegreyaSans}
%\usepackage{Alegreya} % this works fine!

\begin{document}
Test!
\end{document}


I get the error message:

! Undefined control sequence.
<argument> ... AlegreyaSansSC-\Alegreya@boldstyle
}, ItalicFeatures = { Smal...
l.151       {AlegreyaSans}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., \hobx'), type I' and the correct
spelling (e.g., I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
<argument> ... AlegreyaSansSC-\Alegreya@boldstyle
Italic },
l.151       {AlegreyaSans}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., \hobx'), type I' and the correct
spelling (e.g., I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

Requested font "[AlegreyaSans-Regular.ttf]/OT" at 10.0pt
-> /usr/local/texlive/2016/texmf-dist/fonts/truetype/huerta/alegreya/AlegreyaSans-Regular.ttf
\g__fontspec_family_AlegreyaSans_int=\count124
Requested font "[AlegreyaSansSC-Regular.ttf]/OT" at 10.0pt
-> /usr/local/texlive/2016/texmf-dist/fonts/truetype/huerta/alegreya/AlegreyaSansSC-Regular.ttf
Requested font "[AlegreyaSans-Bold.ttf]/OT" at 10.0pt
-> /usr/local/texlive/2016/texmf-dist/fonts/truetype/huerta/alegreya/AlegreyaSans-Bold.ttf
Requested font "[AlegreyaSansSC-.ttf]/OT" at 10.0pt
-> font not found, using "nullfont"

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "AlegreyaSansSC-" cannot be found.


What I don't understand is that, for instance, /usr/local/texlive/2016/texmf-dist/fonts/truetype/huerta/alegreya/AlegreyaSans-Regular.ttf absolutely exists! Is it possible that there is a permissions issue preventing this file from being accessed?

I'm using TeXlive 2016 on Fedora 24; I don't have this problem on a Mac with TeXlive 2015; is this a bug of some kind?

• It's a bug in AlegreyaSans.sty; in some places \Alegreya@boldstyle is used instead of \AlegreyaSans@boldstyle. – egreg Sep 14 '16 at 17:52
• Excellent; I should be able to adjust this myself. Should I report this in some way? – Richard Sep 14 '16 at 17:53
• And you're welcome to add that as an answer if you like; I'll check it tonight and act accordingly. – Richard Sep 14 '16 at 17:54
• I also added a temporary fix – egreg Sep 14 '16 at 18:03
• The 2016/09/15 release of AlegreyaSans has fixed the problem. – egreg Sep 17 '16 at 10:41

## Update

The issue described below has been fixed in AlegreyaSans.sty released 2016/09/15.

## Original answer

It's a bug in AlegreyaSans.sty; in a few places the macro

\Alegreya@boldstyle


is used instead of \AlegreyaSans@boldstyle.

You should make a bug report; in the meantime, using the fact that the undefined control sequence is first used when \setsansfont is performed, you can work around the issue with the following trick:

\documentclass{standalone}
\usepackage[T1]{fontenc}

%%% Fix for the bug in AlegreyaSans
% make sure \setsansfont is defined
\usepackage{fontspec}
% start the fix by temporarily redefining
% \setsansfont to define the wrong macro
% to be the same as the right one
\makeatletter
% save a copy of \setsansfont
\let\fontspec@setsansfont\setsansfont
% redefine it to fix the issue and to redefine
% itself to the original one
\def\setsansfont{%
\let\Alegreya@boldstyle\AlegreyaSans@boldstyle
\let\setsansfont\fontspec@setsansfont
\setsansfont
}
\makeatother
%%% end of fix, now load AlegreyaSans

\usepackage[sfdefault]{AlegreyaSans}

\begin{document}
Test!
\end{document}

• You're a rock star, egreg! Thanks; I'll get on that bug report tonight. – Richard Sep 14 '16 at 18:05