It's the same mechanism that from the input fi produces a ligature. It's indeed font dependent. If you do
tftopl cmr10
you get, among other things,
(LIGTABLE
...
(LABEL O 140)
(LIG O 140 O 134)
(STOP)
...
which means: when character '140 (octal, the backquote) is followed by another character '140, substitute them with character '134. If the current font doesn't have this information, no substitution is made (and cmtt10 hasn't such an entry). Such ligatures are defined in the Metafont sources. For non Metafont produced fonts, the afmtotfm program or the package fontinst add the programs for the ligatures, if so desired, when producing the .tfm files.
When TeX is instructed to load a font, say cmr10, it actually reads cmr10.tfm that contains, in a compact form, what is seen in "human" form via the tftopl program. The two characters must be in the same font:
`\bfseries`
won't give a ligature.
XeTeX uses another method. Some ligatures are defined by the font itself (fi, for instance), but things such as '' aren't. In order to get the "same" output from the same source, you specify a "map file" that uses the TecKit technology. The instruction that's added to the font name is mapping=tex-text which loads, together with the font, a file tex-text.tec which is a compact form of tex-text.map:
; TECkit mapping for TeX input conventions <-> Unicode characters
LHSName "TeX-text"
RHSName "UNICODE"
pass(Unicode)
; ligatures from Knuth's original CMR fonts
U+002D U+002D <> U+2013 ; -- -> en dash
U+002D U+002D U+002D <> U+2014 ; --- -> em dash
U+0027 <> U+2019 ; ' -> right single quote
U+0027 U+0027 <> U+201D ; '' -> right double quote
U+0022 > U+201D ; " -> right double quote
U+0060 <> U+2018 ; ` -> left single quote
U+0060 U+0060 <> U+201C ; `` -> left double quote
U+0021 U+0060 <> U+00A1 ; !` -> inverted exclam
U+003F U+0060 <> U+00BF ; ?` -> inverted question
; additions supported in T1 encoding
U+002C U+002C <> U+201E ; ,, -> DOUBLE LOW-9 QUOTATION MARK
U+003C U+003C <> U+00AB ; << -> LEFT POINTING GUILLEMET
U+003E U+003E <> U+00BB ; >> -> RIGHT POINTING GUILLEMET
The mechanism is similar: for instance, the combination U+0060 U+0060 is transformed into U+201C.
LuaTeX uses another different method.
fflook nice. Am I right?) – Andrew Stacey Jul 27 '11 at 12:15