3

The following code does not create the expected ligatures (note that Alegreya is OTF):

%XeLaTeX
\documentclass{report}
\usepackage{fontspec}
\setmainfont[
  SmallCapsFont={Alegreya SC},
  ItalicFeatures={SmallCapsFont=AlegreyaSC-Italic},
  BoldFeatures={SmallCapsFont=AlegreyaSC-Bold},
  BoldItalicFeatures={SmallCapsFont=AlegreyaSC-BoldItalic},
  Ligatures=TeX,
]{Alegreya}

\begin{document}

fi ff fl

\end{document}

Defining Ligatures=Rare, Historical, and/or Common has no effect on output (as discussed here).

Using the Alegreya package, however, does create the expected ligatures:

%XeLaTeX
\documentclass{report}
\usepackage{Alegreya}

\begin{document}

fi ff fl

\end{document}

However, I need to use fontspec in order to access some Icelandic characters. How can I achieve the ligatures in the first example?

Possibly related:

10
  • I get ligatures with texlive 2015 and miktex. Sep 2, 2015 at 20:54
  • Hmm, I have TeXMaker on Fedora 22; perhaps that's the issue? Sep 2, 2015 at 20:55
  • 1
    Texmaker is not relevant, but what is your texlive and xelatex version? Sep 2, 2015 at 20:57
  • TeX Live 2014 with xelatex 2015.5.27 (I assume that's the correct xelatex information). Sep 2, 2015 at 21:02
  • 2
    @cfr: In the default setting, xdvipdfmx runs in the quiet mode. You will see used fonts by xelatex -output-driver="xdvipdfmx -v -E" foo.tex Sep 2, 2015 at 23:36

1 Answer 1

5

When I run your code with tex live 2015 in Mac OS X, I just get a font-not-found error. As I see it, that's because I can't just say \setmainfont{<name>} if the font isn't installed on your system. But as this discussion shows, other people claim that's wrong. In that case I have no idea why fontspec can't find Alegreya.

But at any rate, if I specify the file names of the fonts, as I usually do, everything works fine:

\documentclass{report}
\usepackage{fontspec}
\setmainfont{Alegreya-Regular.ttf}
\begin{document}
fi ff fl
\end{document}

enter image description here

Now this code is obviously just a minimal example to illustrate how you get the ligatures. Don't use that code and expect to get bold, italic, and small caps fonts. They have to be specified as well.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Alegreya}[
    Extension = .ttf,
    UprightFont = *-Regular,
    ItalicFont = *-Italic,
    BoldFont = *-Bold,
    BoldItalicFont = *-BoldItalic,
    UprightFeatures = {SmallCapsFont = *SC-Regular},
    ItalicFeatures = {SmallCapsFont = *SC-Italic},
    BoldFeatures = {SmallCapsFont = *SC-Bold},
    BoldItalicFeatures = {SmallCapsFont = *SC-BoldItalic}]
\begin{document}

fi ff fl

\textit{fi ff fl}

\textbf{fi ff fl}

\textbf{\textit{fi ff fl}}

\textsc{Small caps}

\textsc{\textit{Small caps}}

\textsc{\textbf{Small caps}}

\textsc{\textbf{\textit{Small caps}}}

\end{document}

enter image description here

I'm not sure why you say that Alegreya is .otf, because the fonts that are distributed with TeX (which come from Google Fonts) are .ttf.

Also, you say that you need fontspec to access Icelandic characters. That's not correct, because all the characters of Modern Icelandic are included in the most common font encoding, T1:

\documentclass{article}
\usepackage{Alegreya}
\usepackage[T1]{fontenc}
\begin{document}
\TH etta er \'islenskt m\'al, og \th a\dh\ er ekki skrifa\dh\ \'a \"o\dh ru m\'ali.
\end{document}

enter image description here

As per your comment, I have no idea why this would give you an error about T1 being undefined for Alegreya. I don't think the Alegreya package ever came without T1 fonts, so that seems very odd to me. Update your Alegreya package and try again.

9
  • I also have the .otf versions installed system-wide. So it is quite possible that the OP has these installed for the system, regardless of what Google Fonts and TeX Live happen to favour. Do you know how to tell for sure which fonts XeTeX is using?
    – cfr
    Sep 2, 2015 at 22:45
  • 1
    Alegreya-Regular.ttf in TeX Live is OK. I downloaded aregreya.zip from http://www.fontsquirrel.com/fonts/alegreya and tested \documentclass{report} \usepackage{fontspec} \setmainfont[Ligatures=TeX]{Alegreya-Regular.otf} \begin{document} fi ff fl \end{document} There are no ligatures. Sep 2, 2015 at 23:25
  • @AkiraKakuto Nonetheless, your hint let me determine that the OP's first example compiles fine for me and it is using the opentype versions of the fonts. Ligatures work fine.
    – cfr
    Sep 2, 2015 at 23:50
  • I too downloaded the font from fontsquirrel, and the command line tells me that the .otf font is being used in both examples. However, compiling Sverre's latter example returns the error Font shape T1/Alegreya(0)/m/n' undefined(Font) using T1/cmr/m/n' instead. Perhaps it is, after all, just because I have TeX Live 2014? Sep 3, 2015 at 2:16
  • After playing around with the several suggestions posted here, I seem to have found a fix (though that doesn't mean I understand it!). Clarifying the .ttf version of the font (as shown in the first example of Sverre's example) resulted in a font-not-found error. I thus used the .otf version of the font, which resulted in a different font-not-found error, this time for Alegreya SC in the SmallCapsFont option. I changed this to SmallCapsFont={AlegreyaSC-Regular} (which matches my font database) and suddenly all ligatures work perfectly, as do the Icelandic characters. Sep 3, 2015 at 2:28

You must log in to answer this question.

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