Fontspec and OTF font files

30 views
Skip to first unread message

Peter Flynn

unread,
Nov 30, 2021, 10:56:06 AM11/30/21
to
I just downloaded a copy of Font Awesome 6 from fontawesome.com and
installed their OTF files and re-ran fc-cache.

Fine. fc-list|grep Awesome now returns:

/home/peter/texmf/fonts/opentype/fontawesome6/Font Awesome 6
Free-Solid-900.otf: Font Awesome 6 Free,Font Awesome 6 Free
Solid:style=Solid

1. With this MWA:

\documentclass{article}
\usepackage{fontspec}
\newfontface{fa}{Font Awesome 6 Free Solid}
\begin{document}
\fa\char"f48e
\end{document}

I get the error:

(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.cfg)))kpathsea:make_tex:
Invalid filename `,', contains ','

! Package fontspec Error: The font "," cannot be found.

which is obviously bogus. There is no comma in the font filename.

2. Replace Font Name in \newfontface with the full filename including
the .otf and it fails with the identical message.

3. Copy the font file to the working directory and call it fa.otf
and then put that in the \newfontface line. Same error.

The font file is not corrupt: I inspected it with fontforge and it
contains exactly what it is supposed to.

FWIW:

This is XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019/Debian)
(preloaded format=xelatex)
\write18 enabled.
entering extended mode
LaTeX2e <2020-02-02> patch level 2

Does anyone know how to overcome this?

Peter

Daniel Flipo

unread,
Nov 30, 2021, 11:10:25 AM11/30/21
to
Le 30/11/2021 à 16:56, Peter Flynn a écrit :
> I just downloaded a copy of Font Awesome 6 from fontawesome.com and
> installed their OTF files and re-ran fc-cache.
>
> Fine. fc-list|grep Awesome now returns:
>
> /home/peter/texmf/fonts/opentype/fontawesome6/Font Awesome 6
> Free-Solid-900.otf: Font Awesome 6 Free,Font Awesome 6 Free
> Solid:style=Solid
>
> 1. With this MWA:
>
> \documentclass{article}
> \usepackage{fontspec}
> \newfontface{fa}{Font Awesome 6 Free Solid}
> \begin{document}
> \fa\char"f48e
> \end{document}
>
> I get the error:
>
> (/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.cfg)))kpathsea:make_tex:
> Invalid filename `,', contains ','
>
> ! Package fontspec Error: The font "," cannot be found.

What about calling the font by filename?

\newfontface{fa}{FontAwesome6Free-Solid-900.otf}

I would avoid spaces in file names: "FontAwesome6Free-Solid-900.otf"
instead of "Font Awesome 6 Free-Solid-900.otf".

--
Daniel Flipo

Peter Flynn

unread,
Nov 30, 2021, 2:34:41 PM11/30/21
to
That's what I did in #3:

>> 3. Copy the font file to the working directory and call it fa.otf
>> and then put that in the \newfontface line. Same error.

No change.

Peter

Manfred Lotz

unread,
Dec 1, 2021, 1:34:23 AM12/1/21
to
On Tue, 30 Nov 2021 15:56:01 +0000
Peter Flynn <pe...@silmaril.ie> wrote:

> ! Package fontspec Error: The font "," cannot be found.
>
> which is obviously bogus. There is no comma in the font filename.

Of course, there is a comma as the output of fc-list.

... Font Awesome 6 Free,Font Awesome 6 Free Solid:style=Solid

If such a specification is ok the fontspec package has to be fixed. If it is not ok then the font definition has to be fixed.


--
Manfred

Peter Flynn

unread,
Dec 1, 2021, 3:42:47 PM12/1/21
to
That is standard in fc-list. The comma separates multiple Font Names for
the same font, eg

/usr/share/texlive/texmf-dist/fonts/truetype/catharsis/cormorantgaramond/CormorantGaramond-SemiBold.ttf:
Cormorant Garamond,Cormorant Garamond SemiBold:style=SemiBold,Regular

The field separator is the colon. The comma is just data (or a subfield
delimiter). So there is no comma in the filename.

Peter

Nuno Silva

unread,
Dec 2, 2021, 2:49:58 AM12/2/21
to
On 2021-11-30, Peter Flynn wrote:

> I just downloaded a copy of Font Awesome 6 from fontawesome.com and
> installed their OTF files and re-ran fc-cache.
>
> Fine. fc-list|grep Awesome now returns:
>
> /home/peter/texmf/fonts/opentype/fontawesome6/Font Awesome 6
> Free-Solid-900.otf: Font Awesome 6 Free,Font Awesome 6 Free
> Solid:style=Solid
>
> 1. With this MWA:
>
>
> \documentclass{article}
> \usepackage{fontspec}
> \newfontface{fa}{Font Awesome 6 Free Solid}


Is this by any chance missing a backslash in the font selection command
name?

I'm able to successfully use \newfontface for "DejaVu Sans", which shows
up in fc-list here with a comma, but only with a backslash in the new
command name, i.e. like

\newfontface{\fa}{Font Awesome 6 Free Solid}


> \begin{document}
> \fa\char"f48e


With XeLaTeX here, it appears that all digits need to be uppercase, but
I may be doing something wrong.


> \end{document}
>
> I get the error:
>
> (/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.cfg)))kpathsea:make_tex:
> Invalid filename `,', contains ','
>
> ! Package fontspec Error: The font "," cannot be found.
>
> which is obviously bogus. There is no comma in the font filename.
>
> 2. Replace Font Name in \newfontface with the full filename including
> the .otf and it fails with the identical message.
>
> 3. Copy the font file to the working directory and call it fa.otf
> and then put that in the \newfontface line. Same error.
>
> The font file is not corrupt: I inspected it with fontforge and it
> contains exactly what it is supposed to.
>
> FWIW:
>
> This is XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019/Debian)
> (preloaded format=xelatex)
> \write18 enabled.
> entering extended mode
> LaTeX2e <2020-02-02> patch level 2
>
> Does anyone know how to overcome this?
>
> Peter

--
Nuno Silva

Manfred Lotz

unread,
Dec 2, 2021, 3:28:56 AM12/2/21
to
On Wed, 1 Dec 2021 20:42:42 +0000
Ok.

But interesting is the following.

This minimal sample works find and creates a pdf

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Font Awesome 5 Free}
\begin{document}
The answer is 42!
\end{document}


If I change the \setmainfont to
\setmainfont{Font Awesome 5 Free Solid}

then I get

./fontfind.aux)
(/usr/local/texlive/2021/texmf-dist/tex/latex/base/ts1cmr.fd) Missing
character: There is no ! (U+0021) in font Font Awesome 5 Free Solid Reg
ular/OT:language=dflt;mapping=tex-text;! [1] (./fontfind.aux)
xdvipdfmx:fatal: Invalid font: -1 (0)

No output PDF file written.
)
Error 256 (driver return code) generating output;
file fontfind.pdf may not be valid.


--
Manfred





Ulrike Fischer

unread,
Dec 2, 2021, 9:00:29 AM12/2/21
to
Am Thu, 02 Dec 2021 07:49:52 +0000 schrieb Nuno Silva:

>> \documentclass{article}
>> \usepackage{fontspec}
>> \newfontface{fa}{Font Awesome 6 Free Solid}
>
>
> Is this by any chance missing a backslash in the font selection command
> name?

Good catch, that actually triggers the error.

I had assumed that that isn't in the real document ;-(


--
Ulrike Fischer
http://www.troubleshooting-tex.de/

Peter Flynn

unread,
Dec 2, 2021, 5:43:52 PM12/2/21
to
On 02/12/2021 14:00, Ulrike Fischer wrote:
> Am Thu, 02 Dec 2021 07:49:52 +0000 schrieb Nuno Silva:
>
>>> \documentclass{article}
>>> \usepackage{fontspec}
>>> \newfontface{fa}{Font Awesome 6 Free Solid}
>>
>>
>> Is this by any chance missing a backslash in the font selection command
>> name?
>
> Good catch, that actually triggers the error.
>
> I had assumed that that isn't in the real document ;-(

How embarrassing. Entirely my fault, and probably due to not enough
coffee. Thanks all for helping to spot this, and sorry for wasting your
time.

Peter
Reply all
Reply to author
Forward
0 new messages