TransWikia.com

Errors with libttf (was Font metric data not found or bad)

TeX - LaTeX Asked by Squinky86 on March 29, 2021

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}
newfontfamilyavestanfont[Path=fonts/,UprightFont=*-Regular,Extension=.ttf]{Noto Sans Avestan}
newcommand{textavestan}[1]{bgrouptextdir TRTavestanfont #1egroup}
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:temptexlive-portable: new install of texlive w/ babel, babel-english, luatex, fontspec, and luaotfload
  • C:tempmwemwe.tex: the mwe.tex example
  • C:tempmwefontsNotoSansAvestan-Regular.ttf: the font extracted from the .zip package

With what I think is a fairly clean setup now, from C:tempmwe, I run:

>C:temptexlive-portablebinwin32lualatex.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.

One Answer

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}
newfontfamilyavestanfont[Path=fonts/,UprightFont=*-Regular,Extension=.otf]{Noto Sans Avestan}
newcommand{textavestan}[1]{bgrouptextdir TRTavestanfont #1egroup}
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.

Answered by Squinky86 on March 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP