summaryrefslogtreecommitdiff
path: root/fonts/cfr-lm/tex/cfr-lm.sty
blob: db98421f720906dc6d18b9165781801c94b8910f (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
%% Copyright 2015 Clea F. Rees
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Clea F. Rees.
%
% This work consists of all files listed in manifest.txt.
%
% Parts of this file are based on lmodern.sty which is included with
% the Latin Modern fonts released by GUST and available from
% http://www.gust.org.pl/projects/e-foundry/latin-modern.
%
% Improvements to this file in v1.2 (unpublished) and v1.3 owe almost
% everything to Enrico Gregorio.
%
% v1.4 adds family-specific support for microtype. This draws also on the
% documentation for the microtype package and MinionPro.sty. MinionPro.sty 
% is available as part of the minionpro package and can be obtain from
% http://mirror.ctan.org/fonts/minionpro. MinionPro.sty is in the public
% domain. The documentation for microtype is available in English and German
% from http://ctan.org/pkg/microtype. It is part of the microtype package which
% is itself licensed under the LPPL.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cfr-lm}[2015/02/01 v1.5 cfr-lm for use with LatinModern v2.004]
\RequirePackage{xkeyval}
\RequirePackage[T1]{fontenc}
\RequirePackage{textcomp}
\RequirePackage{nfssext-cfr}

%:boolkeys for roman osf/lf
\define@boolkey[cfrlm]{rm}{oldstyle}[true]{%
	\ifcfrlm@rm@oldstyle
		\def\cfrlm@rmol{j}%
	\else
		\def\cfrlm@rmol{}%
	\fi}
\define@boolkey[cfrlm]{rm}{lining}[true]{%
	\ifcfrlm@rm@lining
		\def\cfrlm@rmol{}%
	\else
		\def\cfrlm@rmol{j}%
	\fi}

%:boolkeys for roman prop/tab figures
\define@boolkey[cfrlm]{rm}{proportional}[true]{%
	\ifcfrlm@rm@proportional
		\def\cfrlm@rmpt{2}%
	\else
		\def\cfrlm@rmpt{}%
	\fi}
\define@boolkey[cfrlm]{rm}{tabular}[true]{%
	\ifcfrlm@rm@tabular
		\def\cfrlm@rmpt{}%
	\else
		\def\cfrlm@rmpt{2}%
	\fi}

%:boolkeys for sans osf/lf
\define@boolkey[cfrlm]{sf}{oldstyle}[true]{%
	\ifcfrlm@sf@oldstyle
		\def\cfrlm@sfol{j}%
	\else
		\def\cfrlm@sfol{}%
	\fi}
\define@boolkey[cfrlm]{sf}{lining}[true]{%
	\ifcfrlm@sf@lining
		\def\cfrlm@sfol{}%
	\else
		\def\cfrlm@sfol{j}%
	\fi}

%:boolkeys for sans prop/tab figures
\define@boolkey[cfrlm]{sf}{proportional}[true]{%
	\ifcfrlm@sf@proportional
		\def\cfrlm@sfpt{2}%
	\else
		\def\cfrlm@sfpt{}%
	\fi}
\define@boolkey[cfrlm]{sf}{tabular}[true]{%
	\ifcfrlm@sf@tabular
		\def\cfrlm@sfpt{}%
	\else
		\def\cfrlm@sfpt{2}%
	\fi}

%:boolkeys for typewriter osf/lf
\define@boolkey[cfrlm]{tt}{oldstyle}[true]{%
	\ifcfrlm@tt@oldstyle
		\def\cfrlm@ttol{j}%
	\else
		\def\cfrlm@ttol{}%
	\fi}
\define@boolkey[cfrlm]{tt}{lining}[true]{%
	\ifcfrlm@tt@lining
		\def\cfrlm@ttol{}%
	\else
		\def\cfrlm@ttol{j}%
	\fi}

%:boolkeys for typewriter prop/tab figures
\define@boolkey[cfrlm]{tt}{proportional}[true]{%
	\ifcfrlm@tt@proportional
		\def\cfrlm@ttpt{2}%
	\else
		\def\cfrlm@ttpt{}%
	\fi}
\define@boolkey[cfrlm]{tt}{tabular}[true]{%
	\ifcfrlm@tt@tabular
		\def\cfrlm@ttpt{}%
	\else
		\def\cfrlm@ttpt{2}%
	\fi}

%:boolkeys for typewriter mono/variable width
\define@boolkey[cfrlm]{tt}{monowidth}[true]{%
	\ifcfrlm@tt@monowidth
		\def\cfrlm@ttmv{t}%
	\else
		\def\cfrlm@ttmv{v}%
	\fi}
\define@boolkey[cfrlm]{tt}{variable}[true]{%
	\ifcfrlm@tt@variable
		\def\cfrlm@ttmv{v}%
	\else
		\def\cfrlm@ttmv{t}%
	\fi}

%:options for roman
\define@key{cfr-lm.sty}{rm}{%
	\setkeys[cfrlm]{rm}{#1}}

%:options for sans
\define@key{cfr-lm.sty}{sf}{%
	\setkeys[cfrlm]{sf}{#1}}

%:options for typewriter
\define@key{cfr-lm.sty}{tt}{%
	\setkeys[cfrlm]{tt}{#1}}

%:note that this option does nothing unless \qtfont is defined appropriately
\define@boolkey{cfr-lm.sty}[cfrlm@]{qt}[true]{%
	\relax}

%:defaults to ensure everything is defined to something
\ExecuteOptionsX{rm={oldstyle,proportional},sf={oldstyle,proportional},tt={oldstyle,proportional,variable},qt=false}
%\ExecuteOptionsX{rm={lining,tabular},sf={oldstyle,proportional},tt={oldstyle,proportional,variable},qt=false}

%:options override defaults
\ProcessOptionsX

%:make LM default for all families, implementing options for each
\renewcommand{\rmdefault}{clm\cfrlm@rmpt\cfrlm@rmol}
\renewcommand{\sfdefault}{clm\cfrlm@sfpt\cfrlm@sfol s}
\renewcommand{\ttdefault}{clm\cfrlm@ttpt\cfrlm@ttol\cfrlm@ttmv}

%:handle the qt option, failing gracefully if somebody has enabled the option without defining \qtfont appropriately
\ifcfrlm@qt
	\@ifundefined{qtfont}{%
	\PackageWarning{cfr-lm}{Option 'qt' cannot be implemented unless\MessageBreak
		the command qtfont is defined appropriately. This is not\MessageBreak
		done automatically to maximise compatibility with other\MessageBreak
		classes and packages. The suggested use is to have qtfont\MessageBreak
		redefine a command such as quotefont which is initially\MessageBreak
		set to some reasonable default and is then used in the\MessageBreak
		definition of the quote and/or quotation environments.\MessageBreak
		Since these are class and package dependent, it cannot\MessageBreak
		be done by a font package and the option is ignored here.}}{%
	\qtfont{\qtstyle}}
\fi

%:based on lmodern.sty
\SetSymbolFont{operators}   {normal}{OT1}{lmr} {m}{n}
\SetSymbolFont{letters}     {normal}{OML}{lmm} {m}{it}
\SetSymbolFont{symbols}     {normal}{OMS}{lmsy}{m}{n}
\SetSymbolFont{largesymbols}{normal}{OMX}{lmex}{m}{n}
\SetSymbolFont{operators}   {bold}  {OT1}{lmr} {bx}{n}
\SetSymbolFont{letters}     {bold}  {OML}{lmm} {b}{it}
\SetSymbolFont{symbols}     {bold}  {OMS}{lmsy}{b}{n}
\SetSymbolFont{largesymbols}{bold}  {OMX}{lmex}{m}{n}

\DeclareFontSubstitution{OT1}{lmr}{m}{n}
\DeclareFontSubstitution{OML}{lmm}{m}{it}
\DeclareFontSubstitution{OMS}{lmsy}{m}{n}
\DeclareFontSubstitution{OMX}{lmex}{m}{n}

\SetMathAlphabet{\mathbf}{normal}{OT1}{lmr}{bx}{n}
\SetMathAlphabet{\mathsf}{normal}{OT1}{lmss}{m}{n}
\SetMathAlphabet{\mathit}{normal}{OT1}{lmr}{m}{it}
\SetMathAlphabet{\mathtt}{normal}{OT1}{lmtt}{m}{n}
\SetMathAlphabet{\mathbf}{bold}  {OT1}{lmr}{bx}{n}
\SetMathAlphabet{\mathsf}{bold}  {OT1}{lmss}{bx}{n}
\SetMathAlphabet{\mathit}{bold}  {OT1}{lmr}{bx}{it}
\SetMathAlphabet{\mathtt}{bold}  {OT1}{lmtt}{m}{n}

\def\mathsterling{\mathit{\mathchar"70BF}}

%:new in v1.1
\DeclareRobustCommand{\dotdigitenc}{%
  \not@math@alphabet\dotdigitenc\relax
  \fontencoding{U}\selectfont}
\DeclareTextFontCommand{\textdde}{\dotdigitenc}
\newcommand*{\zeroslash}{\textdde{\char 250}}

%:Partly from microtype docs; partly from MinionPro package
%
% We need to set up aliases for the font families created by cfr-lm so that
% microtype recognises them as similar to Computer Modern Roman.
%
% T1 families in cfr-lm: clm clm2 clm2d clm2dj clm2j clm2jqs clm2js clm2jt 
% clm2jv clm2qs clm2s clm2t clm2v clmd clmdj clmj clmjqs clmjs clmjt clmjv 
% clmqs clms clmt clmv
%
% See variants set in nfssext-cfr
%
% Ref: http://tex.stackexchange.com/a/75440/39222
\newcommand{\cfr@ffs}{% alias to cmr
  clm,clm2,clm2j,clmj,% roman
  clms,clm2js,clm2s,clmjs,% sans
  clmqs,clm2jqs,clm2qs,clmjqs%
%  clm2d,clm2dj,clmd,clmdj,% leave unaliased?
%  clm2jv,clmjv,clm2v,clmv,% leave unaliased?
%  clmt,clm2t,clmjt,clm2jt% leave unaliased?
  }
\gdef\cfrlm@MicroType@Aliases{%
  \@for	\xx:=\cfr@ffs \do {%
	  \DeclareMicrotypeAlias{\xx}{cmr}}%
  }
\def\cfrlm@MT@Hook{\cfrlm@MicroType@Aliases}
\@ifpackageloaded{microtype}{%
  \cfrlm@MT@Hook}{%
  \@ifundefined{Microtype@Hook}{%
  	\let\Microtype@Hook\cfrlm@MT@Hook}{% MinionPro has \global before this
	\g@addto@macro\Microtype@Hook{\cfrlm@MT@Hook}}}
\endinput