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:
\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:
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.


\textgreek{\textsf{Αυτό είναι ελληνικά}}– Yorgos Jan 16 '17 at 20:31\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\textsfcommand works, whereas for the rest of it serif font applies – Yorgos Jan 16 '17 at 20:48setmainfontto Liberation Sans and also remove your definitions (it sounds silly, i know :P). – Yorgos Jan 16 '17 at 21:38textsfby definition produces the sans serif font and not the serif font – Yorgos Jan 16 '17 at 21:56\textsf{text}does produce sans serif text, not serifed. – hintze Jan 16 '17 at 22:00textsf{}appears in sans serif – Yorgos Jan 16 '17 at 22:04\sffamily{\textgreek{something}}– Yorgos Jan 16 '17 at 23:07\textit{\textgreek{foo}}it selects the font I set with\newfontfamily\textgreeksf{}. Now the question is much clearer: Why does xelatex not detect greek text on its own? (Or: If it detects it, why does it not choose the correct font?) – hintze Jan 16 '17 at 23:12