I don't bother with pixel-perfect layouts, but there are a couple options.
First, there's the
PixelUtil API provided by Blizzard.
Alternatively, you can calculate the optimal UI scale with a mathematical formula.
Code:
768 / select(2, GetPhysicalScreenSize())
768 is the normalized height of the drawing area before scaling takes place. The width is dynamic, as in it changes based on aspect ratio.
GetPhysicalScreenSize() returns the pixel measurements of the drawing area. Keep in mind, if you're not setting the UI Scale to this, you need to adjust with the effective scale of your frame's parent.