[Tex/LaTex] Problem with fontspec and EBGaramond

fontspecluatexxetex

Im trying to typeset a book using fontspec and the EB Garamond font. I try first to use Lualatex because I wanted to experiment with some features of the impnattypo (french typography) package. However, at first I had some problems rendering OpenType features like historic ligatures, small caps in conjuction with caps to small caps, and almost all the contextual alternatives. Then, I found suggestions about a problem with lualatex, so I changed to XeLaTeX, and some of my problems got fixed, but some of them not. For example, I can't activate historic ligatures, I can't get the alternative "1" (feature cv11), and the TeX ligatures (— and such) don't work. Here is a working example:

% !TEX TS-program = xelatex
% !TEX encoding = UTF-8

\documentclass[11pt,DIV=8]{scrbook} 
\usepackage[papersize={140mm,210mm}]{geometry}
\usepackage{microtype}
\usepackage{realscripts}
\usepackage{fontspec}
\setmainfont{EB Garamond}
\defaultfontfeatures{RawFeature={+hlig,+clig,+dlig,+cv11,+cv90,+calt,+ccmp,+swsh},Ligatures=TeX,Numbers={Proportional,OldStyle}}

%Cool Small caps
\newcommand{\smallcaps}[1]{\textsc{\MakeLowercase{#1}}}

%first paragrpaph definition
\newcommand{\primero}[1]{\noindent{\smallcaps{#1}}}

% cool french typography 
\usepackage[    hyphenation,
            parindent,
            lastparline
            ]{impnattypo}

\usepackage[all]{nowidow}
\raggedbottom
\setlength{\emergencystretch}{3em}  % prevent overfull lines

% footers and headers
\usepackage{fancyhdr}
\fancypagestyle{plain}{%
    \fancyhf{} % clear all header and footer fields
    \fancyfoot[C]{\thepage} % except the center
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
    }%

\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE]{\small{\smallcaps{Some Author}}}
\fancyhead[RO]{\small{\smallcaps{Some Title For This}}}
\fancyfoot[C]{\small\thepage}
\renewcommand{\headrulewidth}{0.1pt}

% chapter start
\renewcommand*\sectfont{\rmfamily\scshape}

\usepackage{kantlipsum}


\begin{document}
Quienes queriendo. \textit{Quienes quieren querer queriendo.} 

---This should be an em-dash,and the ligature in this: Th should work. 

--This should be an en-dash and this historic ligatures should work: estaba octubre. 

--- These ones should not look like roman numerals: 111111. 

\kant[1]

\textit{\kant[2]}
\end{document}

I tried the options in the fontspec manual, and also tried the suggestions from the font author's own specimen data and his recommendations for XeLaTeX use. I also tried using Mapping=tex-text and Ligatures=TeX with no success. I also tried changing from Raw OpenType features to fontspec defined features (like Ligatures={Historic}.

I don't know what else to do. I have scrambled around with this file all day with no success. And the worst thing is that I know I made it work before! but now I can't remeber how… 🙁 I know there must be some little and obvious thing that I'm missing.

Best Answer

You need to declare the default font features before setting the font with \setmainfont.
Also make sure you didn't somehow end up with the TrueType version of the font.

Furthermore, it might be worthwhile to specify the files in more detail:

\setmainfont
    [ Path        = /path/to/fonts/ ,
      Extension   = .otf,
      UprightFont = *12-Regular  ,
      ItalicFont  = *12-Italic ,
      BoldFont    = *08-Regular ]
    {EBGaramond}
Related Question