Math digits are rendered in CM when using libertine and newtxmath with XeLaTeX in TeX Live 2016

Somewhere in the various passages, the mathcode of the digits gets assigned wrongly.

\documentclass{article}

\usepackage{fontspec}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}

\AtBeginDocument{%
  \Umathcode`0="7 "0 `0
  \Umathcode`1="7 "0 `1
  \Umathcode`2="7 "0 `2
  \Umathcode`3="7 "0 `3
  \Umathcode`4="7 "0 `4
  \Umathcode`5="7 "0 `5
  \Umathcode`6="7 "0 `6
  \Umathcode`7="7 "0 `7
  \Umathcode`8="7 "0 `8
  \Umathcode`9="7 "0 `9
}

\begin{document}

Quite some text 123, $123$.

$3 \sin x \alpha$

\begin{displaymath}
\int_0^{+\infty} \left(\frac{\alpha}{\sqrt{\Omega_\Lambda - 1}}\right)^{\frac{1}{x}}
\mathrm{d}x
\end{displaymath}

\end{document}

enter image description here

Note that \XeTeXdefaultencoding is not necessary. Also loading xltxtra is not recommended: favor fontspec directly.


I've also encountered this issue using the newtxmath package with the libertine option and then adding OTF text fonts.

The newtxmath package is supposed to load "minlibertine" if no text font has been loaded, but it seems to fail to do this sometimes. Under LuaLaTeX, forcing it to load ensures that the CM figures are replaced by libertine figures in math. Most of the following just comes from Michael Sharpe's documentation (ex. 3), but the \renewcommand... is the key addition that solved the problem for me:

% load text components other than libertine text to be used in math
\usepackage[T1]{fontenc}
% \usepackage[scaled=.85]{beramono}% used only by \mathtt
% \usepackage[type1]{cabin}% used only by \mathsf
\renewcommand{\rmdefault}{minlibertine} %% This needs to be forced, else doesn't load.  
% (Suspect cmr flag in package vs. lmr default in LuaTeX, but have not investigated...)
\usepackage[libertine,upint]{newtxmath}
% newtxmath should load minlibertine because no other Roman text package was specified; however, for me, it does not detect the need.
% \mathrm and \mathbf use minlibertine

\usepackage[scr=rsfso]{mathalfa}% helps with loading of math alphabets
\usepackage{bm}% load after all math to give access to bold math

% Now load the otf text fonts using fontspec---won't affect math
\usepackage[no-math]{fontspec} % process with XeLaTeX or LuaLaTeX
\usepackage{libertine}