2

I'm having trouble loading some right-to-left fonts in a document I'm working on. I chose one at random — Avestan.

MWE requires that you download https://noto-website-2.storage.googleapis.com/pkgs/NotoSansAvestan-hinted.zip and put the .ttf file in a "fonts/" subdirectory relative to the MWE:

\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage[english]{babel}
\newfontfamily\avestanfont[Path=fonts/,UprightFont=*-Regular,Extension=.ttf]{Noto Sans Avestan}
\newcommand{\textavestan}[1]{\bgroup\textdir TRT\avestanfont #1\egroup}
\begin{document}
Test Avestan: \textavestan{𐬰𐬀𐬭𐬀𐬚𐬎𐬱𐬙𐬭𐬀}
\end{document}

Compilation errors with lualatex:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "NotoSansAvestan-Regular" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................

Furthermore,

! Font \TU/NotoSansAvestan(0)/m/n/10=[fonts/NotoSansAvestan-Regular.ttf]:mode=node; at 10pt not loadable: metric data not found or bad.

Any recommendations on how to get this font to work are appreciated.

Edit Some friendly helpers in the comments were wondering if it's an environmental issue. I've tried this on a clean cygwin texlive install, and using texlive-portable from the install manager on Windows. Using the mwe.tex from above and putting NotoSansAvestan-Regular.ttf in the fonts/ subdirectory, I have the following clean environment set up:

  • C:\temp\texlive-portable: new install of texlive w/ babel, babel-english, luatex, fontspec, and luaotfload
  • C:\temp\mwe\mwe.tex: the mwe.tex example
  • C:\temp\mwe\fonts\NotoSansAvestan-Regular.ttf: the font extracted from the .zip package

With what I think is a fairly clean setup now, from C:\temp\mwe, I run:

>C:\temp\texlive-portable\bin\win32\lualatex.exe mwe
This is LuaTeX, Version 1.0.4 (TeX Live 2017/W32TeX)
 restricted system commands enabled.
(./mwe.tex
LaTeX2e <2017-04-15>
(using write cache: C:/TEMP/texlive-portable/texmf-var/luatex-cache/generic)(us
ing read cache: C:/TEMP/texlive-portable/texmf-var/luatex-cache/generic C:/TEMP
/texlive-portable/texmf-var/luatex-cache/generic)
luaotfload | main : initialization completed in 0.297 seconds
(c:/TEMP/texlive-portable/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(c:/TEMP/texlive-portable/texmf-dist/tex/latex/base/size10.clo(load luc: C:/TEM
P/texlive-portable/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.l
uc))) (c:/TEMP/texlive-portable/texmf-dist/tex/latex/fontspec/fontspec.sty
(c:/TEMP/texlive-portable/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(c:/TEMP/texlive-portable/texmf-dist/tex/latex/l3kernel/expl3.sty
(c:/TEMP/texlive-portable/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(c:/TEMP/texlive-portable/texmf-dist/tex/latex/l3kernel/l3pdfmode.def)))
(c:/TEMP/texlive-portable/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
(c:/TEMP/texlive-portable/texmf-dist/tex/latex/base/fontenc.sty
(c:/TEMP/texlive-portable/texmf-dist/tex/latex/base/tuenc.def))
(c:/TEMP/texlive-portable/texmf-dist/tex/latex/fontspec/fontspec.cfg)(load luc:
 C:/TEMP/texlive-portable/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-bo
ld.luc)(load luc: C:/TEMP/texlive-portable/texmf-var/luatex-cache/generic/fonts
/otl/lmroman10-italic.luc)))
(c:/TEMP/texlive-portable/texmf-dist/tex/generic/babel/babel.sty
(c:/TEMP/texlive-portable/texmf-dist/tex/generic/babel/switch.def)
(c:/TEMP/texlive-portable/texmf-dist/tex/generic/babel/luababel.def)
(c:/TEMP/texlive-portable/texmf-dist/tex/generic/babel-english/english.ldf
(c:/TEMP/texlive-portable/texmf-dist/tex/generic/babel/babel.def
(c:/TEMP/texlive-portable/texmf-dist/tex/generic/babel/luababel.def))))

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "NotoSansAvestan-Regular" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................

l.4 ...=*-Regular,Extension=.ttf]{Noto Sans Avestan}

?

EDIT 2 Ok, I finally got it to work! The font from http://fonts.gstatic.com/ea/notosansavestan/v1/download.zip works just fine, but the font from https://noto-website-2.storage.googleapis.com/pkgs/NotoSansAvestan-hinted.zip is giving me the aforementioned errors. I guess the question is now, "Why is the official Avestan font not loading in lualatex?"

Ttfdump is also failing:

$ ttfdump.exe NotoSansAvestan-Regular.ttf
Unrecognized GPOS lookupFormat

It appears that libttf is the culprit here.

14
  • If you haven’t installed the font as a system font (I assume you haven’t, since you’re putting it in a subdirectory of your project), you must refer to it by filename, not by the name of the font.
    – Thérèse
    Commented Apr 5, 2018 at 20:31
  • It is installed as a system font, I just set up the MWE so that anyone can experience the errors without having to install the font first.
    – Squinky86
    Commented Apr 5, 2018 at 20:33
  • In that case, I can’t reproduce the problem on my system.
    – Thérèse
    Commented Apr 5, 2018 at 20:34
  • Is the example you're using identical to the one above? If not, can you please share what you modified? I feel like I'm missing something stupid.
    – Squinky86
    Commented Apr 5, 2018 at 21:04
  • Identical, except that I removed the reference to the subdirectory since I’ve had the font installed as a system font for months now.
    – Thérèse
    Commented Apr 5, 2018 at 21:05

1 Answer 1

0

This appears to be a bug with fontspec and/or luatex; however, I do have a workaround for anyone running into a similar problem.

Problem: fontspec/luatex is unable to read the .ttf file.

Solution: Convert the .ttf file to a valid .otf file, and luatex will be able to see it.

Using fontforge, I scripted the failing fonts as follows:

fontforge -lang=ff -c 'Open($1); Generate($2)' NotoSansAvestan-Regular.ttf NotoSansAvestan-Regular.otf

then changed the mwe to:

\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage[english]{babel}
\newfontfamily\avestanfont[Path=fonts/,UprightFont=*-Regular,Extension=.otf]{Noto Sans Avestan}
\newcommand{\textavestan}[1]{\bgroup\textdir TRT\avestanfont #1\egroup}
\begin{document}
Test Avestan: \textavestan{𐬰𐬀𐬭𐬀𐬚𐬎𐬱𐬙𐬭𐬀}
\end{document}

and everything works. I would prefer a solution that doesn't rely on an outside tool (fontforge), but at least I have something that gets me a workable solution.

PS: If anyone can figure out a solution to this problem that does not require fontforge, I'll mark their answer as the "accepted" one.

3
  • Update: I still believe that this is a bug, and it is still present with TeXLive 2018. Emails to the package maintainers have gone unanswered. The selected workaround still works.
    – Squinky86
    Commented May 15, 2018 at 2:58
  • TexLive 2020, Windows10: the v1.7 ttf font loads OK under xelatex (with the lualatex \textdir directive removed) using the (space-less) filename method: \newfontfamily\avestanfont[UprightFont=*-Regular,Extension=.ttf]{NotoSansAvestan}. Unrelated: lualatex can find the find using the "human" name (Noto Sans Avestan), looking first in the user's local system fonts folder, then if it's not there in the all-users system fonts folder. Unrelated 2: \pardir TRT would be useful for Avestan, too.
    – Cicada
    Commented May 4, 2021 at 14:25
  • Why do you think the bug is in TeX Live rather than the font? Everything you've said suggests it is the font which is likely buggy. It might not be buggy, of course, but you've not explained why you think it isn't.
    – cfr
    Commented Dec 11, 2023 at 4:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .