\NeedsTeXFormat{LaTeX2e}[2020/02/02]
\ProvidesPackage{geist-nfss}
    [2026/08/24 (autoinst)  Style file for Geist fonts.]

\RequirePackage{xkeyval}
\newcommand*{\Geist@scale}{1}
\DeclareOptionX{scale}{\renewcommand*{\Geist@scale}{#1}}
\DeclareOptionX{scaled}{\renewcommand*{\Geist@scale}{#1}}

\DeclareOptionX{lining}{\edef\Geist@figurestyle{LF}}
\DeclareOptionX{tabular}{\edef\Geist@figurealign{T}}
\DeclareOptionX{proportional}{\edef\Geist@figurealign{}}
\edef\Geist@figurestyle{LF}
\edef\Geist@figurealign{}

\DeclareOptionX{mainfont}{
    \renewcommand{\familydefault}{\sfdefault}
}
\DeclareOptionX{black}{\edef\bfseries@sf{black}}
\DeclareOptionX{extrabold}{\edef\bfseries@sf{extrabold}}
\DeclareOptionX{semibold}{\edef\bfseries@sf{semibold}}
\DeclareOptionX{bold}{\edef\bfseries@sf{bold}}
\DeclareOptionX{medium}{\edef\mdseries@sf{medium}}
\DeclareOptionX{regular}{\edef\mdseries@sf{regular}}

\ProcessOptionsX\relax

\RequirePackage[T1]{fontenc}
\RequirePackage{textcomp}
\RequirePackage{ifthen}
\RequirePackage{xspace}

\ExplSyntaxOn
\IfFileExists{figureversions.sty}{
    \RequirePackage{figureversions}

    \figureversions_new_figurestyle:nnn {superior} {Sup} {Sup}
    \def\supfigures{\@nomath\supfigures
        \fontfigurestyle{superior}\selectfont}
    \let\sufigures\supfigures
    \DeclareTextFontCommand{\textsup}{\supfigures}
    \let\textsu\textsup
    \let\textsuperior\textsup
    \let\@oldtextsuperscript\textsuperscript
    \def\textsuperscript{\@ifstar\@oldtextsuperscript\textsup}
    \def\@makefnmark{%
        \mbox{\footnotemarkfont\textsuperscript{\@thefnmark}}}
    \@ifundefined{ftntm@font}%
        {\let\footnotemarkfont\normalfont}%
        {\let\footnotemarkfont\ftntm@font}

}{}
\ExplSyntaxOff

%   Here we implement the scale=MatchLowercase option.
%   If this is given, we must compute the correct value of
%   the "\Geist@scale" parameter before loading the .fd files;
%   but to determine that value we of course need the font's x-height.
%   To avoid triggering the loading of .fd files,
%   we use plain TeX's \font primitive to load the testfont.
%   We then compute the ratio of the current x-height to our font's x-height;
%   this is the "\Geist@scale" we will pass to the .fd files.
\ifthenelse{\equal{\Geist@scale}{MatchLowercase}}
    {   \newlength{\Geist@currentx}
        \settoheight{\Geist@currentx}{x}
        \newlength{\Geist@xheight}
        \settoheight{\Geist@xheight}
            {{\font\testfont=Geist-Regular-lf-t1 at \f@size pt\testfont x}}
        \renewcommand*{\Geist@scale}
            {\fpeval{\Geist@currentx / \Geist@xheight}}}
    {}

\renewcommand*
    {\sfdefault}
    {Geist-\Geist@figurealign\Geist@figurestyle}

\endinput
