I'm using polyglossia
to switch between languages in my documents and fontspec
to define various fonts. The combination gives me the following problem.
An MWE:
\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{dutch}
\usepackage{fontspec}
\newfontfamily\mono{Latin Modern Mono}[Scale=2] % scaled for visibility
\begin{document}
foo\mono bar foo\textdutch{bar}
\end{document}
Result:
Why isn't the second "bar" typeset in the current font family (\mono
)? Is this due to a feature in polyglossia
that supports different fonts for different languages? If so, how do I redefine \text<language>
so that it uses the current font, or: How do I detect the current font and then activate it within \text<language>{<here>}
? Or am I plainly doing something wrong?
Update: Answered by Ulrike Fischer, see below, but I have a persistent problem and a solution:
Another not-so-MWE to illustrate what I'm doing wrong.
\documentclass[]{memoir}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{dutch}
\newcommand*\dutchfont{} % the solution to the first problem, thanks to Ulrike Fischer
\usepackage{fontspec}
\newfontfamily\titlefont{Latin Modern Mono}[Scale=2] % scaled for visibility
\renewcommand*{\maketitlehooka}{\titlefont} % this hook executes just before \thetitle is printed
\title{fo\textdutch{ob}ar}
\begin{document}
\sffamily % <=== disable this and the thanks have the desired font
% \fontfamily\sfdefault\selectfont % this works correctly
\maketitle
\end{document}
It causes the same incorrect font selection when the language is changed. In this MWE, the text foobar is in english and in a font selected with \titlefont
, but the -ob- in the middle is in dutch. This language change results in a font change as well if \sffamily
(and probably any other \..family
command) has been called before the text. I used \sffamily
before \maketitle
to typeset the various title page elements in sans serif. Any text containing another font than default and language changes reverts to the default sans serif font, based on my experience. Using \fontfamily\sfdefault\selectfont
instead of \sffamily
does work without problems. Why is the use of \sffamily
incorrect here?
polyglossia
applies\<language>font
if defined or else\normalfont
. There's obviously space for improvement here.\<language>font
to always be the current font as soon at it is used? I know the fonts I use are compatible with the languages I use. IMHO there should be a package or language option inpolyglossia
that disables the font resetting. E.g.:\newfontfamily\<language>font{\font}
\cyrillicfont
you don't want that switching to Dutch keeps it.polyglossia
should act dumb in my case and use the current font.