Basically, I want to achieve the same as for instance in this question: Changing the math-mode figures to “old style”. But not in general math, only for URLs, which are set in math mode (in the manual, I read that this is done due to “context-sensitive linebreaking”).
So, a simple MWE:
%!TEX program=lualatex
\documentclass{article}
\usepackage[no-math]{fontspec}
\usepackage{unicode-math}
\usepackage{url}
\urlstyle{same}
\setmainfont[Numbers={OldStyle}]{Libertinus Serif}
\setmathfont[]{Libertinus Math}
\begin{document}
math: $123$
text: 123
url: \url{123}
\end{document}
The math number should of course stay as they are, but I would prefer to have the same number style in URLs as in normal text. In the MWE, I used the predefined url-style \urlstyle{same}. For custom styles, I would use the macro \renewcommand*{\UrlFont}{\mathversion{osf}\normalfont} and define a suitable math version with \setmathfont[version=osf,....enable oldstyle numbers....]{Libertinus Math}.
However, I do not know how to “activate” old-style numbers with unicode-math. When adding the option Numbers={OldStyle} as for the the main font, I do not observe any effect.
Edit
I tried it with \mathversions and substitituting only a range, but this does not work. But \mathversions alone work – at least for equations put inside $ signs. For URLs, it is somehow ignored.
Update MWE
%!TEX program=lualatex
\documentclass{article}
\usepackage[no-math]{fontspec}
\usepackage{unicode-math}
\usepackage{url}
\renewcommand*{\UrlFont}{\mathversion{osf}}
\setmainfont[Numbers={OldStyle}]{Libertinus Serif}
\setmathfont{Libertinus Math}[version=default]
\setmathfont{Libertinus Serif}[version=osf,Numbers=OldStyle]
\begin{document}
\mathversion{osf}
math (osf): $123$
\mathversion{default}
math (default): $123$
text: 123
url: \url{123}
\end{document}



\setmathfont{Libertinus Serif}[range=up/digits, Numbers=OldStyle]and the math version withversion=osf. Unfortunately,range=andversion=are mutually exclusive as of 2021. – Davislor May 09 '21 at 14:29\setmathrmand use the\mathrmfont in math mode, but the way\urlis defined seems to be set up to use commands such as\rmfamilyor\ttfamily, not\mathrm{123}. – Davislor May 09 '21 at 14:30hyperrefmight work better for you? – Davislor May 09 '21 at 14:33hyperrefuses theurlpackage? I do usehyperrefindeed, and wanted to change the appearance of links. – crateane May 09 '21 at 14:35