summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/mweights/mweights.sty
blob: 1f899048055f5767474609a50bb4f47644c016c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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