5

I have a font Exo 2, which comes in three versions: expanded, normal, condensed (lets call it density). I would like to define a new switcher command, that will work in a similar way to \itshape, slshape or bfseries, but will switch me from my current font to another density. Something like \narrowdensity, \normdensity, \expanddensity.

A bad workaround is the following:

\documentclass{scrartcl}

\usepackage[no-math]{fontspec}
\usepackage{polyglossia}

\usepackage{lipsum}

\setmainlanguage{english}
\defaultfontfeatures{Ligatures=TeX}

\setmainfont{Exo 2}[%
    Extension       =   .otf,
    UprightFont     =   *-Regular,
    ItalicFont      =   *-Italic,
    BoldFont        =   *-Bold,
    BoldItalicFont  =   *-BoldItalic,
    FontFace        =   {black}{n}{*-Black},
    FontFace        =   {black}{it}{*-BlackItalic},
]

\newfontfamily{\exoexp}{Exo 2}[%
    Extension       =   .otf,
    UprightFont     =   *-Regular Expanded,
    ItalicFont      =   *-Regular Expanded,%because there is no italic expanded
    BoldFont        =   *-Bold Expanded,
    BoldItalicFont  =   *-Bold Expanded,
    FontFace        =   {black}{n}{*-Black Expanded},
    FontFace        =   {black}{it}{*-Black Expanded},
]

\makeatletter

\DeclareRobustCommand\blackseries
{\not@math@alphabet\blackseries\mathbf
    \fontseries{black}\selectfont
}

\makeatother

\begin{document}
\blackseries
\lipsum[1]

{
\exoexp
\lipsum[1]
}

\mdseries
\lipsum[1]

\end{document}

But I have to define different \exp command for all my fonts. Does fontspec provide the ability to give the font a new characteristic density, like shape or series? Note: if one of the characteristics is switched, the other should remain.

  • 1
    maybe fontaxes package has something useful? – Lev Bishop Aug 17 '17 at 18:29
  • @LevBishop judging be quick look on the documentation -- no. And I am not sure if it is compatible with fontspec. – Michael Fraiman Aug 17 '17 at 18:32
  • @LevBishop BTW, fontspec also allows use of italic small caps. – Michael Fraiman Aug 17 '17 at 18:34
  • Why do you define the \exoexp? Looks quite unneeded. – Ulrike Fischer Aug 17 '17 at 20:08
  • @UlrikeFischer to switch to the expanded variant of the font. – Michael Fraiman Aug 17 '17 at 20:20
3

This FontFace answer may help.

If I wanted to use an ultralight weight, and a condensed black weight, and a small caps extra condensed semibold italic:

three series

MWE

 \documentclass[12pt]{article}
\usepackage{xcolor}
\pagecolor{red!3}

\usepackage{fontspec}

\setromanfont{Noto Serif}[
FontFace={ul}{n}{Font=* Thin},
FontFace={ul}{it}{Font=* Thin Italic},
FontFace={xbc}{n}{Font=* Condensed Black},
FontFace={sbxsci}{i}{Font=* ExtraCondensed SemiBold Italic,SmallCapsFont={* ExtraCondensed SemiBold Italic},SmallCapsFeatures={Letters=SmallCaps},},
  ]

\DeclareRobustCommand{\ulseries}{\fontseries{ul}\selectfont}
\DeclareRobustCommand{\xbcseries}{\fontseries{xbc}\selectfont}
\DeclareRobustCommand{\sbxsciseries}{\fontseries{sbxsci}\fontshape{i}\scshape\selectfont}




\DeclareTextFontCommand{\textul}{\ulseries}
\DeclareTextFontCommand{\textxbc}{\xbcseries}
\DeclareTextFontCommand{\textsbxsci}{\sbxsciseries}


\begin{document}
\begin{center}
%\fontname\mseries
\section*{Noto Serif}
%\rmfamily
%\itshape
%\scshape

\begin{tabular}{c}Cases\\ \hline\ \\
\textul{Abc Thin} {\ulseries Thin}\\
\textxbc{Abc Black} {\xbcseries Black}\\
\textsbxsci{Abc SemiBold} {\sbxsciseries SemiBold}\\
\end{tabular}
\end{center}

The \textsbxsci{definition} of a \textul{Cat} is ``a domesticated carnivorous \textxbc{quadruped}'' descended, it seems, from a \textit{tiger} ancestor. To use \textbackslash textit with \textul{Cat}, I would have to define an italic item as well, being careful to name the shape as \texttt{it} because that is what \textbackslash textit goes looking for: \textit{\textul{Cat}}.

\end{document}

Edited to add: Exo

Exo weights and shapes

Note: No small caps feature (smcp) in the upright shape font faces.

MWE:

 \documentclass[12pt]{article}
\usepackage{xcolor}
\pagecolor{red!3}

\usepackage{fontspec}

\setromanfont{Exo}[
FontFace={ul}{n}{Font=* Thin},
FontFace={el}{n}{Font=* ExtraLight},
FontFace={l}{n}{Font=* Light},
FontFace={r}{n}{Font=* Regular},
FontFace={m}{n}{Font=* Medium},
FontFace={sb}{n}{Font=* SemiBold},
FontFace={b}{n}{Font=* Bold},
FontFace={eb}{n}{Font=* ExtraBold},
FontFace={xb}{n}{Font=* Black},
FontFace={uli}{i}{Font=* Thin Italic},
FontFace={eli}{i}{Font=* ExtraLight Italic},
FontFace={li}{i}{Font=* Light Italic},
FontFace={i}{i}{Font=*  Italic},
FontFace={mi}{i}{Font=* Medium Italic},
FontFace={sbi}{i}{Font=* SemiBold Italic},
FontFace={bi}{i}{Font=* Bold Italic},
FontFace={ebi}{i}{Font=* ExtraBold Italic},
FontFace={xbi}{i}{Font=* Black Italic},
FontFace={ulsc}{s}{Font=* Thin,SmallCapsFont={* Thin},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={elsc}{s}{Font=* ExtraLight,SmallCapsFont={* ExtraLight},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={lsc}{s}{Font=* Light,SmallCapsFont={* Light},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={rsc}{s}{Font=* Regular,SmallCapsFont={* Regular},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={msc}{s}{Font=* Medium,SmallCapsFont={* Medium},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={sbsc}{s}{Font=* SemiBold,SmallCapsFont={* SemiBold},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={bsc}{s}{Font=* Bold,SmallCapsFont={* Bold},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={ebsc}{s}{Font=* ExtraBold,SmallCapsFont={* ExtraBold},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={xbsc}{s}{Font=* Black,SmallCapsFont={* Black},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={ulsci}{i}{Font=* Thin Italic,SmallCapsFont={* Thin Italic},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={elsci}{i}{Font=* ExtraLight Italic,SmallCapsFont={* ExtraLight Italic},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={lsci}{i}{Font=* Light Italic,SmallCapsFont={* Light Italic},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={i}{i}{Font=*  Italic,SmallCapsFeatures={Letters=SmallCaps},},
FontFace={msci}{i}{Font=* Medium Italic,SmallCapsFont={* Medium Italic},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={sbsci}{i}{Font=* SemiBold Italic,SmallCapsFont={* SemiBold Italic},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={bsci}{i}{Font=* Bold Italic,SmallCapsFont={* Bold Italic},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={ebsci}{i}{Font=* ExtraBold Italic,SmallCapsFont={* ExtraBold Italic},SmallCapsFeatures={Letters=SmallCaps},},
FontFace={xbsci}{i}{Font=* Black Italic,SmallCapsFont={* Black Italic},SmallCapsFeatures={Letters=SmallCaps},},
  ]

\DeclareRobustCommand{\ulseries}{\fontseries{ul}\selectfont}
\DeclareRobustCommand{\elseries}{\fontseries{el}\selectfont}
\DeclareRobustCommand{\lseries}{\fontseries{l}\selectfont}
\DeclareRobustCommand{\rseries}{\fontseries{r}\selectfont}
\DeclareRobustCommand{\mseries}{\fontseries{m}\selectfont}
\DeclareRobustCommand{\sbseries}{\fontseries{sb}\selectfont}
\DeclareRobustCommand{\bseries}{\fontseries{b}\selectfont}
\DeclareRobustCommand{\ebseries}{\fontseries{eb}\selectfont}
\DeclareRobustCommand{\xbseries}{\fontseries{xb}\selectfont}
\DeclareRobustCommand{\uliseries}{\fontseries{uli}\fontshape{i}\selectfont}
\DeclareRobustCommand{\eliseries}{\fontseries{eli}\fontshape{i}\selectfont}
\DeclareRobustCommand{\liseries}{\fontseries{li}\fontshape{i}\selectfont}
\DeclareRobustCommand{\iseries}{\fontseries{i}\fontshape{i}\selectfont}
\DeclareRobustCommand{\miseries}{\fontseries{mi}\fontshape{i}\selectfont}
\DeclareRobustCommand{\sbiseries}{\fontseries{sbi}\fontshape{i}\selectfont}
\DeclareRobustCommand{\biseries}{\fontseries{bi}\fontshape{i}\selectfont}
\DeclareRobustCommand{\ebiseries}{\fontseries{ebi}\fontshape{i}\selectfont}
\DeclareRobustCommand{\xbiseries}{\fontseries{xbi}\fontshape{i}\selectfont}
\DeclareRobustCommand{\ulscseries}{\fontseries{ulsc}\scshape\selectfont}
\DeclareRobustCommand{\elscseries}{\fontseries{elsc}\scshape\selectfont}
\DeclareRobustCommand{\lscseries}{\fontseries{lsc}\scshape\selectfont}
\DeclareRobustCommand{\rscseries}{\fontseries{rsc}\scshape\selectfont}
\DeclareRobustCommand{\mscseries}{\fontseries{msc}\scshape\selectfont}
\DeclareRobustCommand{\sbscseries}{\fontseries{sbsc}\scshape\selectfont}
\DeclareRobustCommand{\bscseries}{\fontseries{bsc}\scshape\selectfont}
\DeclareRobustCommand{\ebscseries}{\fontseries{ebsc}\scshape\selectfont}
\DeclareRobustCommand{\xbscseries}{\fontseries{xbsc}\scshape\selectfont}
\DeclareRobustCommand{\ulsciseries}{\fontseries{ulsci}\fontshape{i}\scshape\selectfont}
\DeclareRobustCommand{\elsciseries}{\fontseries{elsci}\fontshape{i}\scshape\selectfont}
\DeclareRobustCommand{\lsciseries}{\fontseries{lsci}\fontshape{i}\scshape\selectfont}
\DeclareRobustCommand{\itseries}{\fontseries{i}\fontshape{i}\scshape\selectfont}
\DeclareRobustCommand{\msciseries}{\fontseries{msci}\fontshape{i}\scshape\selectfont}
\DeclareRobustCommand{\sbsciseries}{\fontseries{sbsci}\fontshape{i}\scshape\selectfont}
\DeclareRobustCommand{\bsciseries}{\fontseries{bsci}\fontshape{i}\scshape\selectfont}
\DeclareRobustCommand{\ebsciseries}{\fontseries{ebsci}\fontshape{i}\scshape\selectfont}
\DeclareRobustCommand{\xbsciseries}{\fontseries{xbsci}\fontshape{i}\scshape\selectfont}




\DeclareTextFontCommand{\textul}{\ulseries}
\DeclareTextFontCommand{\textel}{\elseries}
\DeclareTextFontCommand{\textl}{\lseries}
\DeclareTextFontCommand{\textr}{\rseries}
\DeclareTextFontCommand{\textm}{\mseries}
\DeclareTextFontCommand{\textsb}{\sbseries}
\DeclareTextFontCommand{\textb}{\bseries}
\DeclareTextFontCommand{\texteb}{\ebseries}
\DeclareTextFontCommand{\textxb}{\xbseries}
\DeclareTextFontCommand{\textuli}{\uliseries}
\DeclareTextFontCommand{\texteli}{\eliseries}
\DeclareTextFontCommand{\textli}{\liseries}
\DeclareTextFontCommand{\texti}{\iseries}
\DeclareTextFontCommand{\textmi}{\miseries}
\DeclareTextFontCommand{\textsbi}{\sbiseries}
\DeclareTextFontCommand{\textbi}{\biseries}
\DeclareTextFontCommand{\textebi}{\ebiseries}
\DeclareTextFontCommand{\textxbi}{\xbiseries}
\DeclareTextFontCommand{\textulsc}{\ulscseries}
\DeclareTextFontCommand{\textelsc}{\elscseries}
\DeclareTextFontCommand{\textlsc}{\lscseries}
\DeclareTextFontCommand{\textrsc}{\rscseries}
\DeclareTextFontCommand{\textmsc}{\mscseries}
\DeclareTextFontCommand{\textsbsc}{\sbscseries}
\DeclareTextFontCommand{\textbsc}{\bscseries}
\DeclareTextFontCommand{\textebsc}{\ebscseries}
\DeclareTextFontCommand{\textxbsc}{\xbscseries}
\DeclareTextFontCommand{\textulsci}{\ulsciseries}
\DeclareTextFontCommand{\textelsci}{\elsciseries}
\DeclareTextFontCommand{\textlsci}{\lsciseries}
\DeclareTextFontCommand{\textit}{\itseries}
\DeclareTextFontCommand{\textmsci}{\msciseries}
\DeclareTextFontCommand{\textsbsci}{\sbsciseries}
\DeclareTextFontCommand{\textbsci}{\bsciseries}
\DeclareTextFontCommand{\textebsci}{\ebsciseries}
\DeclareTextFontCommand{\textxbsci}{\xbsciseries}



\begin{document}
\center
\section*{Exo}
\rmfamily

\begin{tabular}{c}Normal\\ \hline\ \\\textul{Abc Thin} {\ulseries Thin}\\
\textel{Abc ExtraLight} {\elseries ExtraLight}\\
\textl{Abc Light} {\lseries Light}\\
\textr{Abc Regular} {\rseries Regular}\\
\textm{Abc Medium} {\mseries Medium}\\
\textsb{Abc SemiBold} {\sbseries SemiBold}\\
\textb{Abc Bold} {\bseries Bold}\\
\texteb{Abc ExtraBold} {\ebseries ExtraBold}\\
\textxb{Abc Black} {\xbseries Black}\\\end{tabular}
\begin{tabular}{c}Normal Italic\\ \hline\ \\\textuli{Abc Thin} {\uliseries Thin}\\
\texteli{Abc ExtraLight} {\eliseries ExtraLight}\\
\textli{Abc Light} {\liseries Light}\\
\texti{Abc Regular} {\iseries Regular}\\
\textmi{Abc Medium} {\miseries Medium}\\
\textsbi{Abc SemiBold} {\sbiseries SemiBold}\\
\textbi{Abc Bold} {\biseries Bold}\\
\textebi{Abc ExtraBold} {\ebiseries ExtraBold}\\
\textxbi{Abc Black} {\xbiseries Black}\\\end{tabular}

\vskip1.5em
\begin{tabular}{c}Normal Small Caps\\ \hline\ \\\textulsc{Abc Thin} {\ulscseries Thin}\\
\textelsc{Abc ExtraLight} {\elscseries ExtraLight}\\
\textlsc{Abc Light} {\lscseries Light}\\
\textrsc{Abc Regular} {\rscseries Regular}\\
\textmsc{Abc Medium} {\mscseries Medium}\\
\textsbsc{Abc SemiBold} {\sbscseries SemiBold}\\
\textbsc{Abc Bold} {\bscseries Bold}\\
\textebsc{Abc ExtraBold} {\ebscseries ExtraBold}\\
\textxbsc{Abc Black} {\xbscseries Black}\\\end{tabular}
\begin{tabular}{c}Normal Italic Small Caps\\ \hline\ \\\textulsci{Abc Thin} {\ulsciseries Thin}\\
\textelsci{Abc ExtraLight} {\elsciseries ExtraLight}\\
\textlsci{Abc Light} {\lsciseries Light}\\
\textit{Abc Regular} {\itseries Regular}\\
\textmsci{Abc Medium} {\msciseries Medium}\\
\textsbsci{Abc SemiBold} {\sbsciseries SemiBold}\\
\textbsci{Abc Bold} {\bsciseries Bold}\\
\textebsci{Abc ExtraBold} {\ebsciseries ExtraBold}\\
\textxbsci{Abc Black} {\xbsciseries Black}\\\end{tabular}

\end{document}

There's an Exo 2: it has Cyrillic in it, but no small caps.

Both Exo and Exo 2 are on Google Fonts.

MWE

 \documentclass[12pt]{article}
\usepackage{xcolor}
\pagecolor{red!3}

\usepackage{fontspec}

\setromanfont{Exo 2}[
FontFace={ul}{n}{Font=* Thin},
FontFace={el}{n}{Font=* Extra Light},
FontFace={l}{n}{Font=* Light},
FontFace={r}{n}{Font=*},
FontFace={m}{n}{Font=* Medium},
FontFace={sb}{n}{Font=* Semi Bold},
FontFace={b}{n}{Font=* Bold},
FontFace={eb}{n}{Font=* Extra Bold},
FontFace={xb}{n}{Font=* Black},
FontFace={uli}{i}{Font=* Thin Italic},
FontFace={eli}{i}{Font=* Extra Light Italic},
FontFace={li}{i}{Font=* Light Italic},
FontFace={i}{i}{Font=* Italic},
FontFace={mi}{i}{Font=* Medium Italic},
FontFace={sbi}{i}{Font=* Semi Bold Italic},
FontFace={bi}{i}{Font=* Bold Italic},
FontFace={ebi}{i}{Font=* Extra Bold Italic},
FontFace={xbi}{i}{Font=* Black Italic},
  ]

\DeclareRobustCommand{\ulseries}{\fontseries{ul}\selectfont}
\DeclareRobustCommand{\elseries}{\fontseries{el}\selectfont}
\DeclareRobustCommand{\lseries}{\fontseries{l}\selectfont}
\DeclareRobustCommand{\rseries}{\fontseries{r}\selectfont}
\DeclareRobustCommand{\mseries}{\fontseries{m}\selectfont}
\DeclareRobustCommand{\sbseries}{\fontseries{sb}\selectfont}
\DeclareRobustCommand{\bseries}{\fontseries{b}\selectfont}
\DeclareRobustCommand{\ebseries}{\fontseries{eb}\selectfont}
\DeclareRobustCommand{\xbseries}{\fontseries{xb}\selectfont}
\DeclareRobustCommand{\uliseries}{\fontseries{uli}\fontshape{i}\selectfont}
\DeclareRobustCommand{\eliseries}{\fontseries{eli}\fontshape{i}\selectfont}
\DeclareRobustCommand{\liseries}{\fontseries{li}\fontshape{i}\selectfont}
\DeclareRobustCommand{\iseries}{\fontseries{i}\fontshape{i}\selectfont}
\DeclareRobustCommand{\miseries}{\fontseries{mi}\fontshape{i}\selectfont}
\DeclareRobustCommand{\sbiseries}{\fontseries{sbi}\fontshape{i}\selectfont}
\DeclareRobustCommand{\biseries}{\fontseries{bi}\fontshape{i}\selectfont}
\DeclareRobustCommand{\ebiseries}{\fontseries{ebi}\fontshape{i}\selectfont}
\DeclareRobustCommand{\xbiseries}{\fontseries{xbi}\fontshape{i}\selectfont}
\DeclareRobustCommand{\ulscseries}{\fontseries{ulsc}\scshape\selectfont}
\DeclareRobustCommand{\elscseries}{\fontseries{elsc}\scshape\selectfont}
\DeclareRobustCommand{\lscseries}{\fontseries{lsc}\scshape\selectfont}
\DeclareRobustCommand{\rscseries}{\fontseries{rsc}\scshape\selectfont}
\DeclareRobustCommand{\mscseries}{\fontseries{msc}\scshape\selectfont}
\DeclareRobustCommand{\sbscseries}{\fontseries{sbsc}\scshape\selectfont}
\DeclareRobustCommand{\bscseries}{\fontseries{bsc}\scshape\selectfont}
\DeclareRobustCommand{\ebscseries}{\fontseries{ebsc}\scshape\selectfont}
\DeclareRobustCommand{\xbscseries}{\fontseries{xbsc}\scshape\selectfont}




\DeclareTextFontCommand{\textul}{\ulseries}
\DeclareTextFontCommand{\textel}{\elseries}
\DeclareTextFontCommand{\textl}{\lseries}
\DeclareTextFontCommand{\textr}{\rseries}
\DeclareTextFontCommand{\textm}{\mseries}
\DeclareTextFontCommand{\textsb}{\sbseries}
\DeclareTextFontCommand{\textb}{\bseries}
\DeclareTextFontCommand{\texteb}{\ebseries}
\DeclareTextFontCommand{\textxb}{\xbseries}
\DeclareTextFontCommand{\textuli}{\uliseries}
\DeclareTextFontCommand{\texteli}{\eliseries}
\DeclareTextFontCommand{\textli}{\liseries}
\DeclareTextFontCommand{\texti}{\iseries}
\DeclareTextFontCommand{\textmi}{\miseries}
\DeclareTextFontCommand{\textsbi}{\sbiseries}
\DeclareTextFontCommand{\textbi}{\biseries}
\DeclareTextFontCommand{\textebi}{\ebiseries}
\DeclareTextFontCommand{\textxbi}{\xbiseries}



\begin{document}
\center
\section*{Exo 2}
\rmfamily

\begin{tabular}{c}Normal\\ \hline\ \\\textul{Abc Thin} {\ulseries Thin}\\
\textel{Abc ExtraLight} {\elseries ExtraLight}\\
\textl{Abc Light} {\lseries Light}\\
\textr{Abc Regular} {\rseries Regular}\\
\textm{Abc Medium} {\mseries Medium}\\
\textsb{Abc SemiBold} {\sbseries SemiBold}\\
\textb{Abc Bold} {\bseries Bold}\\
\texteb{Abc ExtraBold} {\ebseries ExtraBold}\\
\textxb{Abc Black} {\xbseries Black}\\\end{tabular}
\begin{tabular}{c}Normal Italic\\ \hline\ \\\textuli{Abc Thin} {\uliseries Thin}\\
\texteli{Abc ExtraLight} {\eliseries ExtraLight}\\
\textli{Abc Light} {\liseries Light}\\
\texti{Abc Regular} {\iseries Regular}\\
\textmi{Abc Medium} {\miseries Medium}\\
\textsbi{Abc SemiBold} {\sbiseries SemiBold}\\
\textbi{Abc Bold} {\biseries Bold}\\
\textebi{Abc ExtraBold} {\ebiseries ExtraBold}\\
\textxbi{Abc Black} {\xbiseries Black}\\\end{tabular}


\vskip1.5em
\begin{tabular}{c}Normal\\ \hline\ \\\textul{Шрифт Любя, съешь} {\ulseries Полужирный}\\
\textel{Шрифт Любя, съешь} {\elseries Полужирный}\\
\textl{Шрифт Любя, съешь} {\lseries Полужирный}\\
\textr{Шрифт Любя, съешь} {\rseries Полужирный}\\
\textm{Шрифт Любя, съешь} {\mseries Полужирный}\\
\textsb{Шрифт Любя, съешь} {\sbseries Полужирный}\\
\textb{Шрифт Любя, съешь} {\bseries Полужирный}\\
\texteb{Шрифт Любя, съешь} {\ebseries Полужирный}\\
\textxb{Шрифт Любя, съешь} {\xbseries Полужирный}\\\end{tabular}
\begin{tabular}{c}Normal Italic\\ \hline\ \\\textuli{Шрифт Любя, съешь} {\uliseries Полужирный}\\
\texteli{Шрифт Любя, съешь} {\eliseries Полужирный}\\
\textli{Шрифт Любя, съешь} {\liseries Полужирный}\\
\texti{Шрифт Любя, съешь} {\iseries Полужирный}\\
\textmi{Шрифт Любя, съешь} {\miseries Полужирный}\\
\textsbi{Шрифт Любя, съешь} {\sbiseries Полужирный}\\
\textbi{Шрифт Любя, съешь} {\biseries Полужирный}\\
\textebi{Шрифт Любя, съешь} {\ebiseries Полужирный}\\
\textxbi{Шрифт Любя, съешь} {\xbiseries Полужирный}\\\end{tabular}


\end{document}

Combining both into one virtual family is possible. Exo 2

2

Cicada posted a correct answer about how to change the series, which combines the width and the weight together. (As mentioned in that answer, the canonical question that led to the functionality being added to fontspec is here.) I’ll answer a different reading of your question that makes it not a duplicate: how to change only the width, independently of the weight.

In NFSS

The nfssext-cfr package (by our own CFR) introduces a series of commands for this. It splits the standard NFSS commands such as \bfseries, which select bold and expanded, into width commands such as \cdwidth/\textcd for condensed width and unchanged weight, and weight commands such as \sbweight/\textsb for semibold weight and unchanged width.

This doesn’t work out of the box for arbitrary fonts. It’s used as a building-block by several other packages, such as cfr-lm and venturisadf. You might want to follow its naming scheme for a new command you write.

The historical reason for the inability to set weight and width separately is that, in the last century, TeX needed to be compatible with MS-DOS. Therefore, filenames were limited to eight characters plus a three-character extension. This led to an extremely terse convention being adopted where the filename of a font was three or four letters for the font family, plus one or two for the “series” (weight and width) and one or two for the “shape” (most commonly “normal” or italic). Relatively few fonts came in extra widths.

In the Modern Toolchain

The simplest way to switch between regular-width and condensed in fontspec is to declare the condensed version of the font as a different family. You can even \DeclareTextFontCommand{\textexoexp}{\exoexp} to be able to write \textexoexp{expanded text}, instead of {\exoexp expanded text}.

However, fontspec also supports commands to give a font family faces with arbitrary NFSS series and shapes. I don’t have that particular commercial font to test with, but you could write:

\setsansfont{Latin Modern Sans}[
   FontFace = {sbc}{n}{lmsansdemicond10-regular.otf} ,
   FontFace = {sbc}{i}{lmsansdemicond10-oblique.otf} ]

With the proper series defined for your fonts, you could port over code equivalent to \cdwidth in nfssext-cfr. This would keep the current width and weight in string variables (To work correctly, the variables would need to be overridden within the current group or pushed onto a stack. Edit: Or you could use the macro \f@series if restricted to standard names.) and combine the requested width with the saved weight, so that \sbweight\cdwidth\selectfont would work like \fontseries{sbc}\selectfont. The weight-selection commands would do the same with the saved width.

Once you have commands like \sbweight and \cdwidth, you could create the remaining commands with \DeclareTextFontCommand{\textcd}{\cdwidth} and \DeclareTextFontCommand{\textsb}{\sbweight}. However, it might be easier, and sufficient for your purposes, to code \textcd and \textsb that save and restore the previous width and weight settings in local variables.

  • 1
    Very helpful. The arbitrariness allowed by NFSS will come in handy later. Consistent series naming ("Berry-ised" names? something like [weight][display][width][smallcaps, feature set?][upright/italic/oblique]) will help the macros in the tracking layer keep tabs on things. Exo is now a free font, with 9 weights, 2 shapes (regular and italics) and 1 width and 1 presentation mode (body text). SmallCaps are an opentype font feature. 1001fonts.com/exo-font.html#styles – Cicada May 5 at 1:02
  • @Cicada Right. In fontspec, the series and shape parameters no longer have anything to do with looking up a filename, and the limits on length are a thing of the past. Series and shape names can be nearly-arbitrary tokens now. – Davislor May 5 at 3:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.