polyglossia icon indicating copy to clipboard operation
polyglossia copied to clipboard

Wrong font in header/footer using greek and verbatim

Open nplatis opened this issue 13 years ago • 5 comments

[I am rewriting here a bug from the old polyglossia project, hoping that it gets some attention.]

If I use greek as the main language, and have a verbatim environment that is more than one page long, then the header and footer of the page containing the verbatim environment (more exactly: of the page(s) that end inside the verbatim environment) use the monospaced font instead of the normal font.

The problem goes away if I don't use greek as the main language (I tried french or no language at all), or if I use xgreek instead of polyglossia.

Here is a test case:

\documentclass[a4paper, 11pt]{article}

\usepackage{fontspec}
\setmainfont{Constantia}
\setmonofont{Consolas}

%\usepackage{xgreek}
\usepackage{polyglossia}
\setmainlanguage{greek}
\setotherlanguage{english}


\begin{document}

Hello

\begin{verbatim}
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
Hello.
\end{verbatim}

\end{document}

nplatis avatar Jun 08 '12 06:06 nplatis

The issue here is that the verbatim text is in Greek, but you haven't defined a greek mono font (via \greekfonttt).

% !TeX TS-program = xelatex
\documentclass[a4paper, 11pt]{article}

\usepackage{polyglossia}
\setmainlanguage{greek}
\setotherlanguage{english}

\setmainfont{Constantia}
\setmonofont{Consolas}
\newfontfamily\greekfonttt{Consolas}%% <-- LOOK HERE!

\pagestyle{headings}

\begin{document}
	
	\section{Title}
	Hello
	
	\begin{verbatim}
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	Hello.
	\end{verbatim}
	
\end{document}

I am not sure whether polyglossia should set \greekfonttt here itself if not defined or if this just needs documentation.

jspitz avatar Sep 11 '19 16:09 jspitz

This also happens without verbatim. Simpler testcase:

% !TeX TS-program = xelatex
\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage{greek}

\setmainfont{Constantia}
\setmonofont{Consolas}
% Commenting this out cures it:
%\newfontfamily\greekfonttt{Consolas}

\pagestyle{headings}

\begin{document}

\section{Title}

\ttfamily
Hello.
	
\end{document}

And it does not only happen with Greek. With latin script, there is not even a workaround:

% !TeX TS-program = xelatex
\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage{english}

\setmainfont{Constantia}
\setmonofont{Consolas}
%\newfontfamily\englishfonttt{Consolas}

\pagestyle{headings}

\begin{document}

\section{Title}

\ttfamily
Hello.
	
\end{document}

Seems the \*familylatin commands are to blame.

jspitz avatar Oct 26 '19 14:10 jspitz

I have a patch in the pipe for 1.46. The solution here is to define default font families and use that rather than \<xx>familylatin.

jspitz avatar Oct 26 '19 15:10 jspitz

92cdeb3 reintroduced this problem, but only for non-Latin scripts, and as of 8ef31ad the problem occurs with Latin scripts again. The problem is that the font family in \normalfont is determined by \xpg_select_fontfamily:n, which chooses the family according to \familytype, which might not be the default family, as in the example here.

Udi-Fogiel avatar May 28 '24 03:05 Udi-Fogiel

I think this is fixed with bd7e090, but we should probably test that.

Udi-Fogiel avatar May 28 '24 03:05 Udi-Fogiel

Seems fixed.

jspitz avatar Jul 12 '24 08:07 jspitz