diff options
Diffstat (limited to 'macros/latex/contrib/mweights')
-rw-r--r-- | macros/latex/contrib/mweights/README | 53 | ||||
-rw-r--r-- | macros/latex/contrib/mweights/mweights.sty | 129 |
2 files changed, 182 insertions, 0 deletions
diff --git a/macros/latex/contrib/mweights/README b/macros/latex/contrib/mweights/README new file mode 100644 index 0000000000..0c03cfd609 --- /dev/null +++ b/macros/latex/contrib/mweights/README @@ -0,0 +1,53 @@ +This is the README for the mweights package, version +2017-03-30. + +Many font families available for use with LaTeX have multiple +weights, especially when originally aimed at use on the web. For +example, Linux Libertine has both bold and semibold; Cabin, a +sans-serif family, has four weights (regular, medium, semibold, +bold); SourceCodePro, a monospaced family, has seven weights. + +Traditionally the type1-oriented support packages for such fonts +re-define the standard \mddefault or \bfdefault macros. But this can +create difficulties if the weight desired for one font family isn't +available for another font family, or if it differs from the weight +desired for another font family. For example, there is no medium +weight font for Linux Libertine so that setting \mddefault to mb for +use with Cabin will be problematic for Libertine. And \bfdefault +cannot be both sb for use with Cabin and b for use with Libertine, +or vice versa. + +This package provides a solution to these difficulties. The basic +idea (due to Michael Sharpe) is that font packages should *not* +re-define \mddefault or \bfdefault; instead they should define as +many of the following macros as is appropriate: + +\mdseries@rm +\mdseries@sf +\mdseries@tt + +\bfseries@rm +\bfseries@sf +\bfseries@tt + +For example, + +\def\mdseries@sf{mb} +\def\bfseries@sf{b} + +would be appropriate definitions for using a sans font such as Cabin +with medium and bold, and + +\def\bfseries@rm{sb} + +would be appropriate for using a Roman font such as Libertine +with semibold. These macros should always be fully expanded; if +necessary, \edef should be used. + +The package re-defines standard selection commands for series +(\mdseries and \bfseries) and family (\rmfamily, \sffamily, +\ttfamily) to use the macros. It should be a RequiredPackage (for +type1 font use only) in any such font package. + +The package is licensed under the terms of the LaTeX Project Public +License. The maintainer is Bob Tennent (rdt at cs.queensu.ca). diff --git a/macros/latex/contrib/mweights/mweights.sty b/macros/latex/contrib/mweights/mweights.sty new file mode 100644 index 0000000000..1f89904805 --- /dev/null +++ b/macros/latex/contrib/mweights/mweights.sty @@ -0,0 +1,129 @@ +\ProvidesPackage{mweights} + [2017/03/30 (Bob Tennent) Support package for multiple-weight font packages. ] + +\def\mweights@init{% +% Define any undefined \mdseries@rm etc. +% Defined \mdseries@rm etc. assumed to be fully expanded! +\ifdefined\mdseries@rm\else\edef\mdseries@rm{\mddefault}\fi +\ifdefined\bfseries@rm\else\edef\bfseries@rm{\bfdefault}\fi +\ifdefined\mdseries@sf\else\edef\mdseries@sf{\mddefault}\fi +\ifdefined\bfseries@sf\else\edef\bfseries@sf{\bfdefault}\fi +\ifdefined\mdseries@tt\else\edef\mdseries@tt{\mddefault}\fi +\ifdefined\bfseries@tt\else\edef\bfseries@tt{\bfdefault}\fi +% In case any unexpanded macros present in \rmdefault, etc +\edef\rmdef@ult{\rmdefault}% +\edef\sfdef@ult{\sfdefault}% +\edef\ttdef@ult{\ttdefault}% +\edef\bfdef@ult{\bfdefault}% +\edef\mddef@ult{\mddefault}% +\edef\famdef@ult{\familydefault}% +} + +\DeclareRobustCommand\bfseries{% +\mweights@init +\not@math@alphabet\bfseries\mathbf +\ifx\f@family\rmdef@ult\fontseries\bfseries@rm +\else\ifx\f@family\sfdef@ult\fontseries\bfseries@sf +\else\ifx\f@family\ttdef@ult\fontseries\bfseries@tt +\else\fontseries\bfdefault\fi\fi\fi\selectfont}% + +\DeclareRobustCommand\mdseries{% +\mweights@init +\not@math@alphabet\mdseries\relax +\ifx\f@family\rmdef@ult\fontseries\mdseries@rm +\else\ifx\f@family\sfdef@ult\fontseries\mdseries@sf +\else\ifx\f@family\ttdef@ult\fontseries\mdseries@tt +\else\fontseries\mddefault\fi\fi\fi\selectfont} + +\DeclareRobustCommand\rmfamily{% +\mweights@init +\not@math@alphabet\rmfamily\mathrm +% change the current series before changing the family +\ifx\f@family\sfdef@ult + \ifx\f@series\mdseries@sf\fontseries\mdseries@rm + \else\ifx\f@series\bfseries@sf\fontseries\bfseries@rm + \else\ifx\f@series\mddef@ult\fontseries\mdseries@rm + \else\ifx\f@series\bfdef@ult\fontseries\bfseries@rm + \else\fontseries\mdseries@rm + \fi\fi\fi\fi +\else\ifx\f@family\ttdef@ult + \ifx\f@series\mdseries@tt\fontseries\mdseries@rm + \else\ifx\f@series\bfseries@tt\fontseries\bfseries@rm + \else\ifx\f@series\mddef@ult\fontseries\mdseries@rm + \else\ifx\f@series\bfdef@ult\fontseries\bfseries@rm + \else\fontseries\mdseries@rm + \fi\fi\fi\fi +\else\ifx\f@family\rmdef@ult + \ifx\f@series\mdseries@rm\fontseries\mdseries@rm + \else\ifx\f@series\bfseries@rm\fontseries\bfseries@rm + \else\ifx\f@series\mddef@ult\fontseries\mdseries@rm + \else\ifx\f@series\bfdef@ult\fontseries\bfseries@rm + \else\fontseries\mdseries@rm + \fi\fi\fi\fi +\else\fontseries\mdseries@rm +\fi\fi\fi\fontfamily\rmdefault\selectfont} + +\DeclareRobustCommand\sffamily{% +\mweights@init +\not@math@alphabet\sffamily\mathsf +% change the current series before changing the family +\ifx\f@family\rmdef@ult + \ifx\f@series\mdseries@rm\fontseries\mdseries@sf + \else\ifx\f@series\bfseries@rm\fontseries\bfseries@sf + \else\ifx\f@series\mddef@ult\fontseries\mdseries@sf + \else\ifx\f@series\bfdef@ult\fontseries\bfseries@sf + \else\fontseries\mdseries@sf + \fi\fi\fi\fi +\else\ifx\f@family\ttdef@ult + \ifx\f@series\mdseries@tt\fontseries\mdseries@sf + \else\ifx\f@series\bfseries@tt\fontseries\bfseries@sf + \else\ifx\f@series\mddef@ult\fontseries\mdseries@sf + \else\ifx\f@series\bfdef@ult\fontseries\bfseries@sf + \else\fontseries\mdseries@sf + \fi\fi\fi\fi +\else\ifx\f@family\sfdef@ult + \ifx\f@series\mdseries@sf\fontseries\mdseries@sf + \else\ifx\f@series\bfseries@sf\fontseries\bfseries@sf + \else\ifx\f@series\mddef@ult\fontseries\mdseries@sf + \else\ifx\f@series\bfdef@ult\fontseries\bfseries@sf + \else\fontseries\mdseries@sf + \fi\fi\fi\fi +\else\fontseries\mdseries@sf +\fi\fi\fi\fontfamily\sfdefault\selectfont} + +\DeclareRobustCommand\ttfamily{% +\mweights@init +\not@math@alphabet\ttfamily\mathtt +% change the current series before changing the family +\ifx\f@family\rmdef@ult + \ifx\f@series\mdseries@rm\fontseries\mdseries@tt + \else\ifx\f@series\bfseries@rm\fontseries\bfseries@tt + \else\ifx\f@series\mddef@ult\fontseries\mdseries@tt + \else\ifx\f@series\bfdef@ult\fontseries\bfseries@tt + \else\fontseries\mdseries@tt + \fi\fi\fi\fi +\else\ifx\f@family\sfdef@ult + \ifx\f@series\mdseries@sf\fontseries\mdseries@tt + \else\ifx\f@series\bfseries@sf\fontseries\bfseries@tt + \else\ifx\f@series\mddef@ult\fontseries\mdseries@tt + \else\ifx\f@series\bfdef@ult\fontseries\bfseries@tt + \else\fontseries\mdseries@tt + \fi\fi\fi\fi +\else\ifx\f@family\ttdef@ult + \ifx\f@series\mdseries@tt\fontseries\mdseries@tt + \else\ifx\f@series\bfseries@tt\fontseries\bfseries@tt + \else\ifx\f@series\mddef@ult\fontseries\mdseries@tt + \else\ifx\f@series\bfdef@ult\fontseries\bfseries@tt + \else\fontseries\mdseries@tt + \fi\fi\fi\fi +\else\fontseries\mdseries@tt +\fi\fi\fi\fontfamily\ttdefault\selectfont} + +% override default family with new \familydefault +\AtBeginDocument{\mweights@init +\ifx\famdef@ult\rmdef@ult\rmfamily +\else\ifx\famdef@ult\sfdef@ult\sffamily +\else\ifx\famdef@ult\ttdef@ult\ttfamily +\fi\fi\fi} + +\endinput |