summaryrefslogtreecommitdiff
path: root/fonts/inconsolata-nerd-font/inconsolata-nerd-font.dtx
blob: 5ef6e4bb1106621d5ee87d10a82f47a631b330dd (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
% \iffalse meta-comment
%
% File: inconsolata-nerd-font.dtx Copyright (C) 2023 Stephan Lukasczyk
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version.  The latest version
% of this license is in the file
%
%    https://www.latex-project.org/lppl.txt
%
% This file is part of the "inconsolata-nerd-font bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% The released version of this bundle is available from CTAN.
%
% ------------------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
%    https://github.com/stephanlukasczyk/inconsolata-nerd-font
%
% for those people who are interested.
%
% ------------------------------------------------------------------------------
%
%<*driver>
\documentclass{l3doc}
\usepackage[UKenglish]{babel}
\usepackage{libertinus-otf}
\usepackage{hvlogos}
% The next line is needed so that \GetFileInfo will be able to pick up version
% data.
\usepackage{inconsolata-nerd-font}
\usepackage{unicodefonttable}
\fonttablesetup{missing-glyph-color=black!25, color=black!50}
\usepackage{microtype}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \RecordChanges
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \DoNotIndex{
%   \endinput,
%   \ExplFileDate,
%   \ExplLoaderFileDate,
%   \fmtversion,
%   \l_keys_choice_tl,
%   \keys_define:nn,
%   \keys_set:nn,
%   \MessageBreak,
%   \PackageError,
%   \ProcessKeyOptions,
%   \ProcessKeysOptions,
%   \providecommand,
%   \@ifl@t@r,
%   \@ifpackagelater,
%   \@ifundefined,
%   \tl_clear:N,
%   \tl_if_empty:NTF,
%   \tl_if_eq:NnTF,
%   \tl_new:N,
%   \tl_put_right:Nn,
%   \tl_set:Nn,
%   \tl_set_eq:NN,
% }
%
% \changes{v0.1}{2023–09–09}{First public release}
%
% \GetFileInfo{inconsolata-nerd-font.sty}
%
% \title{^^A
%   \pkg{inconsolata-nerd-font}---Support package to use the Inconsolata ^^A
%   Nerd Font TrueType fonts^^A
% }
%
% \author{^^A
%   Stephan Lukasczyk^^A
%   \thanks{^^A
%     E-mail: \href{mailto:stephan@dante.de}{stephan@dante.de}^^A
%   }
% }
%
% \date{\fileversion, \filedate}
%
% \maketitle
%
% \begin{abstract}
%   Inconsolata is a monospaced font designed by Raph Levien.
%   It is already available via the \pkg{inconsolata} package.
%   However, that package provides a pretty old version of the font;
%   Additionally, the Nerd Font project extended the font by a huge amount of
%   additional glyphs.
%   This package provides the font itself
%   and a convenient interface to load the font for the
%   \XeLaTeX{} and \LuaLaTeX{} engines.
% \end{abstract}
%
% \tableofcontents
%
% \begin{documentation}
%
% \section{User Manual}\label{sec:doc}
%
% The Inconsolata font is a monospaced font designed by Raph Levien.
% Its current version is available from the Google Fonts project.\footnote{%
%   \href{https://github.com/googlefonts/Inconsolata}{github.com/googlefonts/Inconsolata}
% }
% There exists an extension of this font by the Nerd Font project,\footnote{%
%   \href{https://www.nerdfonts.com/}{www.nerdfonts.com/}
% }
% which adds a huge amount of additional glyphs,
% especially useful for developers,
% to the original font.
% The extended version is available from GitHub.\footnote{
%   \href{https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/InconsolataLGC}{github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/InconsolataLGC}
% }
% This package provides the TrueType font files
% and a convenient way to use the font
% with the \XeTeX{} or \LuaTeX{} engines.
%
% This user guide gives a brief introduction into the possibilities
% provided by the \pkg{inconsolata-nerd-font} package.
%
% \changes{v0.4}{2023-12-08}{Change variant to have bold-italic and italic glyphs, too}
% Since version 0.4, \pkg{inconsolata-nerd-font} ships and uses the extended
% version of the Inconsolata font, called \emph{InconsolataLGC}.
% This variant also contains Hellenic and Cyrilic glyphs, as well as bold-italic
% and italic variants.
%
% \subsection{License}\label{sec:doc-license}
%
% Permission is granted to copy, distribute, and/or modify this software under
% the terms of the \LaTeX{} Project Public License~(LPPL), version~1.3c or
% later~(\href{https://www.latex-project.org/lppl.txt}{https://www.latex-project.org/lppl.txt}).
% The software has the status \enquote{maintained}.
%
% The font files bundled with the package (\texttt{InconsolataLGCNerdFont*.ttf})
% are licensed under the terms of the SIL Open Font License~(LPPL),
% version~1.1~(\href{http://scripts.sil.org/OFL}{http://scripts.sil.org/OFL}).
%
% \subsection{Helper Macros}\label{sec:doc-helper}
%
% The following macro is not strictly part of the package.
% It is actually defined by recent \LaTeX{} kernels.
% However, to make the package compatible with older kernels, too,
% we provide it, if it is not yet defined.
%
% The macro's purpose is to check whether the used \LaTeX{} format
% is at least from the given date
% and allows to execute code depending on the result of the check.
% \begin{function}{\IfFormatAtLeastTF}
%   \begin{syntax}
%     \cs{IfFormatAtLeastTF} \marg{date} \marg{true} \marg{false}
%   \end{syntax}
%   We define this macro to execute code depending on the \LaTeX{} format date.
%   The macro is only defined if it is not already part of the \LaTeX{} kernel,
%   which it is for recent versions of the kernel.
% \end{function}
%
% \subsection{Package Arguments}\label{sec:doc-arguments}
%
% The \pkg{inconsolata-nerd-font} package provides the following
% load-time options.
% \begin{variable}{variant}
%   \begin{syntax}
%     variant = \meta{choice}
%   \end{syntax}
%   Specifies which variant of the font shall be used, must be one of
%   |default|, |mono|, or |propo|, where |default| is the default value.
%
%   The |mono| variant is limited to only mono-spaced characters,
%   the |default| variant provides bigger icons (around 1.5 times the width of a
%   normal character),
%   the |propo| variant provides proportional symbols,
%   which might be suitable, e.g., for presentations.
% \end{variable}
%
% \begin{variable}{scale, Scale}
%   \begin{syntax}
%     scale = \marg{factor}
%     Scale = \marg{factor}
%   \end{syntax}
%   Set the scaling of the font.
%   See the \pkg{fontspec} documentation for more details.
%   The default value is |MatchLowercase| to match the height of the lower-case
%   character of the default main font of your document.
% \end{variable}
%
% \subsection{Font Macros}\label{sec:doc-macros}
%
% While the package sets the default mono-spaced font
% to the selected variant of the Inconsolata Nerd Font,
% the package provides six additional macros for convenience,
% one pair of each variant of the font.
%
% \begin{function}{\inconsolatanffamily}
%   \begin{syntax}
%     \cs{inconsolatanffamily}
%   \end{syntax}
%   A font family for the Inconsolata Nerd Font,
%   the default variant provided by this package.
% \end{function}
% \begin{function}{\inconsolatanfmonofamily}
%   \begin{syntax}
%     \cs{inconsolatanfmonofamily}
%   \end{syntax}
%   A font family for the Inconsolata Nerd Font,
%   the mono variant provided by this package.
% \end{function}
% \begin{function}{\inconsolatanfpropofamily}
%   \begin{syntax}
%     \cs{inconsolatanfpropofamily}
%   \end{syntax}
%   A font family for the Inconsolata Nerd Font,
%   the propo variant provided by this package.
% \end{function}
%
% \begin{function}{\textinconsolatanf}
%   \begin{syntax}
%     \cs{textinconsolatanf} \marg{text}
%   \end{syntax}
%   A convenience macro to typeset a short |text| using the default
%   Inconsolata Nerd Font variant.
% \end{function}
% \begin{function}{\textinconsolatanfmono}
%   \begin{syntax}
%     \cs{textinconsolatanfmono} \marg{text}
%   \end{syntax}
%   A convenience macro to typeset a short |text| using the mono
%   Inconsolata Nerd Font variant.
% \end{function}
% \begin{function}{\textinconsolatanfpropo}
%   \begin{syntax}
%     \cs{textinconsolatanfpropo} \marg{text}
%   \end{syntax}
%   A convenience macro to typeset a short |text| using the propo
%   Inconsolata Nerd Font variant.
% \end{function}
%
% The following sentence uses the \cs{textinconsolatanf}
% to typeset the words \enquote{an example} using Inconsolata Nerd Font:
% Just \textinconsolatanf{an example} sentence.
%
% \section{Font Tables}\label{sec:doc-font-tables}
%
% \changes{v0.3}{2023-09-13}{Add font tables to the documentation.}
%
% This section provides character tables of the different font variants,
% created using Frank Mittelbach's \pkg{unicodefonttable} package.
% Thanks to Herbert Voß for his suggestion to add these.
%
% \subsection{Regular}\label{sec:doc-font-tables-regular}
%
% \displayfonttable{InconsolataLGCNerdFont-Regular.ttf}
%
% \subsection{Mono Regular}\label{sec:doc-font-tables-mono}
%
% \displayfonttable{InconsolataLGCNerdFontMono-Regular.ttf}
%
% \subsection{Proportional Regular}\label{sec:doc-font-tables-propo}
%
% \displayfonttable{InconsolataLGCNerdFontPropo-Regular.ttf}
%
% \end{documentation}
%
% \clearpage
%
% \begin{implementation}
%
% \section{Implementation}\label{impl:pkg}
%
% Start the \pkg{DocStrip} guards.
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% Identify the internal prefix (\LaTeX3 \pkg{DocStrip} convention): only
% internal matrial in this \emph{module} should be used directly.
%    \begin{macrocode}
%<@@=slcd_inf>
%    \end{macrocode}
% Load only the essential support (\pkg{expl3}) \enquote{up-front}, and only
% if required.
%    \begin{macrocode}
\@ifundefined{ExplLoaderFileDate}
  { \RequirePackage{expl3} }
  {}
%    \end{macrocode}
% Make sure that the version of \pkg{l3kernel} in use is sufficiently new.
% We use \cs{ExplFileDate} as \cs{@ifpackagelater} does not work for
% pre-loaded \pkg{expl3} in the absence of the package.
%    \begin{macrocode}
\@ifl@t@r\ExplLoaderFileDate{2020-01-09}
  {}
  {%
    \PackageError{inconsolata-nerd-font}{Support package expl3 too old}
    {%
      You need to update your installation of the bundles 'l3kernel' and
      'l3packages'.\MessageBreak
      Loading~inconsolata-nerd-font~will~abort!%
    }%
    \endinput
  }%
%    \end{macrocode}
%
% \begin{macro}{\IfFormatAtLeastTF}
%   This macro is not present in older kernels, thus we use the \LaTeXe{}
%   mechanism as this is correct for this case.
%    \begin{macrocode}
\providecommand \IfFormatAtLeastTF { \@ifl@t@r \fmtversion }
%    \end{macrocode}
% \end{macro}
%
% Identify the package and give the overall version information.
%    \begin{macrocode}
\ProvidesExplPackage {inconsolata-nerd-font} {2023-12-08} {0.4}
  {Support package to use the Inconsolata Nerd Font TrueType fonts}
%    \end{macrocode}
%
% \subsection{Options}\label{sec:impl-options}
%
% Define the options for the package.
% \begin{variable}{
%   variant,
%   scale,
%   Scale,
%   \l_@@_variant_tl,
%   \l_@@_scale_tl,
% }
%    \begin{macrocode}
\tl_new:N \l_@@_variant_tl

\keys_define:nn { inconsolatanerdfont }
  {
    variant .choices:nn = { default, mono, propo } {
      \tl_set_eq:NN \l_@@_variant_tl \l_keys_choice_tl
    },

    scale .tl_set:N = \l_@@_scale_tl,
    Scale .tl_set:N = \l_@@_scale_tl,
  }

\keys_set:nn { inconsolatanerdfont }
  {
    variant = default,
    scale = MatchLowercase,
  }
\tl_clear:N \l_@@_variant_tl
%    \end{macrocode}
% \end{variable}
%
% Process the options
%    \begin{macrocode}
\IfFormatAtLeastTF { 2022-06-01 }
  { \ProcessKeyOptions [ inconsolatanerdfont ] }
  {
    \RequirePackage { l3keys2e }
    \ProcessKeysOptions { inconsolatanerdfont }
  }
%    \end{macrocode}
% and set up the default variant if it was not yet chosen
%    \begin{macrocode}
\tl_if_empty:NT \l_@@_variant_tl
  {
    \tl_set:Nn \l_@@_variant_tl { default }
  }
%    \end{macrocode}
%
% \subsection{Load the Font}\label{sec:impl-load}
%
% We require the \pkg{fontspec} package.
%    \begin{macrocode}
\RequirePackage{fontspec}
%    \end{macrocode}
%
% Define and set a helper variable for the respective font name suffix
%    \begin{macrocode}
\tl_new:N \l_@@_font_name_tl
\tl_set:Nn \l_@@_font_name_tl {InconsolataLGCNerdFont}
\tl_if_eq:NnTF \l_@@_variant_tl { mono }
  { \tl_put_right:Nn \l_@@_font_name_tl {Mono} }
  {
    \tl_if_eq:NnT \l_@@_variant_tl { propo }
      { \tl_put_right:Nn \l_@@_font_name_tl {Propo} }
  }
%    \end{macrocode}
%
% Define a font family for the three fonts and commands for easier usage.
% \begin{macro}{\inconsolatanffamily}
%   The defaut font accessible as a \LaTeX{} font family.
%    \begin{macrocode}
\newfontfamily\inconsolatanffamily{InconsolataLGCNerdFont-Regular.ttf}[
  BoldFont       = InconsolataLGCNerdFont-Bold.ttf,
  BoldItalicFont = InconsolataLGCNerdFont-BoldItalic.ttf,
  ItalicFont     = InconsolataLGCNerdFont-Italic.ttf,
  FakeStretch    = {0.9},
  NFSSFamily     = inconsolatanf,
  Scale          = \l_@@_scale_tl,
]
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\inconsolatanfmonofamily}
%   \changes{v0.2}{2023–09–12}{Added macro}
%   The mono font variant, accessible as a \LaTeX{} font family.
%    \begin{macrocode}
\newfontfamily\inconsolatanfmonofamily{InconsolataLGCNerdFontMono-Regular.ttf}[
  BoldFont       = InconsolataLGCNerdFontMono-Bold.ttf,
  BoldItalicFont = InconsolataLGCNerdFontMono-BoldItalic.ttf,
  ItalicFont     = InconsolataLGCNerdFontMono-Italic.ttf,
  FakeStretch    = {0.9},
  NFSSFamily     = inconsolatanfmono,
  Scale          = \l_@@_scale_tl,
]
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\inconsolatanfpropofamily}
%   \changes{v0.2}{2023–09–12}{Added macro}
%   The propo font variant, accessible as a \LaTeX{} font family.
%    \begin{macrocode}
\newfontfamily\inconsolatanfpropofamily{InconsolataLGCNerdFontPropo-Regular.ttf}[
  BoldFont       = InconsolataLGCNerdFontPropo-Bold.ttf,
  BoldItalicFont = InconsolataLGCNerdFontPropo-BoldItalic.ttf,
  ItalicFont     = InconsolataLGCNerdFontPropo-Italic.ttf,
  FakeStretch    = {0.9},
  NFSSFamily     = inconsolatanfpropo,
  Scale          = \l_@@_scale_tl,
]
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\textinconsolatanf}
%   A macro to typeset text in the default font variant.
%    \begin{macrocode}
\DeclareTextFontCommand{\textinconsolatanf}{\inconsolatanffamily}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\textinconsolatanfmono}
%   \changes{v0.2}{2023–09–12}{Added macro}
%   A macro to typeset text in the mono font variant.
%    \begin{macrocode}
\DeclareTextFontCommand{\textinconsolatanfmono}{\inconsolatanffamilymono}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\textinconsolatanfpropo}
%   \changes{v0.2}{2023–09–12}{Added macro}
%   A macro to typeset text in the propo font variant.
%    \begin{macrocode}
\DeclareTextFontCommand{\textinconsolatanfpropo}{\inconsolatanffamilypropo}
%    \end{macrocode}
% \end{macro}
%
% Now we can actually load the font
%    \begin{macrocode}
\setmonofont{\l_@@_font_name_tl}[
  BoldFont       = *-Bold,
  BoldItalicFont = *-BoldItalic,
  ItalicFont     = *-Italic,
  Extension      = .ttf,
  FakeStretch    = {0.9},
  Scale          = \l_@@_scale_tl,
  UprightFont    = *-Regular,
]
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \end{implementation}
%
% \PrintIndex
% \PrintChanges