Debian Codegraph @

texmf-dist/source/fonts/inconsolata-nerd-font/inconsolata-nerd-font.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: inconsolata-nerd-font.dtx Copyright (C) 2023 Stephan Lukasczyk
4 %
5 % It may be distributed and/or modified under the conditions of the
6 % LaTeX Project Public License (LPPL), either version 1.3c of this
7 % license or (at your option) any later version. The latest version
8 % of this license is in the file
9 %
10 % https://www.latex-project.org/lppl.txt
11 %
12 % This file is part of the "inconsolata-nerd-font bundle" (The Work in LPPL)
13 % and all files in that bundle must be distributed together.
14 %
15 % The released version of this bundle is available from CTAN.
16 %
17 % ------------------------------------------------------------------------------
18 %
19 % The development version of the bundle can be found at
20 %
21 % https://github.com/stephanlukasczyk/inconsolata-nerd-font
22 %
23 % for those people who are interested.
24 %
25 % ------------------------------------------------------------------------------
26 %
27 %<*driver>
28 \documentclass{l3doc}
29 \usepackage[UKenglish]{babel}
30 \usepackage{libertinus-otf}
31 \usepackage{hvlogos}
32 % The next line is needed so that \GetFileInfo will be able to pick up version
33 % data.
34 \usepackage{inconsolata-nerd-font}
35 \usepackage{unicodefonttable}
36 \fonttablesetup{missing-glyph-color=black!25, color=black!50}
37 \usepackage{microtype}
38 \EnableCrossrefs
39 \CodelineIndex
40 \RecordChanges
41 \begin{document}
42 \RecordChanges
43 \DocInput{\jobname.dtx}
44 \end{document}
45 %</driver>
46 % \fi
47 %
48 % \DoNotIndex{
49 % \endinput,
50 % \ExplFileDate,
51 % \ExplLoaderFileDate,
52 % \fmtversion,
53 % \l_keys_choice_tl,
54 % \keys_define:nn,
55 % \keys_set:nn,
56 % \MessageBreak,
57 % \PackageError,
58 % \ProcessKeyOptions,
59 % \ProcessKeysOptions,
60 % \providecommand,
61 % \@ifl@t@r,
62 % \@ifpackagelater,
63 % \@ifundefined,
64 % \tl_clear:N,
65 % \tl_if_empty:NTF,
66 % \tl_if_eq:NnTF,
67 % \tl_new:N,
68 % \tl_put_right:Nn,
69 % \tl_set:Nn,
70 % \tl_set_eq:NN,
71 % }
72 %
73 % \changes{v0.1}{2023–09–09}{First public release}
74 % \changes{v0.5}{2024–04–06}{Update Nerd Fonts to v3.2.0}
75 %
76 % \GetFileInfo{inconsolata-nerd-font.sty}
77 %
78 % \title{^^A
79 % \pkg{inconsolata-nerd-font}---Support package to use the Inconsolata ^^A
80 % Nerd Font TrueType fonts^^A
81 % }
82 %
83 % \author{^^A
84 % Stephan Lukasczyk^^A
85 % \thanks{^^A
86 % E-mail: \href{mailto:[email protected]}{[email protected]}^^A
87 % }
88 % }
89 %
90 % \date{\fileversion, \filedate}
91 %
92 % \maketitle
93 %
94 % \begin{abstract}
95 % Inconsolata is a monospaced font designed by Raph Levien.
96 % It is already available via the \pkg{inconsolata} package.
97 % However, that package provides a pretty old version of the font;
98 % Additionally, the Nerd Font project extended the font by a huge amount of
99 % additional glyphs.
100 % This package provides the font itself
101 % and a convenient interface to load the font for the
102 % \XeLaTeX{} and \LuaLaTeX{} engines.
103 % \end{abstract}
104 %
105 % \tableofcontents
106 %
107 % \begin{documentation}
108 %
109 % \section{User Manual}\label{sec:doc}
110 %
111 % The Inconsolata font is a monospaced font designed by Raph Levien.
112 % Its current version is available from the Google Fonts project.\footnote{%
113 % \href{https://github.com/googlefonts/Inconsolata}{github.com/googlefonts/Inconsolata}
114 % }
115 % There exists an extension of this font by the Nerd Font project,\footnote{%
116 % \href{https://www.nerdfonts.com/}{www.nerdfonts.com/}
117 % }
118 % which adds a huge amount of additional glyphs,
119 % especially useful for developers,
120 % to the original font.
121 % The extended version is available from GitHub.\footnote{
122 % \href{https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/InconsolataLGC}{github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/InconsolataLGC}
123 % }
124 % This package provides the TrueType font files
125 % and a convenient way to use the font
126 % with the \XeTeX{} or \LuaTeX{} engines.
127 %
128 % This user guide gives a brief introduction into the possibilities
129 % provided by the \pkg{inconsolata-nerd-font} package.
130 %
131 % \changes{v0.4}{2023-12-08}{Change variant to have bold-italic and italic glyphs, too}
132 % Since version 0.4, \pkg{inconsolata-nerd-font} ships and uses the extended
133 % version of the Inconsolata font, called \emph{InconsolataLGC}.
134 % This variant also contains Hellenic and Cyrilic glyphs, as well as bold-italic
135 % and italic variants.
136 %
137 % \subsection{License}\label{sec:doc-license}
138 %
139 % Permission is granted to copy, distribute, and/or modify this software under
140 % the terms of the \LaTeX{} Project Public License~(LPPL), version~1.3c or
141 % later~(\href{https://www.latex-project.org/lppl.txt}{https://www.latex-project.org/lppl.txt}).
142 % The software has the status \enquote{maintained}.
143 %
144 % The font files bundled with the package (\texttt{InconsolataLGCNerdFont*.ttf})
145 % are licensed under the terms of the SIL Open Font License~(LPPL),
146 % version~1.1~(\href{http://scripts.sil.org/OFL}{http://scripts.sil.org/OFL}).
147 %
148 % \subsection{Helper Macros}\label{sec:doc-helper}
149 %
150 % The following macro is not strictly part of the package.
151 % It is actually defined by recent \LaTeX{} kernels.
152 % However, to make the package compatible with older kernels, too,
153 % we provide it, if it is not yet defined.
154 %
155 % The macro's purpose is to check whether the used \LaTeX{} format
156 % is at least from the given date
157 % and allows to execute code depending on the result of the check.
158 % \begin{function}{\IfFormatAtLeastTF}
159 % \begin{syntax}
160 % \cs{IfFormatAtLeastTF} \marg{date} \marg{true} \marg{false}
161 % \end{syntax}
162 % We define this macro to execute code depending on the \LaTeX{} format date.
163 % The macro is only defined if it is not already part of the \LaTeX{} kernel,
164 % which it is for recent versions of the kernel.
165 % \end{function}
166 %
167 % \subsection{Package Arguments}\label{sec:doc-arguments}
168 %
169 % The \pkg{inconsolata-nerd-font} package provides the following
170 % load-time options.
171 % \begin{variable}{variant}
172 % \begin{syntax}
173 % variant = \meta{choice}
174 % \end{syntax}
175 % Specifies which variant of the font shall be used, must be one of
176 % |default|, |mono|, or |propo|, where |default| is the default value.
177 %
178 % The |mono| variant is limited to only mono-spaced characters,
179 % the |default| variant provides bigger icons (around 1.5 times the width of a
180 % normal character),
181 % the |propo| variant provides proportional symbols,
182 % which might be suitable, e.g., for presentations.
183 % \end{variable}
184 %
185 % \begin{variable}{scale, Scale}
186 % \begin{syntax}
187 % scale = \marg{factor}
188 % Scale = \marg{factor}
189 % \end{syntax}
190 % Set the scaling of the font.
191 % See the \pkg{fontspec} documentation for more details.
192 % The default value is |MatchLowercase| to match the height of the lower-case
193 % character of the default main font of your document.
194 % \end{variable}
195 %
196 % \subsection{Font Macros}\label{sec:doc-macros}
197 %
198 % While the package sets the default mono-spaced font
199 % to the selected variant of the Inconsolata Nerd Font,
200 % the package provides six additional macros for convenience,
201 % one pair of each variant of the font.
202 %
203 % \begin{function}{\inconsolatanffamily}
204 % \begin{syntax}
205 % \cs{inconsolatanffamily}
206 % \end{syntax}
207 % A font family for the Inconsolata Nerd Font,
208 % the default variant provided by this package.
209 % \end{function}
210 % \begin{function}{\inconsolatanfmonofamily}
211 % \begin{syntax}
212 % \cs{inconsolatanfmonofamily}
213 % \end{syntax}
214 % A font family for the Inconsolata Nerd Font,
215 % the mono variant provided by this package.
216 % \end{function}
217 % \begin{function}{\inconsolatanfpropofamily}
218 % \begin{syntax}
219 % \cs{inconsolatanfpropofamily}
220 % \end{syntax}
221 % A font family for the Inconsolata Nerd Font,
222 % the propo variant provided by this package.
223 % \end{function}
224 %
225 % \begin{function}{\textinconsolatanf}
226 % \begin{syntax}
227 % \cs{textinconsolatanf} \marg{text}
228 % \end{syntax}
229 % A convenience macro to typeset a short |text| using the default
230 % Inconsolata Nerd Font variant.
231 % \end{function}
232 % \begin{function}{\textinconsolatanfmono}
233 % \begin{syntax}
234 % \cs{textinconsolatanfmono} \marg{text}
235 % \end{syntax}
236 % A convenience macro to typeset a short |text| using the mono
237 % Inconsolata Nerd Font variant.
238 % \end{function}
239 % \begin{function}{\textinconsolatanfpropo}
240 % \begin{syntax}
241 % \cs{textinconsolatanfpropo} \marg{text}
242 % \end{syntax}
243 % A convenience macro to typeset a short |text| using the propo
244 % Inconsolata Nerd Font variant.
245 % \end{function}
246 %
247 % The following sentence uses the \cs{textinconsolatanf}
248 % to typeset the words \enquote{an example} using Inconsolata Nerd Font:
249 % Just \textinconsolatanf{an example} sentence.
250 %
251 % \section{Font Tables}\label{sec:doc-font-tables}
252 %
253 % \changes{v0.3}{2023-09-13}{Add font tables to the documentation.}
254 %
255 % This section provides character tables of the different font variants,
256 % created using Frank Mittelbach's \pkg{unicodefonttable} package.
257 % Thanks to Herbert Voß for his suggestion to add these.
258 %
259 % \subsection{Regular}\label{sec:doc-font-tables-regular}
260 %
261 % \displayfonttable{InconsolataLGCNerdFont-Regular.ttf}
262 %
263 % \subsection{Mono Regular}\label{sec:doc-font-tables-mono}
264 %
265 % \displayfonttable{InconsolataLGCNerdFontMono-Regular.ttf}
266 %
267 % \subsection{Proportional Regular}\label{sec:doc-font-tables-propo}
268 %
269 % \displayfonttable{InconsolataLGCNerdFontPropo-Regular.ttf}
270 %
271 % \end{documentation}
272 %
273 % \clearpage
274 %
275 % \begin{implementation}
276 %
277 % \section{Implementation}\label{impl:pkg}
278 %
279 % Start the \pkg{DocStrip} guards.
280 % \begin{macrocode}
281 %<*package>
282 % \end{macrocode}
283 % Identify the internal prefix (\LaTeX3 \pkg{DocStrip} convention): only
284 % internal matrial in this \emph{module} should be used directly.
285 % \begin{macrocode}
286 %<@@=slcd_inf>
287 % \end{macrocode}
288 % Load only the essential support (\pkg{expl3}) \enquote{up-front}, and only
289 % if required.
290 % \begin{macrocode}
291 \@ifundefined{ExplLoaderFileDate}
292 { \RequirePackage{expl3} }
293 {}
294 % \end{macrocode}
295 % Make sure that the version of \pkg{l3kernel} in use is sufficiently new.
296 % We use \cs{ExplFileDate} as \cs{@ifpackagelater} does not work for
297 % pre-loaded \pkg{expl3} in the absence of the package.
298 % \begin{macrocode}
299 \@ifl@t@r\ExplLoaderFileDate{2020-01-09}
300 {}
301 {%
302 \PackageError{inconsolata-nerd-font}{Support package expl3 too old}
303 {%
304 You need to update your installation of the bundles 'l3kernel' and
305 'l3packages'.\MessageBreak
306 Loading~inconsolata-nerd-font~will~abort!%
307 }%
308 \endinput
309 }%
310 % \end{macrocode}
311 %
312 % \begin{macro}{\IfFormatAtLeastTF}
313 % This macro is not present in older kernels, thus we use the \LaTeXe{}
314 % mechanism as this is correct for this case.
315 % \begin{macrocode}
316 \providecommand \IfFormatAtLeastTF { \@ifl@t@r \fmtversion }
317 % \end{macrocode}
318 % \end{macro}
319 %
320 % Identify the package and give the overall version information.
321 % \begin{macrocode}
322 \ProvidesExplPackage {inconsolata-nerd-font} {2024-04-06} {0.5}
323 {Support package to use the Inconsolata Nerd Font TrueType fonts}
324 % \end{macrocode}
325 %
326 % \subsection{Options}\label{sec:impl-options}
327 %
328 % Define the options for the package.
329 % \begin{variable}{
330 % variant,
331 % scale,
332 % Scale,
333 % \l_@@_variant_tl,
334 % \l_@@_scale_tl,
335 % }
336 % \begin{macrocode}
337 \tl_new:N \l_@@_variant_tl
338
339 \keys_define:nn { inconsolatanerdfont }
340 {
341 variant .choices:nn = { default, mono, propo } {
342 \tl_set_eq:NN \l_@@_variant_tl \l_keys_choice_tl
343 },
344
345 scale .tl_set:N = \l_@@_scale_tl,
346 Scale .tl_set:N = \l_@@_scale_tl,
347 }
348
349 \keys_set:nn { inconsolatanerdfont }
350 {
351 variant = default,
352 scale = MatchLowercase,
353 }
354 \tl_clear:N \l_@@_variant_tl
355 % \end{macrocode}
356 % \end{variable}
357 %
358 % Process the options
359 % \begin{macrocode}
360 \IfFormatAtLeastTF { 2022-06-01 }
361 { \ProcessKeyOptions [ inconsolatanerdfont ] }
362 {
363 \RequirePackage { l3keys2e }
364 \ProcessKeysOptions { inconsolatanerdfont }
365 }
366 % \end{macrocode}
367 % and set up the default variant if it was not yet chosen
368 % \begin{macrocode}
369 \tl_if_empty:NT \l_@@_variant_tl
370 {
371 \tl_set:Nn \l_@@_variant_tl { default }
372 }
373 % \end{macrocode}
374 %
375 % \subsection{Load the Font}\label{sec:impl-load}
376 %
377 % We require the \pkg{fontspec} package.
378 % \begin{macrocode}
379 \RequirePackage{fontspec}
380 % \end{macrocode}
381 %
382 % Define and set a helper variable for the respective font name suffix
383 % \begin{macrocode}
384 \tl_new:N \l_@@_font_name_tl
385 \tl_set:Nn \l_@@_font_name_tl {InconsolataLGCNerdFont}
386 \tl_if_eq:NnTF \l_@@_variant_tl { mono }
387 { \tl_put_right:Nn \l_@@_font_name_tl {Mono} }
388 {
389 \tl_if_eq:NnT \l_@@_variant_tl { propo }
390 { \tl_put_right:Nn \l_@@_font_name_tl {Propo} }
391 }
392 % \end{macrocode}
393 %
394 % Define a font family for the three fonts and commands for easier usage.
395 % \begin{macro}{\inconsolatanffamily}
396 % The defaut font accessible as a \LaTeX{} font family.
397 % \begin{macrocode}
398 \newfontfamily\inconsolatanffamily{InconsolataLGCNerdFont-Regular.ttf}[
399 BoldFont = InconsolataLGCNerdFont-Bold.ttf,
400 BoldItalicFont = InconsolataLGCNerdFont-BoldItalic.ttf,
401 ItalicFont = InconsolataLGCNerdFont-Italic.ttf,
402 FakeStretch = {0.9},
403 NFSSFamily = inconsolatanf,
404 Scale = \l_@@_scale_tl,
405 ]
406 % \end{macrocode}
407 % \end{macro}
408 % \begin{macro}{\inconsolatanfmonofamily}
409 % \changes{v0.2}{2023–09–12}{Added macro}
410 % The mono font variant, accessible as a \LaTeX{} font family.
411 % \begin{macrocode}
412 \newfontfamily\inconsolatanfmonofamily{InconsolataLGCNerdFontMono-Regular.ttf}[
413 BoldFont = InconsolataLGCNerdFontMono-Bold.ttf,
414 BoldItalicFont = InconsolataLGCNerdFontMono-BoldItalic.ttf,
415 ItalicFont = InconsolataLGCNerdFontMono-Italic.ttf,
416 FakeStretch = {0.9},
417 NFSSFamily = inconsolatanfmono,
418 Scale = \l_@@_scale_tl,
419 ]
420 % \end{macrocode}
421 % \end{macro}
422 % \begin{macro}{\inconsolatanfpropofamily}
423 % \changes{v0.2}{2023–09–12}{Added macro}
424 % The propo font variant, accessible as a \LaTeX{} font family.
425 % \begin{macrocode}
426 \newfontfamily\inconsolatanfpropofamily{InconsolataLGCNerdFontPropo-Regular.ttf}[
427 BoldFont = InconsolataLGCNerdFontPropo-Bold.ttf,
428 BoldItalicFont = InconsolataLGCNerdFontPropo-BoldItalic.ttf,
429 ItalicFont = InconsolataLGCNerdFontPropo-Italic.ttf,
430 FakeStretch = {0.9},
431 NFSSFamily = inconsolatanfpropo,
432 Scale = \l_@@_scale_tl,
433 ]
434 % \end{macrocode}
435 % \end{macro}
436 % \begin{macro}{\textinconsolatanf}
437 % A macro to typeset text in the default font variant.
438 % \begin{macrocode}
439 \DeclareTextFontCommand{\textinconsolatanf}{\inconsolatanffamily}
440 % \end{macrocode}
441 % \end{macro}
442 % \begin{macro}{\textinconsolatanfmono}
443 % \changes{v0.2}{2023–09–12}{Added macro}
444 % A macro to typeset text in the mono font variant.
445 % \begin{macrocode}
446 \DeclareTextFontCommand{\textinconsolatanfmono}{\inconsolatanffamilymono}
447 % \end{macrocode}
448 % \end{macro}
449 % \begin{macro}{\textinconsolatanfpropo}
450 % \changes{v0.2}{2023–09–12}{Added macro}
451 % A macro to typeset text in the propo font variant.
452 % \begin{macrocode}
453 \DeclareTextFontCommand{\textinconsolatanfpropo}{\inconsolatanffamilypropo}
454 % \end{macrocode}
455 % \end{macro}
456 %
457 % Now we can actually load the font
458 % \begin{macrocode}
459 \setmonofont{\l_@@_font_name_tl}[
460 BoldFont = *-Bold,
461 BoldItalicFont = *-BoldItalic,
462 ItalicFont = *-Italic,
463 Extension = .ttf,
464 FakeStretch = {0.9},
465 Scale = \l_@@_scale_tl,
466 UprightFont = *-Regular,
467 ]
468 % \end{macrocode}
469 %
470 % \begin{macrocode}
471 %</package>
472 % \end{macrocode}
473 %
474 % \end{implementation}
475 %
476 % \PrintIndex
477 % \PrintChanges