Say I have turned on 'discretionary' ligatures with \fontspec[Ligatures=Rare]{Junicode} but want to disable the st and the ct ligatures; is that possilbe?
1 Answers
In TeX ligatures can be broken up by inserting an explicit kern between the letters. For instance, to prevent the st ligature, we might write s\kern0pt t instead. This is tedious though, but fortunately xetex offers the concept of charclasses, which comes with the possibility of inserting custom tokens between characters, previously assigned to a class.
We proceed to define two classes, one for c and s and one for t:
\newXeTeXintercharclass\charclasscs
\newXeTeXintercharclass\charclasst
Then we assign the characters to these classes
\XeTeXcharclass`\c\charclasscs
\XeTeXcharclass`\s\charclasscs
\XeTeXcharclass`\t\charclasst
If in a character combination the left character is of class \charclasscs and the right of \charclasst, then we want to insert the kern \kern0pt
\XeTeXinterchartoks\charclasscs\charclasst={\kern0pt}
Finally we enable the functionality with
\XeTeXinterchartokenstate=1 % or 0 to disable
A complete example would read
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=Rare]{Junicode.ttf}
\newXeTeXintercharclass\charclasscs
\newXeTeXintercharclass\charclasst
\XeTeXcharclass`\c\charclasscs
\XeTeXcharclass`\s\charclasscs
\XeTeXcharclass`\t\charclasst
\XeTeXinterchartoks\charclasscs\charclasst={\kern0pt}
\begin{document}
st ct
\XeTeXinterchartokenstate=1
st ct
\end{document}
To restore hyphenation you'd have to use something more complicated
\XeTeXinterchartoks\charclasscs\charclasst={%
\penalty10000\discretionary{-}{}{\kern0pt}%
\penalty10000\hskip0pt\relax}
For completeness, here a solution using luatex and the selnolig package.
\documentclass{article}
\pagestyle{empty}
\usepackage{fontspec,selnolig}
\setmainfont[Ligatures=Rare]{Junicode.ttf}
\nolig{ct}{c|t}
\nolig{st}{s|t}
\begin{document}
st ct
\end{document}
- 109,596
-
There is a serious side-effect to this, it breaks hyphenation, causing un-der-stand-ing to be broken un-derstanding. – Toothrot Feb 12 '16 at 18:23
-
-
2@Lawrence The hyphenation will be awkward, though, because
un-der-stand-ingwill be hyphenatedun-ders-tand-ing. Better use the LuaTeX solution. Mico's packageselnoligis really good. – Henri Menke Feb 12 '16 at 18:54 -
1

luatex, yes, withselnoligor by writing your own feature file. Withxetex, I don’t know of a way, which doesn’t mean that none exists. – Thérèse Feb 01 '16 at 12:14\XeTeXinterchartoksto insert\kern0ptbewteen the pairss/tandc/tto prevent the ligature. – Henri Menke Feb 01 '16 at 22:33