I have a font with a font table containing ligatures, but also math radicals, operators and e.g. an integral sign. (It's a different font from the one I'm showcasing in this question, which doesn't contain the integral sign.)

In my case some character combinations don't trigger the glyph replacement for e.g. the "ffi" ligatures. This happens for both pdflatex (think otftotfm) as well as xelatex (fontspec) solutions for font implementation.

A compiled result containing the commercial font that I intend to use shows (for both fontspec solutions as well as otftotfm)


XeLaTeX (fontspec)

After running the solution outlined in Ligatures for fi, fl, ffl do not work for Times New Roman (XeLaTeX), trying to trigger the ligatures still doesn't work. Egreg mentioned in chat that the solution generally produces the right output for XeTeX documents, granted glyphs are in the right position for the font table. It turns out they are in the font table (screenshot taken from Adobe Illustrator)

enter image description here

This suggests they are not in the right position. It would therefore be desirable to have an option to manually set the link between typing e.g. "ffi" and linking it to the correct ligature in the font.

PdfLaTeX (otftotfm)

Just to be sure, I used otftotfm with the following command:

otftotfm -a -e ec  -fkern -fliga --verbose --vendor <mapfilename> <somefont>.otf T1--<fontname>--<fontweight>

The command produces an errors with regard to ligatures:

otftotfm: warning: 'liga' feature ignored, not supported by font

This is also confirmed after constructing the .pl file:

tftopl T1--<fontname>--<fontweight>.tfm > T1--<fontname>--<fontweight>.pl

The ligature indeed wasn't there. The following is taken from the T1--<fontname>--<fontweight>.pl file:

   (KRN O 41 R 0.08)
   (KRN O 47 R 0.1)
   (KRN O 51 R 0.07)
   (KRN O 52 R 0.08)
   (KRN O 54 R -0.05)
   (KRN O 56 R -0.05)
   (KRN O 77 R 0.12)
   (KRN O 135 R 0.07)
   (KRN C a R -0.01)
   (KRN C b R 0.1)
   (KRN C c R -0.01)
   (KRN C e R -0.01)
   (KRN C g R -0.01)
   (KRN C h R 0.1)
   (KRN C i R 0.03)
   (KRN C j R 0.03)
   (KRN C k R 0.1)
   (KRN C l R 0.1)
   (KRN C o R -0.01)
   (KRN C t R 0.01)
   (KRN C v R 0.01)
   (KRN C w R 0.01)
   (KRN C y R 0.01)
   (KRN O 175 R 0.07)
   (KRN O 15 R -0.05)
   (KRN O 22 R -0.05)
   (KRN O 21 R 0.1)
   (KRN O 346 R -0.01)
   (KRN O 370 R -0.01)
   (KRN O 367 R -0.01)
   (KRN O 344 R -0.01)
   (KRN O 345 R -0.01)
   (KRN O 351 R -0.01)
   (KRN O 352 R -0.01)
   (KRN O 364 R -0.01)
   (KRN O 366 R -0.01)

The one thing I can think of is to mess with the human-readable .pl file (of which the above is an excerpt), and constructing everything manually. But perhaps (hopefully?!) LaTeX has facilities to deal with this kind of thing.

Regardless, it would be nice to assign arbitrary (but specific) glyphs of the font table to specific commands, in a very general way. Think \int which would trigger the integral sign from i.e. (made up numbers), octal 501, or unicode +00a6, or combinations of letters, such that "ffi" becomes (links to) -->"ligature ffi". I wouldn't even mind the necessity to declare all 256 slots to a particular command or combination of letters in the source, as long as I know how to do it.

Consider the below example with another (non-commercial) font, which also contains ligatures: http://exljbris.com/tallys.html. For the windows users amongst us, you can copy paste this into a batch file if you want. I've intentionally disabled the -fkern and -fliga features, since that exactly is the relevant part: my font doesn't map the glyphs correctly.

otftotfm -a -e ec  --verbose --vendor tallys Tallys_15.otf T1--Tallys15--Regular

Here is also the t1tallys.fd file:

   [2015/04/30 scalable font definitions for T1/Tallys.]

\DeclareFontShape{T1}{Tallys}{m}{n}{<-> T1--Tallys15--Regular}{}
\DeclareFontShape{T1}{Tallys}{m}{it}{<-> ssub * Tallys/m/n}{}
\DeclareFontShape{T1}{Tallys}{m}{sc}{<-> ssub * Tallys/m/n}{}
\DeclareFontShape{T1}{Tallys}{m}{sl}{<-> ssub * Tallys/m/n}{}

\DeclareFontShape{T1}{Tallys}{b}{n}{<-> ssub * Tallys/m/n}{}
\DeclareFontShape{T1}{Tallys}{b}{it}{<-> ssub * Tallys/m/n}{}
\DeclareFontShape{T1}{Tallys}{b}{sc}{<-> ssub * Tallys/m/n}{}
\DeclareFontShape{T1}{Tallys}{b}{sl}{<-> ssub * Tallys/m/n}{}

\DeclareFontShape{T1}{Tallys}{l}{n}{<-> ssub * Tallys/m/n}{}
\DeclareFontShape{T1}{Tallys}{l}{it}{<-> ssub * Tallys/m/n}{}
\DeclareFontShape{T1}{Tallys}{l}{sc}{<-> ssub * Tallys/m/n}{}
\DeclareFontShape{T1}{Tallys}{l}{sl}{<-> ssub * Tallys/m/n}{}

\DeclareFontShape{T1}{Tallys}{bx}{n}{ssub * Tallys/m/n}{}
\DeclareFontShape{T1}{Tallys}{bx}{it}{ssub * Tallys/m/n}{}
\DeclareFontShape{T1}{Tallys}{bx}{sc}{ssub * Tallys/m/n}{}
\DeclareFontShape{T1}{Tallys}{bx}{sl}{ssub * Tallys/m/n}{}


and an MWE (XeLaTeX will still produce the right result in this case, with the ligatures... If you want to take on the XeLaTeX approach, just map any other character. I'd still like to know how to do this in XeLaTeX.)



\fontsize{100pt}{0pt}\selectfont ffi fi fl ffl

The idea is to still be able to map the combination of characters ffi to the ligature. It would also be nice to somehow set the right characters for the right math commands (I understand this is more involved but please understand, I'm really looking for a general solution that will allow me to completely map the font and allow TeX to completely understand when to use what character.) The ideal solution would describe the complete process required to get it done. It would also allow the possibility of mixing different fonts (which wouldn't be too involved as compared to the single font solution -- it's just to generalize the answer).

closed as too broad by cfr, Paul Gessler, Werner, user13907, Paul Gaborit Apr 30 '15 at 21:56

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    I've wondered the same thing. When I convert a TTF font for pdflatex use, the ligatures seem inoperative. – Steven B. Segletes Apr 30 '15 at 19:40
  • 1
    As it stands, this question is simply too enormous to be answered in anything like this format. For one thing, you will need different solutions for pdfTeX and XeTeX (except in the case where you are using traditional TeX fonts with XeTeX). In the case of pdfTeX, what you want is entirely possible but not at the document level. The solution is to set the fonts up correctly. This is where you have complete control. You can tell TeX which character in which font should be used for each slot in the encoding, and you can change the encoding to create whatever ligatures you like. – cfr Apr 30 '15 at 21:17
  • @cfr I had considered splitting it into two seperate questions and asked about it in chat, but didn't get any response so I figured the situations were comparable. I'll split it up into two questions somewhere tomorrow, unless somebody posted before that (which I think is unlikely). – 1010011010 Apr 30 '15 at 21:23
  • You can enable contextual swashes (e.g. end of word, beginning of word), support stylistic variants and generally muck about as much as you like. otftotfm relies on the features of the opentype source font. If you have a font which is not opentype or you have a poorly designed opentype font, either you get the font corrected or you use another method. But the kind of general solution you are seeking cannot be provided here. Read the Font Installation Guide. Look at examples of how this kind of thing is done. Then you will be able to meet precise desiderata by customising TeX/pdfTeX support. – cfr Apr 30 '15 at 21:23
  • I don't know about the XeTeX case. But the TeX/pdfTeX case is too huge on its own. You can do this for TeX/pdfTeX, but you can't do it in the document itself (which is what you are asking for). You do it by creating custom fonts (in TeX's sense of 'font' i.e. custom .tfm and, perhaps, .vf files). But how to do all of the stuff you are asking for a custom font is an enormous question, even leaving out the maths which would certainly be a different topic. If you read up on it and have specific problems, those questions can almost certainly be answered here. But not the general question. – cfr Apr 30 '15 at 21:28