aliftype / xits

XITS - OpenType implementation of STIX fonts with math support
SIL Open Font License 1.1
351 stars 35 forks source link

italic bold math font #46

Closed ptoche closed 8 years ago

ptoche commented 8 years ago

As far as I understand there is currently no italic bold math font. Is that something that could be developed? The use case is some matrix notation (ISO/IEC convention). Or is there a workaround?

khaledhosny commented 8 years ago

There is serif italic bold math alphabet, but no sans-serif italic bold one. There are italic bold math alphabets, both serif and sans serif, what makes you think otherwise?

ptoche commented 8 years ago

Thanks for your help Khaled. I know nothing about fonts and I'm probably misunderstanding things. Apologies! Clarification: I was referring to a xits-math bold+italic font. So here was my reasoning.

First, I noticed that in http://tex.stackexchange.com/questions/43642 or more recently http://tex.stackexchange.com/questions/296603, you and other font experts only ever write

\setmathfont
[    Extension = .otf,
      BoldFont = *bold,
]{xits-math}

with no reference to bold italic math fonts. So that was my first clue. When I added the line

BoldItalicFont = *-bolditalic,

to the above, I received an error message 'fontspec error: "font-not-found". Second clue.

When I looked inside the font .otf files, I didn't see a bold-italic-math font. Third clue.

And when I tried to insert this in the preamble:

\DeclareMathAlphabet{\mathbit}{OML}{cmm}{b}{it}

which is something I read here (http://tex.stackexchange.com/questions/14395/bold-italic-vectors) about how to emulate a bold italic font, the outcome was very ugly. That was my fourth clue. But perhaps I just don't know how to set it up properly?

Below a MWE used for my experiments:

\documentclass{article}
\usepackage[bold-style=ISO]{unicode-math}
%\usepackage[bold-style=TEX]{unicode-math}
\setmainfont
[    Extension = .otf,
   UprightFont = *-regular,
      BoldFont = *-bold,
    ItalicFont = *-italic,
BoldItalicFont = *-bolditalic,
]{xits}
\setmathfont
[    Extension = .otf,
      BoldFont = *bold,
]{xits-math}
\DeclareMathAlphabet{\mathbit}{OML}{cmm}{b}{it}
\begin{document}
\begin{itemize}
\item
mainfont:
\[x(t)=\int_{-B}^B X(f)e^{j2\pi ft} df\] 
\item 
boldmath: 
{\boldmath
\[ x(t)=\int_{-B}^B X(f)e^{j2\pi ft} df\]
}
\item 
mathbf: 
\[\mathbf{x(t)=\int_{-B}^B X(f)e^{j2\pi ft} df}\] 
\item 
mathbit: 
\[\mathbit{x(t)=\int_{-B}^B X(f)e^{j2\pi ft} df}\] 
\end{itemize}    
\end{document}
khaledhosny commented 8 years ago

The way OpenType math fonts is structured is different than traditional TeX fonts. All math alphabets are included in a single font file, so If you installed XITS Math in the system font directories (the recommended way), then all you need is \setmathfont{XITS Math}. The invocation you use is for loading the fonts by file name and in this case you need to load the bold font manually, however this bold font is not for bold math alphabets but for \boldmath, \boldsymbol and similar commands that expects a math font where everything is bold.

The \DeclareMathAlphabet is definitely wrong, you are trying to load the Computer Modern Math (cmm) bold italic font, you should drop it. \mathbf and \mathbi used to work with uncode-math out of box, but it seems that for some LaTeX people compatibility with crippled 8-bit TeX engines is more important than a system that works in the 21 century, so that was dropped and you now have to use \symbf and \symbfit instead, please refer to unicode-math documentation (hopefully it was updated, I didn’t check).

So your document should look like:

\documentclass{article}
\usepackage[bold-style=ISO]{unicode-math}
%\usepackage[bold-style=TEX]{unicode-math}
\setmainfont
[    Extension = .otf,
   UprightFont = *-regular,
      BoldFont = *-bold,
    ItalicFont = *-italic,
BoldItalicFont = *-bolditalic,
]{xits}
\setmathfont
[    Extension = .otf,
      BoldFont = *bold,
]{xits-math}
\begin{document}
\begin{itemize}
\item
mainfont:
\[x(t)=\int_{-B}^B X(f)e^{j2\pi ft} df\] 
\item 
boldmath: 
{\boldmath
\[ x(t)=\int_{-B}^B X(f)e^{j2\pi ft} df\]
}
\item 
mathbf: 
\[\symbf{x(t)=\int_{-B}^B X(f)e^{j2\pi ft} df}\] 
\item 
mathbit: 
\[\symbfit{x(t)=\int_{-B}^B X(f)e^{j2\pi ft} df}\] 
\end{itemize}    
\end{document}
ptoche commented 8 years ago

Thanks Khaled! Your explanation clarifies a lot of things for me. I noticed \setmainfont{XITS} is throwing errors, so I'm going to look into my setup again.

I'm not seeing a big difference between \symbf and \symbfit and no difference at all between \symbf{A} and \symbfit{A}. See screenshot here: http://s33.postimg.org/gt176cu6n/tmp.png Should there not be a difference ?

khaledhosny commented 8 years ago

They are different in the font. You probably need to ask in unicode-math tracker, or some general TeX questions site like http://tex.stackexchange.com/.

ptoche commented 8 years ago

Will do, thanks Khaled!