
\ProvidesPackage{minim-math}[2025/02/12 Unicode mathematics]

\RequirePackage[no-math]{fontspec}

% load the plain package
\let\minimmathlatex=\relax
\input minim-math

% do not reset math fonts in everymath
\let\check@mathfonts = \relax
\let\mathgroup = \fam

% unicode-math compatibility
\let \symup     = \mup
\let \symbfup   = \mbf
\let \symbf     = \mbf
\let \symit     = \mit
\let \symbfit   = \mbfit
\let \symbb     = \mbb
\let \symscr    = \scr
\let \symcal    = \scr
\let \symbfscr  = \bfscr
\let \symfrak   = \frak
\let \symbffrak = \bffrak
\def \symsfup   #1{{\mathstyle{sf}}}
\def \symbfsfup #1{{\mathstyle{sfbf}}}
\def \symsfit   #1{{\mathstyle{sfit}}}
\def \symbfsfit #1{{\mathstyle{sfbfit}}}
\def \symtt     #1{{\mathstyle{tt}}}

% more compatibility
\let \mathup     = \symup
\let \mathbfup   = \symbfup
\let \mathbf     = \symbf
\let \mathit     = \symit
\let \mathbfit   = \symbfit
\let \mathbb     = \symbb
\let \mathscr    = \symscr
\let \mathcal    = \symcal
\let \mathbfscr  = \symbfscr
\let \mathfrak   = \symfrak
\let \mathbffrak = \symbffrak
\let \mathsfup   = \symsfup
\let \mathbfsfup = \symbfsfup
\let \mathsfit   = \symsfit
\let \mathbfsfit = \symbfsfit
\let \mathtt     = \symtt

% \setmathfam 0 [features] {font name or file}
\newcount\set@mathfamcount
\protected\def\setmathfam{\afterassignment\set@mathfam\set@mathfamcount= }
\newcommand\set@mathfam[2][]{%
    \calculate@math@sizes \csname S@\f@size\endcsname
    \expandafter\font\csname math main font \the\set@mathfamcount\endcsname
        {#2:mode=base;script=math;ssty=0;#1} at \tf@size pt
    \expandafter\font\csname math script font \the\set@mathfamcount\endcsname
        {#2:mode=base;script=math;ssty=1;#1} at \sf@size pt
    \expandafter\font\csname math sscript font \the\set@mathfamcount\endcsname
        {#2:mode=base;script=math;ssty=2;#1} at \ssf@size pt
    \textfont\the\set@mathfamcount
        \expandafter\csname math main font \the\set@mathfamcount\endcsname
    \scriptfont\the\set@mathfamcount
        \expandafter\csname math script font \the\set@mathfamcount\endcsname
    \scriptscriptfont\the\set@mathfamcount
        \expandafter\csname math sscript font \the\set@mathfamcount\endcsname}

% load a default font
\setmathfam 0 {Latin Modern Math}

