0

I'm trying to convert a document from using xelatex+polyglossia to luatex+babel (following a suggestion here).

The relevant code is:

\usepackage[english, bidi=basic]{babel}
\usepackage{fontspec}
\babelprovide[import,main]{hebrew}
\babelfont[*hebrew]{rm}{David CLM}

lualatex starts to chug along, but then says:

luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: "Font DavidCLM not found.".
luaotfload | resolve : sequence of 3 lookups yielded nothing appropriate.

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

David CLM is a system font (on my Devuan GNU/Linux 3.0 Beowulf system); and xelatex is able to use it. Why can't lualatex also use it? And how can I make lualatex recongize and use the font?

3
  • you could try the font file name rather than name (although usually luatex can find fonts by name) what is the actual path to the font ? Jun 22 at 17:57
  • You have to explicitly specify which font should be used for regular weight and which one for bold. The autodetection fails since there is no regular version of the font. Jun 22 at 18:33
  • @MarcelKrüger: See my answer. But please consider adding your own with an example of when this would work and when it would fail.
    – einpoklum
    Jun 22 at 18:42
2

If XeTeX can find the font, fc-match should as well. So, you can get all the names it’s indexed under with

fc-match -v "David CLM"

On my system, this tells me that the filename is DavidCLM-Medium.otf, the family is "David CLM", the style is "Medium" and the fullname is "David CLM Medium". XeTeX is matching "David CLM" with "David CLM Medium", and LuaTeX is not.

The recommended way to load the font family is by its filenames:

\documentclass{article}
\usepackage[bidi=basic, layout=sectioning.tabular]{babel}
\usepackage{fontspec}

\babelprovide[import=he]{hebrew}
\defaultfontfeatures{ Scale = MatchUppercase,
                      Ligatures = TeX }

\defaultfontfeatures[DavidCLM]{
  UprightFont = *-Medium,
  BoldFont = *-Bold,
  Ligatures = Discretionary,
  Extension = .otf,
  % For italics that slant right-to-left, use:
  ItalicFont = *-MediumItalic,
  BoldItalicFont = *-BoldItalic,
  % For italics that slant left-to-right, instead use:
  % AutoFakeSlant = 0.15
  }

\babelfont{rm}
          [Scale=1.0]{TeX Gyre Schola}
\babelfont[hebrew]{rm}
          {David CLM}

\begin{document}
\begin{otherlanguage}{hebrew}
שָׁלוֹם חֲבֵרִים
\end{otherlanguage}
\end{document}

David CLM sample

This removes all guesswork and tells fontspec to look for files with the exact names DavidCLM-Medium.otf, DavidCLM-Bold.otf, etc.

A more minimal MWE would be

\documentclass{article}
\usepackage[bidi=basic, layout=sectioning.tabular]{babel}

\babelprovide[import, main]{hebrew}

\babelfont{rm}
          [UprightFont=*-Medium]{DavidCLM}

\begin{document}
שָׁלוֹם חֲבֵרִים
\end{document}

David CLM sample

Note that I have version 1.33 of the Culmus Project fonts installed. If you have a different version installed on your system, your files might have different filenames. You should also be able to load it by family name plus style, as UprightFont = {David CLM Medium}, BoldFont = {David CLM Bold} (not worrying about slanted faces you don’t want).

14
  • How much of the code is necessary for the import, and how much is just code from wherever you copied this? For example, does the command with TeX Gyre Schola matter for Hebrew at all? How about the font features (scale, ligatures)? I'm guessing they don't really apply to Hebrew fonts. etc.
    – einpoklum
    Jun 22 at 20:53
  • Also - it is a faux pas, typography-wise, to use "italic" Hebrew fonts. There is no such thing, historically and culturally. It's just a meaningless, and regrettable, attempt to copy a kind of variant which exists in Latin-alphabet languages. Silly insistence on "Italic has to do something in Hebrew too" by word processor makers (cough Microsoft cough) has made this abomination popular among lay authors, but no professionally-typed document has that.
    – einpoklum
    Jun 22 at 21:30
  • @einpoklum I didn’t copy it from anywhere. You don’t need Schola; I just gave it as an example of using different fonts for English and Hebrew. You do need just about everything else.
    – Davislor
    Jun 22 at 22:27
  • @einpoklum You can call it SlantedFont= and BoldSlanted= font instead if you want. You could also load Drugulin as your alternative typeface instead, which is a bit more traditional. In that case, you’d load the font family with \newfontfamily\drugulin and then something like \declaretextfontcommand\textemhe{\drugulin}.
    – Davislor
    Jun 22 at 22:30
  • I think the minimal version is, \babelfont{rm}[UprightFont=*-Medium]{DavidClM}.
    – Davislor
    Jun 22 at 22:32
0

Maybe there's a smarter solution, but here's what I did. Answers to this question:

How do I get a list of all available fonts for luaotfload?

allow you to list all fonts you can use with lualatex (for some definition of "use"). I looked for the basic part of my font's name, "David", but while ignoring capitalization, because all items on the list seemed to be lower caps. So:

$ ./listluatexfonts | egrep -i "david.*clm" | sort -u
davidclmbold
davidclmbolditalic
davidclmmedium
davidclmmediumitalic
taameydavidclmbold
taameydavidclmboldoblique
taameydavidclmmedium

and the bottom line answer for my case is davidclmmedium for my {rm} font. Maybe I also need to issue commands for bold.


For completeness, the listluatexfonts file's contents are:

#!/usr/bin/env texlua

kpse.set_program_name("listluatexfonts")
cachefile  = kpse.expand_var("$TEXMFVAR")  .. "/luatex-cache/generic/names/luaotfload-names.luc"
fontlist = dofile(cachefile)
assert(fontlist,"Could not load font name database")

local tmp = {}

for _,font in ipairs(fontlist.mappings) do
  tmp[#tmp + 1] = font.fontname
end
table.sort(tmp)

for _,fontname in ipairs(tmp) do
  print(fontname)
end
6
  • You can do the same query with luaotfload-tool --list=fontname:"*David*CLM*". Jun 22 at 18:45
  • @MarcelKrüger: I can run that, but it doesn't produce any results for some reason.
    – einpoklum
    Jun 22 at 19:02
  • Is your TeX Live version up-to-date? Jun 22 at 19:20
  • @MarcelKrüger: Nope, it's TeXLive 2019. I'm on Devuan 3 (~= Debian Stable).
    – einpoklum
    Jun 22 at 19:28
  • 1
    So the more precise comment is: Starting with TeXLive 2020, you can do the same query with luaotfload-tool --list=fontname:"*David*CLM*". Jun 22 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.