summaryrefslogtreecommitdiff
path: root/fonts/utilities/hep-font/hep-font-implementation.dtx
blob: 50c01310ecb3fc5aea132ea9041e27b4813991d8 (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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
% \iffalse meta-comment
%
% Copyright (C) 2019 by Jan Hajer
% -----------------------------------
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% 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.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% \fi
%
% \iffalse
%
%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
%<package>\ProvidesPackage{hep-font}[2021/09/01 v1.0 hep-font]
%<documentation>\ProvidesFile{hep-font-documentation.tex}[2021/09/01 v1.8 hep-font documentation]
%
%<*documentation>

\RequirePackage[l2tabu, orthodox]{nag}

\documentclass{ltxdoc}
\AtBeginDocument{\DeleteShortVerb{\|}}
\AtBeginDocument{\MakeShortVerb{\"}}

\EnableCrossrefs
\CodelineIndex
\RecordChanges

\usepackage[parskip]{hep-paper}

\bibliography{bibliography}

\acronym{CM}{computer modern}
\acronym{LM}{latin modern}
\acronym{NFSS}{new font selection scheme}

\usepackage{hologo}

\MacroIndent=1.5em
\AtBeginEnvironment{macrocode}{\renewcommand{\ttdefault}{clmt}}
%</documentation>

%<*driver>
\expandafter\newif\csname ifshort\endcsname
\shortfalse
\begin{document}
\DocInput{hep-font-implementation.dtx}
\end{document}
%</driver>
%
% \fi
%
% \CheckSum{392}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \changes{v1.0}{2021/09/01}{Initial version of the style file.}
%
% \ifshort
%<*documentation>
% \fi
%
\GetFileInfo{hep-font.sty}

\title{The \software{hep-font} package\thanks{This document corresponds to \software{hep-font}~\fileversion.}}
\subtitle{Latin modern extended by computer modern}
\author{Jan Hajer \email{jan.hajer@unibas.ch}}
\date{\filedate}

% \ifshort
\begin{document}
% \fi

\newgeometry{vscale=.8, vmarginratio=3:4, includeheadfoot, left=11em, marginparwidth=4.6cm, marginparsep=3mm, right=7em}

\maketitle

\begin{abstract}
The \software{hep-font} package loads standard font packages and extends the usual \glsdesc{LM} implementations by replacing missing fonts with \glsdesc{CM} counterparts.
\end{abstract}

The package is loaded using "\usepackage{hep-font}".

\DescribeMacro{oldstyle}
The "oldstyle" option switches to oldstyle numerals such as 123 in text mode instead of lining numerals such as \textl{123}.

The \software{fontenc} package \cite{fontenc} with "T1" and "TU" font encoding is loaded for \hologo{pdfTeX} and \hologo{LuaTeX}, respectively.

Some restrictions of \CM fonts are lifted with the \software{fixcm} package \cite{fix-cm}.

The \software{microtype} \cite{microtype} optimizations are activated.

The \hologo{LaTeX} \NFSS is extended with the \software{nfssext-cfr} package \cite{nfssext-cfr}.

The \LM font is loaded using the \software{cfr-lm} \cite{cfr-lm}  and \software{lmodern} \cite{lmodern} packages for \hologo{pdfTeX} and \hologo{LuaTeX}, respectively.

The text companion fonts are loaded \cite{textcomp}.

\DescribeMacro{\textsc}
Bold \textbf{\textsc{Small Caps}} and a sans serif \textsf{\textsc{Small Caps}} based on the \CM font \cite{cm} is provided, the latter using the \software{sansmathfonts} \cite{sansmathfonts} and \software{hfoldsty} \cite{hfoldsty} packages.

\DescribeMacro{\textui}
A sans-serif upright italic font is provided using the \software{sansmathfonts} package \cite{sansmathfonts}.

Finally the \software{inputenc} package \cite{inputenc} with the "utf8" option is loaded.

% \ifshort
\printbibliography

\end{document}
%
%</documentation>
% \fi
%
% \StopEventually{
% \printbibliography
% \PrintChanges
% }
%
% \appendix
%
% \section{Implementation}
%
%<*package>
%
% Define a hepfont namespace for the options using the \software{kvoptions} package \cite{kvoptions}.
%    \begin{macrocode}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
  family=hepfont,
  prefix=hepfont@
}
%    \end{macrocode}
%
% \begin{macro}{lining}
% Define the "lining" option deactivating the use of text figures in text mode.
%    \begin{macrocode}
\DeclareBoolOption[true]{lining}
\DeclareComplementaryOption{oldstyle}{lining}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\ProcessKeyvalOptions*
%    \end{macrocode}
%
%
% \begin{macro}{\ifxetexorluatex}
% Load the \software{ifluatex} \cite{ifluatex} and \software{ifxetex} \cite{ifxetex} packages.
% Define the "\ifxetexorluatex" conditional checking if the package is executed by \hologo{LuaLaTeX} or \hologo{XeLaTeX}.
%    \begin{macrocode}
\RequirePackage{ifluatex}
\RequirePackage{ifxetex}
\newif\ifxetexorluatex
\ifxetex\xetexorluatextrue
\else\ifluatex\xetexorluatextrue
  \else\xetexorluatexfalse\fi
\fi
%    \end{macrocode}
% \end{macro}
%
% Pick the correct font encoding depending on the engine used and load the \software{fontenc} package \cite{fontenc} with this encoding.
% For details of the font encoding see \cite{encguide}.
%    \begin{macrocode}
\def\hep@encoding{T\ifxetexorluatex U\else 1\fi}
\RequirePackage[\hep@encoding]{fontenc}
%    \end{macrocode}
% Fix the remaining \CM \cite{cm} fonts using the \software{fix-cm} package \cite{fix-cm} and load the \software{microtype} font optimizations \cite{microtype}.
%    \begin{macrocode}
\RequirePackage{fix-cm}
\RequirePackage{microtype}
%    \end{macrocode}
% Switch to the \LM font using the \software{cfr-lm} \cite{cfr-lm} or \software{lmodern} \cite{lmodern} packages depending on the \hologo{TeX} engine.
% In both cases the \NFSS is extended using the \software{nfssext-cfr} \cite{nfssext-cfr} package.
%    \begin{macrocode}
\ifxetexorluatex
  \RequirePackage{nfssext-cfr}
  \RequirePackage{lmodern}
\else
  \ifhepfont@lining
    \RequirePackage[rm={lining},sf={lining},tt={lining}]{cfr-lm}
  \else
    \RequirePackage{cfr-lm}
  \fi
\fi
%    \end{macrocode}
% Adjust the figures according to the "lining" option and ensure that tables always use lining.
%    \begin{macrocode}
% \RequirePackage{etoolbox}
% \AtBeginEnvironment{tabular}{\tlstyle}
%    \end{macrocode}
%
% Load the \software{textcomp} extension \cite{textcomp} and define helper functions.
%    \begin{macrocode}
\RequirePackage{textcomp}
\newcommand{\hep@sf@fontshape}[3]{%
  \DeclareFontShape{\hep@encoding}{\sfdefault}{#1}{#2}{#3}{}%
}
\newcommand{\hep@rm@fontshape}[3]{%
  \DeclareFontShape{\hep@encoding}{\rmdefault}{#1}{#2}{#3}{}%
}
%    \end{macrocode}
%
% For modern \hologo{TeX} engines define the bold and sans serif small caps font shapes using the \software{fontspec} package \cite{fontspec}.
%    \begin{macrocode}
\ifxetexorluatex
  \RequirePackage{fontspec}
  \setmainfont{Latin Modern Roman}[
    UprightFeatures={SmallCapsFont={[lmromancaps10-regular.otf]}},
    BoldFeatures={
      SmallCapsFeatures={Letters=SmallCaps},
      SmallCapsFont={[cmunbx.otf]}
    }
  ]
  \hep@sf@fontshape{bx}{sc}{<->cmssbxcsc10}{}
  \hep@sf@fontshape{b}{sc}{<->cmssbxcsc10}{}
  \hep@sf@fontshape{m}{scit}{<->cmsscsci10}{}
  \hep@sf@fontshape{m}{sc}{%
    <-9>cmsscsc8<9-10>cmsscsc9<10->cmsscsc10%
  }{}
%    \end{macrocode}
%If \hologo{pdfLaTeX}
%    \begin{macrocode}
\else
%    \end{macrocode}
%For serif fonts
%    \begin{macrocode}
  \rmfamily
%    \end{macrocode}
%\begin{macro}{\textsc}
%For lining numerals add \CM roman small caps (italic and bold) from the \software{slantsc} package \cite{slantsc}.
%    \begin{macrocode}
  \ifhepfont@lining
    \RequirePackage{slantsc}
    \hep@rm@fontshape{b}{sc}{<->ssub*cmr/bx/sc}{}
    \hep@rm@fontshape{bx}{sc}{<->ssub*cmr/bx/sc}{}
    \hep@rm@fontshape{b}{scsl}{<->ssub*cmr/bx/scsl}{}
    \hep@rm@fontshape{bx}{scsl}{<->ssub*cmr/bx/scit}{}
    \hep@rm@fontshape{b}{scit}{<->ssub*cmr/bx/scsl}{}
    \hep@rm@fontshape{bx}{scit}{<->ssub*cmr/bx/scit}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\textsc}
%For oldstyle numerals use the fonts from the \software{hfoldsty} package \cite{hfoldsty}.
%    \begin{macrocode}
  \else
    \DeclareFontFamily{\hep@encoding}{hfor}{}
    \DeclareFontShape{\hep@encoding}{hfor}{bx}{sc}{
      <-6>hfoxc0500<6-7>hfoxc0600<7-8>hfoxc0700<8-9>hfoxc0800
      <9-10>hfoxc0900<10-12>hfoxc1000<12-17>hfoxc1200<17->hfoxc1728
    }{}
    \DeclareFontShape{\hep@encoding}{hfor}{bx}{scsl}{
      <-6>hfooc0500<6-7>hfooc0600<7-8>hfooc0700<8-9>hfooc0800
      <9-10>hfooc0900<10-12>hfooc1000<12-17>hfooc1200<17->hfooc1728
    }{}
    \hep@rm@fontshape{b}{sc}{<->ssub*hfor/bx/sc}{}
    \hep@rm@fontshape{bx}{sc}{<->ssub*hfor/bx/sc}{}
    \hep@rm@fontshape{bx}{scsl}{<->ssub*hfor/bx/scsl}{}
    \hep@rm@fontshape{b}{scit}{<->ssub*hfor/bx/scsl}{}
    \hep@rm@fontshape{bx}{scit}{<->ssub*hfor/bx/scsl}{}
    \hep@rm@fontshape{b}{scsl}{<->ssub*hfor/bx/scsl}{}
  \fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\textsc}
%Provide the sans serif small caps font shape using the extended \CM from the \software{sansmathfonts} package \cite{sansmathfonts}.
%    \begin{macrocode}
  \sffamily
  \hep@sf@fontshape{m}{sc}{<->ssub*xcmss/m/sc}{}
  \hep@sf@fontshape{b}{sc}{<->ssub*xcmss/bx/sc}{}
  \hep@sf@fontshape{bx}{sc}{<->ssub*xcmss/bx/sc}{}
  \hep@sf@fontshape{m}{scit}{<->ssub*xcmss/m/scit}{}
  \hep@sf@fontshape{b}{scit}{<->ssub*xcmss/bx/scit}{}
  \hep@sf@fontshape{bx}{scit}{<->ssub*xcmss/bx/scit}{}
  \hep@sf@fontshape{m}{scsl}{<->ssub*xcmss/m/scit}{}
  \hep@sf@fontshape{b}{scsl}{<->ssub*xcmss/bx/scit}{}
  \hep@sf@fontshape{bx}{scsl}{<->ssub*xcmss/bx/scit}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\textui}
%Provide a sans upright italic font.
%    \begin{macrocode}
  \hep@sf@fontshape{m}{ui}{<->cmssu10}{}
\fi
%    \end{macrocode}
%\end{macro}
%
% Load the \software{inputenc} package \cite{inputenc} whe using \hologo{pdfLaTeX}.
%    \begin{macrocode}
\ifxetexorluatex\else\RequirePackage[utf8]{inputenc}\fi
%    \end{macrocode}
%
% \begin{macro}{\unit}
% Patch the "\unit" and "\unitfrac" macros to work with lining numerals using the \software{xpatch} package \cite{xpatch} if the \software{units} package \cite{units} is loaded.
% TODO implement patch without actually loading the package.
%    \begin{macrocode}
\ifhepfont@lining\else
% \AtBeginDocument{
%   \@ifpackageloaded{
    \RequirePackage{units}
    \RequirePackage{xpatch}
    \xpatchcmd{\unit}{\else#1}{%
      \else\ifthenelse{\boolean{mmode}}{#1}{\textl{#1}}%
    }{}{}
    \xpatchcmd{\unitfrac}{\else#1}{%
      \else\ifthenelse{\boolean{mmode}}{#1}{\textl{#1}}%
    }{}{}
%   }{}
% }
\fi
%    \end{macrocode}
% \end{macro}
%
%</package>
%
% \section{Test}
%
%<*test>
%
%    \begin{macrocode}
\documentclass[a4paper]{article}

\usepackage[oldstyle]{hep-font}
%% \usepackage[oldstyle]{hep-paper}

\usepackage{fullpage}

\usepackage{fancyvrb}\DefineShortVerb{\|}
\newenvironment{vrb}{\begin{tabular}{@{}p{5cm}ll@{}}}{\end{tabular}}

\begin{document}

\subsection*{Roman}

\rmfamily
\begin{vrb}
|\rmfamily| & {Latin Modern Roman 123} \\
|  \sbweight| & {\sbweight Latin Modern Roman Semi Bold 123} \\
|  \bfseries| & {\bfseries Latin Modern Roman Bold Extended 123} \\
|\slshape| & {\slshape Latin Modern Roman Oblique 123} \\
|  \sbweight| & {\sbweight\slshape Latin Modern Roman Semi Bold Oblique 123} \\
|  \bfseries| & {\bfseries\slshape Latin Modern Roman Bold Oblique Extended 123} \\
|\itshape| & {\itshape Latin Modern Roman Italic 123} \\
|  \bfseries| & {\bfseries\itshape Latin Modern Roman Bold Italic Extended 123} \\
|\uishape| & {\uishape Latin Modern Roman Upright Italic 123} \\
|\scshape| & {\scshape Latin Modern Roman Small Caps 123} \\
|  \bfseries| & {\bfseries\scshape Computer Modern Roman Bold Small Caps 123} \\
|  \sishape| & {\scshape\slshape Latin Modern Roman Oblique Small Caps 123} \\
|    \bfseries| & {\slshape\bfseries\scshape Computer Modern Roman Bold Small Caps 123} \\
\end{vrb}

\subsubsection*{Dunhill}

\tistyle
\begin{vrb}
|\tistyle | & {Latin Modern Dunhill 123} \\
|  \slshape| & {\slshape Latin Modern Dunhill Oblique 123} \\
\end{vrb}

\subsubsection*{Funny}

\fontfamily{cmfr}\selectfont
\begin{vrb}
|\fontfamily{cmfr}\selectfont | & {Computer Modern Funny 123} \\
|  \itshape| & {\itshape Computer Modern Funny Oblique 123} \\
\end{vrb}

\subsubsection*{Fib}

\fontfamily{cmfib}\selectfont
\begin{vrb}
|\fontfamily{cmfib}\selectfont | & {Computer Modern Fibonacci 123} \\
|  \slshape| & {\slshape Computer Modern Fibonacci Oblique 123} \\
\end{vrb}

\subsection*{Sans}

\sffamily
\begin{vrb}
|\sffamily| & {Latin Modern Sans 123} \\
|  \fontseries{sbc}\selectfont| & {\fontseries{sbc}\selectfont Latin Modern Sans Demi Condensed 123} \\
|  \bfseries| & {\bfseries Latin Modern Sans Bold 123} \\
|\slshape| & {\slshape Latin Modern Sans Oblique 123} \\
|  \fontseries{sbc}\selectfont| & {\fontseries{sbc}\selectfont\slshape Latin Modern Sans Demi Condensed Oblique 123} \\
|  \bfseries| & {\bfseries\slshape Latin Modern Sans Bold Oblique 123} \\
|\uishape| & {\uishape Computer Modern Sans Upright Italic 123} \\
|\scshape| & {\scshape Computer Modern Sans Small Caps 123} \\
|  \bfseries| & {\bfseries\scshape Computer Modern Sans Bold Small Caps 123} \\
|  \itshape| & {\itshape\scshape Computer Modern Sans Italic Small Caps 123} \\
|    \bfseries| & {\itshape\bfseries\scshape Computer Modern Sans Italic Bold Small Caps 123} \\
\end{vrb}

\subsubsection*{Quotation}

\qtstyle
\begin{vrb}
|\qtstyle | & {Latin Modern Sans Extended 123} \\
|  \bfseries | & {\bfseries Latin Modern Sans Bold Extended 123} \\
|\slshape | & {\slshape Latin Modern Sans Extended Oblique 123} \\
|  \bfseries | & {\bfseries\slshape Latin Modern Sans Bold Extended Oblique 123} \\
\end{vrb}

\subsection*{Typewriter}

\ttfamily
\tvstyle
\begin{vrb}
|\ttfamily\tvstyle | & {Latin Modern Typewriter Proportional 123} \\
|  \bfseries | & {\bfseries Latin Modern Typewriter Proportional Dark 123} \\
|  \lgweight | & {\lgweight Latin Modern Typewriter Proportional Light 123} \\
|\slshape | & {\slshape Latin Modern Typewriter Proportional Oblique 123} \\
|  \bfseries | & {\bfseries\slshape Latin Modern Typewriter Proportional Dark Oblique 123} \\
|  \lgweight | & {\lgweight Latin Modern Typewriter Proportional Light Oblique 123} \\
\end{vrb}

\subsubsection*{Fixed-width}

\tmstyle
\begin{vrb}
|\ttfamily\tmstyle | & {Latin Modern Typewriter 123} \\
|  \lgweight | & {\lgweight Latin Modern Typewriter Light 123} \\
|  \bfseries | & {\bfseries Latin Modern Typewriter Dark 123} \\
|  \fontseries{lc}\selectfont | & {\fontseries{lc}\selectfont Latin Modern Typewriter Light Condensed 123} \\
|\slshape | & {\slshape Latin Modern Typewriter Oblique 123} \\
|  \lgweight | & {\lgweight\slshape Latin Modern Typewriter Light Oblique 123} \\
|  \bfseries | & {\bfseries\slshape Latin Modern Typewriter Dark Oblique 123} \\
|  \fontseries{lc} | & {\fontseries{lc}\slshape Latin Modern Typewriter Light Condensed Oblique 123} \\
|\itshape | & {\itshape Latin Modern Typewriter Italic 123} \\
|\scshape | & {\scshape Latin Modern Typewriter Small Caps 123} \\
|  \slshape | & {\scshape\slshape Latin Modern Typewriter Oblique Small Caps 123} \\
\end{vrb}

\end{document}
%    \end{macrocode}
%
%</test>
%
% \section{Readme}
%
%<*readme>
%
%    \begin{macrocode}
# The `hep-font` package

Latin modern extended by computer modern.

## Introduction

The `hep-font` package loads standard font packages and extends the usual Latin Modern implementations by replacing missing fonts with Computer Modern counterparts.

The package is loaded with `\usepackage{hep-font}`.

## Author

Jan Hajer

## License

This file may be distributed and/or modified under the conditions of the `LaTeX` Project Public License, either version 1.3c 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.3c or later is part of all distributions of LaTeX version 2005/12/01 or later.
%    \end{macrocode}
%
%</readme>
%
% \Finale

\endinput

% \PrintIndex
% makeindex -s gglo.ist -o hep-font-implementation.gls hep-font-implementation.glo
% makeindex -s gglo.ist -o hep-font-implementation.ind hep-font-implementation.idx