[XeTeX] Spaces are lost in font names

Sivan Toledo stoledo at tau.ac.il
Sun Jun 24 17:38:22 CEST 2007


Thanks to all for the detailed replies! (And to Will for the welcome
comments.)

Will's solution,

\newcommand\MyFontShape[6]{\DeclareFontShape{#1}{#2}{#3}{#4}{#5}{#6}}
\MyFontShape{U}{test}{m}{n}{<->"Times New Roman"}{}

is certainly good enough for me.

As to Jonathan's question:

Yes, there is markup to mark the Latin words, paragraphs, etc. I use LyX,
which works very well in these mixed-direction documents, and it wraps
English text within the Hebrew flow with \L, as in \L{Matlab}. This is
processed by babel to switch both direction and language. The problem is
that babel will switch a font encoding when it switches language, but I
don't think that there is a way to tell it to switch font family. I prefer
to hack babel as little as possible, because major hacks tend to be
difficult to distribute to other Hebrew users and to maintain.

So in summary, I am looking for a small hack, even if it is ugly, in order
to use LyX and babel "out-of-the-box" as much as possible.

I think that I still need to resolve other problems, like mirroring of
parenthesis and some spacing problems in enumerate environments.

But the ability to use installed OpenType is a joy!

Regards, Sivan


On 6/24/07, Jonathan Kew <jonathan_kew at sil.org> wrote:
>
> 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
>
> _______________________________________________
> XeTeX mailing list
> postmaster at tug.org
> http://tug.org/mailman/listinfo/xetex
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/xetex/attachments/20070624/c4ab58c7/attachment-0001.html 


More information about the XeTeX mailing list