I'm trying to set a distance which is relative to the font size. The problem is that the distance is reused several times in the document, potentially in environments with a different font size. In each case the distance should automatically rescale to retain it's proportion to the font size. Unfortunately, simply specifying the distance in em or ex doesn't work because the distance is stored at the size of em or ex in the current font. When the font changes, the distance is not updated accordingly.
Is there a way around this? Ideally the solution should work under both LaTeX and PlainTeX.
Below is a M(n)WE which shows the current, undesired, behavior.
\documentclass[12pt]{article}
\newskip\test
\test = 1em
\begin{document}
In each row, the lines should be the same length.
\rule{0.4pt}{1em} \rule{0.4pt}{\test}
{\tiny\rule{0.4pt}{1em} \rule{0.4pt}{\test}}
{\Huge\rule{0.4pt}{1em} \rule{0.4pt}{\test}}
\end{document}

