I would like to define \textsb command for semibold text as I could not find a package providing one (I very much wonder why it’s not part of the standard commands). I’ve found a nice solution in related answer but I do not want to use \setmainfont as it overwrites settings provided by the libertine package.
So I tried with \addfontfeatures, but unlike with \setmainfont
- it works only after a font is actually selected, i.e. it does not work from a preamble,
- it is forgotten as soon as the family is changed, e.g. after
\ttfamily \normalfont.
I would like to know if there is a way to modify mainfont such that it is remembered throughout the document. Or if my approach is completely wrong, is there a more viable way?
\documentclass{scrreprt}
\usepackage[mono=false,oldstyle=true,proportional=true]{libertine}
\addfontfeature{
FontFace = {sb}{n}{LinLibertine_RZah.ttf},
FontFace = {sb}{it}{LinLibertine_RZIah.ttf}
}
\DeclareOldFontCommand{\sbseries}{\fontseries{sb}\selectfont}{\mathbf}
\DeclareTextFontCommand{\textsb}{\sbseries} % {\sbseries foo} \textsb{bar}

\DeclareOldFontCommandis just for defining the old 2-letter commands such as\bffor compatibility with latex2.09, you shouldn't need it here, a more normal definition for\sbserieswould be\newcommand\sbseries{\fontseries{sb}\selectfont}as that would match other\..seriescommands. – David Carlisle Jul 07 '18 at 16:52\ttfamilyetc is because\DeclareOldFontCommanddefines commands that do not combine\bf\itis normal weight italic, not bold italic, for compatibility with latex2.09 font commands. – David Carlisle Jul 07 '18 at 16:54\DeclareOldFontCommand is not intended to be used in this way– David Carlisle Jul 08 '18 at 08:31