% \iffalse meta-comment
%
% File: arsenal.dtx
% Copyright 2023-2025 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.  The math support is provided by
% \pkg{ArsenalMath} package by Rajeesh KV~\cite{arsenal-math}.
%
% 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}
%   \changes{v1.0}{2025/10/13}{Made math option boolean}
%   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, either |true| or
%   |false|. By default |true| if Arsenal is the main font, and
%   |false| otherwise.  Historically Arsenal provided the options to
%   use  KpSans and Iwona for
%   math. Since Rajeesh KV wrote the package~\cite{arsenal-math}, they
%   are obsolete.
% \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}
%
%
%
% \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}
{2025-10-13} {v1.0}
{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,
% }
%   \changes{v1.0}{2025/10/13}{Made math option pseudoboolean}
% We cannot define |math| to set a boolean, since we want to process the
% case when it is not set and look at the default options and also
% process obsolete options as well.  Thus this option sets a token
% list, which happens to contain |true| and |false|.
%    \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 = {true, false, 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
  {
    \tl_set:Nn \l_@@_math_tl {true}
  }
  {
    \tl_set:Nn \l_@@_math_tl {false}
  }
}
%    \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}
%
% Obsolete options produce a warning
%    \begin{macrocode}
\tl_if_eq:NnT \l_@@_math_tl {iwona} 
{
  \ClassWarningNoLine{arsenal}{Option~math=iwona ~ is~obsolete.~
    Switching~to~the~native~Arsenal~math}
   \tl_set:Nn \l_@@_math_tl {true}
}
\tl_if_eq:NnT \l_@@_math_tl {kpsans} 
{
  \ClassWarningNoLine{arsenal}{Option~math=kpsans ~ is~obsolete.~
    Switching~to~the~native~Arsenal~math}
   \tl_set:Nn \l_@@_math_tl {true}
}
\tl_if_eq:NnT \l_@@_math_tl {arsenal+kpsans} 
{
  \ClassWarningNoLine{arsenal}{Option~math=arsenal+kpsans ~ is~obsolete.~
    Switching~to~the~native~Arsenal~math}
   \tl_set:Nn \l_@@_math_tl {true}
}
%    \end{macrocode}
%
% We use Arsenal Math:
%    \begin{macrocode}
\tl_if_eq:NnT \l_@@_math_tl {true}
{
  \RequirePackage{unicode-math}
  \setmathfont[BoldFont=ArsenalMath-SansBold.otf,
  Scale=\l_@@_scale_tl]{ArsenalMath-Sans.otf}
}
      
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \end{implementation}
%
% \bibliography{arsenal}
% \bibliographystyle{plainnat}
%
%
% \PrintIndex
% \PrintChanges
