# Problem with fontspec and EBGaramond

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

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

\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{\small\thepage}

% 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.

-
Have you tried setting the default font features before setting the main font? –  Silex Oct 30 '12 at 22:15
D-OH! Of course! thanks! fool of me.... –  El Andi Oct 30 '12 at 22:17

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}

-
Thanks for the suggestion, and now I know that I should do that. However, I'm pretty sure I'm using the OTF files (because I installed just those) and I wanted to let the system select automatically the correct optical size (12 for 11pt and higer sizes, 08 for 10 and lower sizes. It now works wonderfully! :) –  El Andi Oct 30 '12 at 22:47