I want to switch fonts, away from computer modern. I'm pretty sure that I will end up with a mixture of fonts. I can't provide a full list of required features, but Linux Libertine's feature set pretty much covers it. It is, at the moment, my base font for text work, together with Linux Biolinum.
I need to adjust the math glyphs, though. They are still taken from the cm fonts and obviously don't fit. As a start, I want to use those provided by GFS, like GFS Bodoni (too playful), or GFS Didot (all available as OTF). To achieve this glyph replacement, I started with one of the mathastext examples:
\documentclass{article}
\usepackage[T1]{fontenc}
\renewcommand{\rmdefault}{bodoni}
\usepackage[LGRgreek,defaultmathsizes,italic]{mathastext}
\usepackage{libertine}
\let\varphi\phi
\linespread{1.06}
\begin{document}
ff fi fj fi ffj fl ffl äÄ öÖ üÜ ß\\
01234567890\\
\begin{equation}
abcdefghijklmnopqrstuvwxyz
\end{equation}
\begin{equation}
\alpha \beta \gamma \delta
\end{equation}
\end{document}
This compiles without any errors, and the math glyphs are replaced by those from GFS Bodoni, I get ligatures, correct Umlauts (the next problem arises here: LL provides an alternative O-umlaut, which I prefer). However, I don't know how to access text figures from either LL or GFS Bodoni, while both provide them. My plan was to translate the above mwe to valid code for LuaLaTeX, gaining more control over the font selection. I failed:
\documentclass{article}
\usepackage[no-math]{fontspec}
\renewcommand{\rmdefault}{bodoni}
\usepackage[LGRgreek,defaultmathsizes,italic]{mathastext}
\setmainfont{Linux Libertine O}
\setsansfont{Linux Biolinum O}
This sets mathnormal, mathrm, mathbf and mathit to computer modern (bad), but uses greek glyphs (which is good). The symbols used are still taken from the CM fonts, but I have not yet tried to replace them. I will need to, because the default int-symbol's terminals are - as an example - ball-shaped.
I then found the unicode-math package, but from what I read it is meant to be used for fonts which provide a full unicode math alphabet, which the GFS fonts do not. I tried to use unicode-math, but with less success than with the examples given above.
Ultimately, I need a font selection procedure which is not hacked to fit one specific situation. I want to see how the different glyphs work together on the same page, and I might even buy a font that suits the text and its purpose, and not the technical limitations caused by my lack of skill. How can I develop a procedure of selecting fonts and glyphs that is robust and gives me the required flexibility?
Is unicode-math the way to go?
Regarding \setmainfont instead of \renewcommand: I now used
\documentclass{article}
\usepackage{fontspec}
\setmainfont[%
]{GFSBodoni}
\usepackage[LGRgreek,defaultmathsizes,italic]{mathastext}
as you suggested, with and without the no-math option for fontspec, and lualatex complains:
! Font \LGR/GFSBodoni(0)/m/it/7=grmn0700 at 7pt not loadable: metric data not found or bad.
! Font \LGR/GFSBodoni(0)/m/it/5=grmn0500 at 5pt not loadable: metric data not found or bad.
These errors occur in
\begin{equation}
abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
\end{equation}
This could either be caused by my usage of the font or by an error in my miktex 2.9 installation. However, a pdf is produced, with the following features:
- The main fonts are GFS Bodoni,
- The greek glyphs in math mode are upright, not CM anymore, but not to be found in the GFS Bodoni Specimen sheet either. I don't know where they come from. The preamble above is what I used, it is directly followed by \begin{document}.
I then downloaded the otf files from the GFS website, and told fontspec to use them directly. I even renamed them to make sure that lualatex does not find any other Bodoni files elsewhere:
\setmainfont[%
ItalicFont=GFS-Bodoni-Italic.otf,
BoldFont=GFS-Bodoni-Bold.otf,
BoldItalicFont=GFS-Bodoni-Bold-Italic.otf
]{GFS-Bodoni.otf}
I'm puzzled. I'll now start trying the same thing with unicode-math, as you suggested.
unicode-math: After switching back and forth between different combinations of options, this is what I first came up with:
\documentclass{article}
\usepackage{unicode-math}
\setmathfont{XITS Math}
\setmainfont{Linux Libertine O}
\setsansfont{Linux Biolinum O}
\setmathfont[
math-style=ISO,
range=\mathit/{greek,Greek},
]{GFSBodoni-Italic}
\setmathfont[
math-style=ISO,
range=\mathrm/{greek,Greek},
]{GFSBodoni}
Greek glyphs are now replaced, as intended. I can change the latin characters to Linux Libertine with the same trick, using two new blocks and {latin,Latin} in the range option. My original question has been answered, in the sense that I was encouraged to use unicode-math. Thanks Ulrike!
However, the quest goes on. Using a unicode math font left me with undesired figures, which I could also replace by figures from GFS Bodoni or Linux Libertine. Unfortunately, none of the following ideas work (the first is taken from the unicode-math documentation):
\setmathfont[
math-style=ISO,
range=\mathit/{num},
]{Linux Libertine O}
\setmathfont[
math-style=ISO,
range=\mathrm/{num},
]{Linux Libertine O}
\setmathfont[
math-style=ISO,
range=\mathit/{"0030-"0039},
]{Linux Libertine O}
\setmathfont[
math-style=ISO,
range=\mathrm/{"0030-"0039},
]{Linux Libertine O}
A major drawback is that I need to use a unicode math font, as above. My choice is at the moment limited to XITS, Asana Math, and (partially) Neo Euler. Neo Euler seems to have problems with scaling parentheses. Apart from that, I don't really like any of these choices, judging just by the more prominent math symbols (like int, parentheses, n-ary sum and n-ary product sign), but that's not the point of this question.