Draw an 5cm long line on a canvas / access screen DPI?

I would like to draw a 5cm long line on a canvas. Is there a way to automatically retrieve the client’s display DPI for seamless scaling?

I am currently using correct_canvas_resolution as described in the following Anvil forum post: Canvas resolution blurry.