
Usando o mecanismo XeLaTeX, MWE1 funciona bem com o pacote fontspec e ucharclasses. Mas quando altero fontspec para polyglossia (MWE2), não há efeito de fonte TypeWriter. Além disso, a primeira frase do texto em inglês não está na fonte Times New Roman. Existe alguma solução?
MWE1
\documentclass[11pt,a4paper]{article}
\usepackage{fontspec}
\newfontfamily\khmerfont[Script=Khmer,Scale=0.9]{Khmer OS}
\newfontfamily\khmerfonttt[Script=Khmer,Scale=0.9]{Khmer OS}
\newfontfamily\englishfont{Computer Modern Roman}
\usepackage{ucharclasses}
\setTransitionTo{Khmer}{\khmerfont}
\setTransitionFrom{Khmer}{\englishfont}
\usepackage{fancyvrb}
\begin{document}
\noindent What is wrong? តើមានអ្វីប្លែក? What is wrong? តើមានអ្វីប្លែក?
\begin{Verbatim}
What is wrong? តើមានអ្វីប្លែក? What is wrong? តើមានអ្វីប្លែក?
\end{Verbatim}
\end{document}
MWE2
\documentclass[11pt,a4paper]{article}
\usepackage{polyglossia}
\newfontfamily\khmerfont[Script=Khmer,Scale=0.9]{Khmer OS}
\newfontfamily\khmerfonttt[Script=Khmer,Scale=0.9]{Khmer OS}
\newfontfamily\englishfont{Computer Modern Roman}
\setdefaultlanguage[numerals=khmer]{khmer}
\setotherlanguage{english}
\usepackage{ucharclasses}
\setTransitionTo{Khmer}{\khmerfont}
\setTransitionFrom{Khmer}{\englishfont}
\usepackage{fancyvrb}
\begin{document}
\noindent What is wrong? តើមានអ្វីប្លែក? What is wrong? តើមានអ្វីប្លែក?
\begin{Verbatim}
What is wrong? តើមានអ្វីប្លែក? What is wrong? តើមានអ្វីប្លែក?
\end{Verbatim}
\end{document}
Fonte Khmer OShttp://www.khmeros.info/en/fonts
Responder1
Recebo saída errada em ambos os casos. Pelo menos no texto em inglês há mais famílias de fontes envolvidas, então você precisa de uma mudança de fonte um pouco mais sofisticada. Em vez disso, tente isto:
\documentclass[11pt,a4paper]{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\newfontfamily\khmerfont[Script=Khmer,Scale=0.9]{Khmer OS}
\setdefaultlanguage[numerals=khmer]{khmer}
\setotherlanguage{english}
\usepackage{ucharclasses}
\makeatletter
\setTransitionTo{Khmer}{%
\global\let\orif@family\f@family
\khmerfont}
\setTransitionFrom{Khmer}{%
\fontfamily{\orif@family}\selectfont}
\makeatother
\usepackage{fancyvrb}
\begin{document}
\noindent What is wrong? តើមានអ្វីប្លែក ? What is wrong? តើមានអ្វីប្លែក?
\begin{Verbatim}
What is wrong? តើមានអ្វីប្លែក? What is wrong? តើមានអ្វីប្លែក?
\end{Verbatim}
\end{document}
Se você tiver uma fonte tt dedicada para khmer, poderá adicionar alguns testes para a família atual.