[Tex/LaTex] How to use otf fonts correctly

font-encodingsfontspecluatex

I'm using Linux. I'd discovered that is possible to run lualatex and use my system fonts. Well, I'm trying to see how they look like.

Here is my sample:

\documentclass[11pt,a4paper]{amsart}
\usepackage[math]{fontspec}
\usepackage{unicode-math}
\setmathfont{Asana-Math.otf}
\usepackage{fontenc}
\setmainfont{Droid Serif}
\begin{document}
\[(D_e\Phi_{\gamma(s)})^{-1}(\gamma'(s))=\varphi'(s)(D_e\Phi_{\alpha(\varphi(s))})^{-1}(\alpha'(\varphi(s)))\]
\end{document}

After running fc-list I just copy some font name and use it on \setmainfont, like above.

My question is: how to be sure that I'm doing this for text and math fonts? When I change as above does the math fonts change accordingly? How to test the math fonts also? How to list all the other otf fonts to use in \setmathfont?

Best Answer

As I mentioned in my comment, you should only use one of fontspec or fontenc. Basically fontspec is to be used with LuaLaTeX and XeLaTeX, whereas fontenc is to be used with the other engines (LaTeX, pdfLaTeX,...).

Regarding which font are available on your system, fc-list only gives you the list of the font that fontconfig knows about (those in /usr/share/fonts/ and ~/.fonts/), that is the one your Linux distribution can see. However it will not list the font that came with your LaTeX distribution as usually , the TeX distribution does not add these fonts to the system path. This is why fc-list will not show you Asana Math.

There is however a command that LuaLaTeX runs to scan your system and find out which font are accessible: mkluatexfontdb. You can run this command yourself and it will create a file in: ~/.texlive2012/texmf-var/luatex-cache/generic/names/otfl-names.lua which list all the fonts (system or not) which LuaLaTeX can see. (LuaLaTeX will run this command automatically the first time you run it and every time you try to use a font it doesn't know about (in case you added it since).

With LuaLaTeX, it is also possibly best not to use the font file name and rather use the actual font name. This is because in most cases, the different shapes and series are located in a different file. Although this is not the case with Asana Math it is I think a good habit to take. (A note here though is that if you want to use font that are provided by the TeX distribution currently have to be called via their filename when using XeLaTeX, which is not the case with LuaLaTeX)

In your case, you can easily call

\usepackage{unicode-math} %as noted in the comments this will load fontspec as well
\setmathfont{Asana Math}
\setmainfont{Droid Serif}

note that the [math] option to the fontspec package is not necessary at it is the default. However since you are using unicode-math you may want to use the [no-math] option. Indeed the fontspec documentation says

By default, fontspec adjusts LATEX’s default maths setup in order to maintain the correct Computer Modern symbols when the roman font changes. However, it will attempt to avoid doing this if another maths font package is loaded (such as mathpazo or the unicode-math package). If you find that fontspec is incorrectly changing the maths font when it should be leaving well enough alone, apply the [no-math] package option to manually suppress its maths font.

Although I do find that unicode-math is very good and simplifies nicely the use of OTF/TTF for typesetting maths, I should also mention that it is not actually necessary since fontspec also has the \setmathrm, \setmathsf, \setmathtt and \setboldmathrm commands. But since the font you are planning on using contains all this, using \setmathfont is a better solution.

Related Question