1

If I set the default language to, lets say, english, and as another language greek, I can not get polyglossia (i.e. fontspec in the end?) to use the greek font family I set in my xetex code (with \newfontfamily\greekfont) when compiling with xelatex. If I set the default language to greek, and the other one english, it works.

My M(not)WE is the following. Here, I set the greekfont to Liberation Sans and the greekfontsf to Liberation Serif, just to show that it ignores those definitions. It renders the normal greek (serif) part in serif, and the sans serif part in sans, like this:

enter image description here

\documentclass{article}

\usepackage{polyglossia}

\setmainfont{Liberation Serif}
\setsansfont{Liberation Sans}
\newfontfamily\greekfont{Liberation Sans}
\newfontfamily\greekfontsf{Liberation Serif}
\setdefaultlanguage{english}
\setotherlanguage{greek}

\begin{document}
\tableofcontents{}

\section{Αυτό είναι ελληνικά.}
Welcome to Greek should-not-be-serif: Αυτό είναι ελληνικά

Welcome to Greek should-not-be-sans: \textsf{Αυτό είναι ελληνικά}

Another try to should-not-be-sans: \textgreek{\textsf{Αυτό είναι ελληνικά}}
\end{document}

If one now sets \setdefaultlanguage{greek} and \setotherlanguage{english}, it does select the correct font shapes:

enter image description here

What is going on? Unfortunately, other similar questions didnt help. Specifically, this one seemed to be very relevant. But it didnt work :/

//UPDATE: Since the scope of this question is answered, I was able to refine what the problem actually is. Thus, I opened another question found here.

  • try this: \textgreek{\textsf{Αυτό είναι ελληνικά}} – Yorgos Jan 16 '17 at 20:31
  • Thank you for your suggestion @Yorgos, but the result looks the same as without \textgreek, it doesnt work. May I ask whether my MWE produces a PDF with correct fonts selected in your tex setup? – hintze Jan 16 '17 at 20:33
  • i compiled your mwe with no problem. Liberation Sans works for greek language – Yorgos Jan 16 '17 at 20:43
  • thanks for clarification. but, unfortunately, thats not the problem. both, sans and serif, work for greek. but please note how I chose a sans font for serifed greek and vice versa. the greek text in my compiled PDF just does not select the correct font. – hintze Jan 16 '17 at 20:46
  • I understood your problem, but as I said your mwe worked for me. That is, \textsf command works, whereas for the rest of it serif font applies – Yorgos Jan 16 '17 at 20:48
1

Just try to specify firstly your family font and then the greek text. As you can see, in the second case definitions are taking into account, whereas in the third are ignored

\documentclass{article}

\usepackage{polyglossia}

\setmainfont{Liberation Serif}
\setsansfont{Liberation Sans}
\newfontfamily\greekfont{Liberation Sans}
\newfontfamily\greekfontsf{Liberation Serif}
\setdefaultlanguage{english}
\setotherlanguage{greek}

\begin{document}
\tableofcontents{}

\section{Αυτό είναι ελληνικά.}
Welcome to Greek should-not-be-serif: Αυτό είναι ελληνικά

Welcome to Greek should-not-be-sans: \sffamily{\textgreek{Αυτό είναι ελληνικά}}

Another try to should-not-be-sans: \textgreek{\sffamily{Αυτό είναι ελληνικά}}
\end{document}
  • Since it works within \textgreek{}: Why does xelatex not detect greek text on its own? (Or: If it detects it, why does it not choose the correct font?) Because, for example, if I have a bibliography with greek letters within latin text, I would have to enclose those greek letters in \textgreek in my bib-file. – hintze Jan 16 '17 at 23:14
  • I always use \defaultfontfeaures{Mapping=tex-text} and so xelatex always detect greek characters, without using \textgreek{} command – Yorgos Jan 16 '17 at 23:39
  • Adding \defaultfontfeatures{Mapping=tex-text} to the MWE still produces the same PDF output with xelatex like before. Still, you have kind of solved my problem. Not completely, but in scope of my original post you answered how to get correct font selection by enclosing greek text in \textgreek{}. Since changing my question now to focus on how to let xetex/polyglossia/fontspec select the correct font on its own, I am going to post a new question and add a link here. Thank you. – hintze Jan 17 '17 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.