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:

Richard
  • 2,084
  • I get ligatures with texlive 2015 and miktex. – Ulrike Fischer Sep 02 '15 at 20:54
  • Hmm, I have TeXMaker on Fedora 22; perhaps that's the issue? – Richard Sep 02 '15 at 20:55
  • 1
    Texmaker is not relevant, but what is your texlive and xelatex version? – Ulrike Fischer Sep 02 '15 at 20:57
  • TeX Live 2014 with xelatex 2015.5.27 (I assume that's the correct xelatex information). – Richard Sep 02 '15 at 21:02
  • Set Ligatures = Common. That setting is default in newer versions of fontspec, but maybe you're running an old version. – Sverre Sep 02 '15 at 21:34
  • Sorry, Sverre, I forgot to clarify: I tried that as well and it didn't work. (I just forgot to include it in the original post; I'll edit it.) – Richard Sep 02 '15 at 21:35
  • I get the same output with both documents. I have the opentype version of Alegreyra installed system-wide. What I'm not sure is how to tell which font is being used when I run the second document. In pdfTeX and LuaTeX, finding this out is easy. With XeTeX, I have yet to discover a method. – cfr Sep 02 '15 at 22:43
  • 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 – Akira Kakuto Sep 02 '15 at 23:36
  • @AkiraKakuto Thank you - this has been annoying me for some time! – cfr Sep 02 '15 at 23:46
  • When I compile the first document, XeTeX uses the opentype versions of the fonts. Yet the output is identical: ligatures work fine. I have version 1.004 of the font Alegreya-Regular.otf. – cfr Sep 02 '15 at 23:51

1 Answers1

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.

Sverre
  • 20,729
  • 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 02 '15 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. – Akira Kakuto Sep 02 '15 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 02 '15 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 shapeT1/Alegreya(0)/m/n' undefined(Font) using T1/cmr/m/n' instead. Perhaps it is, after all, just because I have TeX Live 2014? – Richard Sep 03 '15 at 02: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. – Richard Sep 03 '15 at 02:28
  • But alas, the above comment takes away my bold and italic characters (font shape undefined); any suggestions? – Richard Sep 03 '15 at 02:34
  • @Sam It's a bit hard to comment on your recent errors, because you can't get those from running my code (you can't get errors about SC with it). I just wrote a minimal example showing that you do get ligatures with the font. The reason you don't get a bold font with my code is because I didn't bother to specify a bold font. I assumed you knew how to set fontspec options, so I just focused on your question about ligatures. I can post a more complete example soon. – Sverre Sep 03 '15 at 04:58
  • @Sverre, I had to tweak your code to match the .otf format and some of the font names on my machine, but everything is up and running now. My fontspec options problem was another result of .otf and .ttf confusion. Thank you so much for your patience and help! – Richard Sep 03 '15 at 05:54
  • @Sam It might be a better idea to just use the .ttf fonts to begin with, as there appears to be some problem with the .otf version you have. – Sverre Sep 03 '15 at 05:57