[XeTeX] Math Problem and XeLaTeX

Bruno Voisin bvoisin at mac.com
Sun Mar 6 09:26:14 CET 2005


Hi Will,

I'll answer based on my bare-bones XeLaTeX use, not on fontspec which 
I've only started to experiment with. Namely, based on the typical 
instructions I use for getting Hoefler and Lucida:

	\usepackage[LY1]{fontenc}
	\usepackage[expert,vargreek,lucidasmallscale]{lucbmath}
	\usepackage{xunicode}

	\DeclareFontFamily{U}{hoefler}{}
	\DeclareFontShape{U}{hoefler}{m}{n}
	  {<-> "Hoefler\space Text:mapping=tex-text;
	          Number\space Case=Upper\space Case\space Numbers
	       "}{}
	\DeclareFontShape{U}{hoefler}{m}{it}
	  {<-> "Hoefler\space Text\space Italic:mapping=tex-text;
	          Smart\space Swashes=!Line\space Final\space Swashes,
	                              !Line\space Initial\space Swashes;
	          Number\space Case=Uppercase\space Numbers
	       "}{}
	\DeclareFontShape{U}{hoefler}{b}{n}
	  {<-> "Hoefler\space Text\space Black:mapping=tex-text;
	          Number\space Case=Diphthong\space Ligatures
	       "}{}
	\DeclareFontShape{U}{hoefler}{b}{it}
	  {<-> "Hoefler\space Text\space Black\space Italic:mapping=tex-text;
	          Smart\space Swashes=!Line\space Final\space Swashes,
	                              !Line\space Initial\space Swashes;
	          Number\space Case=Normal\space Vertical\space Position
	       "}{}
	\DeclareFontShape{U}{hoefler}{bx}{n}
	  {<-> ssub * hoeftxt/b/n}{}
	\DeclareFontShape{U}{hoefler}{bx}{it}
	  {<-> ssub * hoeftxt/b/it}{}
	\DeclareFontShape{U}{hoefler}{m}{sc}
	  {<-> "Hoefler\space Text:
	          Letter\space Case=Small\space Caps
	       "}{}
	\renewcommand{\encodingdefault}{U}
	\renewcommand{\rmdefault}{hoefler}

	\SetSymbolFont{operators}{normal}{\encodingdefault}{\rmdefault}{m}{n}
	\SetSymbolFont{operators}{bold}  {\encodingdefault}{\rmdefault}{b}{n}
	\SetMathAlphabet{\mathrm}{normal}{\encodingdefault}{\rmdefault}{m}{n}
	\SetMathAlphabet{\mathbf}{normal}{\encodingdefault}{\rmdefault}{b}{n}
	\SetMathAlphabet{\mathit}{normal}{\encodingdefault}{\rmdefault}{m}{it}
	\SetMathAlphabet{\mathrm}{bold}  {\encodingdefault}{\rmdefault}{b}{n}
	\SetMathAlphabet{\mathit}{bold}  {\encodingdefault}{\rmdefault}{b}{it}

> Bruno, I remember that you've got some nice math setups going with 
> Hoefler and Lucida. Do you have an example in which \dot's work and 
> \sin and \cos are in the correct font?

Using the above (ie, using the same test file as Herb:

	\documentclass[12pt,a4paper]{article}

	\usepackage{amsmath}
	\usepackage[expert,vargreek,lucidasmallscale]{lucbmath}
	\usepackage{fontspec}
	\usepackage{xunicode}

	\defaultfontfeatures{Mapping=tex-text}
	\setromanfont[Numbers=Lining,Scale=1.05]{Hoefler Text}
	\setsansfont[Scale=1.01]{Gill Sans}
	\setmonofont[Scale=0.84]{Verdana}

	\begin{document}

	Here are ``dotted'' and ``ddotted'' \(x\)'s in math mode: \(\dot 
x=\ddot
	x\). And now in displayed math mode:
	\[
	\dot x=\ddot x.
	\]

	\end{document}

and replacing the fontspec-specific instructions by the above), I get 
the same error as Herb. Commenting out the last bit of instructions 
(ie, those including \SetSymbolFont and \SetMathAlphabet), the error 
disappears and the dot-accents are correct (but of course Lucida is 
used for all things math then, not Hoefler).

What's more strange is that, if this last bit is uncommented and now I 
play with the encoding with which the Lucida fonts are loaded, here's 
what I get:

	\usepackage[LY1]{fontenc}   --> error
	%\usepackage[LY1]{fontenc}  --> error
	\usepackage[T1]{fontenc}    --> no error (but wrong accents)

I think the problem is caused by the new way in which XeTeX deals with 
PostScript fonts:

- Previously it did not see the PFB Lucida fonts inside 
/Library/teTeX/share/texmf.local/fonts/type1/yandy/, and used the ones, 
in Classic LWFN format, inside /System Folder/Fonts/, making at that 
point some assumptions on their encoding (I don't know these 
assumptions, I'm just quoting more-or-less what Jonathan said then).

- Now it does see the PFB fonts and converts them on-the-fly to OTF 
format by using /Library/teTeX/bin/powerpc-apple-darwin-current/T1Wrap 
and creating files inside /Library/Caches/Type1-sfnt-fonts/. I imagine 
that at that point it makes some other assumptions on the encoding of 
the fonts, which end up by crashing xdv2pdf.

A final thought: could the problem be caused by XeTeX handling 
incorrectly the re-encoding that needs to be applied to the PFB fonts 
before incorporation inside its output, and, for example, re-encoding 
to T1 encoding in all cases? I'm referring to the different kinds of 
treatment required, for example, by these lines of 
/Library/teTeX/share/texmf.local/fonts/map/dvips/updmap/psfonts.map:

	hlcrm LucidaNewMath-Roman <lbmr.pfb
	hlhr8r LucidaBright "TeXBase1Encoding ReEncodeFont" <8r.enc <lbr.pfb
	hlhr8y LucidaBright "TeXnANSIEncoding ReEncodeFont" <texnansi.enc 
<lbr.pfb

Probably not, as when Lucida is used for all things math (see above), 
there's no error and the math accents are correct. The error is only 
there when attempting to use Hoefler, in U encoding (hence with no 
re-encoding at all), in math mode, creating apparently an encoding 
clash.

Take all this with care, as the last time I've used XeTeX seriously for 
typesetting maths was before Xmas, and I've forgotten a lot. I would 
now need to harvest my whole ~/Documents directory for all TeX files 
using XeTeX, and consolidate all the font-loading preambles I've in 
each case rewritten practically from scratch into a consistent set of 
instructions. For example, I've no idea now why I bothered to write:

	\usepackage[LY1]{fontenc}

when calling the Lucida fonts in XeLaTeX.

Bruno



More information about the XeTeX mailing list