When should package fontenc be used with pdflatex?
There is no simple answer to this. Or, rather, you already know the simple answer. In general, I would recommend
\usepackage[T1]{fontenc}
unless you know you need something different. In general, this will give good results which will be better than the alternatives in most cases.
This is because the T1 encoding will get you everything the default OT1 encoding gets you, plus a wide range of pre-composed accented characters and some additional characters needed in various Western European languages. Meanwhile, English will be at least as good, possibly better than with OT1.
However, it is possible to alter an encoding when creating a font support package so that the T1 encoding or the OT1 encoding or whatever is not quite the same as the official one. This only works straightforwardly for certain kinds of characters. Most notably, it works for ligatures.
This means that it is possible to add additional ligatures into spots in the encoding which would otherwise be empty or to substitute them into spots which would otherwise be used for other characters (perhaps for characters the font doesn't include anyway).
The result of this is that
\usepackage[<encoding>]{fontenc}
may not get you exactly <encoding>
. It may get you a hacked version of <encoding>
.
The font support files for the libertine
package are produced using the autoinst
script which can be configured to utilise empty slots in an encoding for additional ligatures. When fonts are prepared in this way, slots will not be reassigned to ligatures, but if an encoding has empty slots, these may be used for ligatures beyond those normally supported by the encoding.
Here's a mapping line from the .map
file fragment for the package
LinLibertineT-tlf-ot1--base LinLibertineT "AutoEnc_c7kyj5lv7lwhdgytk3lalexyxf ReEncodeFont" <[lbtn_c7kyj5.enc <LinLibertineT.pfb
lbtn_c7kyj5.enc
is the encoding file the line is using. When we exam,ine this file, we find
%00
/Gamma /Delta /Theta /Lambda /Xi /Pi /Sigma /Upsilon
/Phi /Psi /Omega /.notdef /.notdef /.notdef /.notdef /.notdef
and
%80
/f_i /f_f_i /f_f /f_l /f_f_l /f_b /f_h /f_j
/f_k /f_t /t_t /Q_u /T_h /f_f_h /f_f_j /f_f_k
%90
/f_f_t /exclamdbl /question_question /question_exclam /exclam_question /ellipsis /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
In contrast, here are the corresponding parts of 7t.enc
which corresponds to the standard OT1 encoding:
%00
/Gamma /Delta /Theta /Lambda /Xi /Pi /Sigma /Upsilon
/Phi /Psi /Omega /ff /fi /fl /ffi /ffl
and
%80
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
%90
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
This is obviously not the standard OT1 encoding.
Here, autoinst
has used slots in the encoding beyond 128. That is, it is essentially treating the encoding as 8 bit (256 slots) rather than 7 bit (128 slots), whereas the original TeX encodings were all 7 bit (128 slots), including OT1.
However, the T1 encoding is an 8 bit encoding (256 slots) already. Moreover, it does not have a single spare slot. Hence, autoinst
cannot assign additional ligatures to spare slots because there are none.
In contrast, the LY1 encoding is an 8 bit encoding with some spare slots. In this case, autoinst
assigns additional ligatures to spare slots until it exhausts the supply of slots. This means that it uses some of the additional ligatures, but not all. In particular, the fj
ligature works with this encoding, whereas the Th
and Qu
ligatures do not.
The only real answer here is that you should choose the encoding which best suits your needs. Which depends on the content of your document and, in some unusual cases, the specifics of hacked encodings used by the fonts you load.
At David's suggestion, I will turn my comment into an answer.
First: The above answers, regarding font encoding and modification, do work. A few years ago I hand-modified the LY1 encoding so that it would accomodate the "Th" ligature, and also pull in an alternate form of the em-dash, using Adobe Garamond Pro font. Worked great, but is tedious.
The more modern method is to forget about fontenc
and OT1
. Switch to LuaTeX. Most packages that work with ordinary pdfLaTeX also work with LuaTeX, right out of the box, without any special effort.
With LuaTeX, and with all text in utf-8, the fontspec
package handles TrueType and Open Type fonts directly. If the desired ligatures are part of a font's "liga" (standard ligatures) feature set, then they will automatically be enabled. If instead they are "discretionary" ligatures (dlig feature) then it is easy to ask for them.
You don't need to know anything about LuaTeX, or the Lua language. The heavy lifting is done in the background. Have a look at the fontspec
package documentation, to see what it can do. If you make a test run, be sure to specify that you want TeX Ligatures (described in fontspec
) so that your previous text input will be compatible.
Once I discovered this, I'll never go back to the pre-LuaTeX methods again.
Works with XeTeX too (but I happen to need something that XeTeX cannot do).
EDIT: Added MWE
% !TeX program = LuaLaTeX
% !TeX encoding = UTF-8
\documentclass{article}
\RequirePackage{fontspec}
\title{MWE}
\setmainfont{Adobe Garamond Pro}
\begin{document}
“This is a baffling fjord,” said Sven.
\end{document}
Result: Notice that ligatures Th ffl and fj are there. Also note that ordinary curly quotes were typed into the document, since it understands utf-8. If you try this with libertine, be sure to request "Linux Libertine O" (see that capital O) as the font.