When an image with a fixed DPI as the paint device for a QTextDocument's layout then it will still have differences when the Windows scale factor is changed. Since the image has the same DPI then the Windows scale factor should not influence the outcome. To reproduce run the example with the Windows display set to 100% scale factor. Then do the same for 125% and 150%. The output should still be the same, but there are slight differences as a result.
This used to be the same until the various DPI changes came into play, 5.6 will give consistent results, whereas 5.12 shows slightly more subtle changes with 5.15 showing a bit more.