[Tex/LaTex] How to use OpenType fonts with plain-LuaTeX

fontsluatexopentypeplain-tex

Is it possible to have OpenType fonts with LuaTeX using the plain format?

I have tried:

\font\test="texgyrepagellaregular"\test test\bye

but I get ! Font \test=texgyrepagellaregular not loadable: metric data not found or bad..

mtxrun --script fonts --list --all --pattern=pagella shows the above font name when I followed the instructions at http://wiki.contextgarden.net/Fonts_in_LuaTeX.

But on actually using the fonts, the page switches to speaking of ConTeXt instead of LuaTeX, which leaves me to wonder if it is possible to use OT-fonts with plain?

UPDATE

Even though this now works fine for fonts which are located in my home directory (OSX Lion, BasicTeX2012, luatex-plain-format constructed as instructed below), I am unable to use fonts which are located in the system directories. So while the above example works (with texgyrepagellaregular), as the mtxrun-script shows its location as ~/Library/Fonts, the following doesn't:

\font\test="minionproregular"

presumably because mtxrun shows its location as /Library/Fonts (the same issue seems to be with fonts inside /System/Library/Fonts).

Now, I added to my ~/.zshrc:

export OSFONTDIR=/System/Library/Fonts:/Library/Fonts:$OSFONTDIR

after which I was able to update the fonts database with mtxrun --script fonts --reload (following these instructions), and indeed now the mtxrun listing does show all of the fonts. It's just that luatex-plain doesn't see them.

How can I make luatex-plain see the fonts mtxrun sees?

Best Answer

Let me add to the confusion a bit: there are actually two formats for running Plain with LuaTeX! One of them is the format that gets called when you run the command luatex from e.g. TeX Live; egreg already posted instructions for it in his answer.

There exists, however, another format called luatex-plain. Since it comes with the font loader built in, it has the advantage of being able to use OpenType fonts without additional packages. Here’s a demo (you’ll need the free Minion Pro fonts from Adobe for the second part):

\font\iwonaregular   =file:Iwona-Regular    at 12pt
\font\iwonaitalic    =file:Iwona-Italic     at 12pt
\font\iwonabold      =file:Iwona-Bold       at 12pt
\font\iwonabolditalic=file:Iwona-BoldItalic at 12pt

{\iwonaregular     foo}\par
{\iwonaitalic      bar}\par
{\iwonabold        baz}\par
{\iwonabolditalic  xyzzy}\par

\font\minionproliningfigures =file:MinionPro_Regular         at 12pt
\font\minionprotextfigures   =file:MinionPro_Regular:+onum;  at 12pt
\font\minionprosmallcaps     =file:MinionPro_Regular:+smcp;  at 12pt

{\minionproliningfigures  0123456789abcdef}\par
{\minionprotextfigures    0123456789abcdef}\par
{\minionprosmallcaps      0123456789abcdef}\par %% implicit +onum!

\bye

font definition demo

For more complicated examples see the test file.

luatex-plain is distributed with ConTeXt and available through TeX Live in the directory texmf-dist/tex/generic/context/luatex/. (Pro Tip: build the format and then symlink the luatex binary to luatex-plain, so you don’t have to specify the --fmt parameter.)