[Tex/LaTex] Command that returns current font size as a length

fontsizemacros

I need a way to get the current fontsize as a length.

I hope I didn't overlook anything that already provides this. What I found that I can do

\makeatletter
\newlength{\fsize}
\setlength{\fsize}{\f@size pt}
\makeatother

but it will be set to a fixed length that does not update when font size changes.

Now I tried to put it into a command:

\makeatletter
\newlength{\fsizeb}
\setlength{\fsizeb}{\f@size pt}
\newcommand\fsize{\fizeb}
\makeatother

(still works as a length but also does not update – not sure if this is actually valid, maybe this is my first fault)

And finally I tried

\makeatletter
\newlength{\fsizeb}
\newcommand\fsize{%
    \setlength{\fsizeb}{\f@size pt}%
    \fsizeb%
}

which fails and does not seem to return a length.

I assume I'm doing something horribly wrong (I'm quite new to this part of LaTeX, so I hope you can tell me wether what I want is at all possible and give me some pointers how to implement…)


As for why I (think to) need this:
I want to be able to set \baselineskip to a specific multiple of the font size (similarly as the line-height property works in CSS/SVG) like so (with the solution suggested by Manuel in the comments):

\documentclass{scrartcl}

\makeatletter
\newcommand*\fsize{\dimexpr\f@size pt\relax}
\makeatother

\begin{document}

\setlength{\baselineskip}{1\fsize}
\verb=\setlength{\baselineskip}{1\fsize}= -- line-height: 1; bars touching exactly\\\textbar\\\textbar

\setlength{\baselineskip}{1.25\fsize}
\verb=\setlength{\baselineskip}{1.25\fsize}= -- line-height: 1.25; (relative to font-size)\\\textbar\\\textbar

\end{document}

If there are yet easier solutions I'd be happy to hear.

Best Answer

\makeatletter
\newcommand*\fsize{\dimexpr\f@size pt\relax}
\makeatother

This way you can use the macro like \setlength{\baselineskip}{1.33\fsize}.