2

A weird problem in fontspec. In the MWE and the image below, you see that fontspec renders Greek small caps when Script=Greek but it doesn't render Latin small caps and conversely, when Script=Latin. What is wrong with it and how to fix it?

Note: I don't want to have to let LaTeX know which language am I using, I want a global solution, if possible.

Thanks a lot, beforehand.

\documentclass{minimal}

\usepackage{fontspec}
\newfontfamily{\greek}[Script=Greek]{CMU Serif}
\newfontfamily{\latin}[Script=Latin]{CMU Serif}

\begin{document}
\noindent
{\greek\scshape Παράξενο Aυτό, Don't You Think?} \\
{\latin\scshape Παράξενο Αυτό, Don't You Think?}
\end{document}

that's weird, don't you think?

3
  • CMU Serif has no small caps Greek letters.
    – egreg
    Feb 3, 2018 at 14:18
  • @egreg If it hasn't, how do you explain the picture? Feb 3, 2018 at 14:24
  • It doesn't have them when the script is set to Latin (and conversely).
    – egreg
    Feb 3, 2018 at 14:29

1 Answer 1

3

It is not fontspec but the font. It has implemented the small caps feature so that it is disabled for other scripts.

With xelatex there is nothing that can done (apart from correctly selecting the language which imho you should do as it would also set the correct hyphenation patterns).

With lualatex you can try to patch the font. The following works but I'm really not sure if this the correct way to declare the feature and if some other values need a change too.

\documentclass{article}

\usepackage{fontspec}

\usepackage{luacode}

\begin{luacode}

local patch_cmuserif = function (fontdata)
 if fontdata.psname == "CMUSerif-Roman"
 then
  for i, v in ipairs(fontdata.resources.sequences) do
   if 
   fontdata.resources.sequences[i].features.name==s_s_1 
   or
   fontdata.resources.sequences[i].features.name==s_s_3
   then
    fontdata.resources.sequences[i].features.smcp={
       ["dflt"]={["dflt"]=true,}, 
       ["cyrl"]={["dflt"]=true,},
       ["latn"]={["dflt"]=true,},
       ["grek"]={["dflt"]=true,},
        }
   end 
  end
 end
end



luatexbase.add_to_callback
 (
  "luaotfload.patch_font",
  patch_cmuserif,
  "change_cmuserif"
 )
\end{luacode}


\newfontfamily{\greek}[Script=Greek]{CMU Serif}
\newfontfamily{\latin}[Script=Latin]{CMU Serif}

\begin{document}


\noindent
{\greek\scshape Παράξενο Aυτό, Don't You Think?} \\
{\latin\scshape Παράξενο Αυτό, Don't You Think?}
\end{document}

enter image description here

2
  • Thanks. Do you happen to know if there is a way to patch the font in FontForge instead, so that I can use it with xelatex too? Feb 3, 2018 at 17:47
  • I'm rather certain that you can adapt such open type features in fontforge. Feb 3, 2018 at 23:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .