To fight obesity, legislation would ban candy and sugary beverages, and many schools would be required to offer more nutritious fare.