Extract dpi_scale_factor() to a function.