Text this: The mathematics of foam