Cannot find font in RMarkdown PDF

I have dusted off an old LaTeX template that I used with RMarkdown some time ago (when it worked), updated to the latest R, RMarkdown, tinytex etc.

When I try to knit the document, it gives an error that it cannot find the Accanthis font:

! Package fontspec Error: The font "AccanthisADFStdNo3-Regular" cannot be
(fontspec) found.

! name = AccanthisADFStdNo3-Regular, rootname = AccanthisADFStdNo3-Regular, pointsize =

! mktexmf: empty or non-existent rootfile!
...

This is called from the template with lines:

\usepackage{fontspec}

\setmainfont{AccanthisADFStdNo3}[
UprightFont = *-Regular,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-BoldItalic,
Ligatures={TeX,NoRequired},
]

TinyTex can see the font in that
tinytex::tlmgr_search("/AccanthisADFStdNo3-Regular[.](tfm|afm|mf|otf)")
locates an.otf file

but running from the command line
mktextfm AccanthisADFStdNo3-Regular
gives "mktexmf: empty or non-existent rootfile!" and is looking for a .mf file that does not exist.

Any idea what the cause of this is?
Thanks

Can you try installing the accanthis package where this otf file is from ?

tinytex::tlmgr_install("accanthis")

Does that solve the rendering issue ?

Thanks, but sadly the same.

I can't reproduce this.

It is possible that your installation to LaTeX is messed up and this caused R Markdown to fail.

You can try compiling a latex file if you know how.

Otherwise, if you are willing to, you can easily reinstall a clean version of TinyTeX using tinytex:::reinstall_tinytex() or tinytex:::install_tinytex() if you don't have TinyTeX already as a LaTeX distribution.

Without being able to reproduce, it is hard for me to know more. And I don't think this is an issue with knitr or rmarkdown but rather with LaTeX - you can google the error for LaTeX specific issue maybe.

Thanks cderv,
I have tried reinstall_tinytex many times with different options.
I agree that this is probably a messed up installation, but I don't know what to uninstall or how to clean it up.

tinytex::uninstall_tinytex()

This should uninstall TinyTeX and get you a clean state regarding TinyTeX.

After that you can install a new version using tinytex::install_tinytex()

If you have leftover from a past TeX Live installation I am not sure to know how to clean more.

Does this leads somewhere ?

Only to heartache and despair :frowning:
I had previously tried all the suggestions I found for this error with TinyTeX and other TeX versions.
Worryingly, the answers were very diverse, suggesting they were perhaps solved by accident.

Nonetheless, thanks for the suggestion @cderv.

I uninstalled Tinytex and even threw in a remove.packages("tinytex") for good measure.
Then reinstalled and installed the fonts and other TeX packages needed, but the result is exactly the same.

TexLive is a package in the tlpkg directory under TinyTeX. These were all deleted when TinyTeX was uninstalled, so there shouldn't be leftover, unless TinyTeX has helpfully stored the settings somewhere.

Could it be a lower case / Upper case issue ?

Also can you share a Rmd file with this issue ? I cannot reproduce on my side.

It is always possible with such ridiculously convoluted names, but on the one hand the template worked a few months ago and I haven't changed the name and on the other tlmgr_search sends back

accanthis: texmf-dist/fonts/opentype/arkandis/accanthis/AccanthisADFStdNo3-Regular.otf

which matches the capitalisation I am using.

Then I don't get anymore idea. Sorry

It has been some time since I wrote YAML, I hope I didn't create too many new errors.
Here is the simplest example I can make think of and which removes the dependency on my template.

---
header-includes:
   - \usepackage{fontspec}
mainfont: AccanthisADFStdNo3-Regular
output:
    pdf_document:
        latex_engine: xelatex
---

The man from Accanthis.

Thanks - now I can reproduce !

I'll look closer to this.

Found it and I am sooo annoyed at the waste of both our time!

I now have to add the .otf extension to the font name, which I didn't a few months ago.
Presumably some breaking change has been applied in some package somewhere (perhaps fontspec).

My new template looks like this with the only change being in the 2nd line:

\usepackage{fontspec}
\setmainfont{AccanthisADFStdNo3.otf}[
UprightFont    = *-Regular,
ItalicFont     = *-Italic,
BoldFont       = *-Bold,
BoldItalicFont = *-BoldItalic,
Ligatures={TeX,NoRequired},
]

Another random solution unrelated to those I found in Google searches.
I hope it keeps working, but I have little confidence in the robustness of this toolchain now.

Thanks for your help @cderv

1 Like

Awesome? Glad it works. I am now learning you need the extension in this case.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.