[Tex/LaTex] How to use a different font for a specific language with XeTeX

fontslanguagesxetex

I am trying to set a specific font for polutonikogreek. To make it easy to switch to that language, I defined the following command:

\newfontfamily{\Vusillus}[]{Vusillus Old Face}
\newcommand{\greek}[1]{{%
\Vusillus\selectlanguage{polutonikogreek}#1%
}}  

But when I try something like this:

\greek{>erot'aw}

the font Vusillus Old Face isn't used, while this:

\Vusillus Something without a meaning

works well. Am I missing something?

Here an working example:

\documentclass[10pt,twoside]{memoir}
\usepackage[english,greek,polutonikogreek,ngerman,german]{babel}
\usepackage{blindtext}
\usepackage[utf8]{inputenc} 
\usepackage{scrpage2}

% rubber: set program xelatex

\usepackage{fontspec}
\usepackage{xltxtra}
\setmainfont[Numbers={OldStyle},Ligatures={Common, Historic}]{Adobe Garamond Pro}

\newfontfamily{\Vusillus}[]{Vusillus Old Face}
\newcommand{\greek}[1]{{%
\Vusillus\selectlanguage{polutonikogreek}#1%
}}

\begin{document}
Das ist nur ein Flie{\ss}text, sonst nichts: {\greek{>erot'aw}} und {\greek{>'erowc}}.
As you may have noticed the greek words are not in Vusillus, but \Vusillus this text actually is.
\end{document}

Best Answer

You can't do that way. With babel, the \greek command switches to an internal font encoding that's not understood by OpenType fonts (see later for more information).

With Polyglossia you can define a \greekfont that will do as you want, provided you input the Greek text using the actual characters.

\documentclass[10pt,twoside]{memoir}
\usepackage{polyglossia}
\setmainlanguage[spelling=new]{german}
\setotherlanguage[variant=polytonic]{greek}
\setotherlanguage{english}

\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Hoefler Text}

\newfontfamily{\greekfont}[Ligatures=TeX]{Old Standard}

\begin{document}

Das ist nur ein Flie{\ss}text, sonst nichts: 
\textgreek{ἐροτάω} und \textgreek{ἔροως}.

\begin{otherlanguage*}{english}
As you may have noticed the greek words \emph{are} in Old Standard,
like \greekfont this text actually is.
\end{otherlanguage*}

\end{document}

Note that inputenc must not be used with XeLaTeX. I simplified the language calls and used fonts I have on my system.

enter image description here

What about entering Greek text with the old transliteration scheme? See How to insert Greek with "ascii keyboard" and XeTeX, Polyglossia

After building the asciitogreek.tec file following the instructions, the input can become

\documentclass[10pt,twoside]{memoir}
\usepackage{polyglossia}
\setmainlanguage[spelling=new]{german}
\setotherlanguage[variant=polytonic]{greek}
\setotherlanguage{english}

\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Hoefler Text}

\newfontfamily{\greekfont}[Mapping=asciitogreek]{Old Standard}

\begin{document}

Das ist nur ein Flie{\ss}text, sonst nichts: 
\textgreek{>erot'aw} und \textgreek{>'erowc}.

\begin{otherlanguage*}{english}
As you may have noticed the greek words \emph{are} in Old Standard,
like \greekfont this text actually is.
\end{otherlanguage*}

\end{document}

Of course also text after \greekfont will be transliterated (I left it just by way of example). You can also use direct input of Greek characters.

enter image description here

Actually there is a problem with ~, see the linked answer for a workaround.

Related Question