Use text digits in math mode

environmentsmath-fontsmath-modemathastext

I am trying to typeset an old math paper that uses the text digits instead of the math digits in equations. E.g.

enter image description here

However, mathastext loads the math digits font from the baskervillef package in math environments by default. How can I change the default math digits font to the text digits font in math environments? Are there any solutions that do not require XeLaTeX?

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[p,osf]{baskervillef}
\usepackage[basic, frenchmath]{mathastext}

\begin{document}
Text digit: $i \neq n + \text{1}$

Math digit: $i \neq n + 1$
\end{document}

enter image description here

Best Answer

You can declare the text font as a Math symbol font, then set up the digits to use it

enter image description here

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[p,osf]{baskervillef}

\DeclareSymbolFont{digits}{T1}{BaskervilleF-OsF}{m}{n}
\DeclareMathSymbol{0}{\mathalpha}{digits}{`0}
\DeclareMathSymbol{1}{\mathalpha}{digits}{`1}
\DeclareMathSymbol{2}{\mathalpha}{digits}{`2}
\DeclareMathSymbol{3}{\mathalpha}{digits}{`3}
\DeclareMathSymbol{4}{\mathalpha}{digits}{`4}
\DeclareMathSymbol{5}{\mathalpha}{digits}{`5}
\DeclareMathSymbol{6}{\mathalpha}{digits}{`6}
\DeclareMathSymbol{7}{\mathalpha}{digits}{`7}
\DeclareMathSymbol{8}{\mathalpha}{digits}{`8}
\DeclareMathSymbol{9}{\mathalpha}{digits}{`9}

\usepackage{amsmath}

\begin{document}


Text digit: $i \neq n + \text{1}$

Math digit: $i \neq n + 1$
\end{document}