Text this: Spectral distortions of optical pulses in resonant media of complex spatial structure