TransWikia.com

Adding Font Features to only certain Font Shapes

TeX - LaTeX Asked on August 18, 2021

How do I add some font features (such as ligatures) to only certain font shapes?

The ideas is to disable ligatures for RB, RBI shapes, etc. since they give me a warning anyway.

I briefed over the documentation, but to no avail.

MWE (not compilabile without font files)

documentclass{article}
usepackage{fontspec}

defaultfontfeatures[LinLibertine_]{
    Extension      = {.otf},
    UprightFont    = {*R},
    BoldFont       = {*RB},
    ItalicFont     = {*RI},
    BoldItalicFont = {*RBI},
    Ligatures      = {Common, Rare, Historic, TeX}, 
    Numbers        = {OldStyle},
}

setmainfont{LinLibertine_}

begin{document}
textbf{ff fi fl...}
end{document}

One Answer

Use the options BoldFeatures={ Ligatures={...}}, and so on.

documentclass{article}
usepackage{fontspec}
usepackage{lipsum}

defaultfontfeatures[LinLibertine]{
    Extension      = {.otf},
    UprightFont    = {*_R},
    UprightFeatures = { Ligatures  = {Common, Rare, Historic, TeX}},
    BoldFont       = {*_RB},
    BoldFeatures = { Ligatures = {Common, Historic, TeX}},
    ItalicFont     = {*_RI},
    ItalicFeatures = { Ligatures  = {Common, Rare, Historic, TeX}},
    BoldItalicFont = {*_RBI},
    BoldItalicFeatures = { Ligatures = {Common, Historic, TeX}}, 
    Numbers        = {OldStyle},
}

setmainfont{LinLibertine}

begin{document}
lipsum
end{document}

You could also try turning Ligatures=Rare on by default and off for a particular face, with BoldTialicFeatures={ Ligatures=NoRare }.

Correct answer by Davislor on August 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP