libertinus icon indicating copy to clipboard operation
libertinus copied to clipboard

How to enable Qu, Th, ft ligatures in pdflatex

Open kalaschnik opened this issue 4 years ago • 10 comments

I still prefer to use the pdflatex compiler (mostly because of the better microtype support), yet I am unable to get the following ligatures in my text: Qu, Th, ft

Is there anyway I can use these with pdflatex?

kalaschnik avatar Dec 08 '20 19:12 kalaschnik

How are you loading the font up for use in your document? With \usepackage{libertinus}?

alerque avatar Dec 08 '20 20:12 alerque

correcto!

kalaschnik avatar Dec 08 '20 21:12 kalaschnik

I may be wrong, but I am afraid this is only possible with custom tfm files.

sieversMartin avatar Dec 08 '20 21:12 sieversMartin

Some searching on tex.stackexchange.com suggests that the only way to handle this in Type1 fonts is to assemble your own with the options you want. See e.g. this comment. I don't know how the build process works for how the current Type1 set is generated, but if you could find that it probably wouldn't be too hard to modify it to get your preferred set of ligatures and style alternates.

If you do find it it might be nice to document here. This isn't the first time similar desires have come up for this project .

alerque avatar Dec 08 '20 21:12 alerque

Having libertine in pdflatex:

\usepackage{libertine}

\usepackage[T1]{fontenc}

\newcommand{\Th}{\begingroup\fontencoding{OT1}\selectfont Th\endgroup}
\newcommand{\Qu}{\begingroup\fontencoding{OT1}\selectfont Qu\endgroup}
\newcommand{\fft}{\begingroup\fontencoding{OT1}\selectfont fft\endgroup}

I can do this:

\begin{itemize}
    \item \Qu{}alität kommt immer vor Quantität.
    \item Ich finde dich toll.
    \item Ich mag die Schifffahrt.
    \item Scha\fft{} ihr das?
    \item \Th{}is is cool. This is not.
\end{itemize}

Which results into this: image

But this does not work for libertinus, is there something similar I could do?

In other words, I could write my text in libertine. And use Search and Replace at the end of writing to insert the \Th, \Qu, etc. commands.

kalaschnik avatar Dec 09 '20 15:12 kalaschnik

Thanks for that interesting result. I had a closer look at the used .enc files. For Libertine I found:

...
%80
  /f_i /f_f_i /f_f /f_l /f_f_l /f_b /f_h /f_j
  /f_k /f_t /Lslash /t_t /f_f_h /f_f_j /f_f_k /f_f_t
%90
  /Q_u /T_h /exclamdbl /question_question /question_exclam /exclam_question /ellipsis /.notdef
  /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
...

while there is nothing like that in the enc files used when switching to libertinus-type1.

Maybe it has something to do with the way the Type1 fonts are created. For Libertine I find:

% Command line: 'otftotfm --automatic --encoding=fontools_ot1
% --tfm-directory=texmf/fonts/tfm/public/libertine
% --vf-directory=texmf/fonts/vf/public/libertine
% --type1-directory=texmf/fonts/type1/public/libertine
% --truetype-directory=texmf/fonts/truetype/public/libertine
% --encoding-directory=texmf/fonts/enc/dvips/libertine
% --map-file=texmf/fonts/map/dvips/libertine/LinuxLibertineT.map --no-updmap
% --coding-scheme=TEX TEXT --feature=kern --feature=liga --feature=lnum
% --feature=tnum LinLibertine530_R.otf LinLibertineT-tlf-ot1'

while for Libertinus the settings for ligatures are:

% Command line: 'otftotfm --automatic --encoding=fontools_ot1
% --tfm-directory=texmf/fonts/tfm/public/libertinus-type1
% --vf-directory=texmf/fonts/vf/public/libertinus-type1
% --type1-directory=texmf/fonts/type1/public/libertinus-type1
% --encoding-directory=texmf/fonts/enc/dvips/libertinus-type1
% --map-file=texmf/fonts/map/dvips/libertinus-type1/LibertinusSerif.map
% --no-updmap --force --coding-scheme=TEX TEXT --feature=kern --feature=liga
% --feature=lnum --feature=tnum --ligkern=f i =: fi --ligkern=f l =: fl
% --ligkern=f f =: ff --ligkern=ff i =: ffi --ligkern=ff l =: ffl
% LibertinusSerif-Regular.otf LibertinusSerif-Regular-tlf-ot1'

sieversMartin avatar Dec 09 '20 16:12 sieversMartin

Humn, it seems extra ligatures are hard to get in libertinus and pdflatex... I think I will go for classic libertine. As I really like what microtype is doing with my text and it still works best with pdflatex.

I also noticed whenever ligatures are rendered in pdflatex you are required to use:

\input{glyphtounicode}
\pdfgentounicode=1

... in order to actually search the pdf for words containing a ligature.

I assembled a small demo playground (view-only) https://www.overleaf.com/read/mxcqmqxhzvcv

kalaschnik avatar Dec 11 '20 14:12 kalaschnik

In recent versions of Libertinus, Qu was reimplemented as calt feature that makes Q elongated before u or v, Th need to insert ZWJ to reproduce a ligature, or alternatively, enabling dlig feature.

KrasnayaPloshchad avatar Dec 15 '20 06:12 KrasnayaPloshchad

But that does not solve the problem with pdfTeX.

sieversMartin avatar Dec 15 '20 07:12 sieversMartin

I'm happy to fix anything in the font that needs fixing, but this is looking more and more like something to do with the TeX packaging and specifically the conversion from an OpenType font to a Type1 encoding. This is simply beyond my expertise (or interest). Have you asked on Stack Exchange or Top Answers? There is far more expertise floating around there and somebody might know what knobs need to be twiddled. Eventually we probably need to get Bob Tennent who maintains the libertinus-type1 packaging to apply a fix, but my first move would probably be asking on one or both of those Q&A sites before trying to contact him (I found two email addresses but don't see him on GitHub anywhere).

alerque avatar Feb 22 '21 06:02 alerque