\NeedsTeXFormat{LaTeX2e}[2020/02/02]
\ProvidesPackage{geistserif-nfss}
    [2026/11/08 (autoinst)  Style file for GeistSerif fonts.]

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

\DeclareOptionX{lining}{\edef\GeistSerif@figurestyle{LF}}
\DeclareOptionX{oldstyle}{\edef\GeistSerif@figurestyle{OsF}}
\DeclareOptionX{tabular}{\edef\GeistSerif@figurealign{T}}
\DeclareOptionX{proportional}{\edef\GeistSerif@figurealign{}}
\edef\GeistSerif@figurestyle{OsF}
\edef\GeistSerif@figurealign{}

\DeclareOptionX{mainfont}{
    \renewcommand{\familydefault}{\rmdefault}
}
\DeclareOptionX{regular}{\edef\mdseries@rm{regular}}

\ProcessOptionsX\relax

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

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

}{}
\ExplSyntaxOff

%   Here we implement the scale=MatchLowercase option.
%   If this is given, we must compute the correct value of
%   the "\GeistSerif@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 "\GeistSerif@scale" we will pass to the .fd files.
\ifthenelse{\equal{\GeistSerif@scale}{MatchLowercase}}
    {   \newlength{\GeistSerif@currentx}
        \settoheight{\GeistSerif@currentx}{x}
        \newlength{\GeistSerif@xheight}
        \settoheight{\GeistSerif@xheight}
            {{\font\testfont=GeistSerif-Regular-osf-t1 at \f@size pt\testfont x}}
        \renewcommand*{\GeistSerif@scale}
            {\fpeval{\GeistSerif@currentx / \GeistSerif@xheight}}}
    {}

\renewcommand*
    {\rmdefault}
    {GeistSerif-\GeistSerif@figurealign\GeistSerif@figurestyle}

\endinput
