Function and Fourier transform vanish on an interval

A distribution for which both the distribution and its Fourier transform vanish on some interval is the Shah function aka Dirac comb
$$ Ш = \sum_{k=-\infty}^\infty \delta_k $$ which is its own Fourier transform (if the right scaling and normalization is used), i.e. $\hat Ш = Ш$.

Mollfying $Ш$ gives a function that vanishes on some interval and the Fourier transform (still not a function) does so, too.

To get a Schwartz function with a Schwartz function as Fourier transform, we could take two compactly supported mollifiers $\phi$ and $\psi$ and set $f = \hat\psi\cdot (\phi * Ш)$ which is a blurred and damped version of the Shah function (and actually a Schwartz function). Its Fourier transform is $\hat f = \psi * (\hat\phi\cdot Ш)$ which is a damped and blurred version of the Shah function. Choosing the support of $\phi$ and $\psi$ narrow enough will lead to $f$ and $\hat f$ which are zero on intervals of positive length. By construction, both functions are Schwartz functions. This is basically the same construction as in Christian Remling's answer and the adaption to the previous version that made this approach work is due to reuns comment below.


Over at MSE (see linked question), user1952009 (= reuns on MO) has given a very elegant construction of a Schwartz function with this property. I am reproducing his/her answer here.

Let $g,h\in C_0^{\infty}$ with support contained in $[1/3,1/2]$, and write $\widehat{h}_n=\int_0^1 h(x)e^{-2\pi inx}\, dx$ for the discrete Fourier coefficients of $h$, viewed as a $1$-periodic function $h_p$. Let $$ f(x)=\sum_{n=-\infty}^{\infty} \widehat{h}_n g(x-n) . $$ Then $$ \widehat{f}(\xi)= \sum \widehat{h}_n e^{2\pi in\xi}\widehat{g}(\xi) = h_p(\xi)\widehat{g}(\xi) . $$ Thus $f$ is as desired; this calculation also confirms that $f\in\mathcal S$.