# Wrong font for digits in math-mode

in my minimum example

\documentclass[12pt]{article}
\usepackage[sfdefault]{FiraSans}
\usepackage{newtxsf}
\begin{document}
This is a test: $5$ = 5
\end{document}


compiled with lualatex -shell-escape doc.tex I get a wrong font for math-digits:

What can I do to get the same digits as in non-math-mode?

• Why you say wrong? It is math font, not equal to text font. This is acceptable. Of course, depending which text font you use, it could be ugly, but not wrong. Dec 28, 2017 at 15:08
• I'd like the math-font to be equal or at least similar to the text-font. Digits should look the same. Dec 28, 2017 at 15:10
• @Sigur With newtxsf the math should be sans serif. Dec 28, 2017 at 15:12
• @user2033412 Would compiling with pdflatex be a workaround? Dec 28, 2017 at 15:13
• @samcarter: nope -- The build-server uses lualatex. Dec 28, 2017 at 15:18

With lining numbers it's not so difficult.

\documentclass[12pt]{article}
\PassOptionsToPackage{no-math}{fontspec}
\usepackage[sfdefault,lining,scaled=0.9]{FiraSans}
\usepackage{newtxsf}

\DeclareSymbolFont{digits}{TU}{\sfdefault}{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}

\begin{document}
This is a test: $0123456789$ = 0123456789

$a-b=c$ abc

\end{document}