summaryrefslogtreecommitdiff
path: root/fonts/arsenal/arsenal.dtx
blob: 16db2a0a072a35b70be640703edcebe96e8296df (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
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
% \iffalse meta-comment
%
% File: arsenal.dtx
% Copyright 2023 by Boris Veytsman
%
% 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
%
%<*driver>
\documentclass{l3doc}
\usepackage[default]{arsenal}
\usepackage{natbib, booktabs}
\usepackage[tableposition=top]{caption}
\urlstyle{rm}
\begin{document}
  \RecordChanges
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
% \GetFileInfo{arsenal.sty}
% \title{\pkg{arsenal}---\LaTeX\ support of Arsenal fonts by Andrij Shevchenko}
% \date{\fileversion, \filedate}
% \author{Boris
% Veytsman\thanks{\href{mailto:borisv@lk.net}{borisv@lk.net},
% \href{mailto:boris@varphi.com}{boris@varphi.com}}}
% \maketitle
% \begin{abstract}
%   Arsenal is the font created by Andrij Shevchenko.  It won
%   Ukrainian Type Design Competition `Mystetsky Arsenal' in 2011.
%   This package provides \LaTeX\ support for it and matching math
%   fonts.
% \end{abstract}
% \tableofcontents
% \begin{documentation}
%
%\section{User manual}
%\label{sec:ug}
%
% 
%\subsection{Introduction}
%\label{sec:ug-intro}
%
% In 2011 the Ukrainian Type Design Competition ``Mystetsky Arsenal''
% (\url{http://www.ukrainian-type.com/about/}) was won by the font by
% Andrij Shevchenko.  The competiton was aimed at the creation of a
% modern practical font based on Ukrainian traditions.  The winner is
% remarkable for its clarity and clean shapes.
%
% Later the font was extended by Alexei Vanyashin \& cyreal.org, Nhung
% Nguyen, and Marc Foley (see
% \url{https://github.com/alexeiva/Arsenal}).  The font now supports a
% large number of languages with Latin and Cyrillic alphabet, it has
% real small caps, historic forms, swash capitals and many other
% features.  
%
% This package provides
% \LaTeX\ interface for the font and optionally math support.
%
% Since the font it in \textsc{otf} format, you do need a Unicode
% engine like \XeTeX\ or Lua\TeX\ to use it.  
%
%
%\subsection{Package options}
%\label{sec:ug-options}
%
% \begin{variable}{default, sfdefault, math, scale, Scale}
%   \changes{v0.2}{2023/09/04}{Added arsenal+kpsans value for math option}
%   The options for the package use the key-value interface.
%   The part |=true| for the boolean options can be dropped.
%
%   The following options are recognized:
%   \begin{description}
%   \item[default] whether to make Arsenal the main font of the
%     document, either |true| (the default) or |false|.
%   \item[sfdefault] whether to make Arsenal the sans serif font of your
%     document, either |true| or |false| (the default).
%   \item[math] whether to enable math support.  The currently
%     recognized options are |none|, |arsenal+kpsans|, |kpsans|, and
%     |iwona|.  The meaning is the following:
%     \begin{description}
%     \item[arsenal+kpsans] Use native font for math, adding missing
%       letter from the \textsc{otf} version of KpSans
%       font~\citep{kpfonts-otf}.  Unfortunately this option presently
%       does not work properly with \XeTeX, using wrong font
%       dimensions resulting in rather bad spacing.
%     \item[kpsans] Use \textsc{otf} version of KpSans
%       font~\citep{kpfonts-otf} for math.
%     \item[iwona] Use use \pkg{iwonamath}~\citep{iwonamath} for math.
%     \item[none] Do not define math fonts, leaving the math setup to the user.
%     \end{description}
%     The default depends on whether Arsenal is your main font and
%     which engine is used:
%     \begin{enumerate}
%     \item If Arsenal is the main font, and \XeTeX\ is used, then
%       |iwona|.
%     \item If Arsenal is the main font, and Lua\TeX\ is used, then
%     |arsenal+kpsans|. 
%     \item If Arsenal is not your main font, then |none|.
%     \end{enumerate}
% \item[scale] the scale for the font, by default 0.89.  The option
% |Scale| is a synonym.
%   \end{description}
% \end{variable}
%
%
%\subsection{Font features}
%\label{sec:ug-families}
%
% \begin{function}{\arsenalfamily, \textarsenal}
%   \begin{syntax}
%     \cs{arsenalfamily} \meta{text}
%     \cs{textarsenal}\Arg{text}
%   \end{syntax}
%   The font provides the commands \cs{arsenalfamily} and
%   \cs{textarsenal} for selecting the font.  Alternatively, the NFSS
%   commands \cs{fontfamily}|{arsenal}|\cs{selectfont} can be used to
%   select Arsenal family.
% \end{function}
%
% The font has normal and \textit{italic} shapes, as well as bolded
% \textbf{bold} and \textbf{\itshape bold italic}. It has
% \textsc{Small Caps}, \textsc{\itshape Italic Small Caps},
% \textsc{\bfseries Bold Small Caps} and \textsc{\bfseries\itshape
% Bold Italic Small Caps}.  They are selected by the standard \LaTeX\
% commands.  
%
% \begin{function}{\swshape, \textsw}
%   The font has Swash shape, selected by the commands \cs{swshape}
%   and \cs{textsw}.  There are both normal and bold versions:
%   \textsw{SWASH}, \textsw{\bfseries Bold SWASH}.  Moreover, there is
%   an italic version \textsw{\itshape SWASH},
%   \textsw{\bfseries\itshape Bold SWASH}, and even a small caps
%   version \textsw{\scshape Swash}, \textsw{\scshape\bfseries Bold
%   Swash}.
% 
% \end{function}
%
% The font has other features, such are two alternate forms and
% historic style.  They can be selected by the
% \pkg{fontspec}~\citep{fontspec} commands like
% |\addfontfeatures{Style=Historic}| or
% |\addfontfeautures{Alternate=1}|.  
%
%
%
%\subsection{Special symbols in text}
%\label{sec:chars}
%
% \begin{function}{
%   \texthryvnia,
%   \texttugrik,
%   \texttenge,
%   \textruble
% }
% The font has common currency characters, like \cs{textdollar}
% (\textdollar), \cs{textyen} (\textyen), \cs{textsterling}
% (\textsterling), \cs{texteuro} (\texteuro).  It also defines several
% less common currency characters:
%   \cs{texthryvnia} (\texthryvnia),
%   \cs{texttugrik} (\texttugrik),
%   \cs{texttenge} (\texttenge),
%   \cs{textruble} (\textruble).
% \end{function}
%
% \begin{function}{
%   \textaldine,
%   \textsmilewhite,
%   \textsmileblack
% }
% The font has \cs{textnumero} sign: \textnumero. It also defines some
% less common characters:
%   \cs{textaldine} (\textaldine),
%   \cs{textsmilewhite} (\textsmilewhite)
%   \cs{textsmileblack} (\textsmileblack).
% \end{function}
%
%
%\subsection{Math support}
%\label{sec:ug-math}
%   \changes{v0.2}{2023/09/04}{Added a section about math support}
%
% The support of math is presently experimental.  We offer several
% options, as discussed above in Section~\ref{sec:ug-options}.  Iwona font
% matches Arsenal in color and sizes, but some letters and proportions
% are different from those for Arsenal.  KpSans seems to be slightly
% darker.  The option of taking Latin letters from Arsenal and the
% missing symbols from KpSans is attractive, but is currently
% recommended for Lua\TeX\ only, since the font parameters seem to be
% misinterpreted by the \XeTeX\ engine.
%
%
% As discussed in \pkg{kpsans} documentation, if you use this package
% (options |kpsans| and |arsenal+kpsans|), do \emph{not} use
% \pkg{amssymb}.  The corresponding symbols are reimplemented in
% \pkg{kpsans}, and (almost) all \pkg{amssymb} commands are available
% by default when one of these options is chosen.  
%
% \end{documentation}
% \clearpage
%
% \begin{implementation}
%
% \section{Implementation}
% \label{sec:impl}
%
% 
%
%\subsection{Setting up}
%\label{sec:settingup}
%
%
% 
% First, we declare who we are:
%    \begin{macrocode}
%<@@=arsenal>
%<*package>
\ProvidesExplPackage {arsenal}
{2023-09-05} {v0.2}
{Arsenal font by Andrij Shevchenko}
%    \end{macrocode}
%
%
%\subsection{Options}
%\label{sec:options}
%
% \begin{variable}{
%   default,
%   sfdefault,
%   math,
%   scale,
%   Scale,
%   \l_@@_default_bool,
%   \l_@@_sfdefault_bool,
%   \l_@@_math_tl,
%   \l_@@_scale_tl,
% }
%    \begin{macrocode}
\tl_new:N \l_@@_math_tl
\keys_define:nn {arsenal}
{
  default .bool_set:N = \l_@@_default_bool,
  default .default:n = true,
  sfdefault .bool_set:N = \l_@@_sfdefault_bool,
  sfdefault .default:n = true,
  math .choices:nn = {none, arsenal+kpsans, kpsans, iwona}
  {\tl_set_eq:NN \l_@@_math_tl \l_keys_choice_tl },
  scale .tl_set:N = \l_@@_scale_tl,
  Scale .tl_set:N = \l_@@_scale_tl,
}
\keys_set:nn { arsenal }
{
  default=true,
  sfdefault = false,
  scale = 0.89,
}
\tl_clear:N \l_@@_math_tl
%    \end{macrocode}
% \end{variable}
%
% Processing options
%    \begin{macrocode}
\IfFormatAtLeastTF { 2022-06-01 }
  { \ProcessKeyOptions [ arsenal ] }
  {
    \RequirePackage { l3keys2e }
    \ProcessKeysOptions { arsenal }
  }
%    \end{macrocode}
% And setting up math
%    \begin{macrocode}
\tl_if_empty:NT \l_@@_math_tl
{
  \bool_if:NTF \l_@@_default_bool
  {
    \sys_if_engine_xetex:TF
    {
      \tl_set:Nn \l_@@_math_tl {iwona}
    }
    {
      \tl_set:Nn \l_@@_math_tl {arsenal+kpsans}
    }
  }
  {
    \tl_set:Nn \l_@@_math_tl {none}
  }
}
%    \end{macrocode}
%
%
%\subsection{Setting up font}
%\label{sec:font}
%
%    \begin{macrocode}
\RequirePackage{fontspec}
\newfontfamily\arsenalfamily{Arsenal-Regular.otf}
[
  NFSSFamily=arsenal,
  Ligatures=TeX,
  Scale=\l_@@_scale_tl,
  ItalicFont = Arsenal-Italic.otf,
  BoldFont = Arsenal-Bold.otf,
  BoldItalicFont = Arsenal-BoldItalic.otf,
  SwashFont = Arsenal-Regular.otf,
  SwashFeatures={Style=Swash},
  BoldSwashFont = Arsenal-Bold.otf,
  BoldSwashFeatures={Style=Swash},
  FontFace = {m}{itsw}{Font = Arsenal-Italic.otf, Style=Swash},
  FontFace = {b}{itsw}{Font = Arsenal-BoldItalic.otf, Style=Swash},
]
%    \end{macrocode}
%
% Checking whether we want the font to be default
%    \begin{macrocode}
\bool_if:NT \l_@@_default_bool
{
  \renewcommand\rmdefault{arsenal}
}

\bool_if:NT \l_@@_sfdefault_bool
{
  \renewcommand\sfdefault{arsenal}
}
%    \end{macrocode}
%
% \begin{macro}{\textarsenal}
%    \begin{macrocode}
\DeclareTextFontCommand{\textarsenal}{\arsenalfamily}
%    \end{macrocode}
% \end{macro}
%
% Swash changing rules
%    \begin{macrocode}
\DeclareFontShapeChangeRule {sw}{it}  {itsw}  {it}
\DeclareFontShapeChangeRule {it}{sw}  {itsw}  {sw}
%    \end{macrocode}
%
% Special characters, absent in the default
% \begin{macro}{
%   \texthryvnia,
%   \texttugrik,
%   \texttenge,
%   \textruble
% }
% Currency symbols
%    \begin{macrocode}
\DeclareUnicodeSymbol{\texthryvnia}       {"20B4}
\DeclareUnicodeSymbol{\texttugrik}        {"20AE}
\DeclareUnicodeSymbol{\texttenge}         {"20B8}
\DeclareUnicodeSymbol{\textruble}         {"20BD}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{
%   \textaldine,
%   \textsmilewhite,
%   \textsmileblack
% }
%  Other symbols
%    \begin{macrocode}
\DeclareUnicodeSymbol{\textaldine}        {"2767}
\DeclareUnicodeSymbol{\textsmilewhite}    {"263A}
\DeclareUnicodeSymbol{\textsmileblack}    {"263B}
%    \end{macrocode}
% \end{macro}
%
%
%\subsection{Math}
%\label{sec:math}
%
% Iwona is simple\ldots
%    \begin{macrocode}
\tl_new:N \l_@@_tmp_tl
\tl_if_eq:NnT \l_@@_math_tl {iwona}
{
  \tl_set:Nn \l_@@_tmp_tl {\fp_to_tl:n {\l_@@_scale_tl * 1.1}}
  \RequirePackage[Scale=\l_@@_tmp_tl, condensed, light]{iwonamath}
}
%    \end{macrocode}
%
% \changes{v0.2}{2023/09/04}{Separate scaling for upper and lowercase
% for kpsans}
% Now kpsans, see~\citep{kpfonts-otf}.  We adjust separately
% upper and lower cases\ldots 
%    \begin{macrocode}
\tl_if_eq:NnT \l_@@_math_tl {kpsans}
{
  \tl_set:Ne \l_@@_tmp_tl {\fp_to_tl:n {\l_@@_scale_tl * 1.1}}
  \RequirePackage[symbols]{kpfonts-otf}
  \setmathfont{KpMath-Sans.otf}[
  Scale=\l_@@_tmp_tl,
  BoldFont=KpMath-SansBold.otf]

  \setmathfont{KpMath-Sans.otf}[
  range={cal,bfcal},
  RawFeature=+ss01,
  Scale=\l_@@_tmp_tl,
  BoldFont=KpMath-SansBold.otf]
  
  \setmathfont{KpMath-Sans.otf}[
  range={
    scr/{Latin},
    bfscr/{Latin},
    frak/{Latin},
    bffrak/{Latin},
    up/{Latin, Greek, misc},
    bb/{Latin, Greek, misc},
    it/{Latin, Greek, misc},
    bbit/{Latin, Greek, misc},
    tt/{Latin, Greek, misc},
    sfup/{Latin, Greek, misc},
    sfit/{Latin, Greek, misc},
    bfup/{Latin, Greek, misc},
    bfit/{Latin, Greek, misc},
    bfsfup/{Latin, Greek, misc},
    bfsfit/{Latin, Greek, misc},
  },
  Scale=\fp_to_tl:n {\l_@@_tmp_tl * 0.9},
  BoldFont=KpMath-SansBold.otf]
}
%    \end{macrocode}
%
%   \changes{v0.2}{2023/09/04}{Added the warining about using
%   arsenal+kpsans with \XeTeX}
% And arsenal+kpsans.  We again adjust separately upper and lower cases\ldots
%    \begin{macrocode}
\tl_if_eq:NnT \l_@@_math_tl {arsenal+kpsans}
{
  \sys_if_engine_xetex:T
  {
    \ClassWarningNoLine{arsenal}{Option~ arsenal+kpsans~ may~ not~ work~
      with~ XeTeX~ engine.~  Please~ use~ lualatex}
  }
  \tl_set:Ne \l_@@_tmp_tl {\fp_to_tl:n {\l_@@_scale_tl * 1.1}}
  \RequirePackage[symbols]{kpfonts-otf}

  \setmathfont{KpMath-Sans.otf}[
  Scale=\l_@@_tmp_tl,
  BoldFont=KpMath-SansBold.otf]

  \setmathfont{KpMath-Sans.otf}[
  range={cal/{Latin},bfcal/{Latin}},
  RawFeature=+ss01,
  Scale=\fp_to_tl:n {\l_@@_tmp_tl * 0.9},
  BoldFont=KpMath-SansBold.otf]

  \setmathfont{KpMath-Sans.otf}[
  range={
    scr/{Latin, num},
    bfscr/{Latin, num},
    frak/{Latin, num},
    bffrak/{Latin, num},
    up/{Greek, misc, num},
    bb/{Latin, Greek, misc, num},
    it/{Greek, misc, num},
    bbit/{Greek, misc, num},
    tt/{Greek, misc, num},
    sfup/{Greek, misc, num},
    sfit/{Greek, misc, num},
    bfup/{Greek, misc, num},
    bfit/{Greek, misc, num},
    bfsfup/{Greek, misc, num},
    bfsfit/{Greek, misc, num},
  },
  Scale=\fp_to_tl:n {\l_@@_tmp_tl * 0.9},
  BoldFont=KpMath-SansBold.otf]
  
  
  \setmathfont{Arsenal-Regular.otf}[
  range={
    up/{Latin, latin, num},
    tt/{Latin, latin, num},
    sfup/{Latin, latin, num},
    bfup/{Latin, latin, num},
    bfsfup/{Latin, latin, num},
  },
  Scale=\l_@@_scale_tl,
  BoldFont=Arsenal-Bold.otf]

  \setmathfont{Arsenal-Italic.otf}[
  range={
    it/{Latin, latin, num},
    bbit/{Latin, latin, num},
    sfit/{Latin, latin, num},
    bfit/{Latin, latin, num},
    bfsfit/{Latin, latin, num},
  },
  Scale=\l_@@_scale_tl,
  BoldFont=Arsenal-BoldItalic.otf]


}      
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \end{implementation}
%
% \bibliography{arsenal}
% \bibliographystyle{plainnat}
%
%
% \PrintIndex
% \PrintChanges