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?

einpoklum
  • 12,311
  • 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 ? – David Carlisle Jun 22 '21 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. – Marcel Krüger Jun 22 '21 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 '21 at 18:42

2 Answers2

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).

Davislor
  • 44,045
  • 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 '21 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 '21 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 '21 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 '21 at 22:30
  • I think the minimal version is, \babelfont{rm}[UprightFont=*-Medium]{DavidClM}. – Davislor Jun 22 '21 at 22:32
  • Minimum version doesn't work either, I get: Package fontspec Error: The font "UprightFont=*-Medium" cannot be found. – einpoklum Jun 23 '21 at 09:58
  • @einpoklum It works fine for me. I’ll add the two lines to expand it to a MWE. – Davislor Jun 23 '21 at 14:28
  • @einpoklum You might have an older version of the font package installed. If so, [UprightFont = {David CLM Medium}, BoldFont = {David CLM Bold}] should work for you, as you do not want slanted Hebrew. – Davislor Jun 23 '21 at 14:36
  • I have the culumus 0.133-1 package on Devuan (~= Debian) stable. Also, using "David CLM Medium" doesn't work either. And again - I can't use \defaultfontfamily , so I tried with the "minimal version". – einpoklum Jun 23 '21 at 17:11
  • @einpoklum My code snippet had an error. That should have been \defaultfontfeatures. My mistake. There is no \defaultfontfamily. I replaced it by a MWE that definitely works. – Davislor Jun 23 '21 at 19:48
  • @einpoklum What does the command at the top of my answer, fc-match -v "David CLM", tell you are its family, style, fullname and file? – Davislor Jun 23 '21 at 19:51
  • family: "David CLM"(s) style: "Medium"(s) fullname: "David CLM Medium"(s) file: "/usr/share/fonts/truetype/culmus/DavidCLM-Medium.otf"(w) – einpoklum Jun 23 '21 at 20:17
  • @einpoklum Then what I posted ought to be working. What does luaotfload-tool --find "David CLM Medium" give you? Does luaotfload-tool -f -u -p -v correctly add it to the index? – Davislor Jun 23 '21 at 23:17
  • Can luaotfload-tool --list=fullname:"David CLM*" find it? What about luaotfload-tool --list=fontname:"DavidCLM*"> – Davislor Jun 23 '21 at 23:35
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

einpoklum
  • 12,311