I think you are close, here is a helpful link with the base equation for that type of lines:
a and b will be constants which you can experiment with to find, y will be your final displacement on your up axis e.g. pos.z in your case, and x will be the position of the vertex in the axis that your text runs on e g. pos.y