Based on the answer by Ulrike Fischer I wrote a small package which stores the values for a few commonly used fonts, namely: Libertinus Math, TeX Gyre Pagella Math, TeX Gyre Schola Math, TeX Gyre Bonum Math, STIX Two Math, Cambria Math. I thought I would share them here in case someone encounters the same problem. Maybe I will also updated the answer in case I add more fonts.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mycd}
\RequirePackage{tikz-cd}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{tikz-cd}}
\newcommand{\tikzcdarrowdimens}[2]{%
\tikzcdset{every arrow/.append style={line width=#1}}%
\pgfmathdeclarefunction*{axis_height}{0}{%
\begingroup%
\pgfmathreturn#2%
\endgroup%
}%
}
\DeclareOption{Libertinus}{%
\tikzcdset{arrow style=math font}%
\tikzcdarrowdimens{0.052em}{0.250em}%
}
\DeclareOption{Pagella}{%
\tikzcdset{arrow style=math font}%
\tikzcdarrowdimens{0.060em}{0.250em}%
}
\DeclareOption{Schola}{%
\tikzcdset{arrow style=math font}%
\tikzcdarrowdimens{0.070em}{0.260em}%
}
\DeclareOption{Bonum}{%
\tikzcdset{arrow style=math font}%
\tikzcdarrowdimens{0.072em}{0.260em}%
}
\DeclareOption{STIX}{%
\tikzcdset{arrow style=math font}%
\tikzcdarrowdimens{0.068em}{0.259em}%
}
\DeclareOption{Cambria}{%
\tikzcdset{arrow style=math font}%
\tikzcdarrowdimens{0.06494140625em}{0.285888671875em}%
}
\ProcessOptions\relax
Basic usage is as follows:
\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Libertinus Math}
\usepackage[Libertinus]{mycd}
\begin{document}
\begin{tikzcd}
a\arrow[r]&b
\end{tikzcd}
\end{document}
\tikzcdset{arrow style=math font}, but the stem gets misplaced. – egreg Mar 14 '18 at 13:46