[XeTeX] Spaces are lost in font names

Jonathan Kew jonathan_kew at sil.org
Sun Jun 24 13:53:33 CEST 2007


On 24 Jun 2007, at 11:56 am, Sivan Toledo wrote:

> Hi, I use a declaration like
>
> \DeclareFontShape{EU2}{arial}{m}{n}{<-> "Times New Roman" }{}
>
> but I am getting an error message:
>
> ! Font EU2/arial/m/n/10=TimesNewRoman at 10.0pt not loadable:  
> Metric (TFM) file or installed font not found.
>
> I am running under windows, with
>
> \XeTeXinputencoding "iso8859-8"
>
> It seems that spaces are truncated in font names. I don't have a  
> problem with things like "Arial".
>
> Any help will be appreciated.

This is because the LaTeX NFSS macros deliberately ignore spaces  
within the scope of \DeclareFontShape. To work around this, you can  
use the \space macro to include them, I believe:

   \DeclareFontShape{EU2}{arial}{m}{n}{<-> "Times\space New\space  
Roman" }{}

> (why I am trying to use \DeclareFontShape with a weird encoding  
> rather rely on fontspec:
> because I am trying to get XeLaTeX to work with Hebrew documents,  
> which often contain latin words/phrases. Good Hebrew fonts often  
> don't have good Latin glyphs, so the usual solution, which works  
> well under babel, is to switch fonts when you switch language.  
> There isn't a built in mechanism for this under babel, as far as I  
> know, so I cheat and tell babel to switch encoding, just to force  
> it to switch the physical font when switching language; I am trying  
> to get this to work with XeTeX now and I have the above problem  
> with spaces).

If I'm understanding your description correctly, there must be markup  
in your source document to distinguish the Latin-script fragments,  
right? In that case, would it be simpler to explicitly switch fonts  
at the same time as switching language, by creating a command that  
incorporates both the Babel language-switch and a fontspec font- 
switch? I don't really know about using Hebrew and Babel, but I'd  
guess that something along the lines of:

   \usepackage[english,hebrew]{babel}
   \usepackage{fontspec}
   \setmainfont[Script=Hebrew]{Arial}
   \newfontfamily{\tnr}{Times New Roman}

   \newcommand{\eng}[1]{{\beginL\selectlanguage{english}\tnr #1\endL}}

would allow you to mark English words with \eng{word} in the  
document, and have the Babel language and the font switch as needed.  
(Adjust commands, languages, fonts, etc as needed for your situation,  
of course.)

JK



More information about the XeTeX mailing list