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
|
% \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{libertinus-otf}
\usepackage{hvlogos}
% The next line is needed so that \GetFileInfo will be able to pick up version
% data.
\usepackage{inconsolata-nerd-font}
\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,
% }
%
% \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 a convenient interface to load the font for the
% \XeTeX{} and \LuaTeX{} 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/Inconsolata}{github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Inconsolata}
% }
% This package provides 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.
%
% \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.
% It 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.
% \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 two additional macros for convenience.
%
% \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}{\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}
%
% The following sentence uses the \cs{textinconsolatanf}
% to typeset the words \enquote{an example} using Inconsolata Nerd Font:
% Just \textinconsolatanf{an example} sentence.
%
% \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-09-09} {0.1}
{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 = 0.9,
}
\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 {InconsolataNerdFont}
\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 font and a command for esiere usage
% \begin{macro}{\inconsolatanffamily, \textinconsolatanf}
% \begin{macrocode}
\newfontfamily\inconsolatanffamily{InconsolataNerdFont-Regular.ttf}[
BoldFont = InconsolataNerdFont-Bold.ttf,
FakeStretch = {0.9},
NFSSFamily = inconsolatanf,
Scale = \l_@@_scale_tl,
]
\DeclareTextFontCommand{\textinconsolatanf}{\inconsolatanffamily}
% \end{macrocode}
% \end{macro}
%
% Now we can actually load the font
% \begin{macrocode}
\setmonofont{\l_@@_font_name_tl}[
BoldFont = *-Bold,
Extension = .ttf,
FakeStretch = {0.9},
Scale = \l_@@_scale_tl,
UprightFont = *-Regular,
]
% \end{macrocode}
%
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \end{implementation}
%
% \PrintIndex
% \PrintChanges
|