The Gauss–Bonnet formula on surfaces with densities