#StackBounty: #fonts #fontspec Fontspec – Custom font shape feature

Bounty: 50

I would like to be able to add (or remove) a feature from a font shape.

I have read chapter III.3 of the fontspec package manual entitled Different features for different font shapes. So it is possible to use BoldFeatures, ItalicFeatures and so on, which solves my problem for these font shapes.

But what if I have defined custom font shapes? For example, I have created a semi-bold font; how can I define something like SemiboldFeatures or SemiboldItalicFeatures?

Looking for example at the definition of ItalicFeatures doesn’t help much…

@@_keys_define_code:nnn {fontspec-preparse} {ItalicFeatures}
  {
    clist_put_right:Nn l_@@_fontfeat_it_clist {#1}
  }

Example:

documentclass{article}

usepackage{fontspec}
setmainfont{LibertinusSerif}[FontFace={sb}{n}{Font=*-Semibold}, FontFace={sb}{it}{Font=*-SemiboldItalic}]

begin{document}
firefly textit{firefly}quad 
{addfontfeatures{ItalicFeatures={Ligatures=CommonOff}} firefly textit{firefly}}

firefly {fontseries{sb}fontshape{it}selectfont firefly}quad 
{addfontfeatures{SemiboldItalicFeatures={Ligatures=CommonOff}} firefly {fontseries{sb}fontshape{it}selectfont firefly}}
end{document}


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.