A function and its Fourier transform cannot both be compactly supported

I am stuck on the following problem from Stein and Shakarchi’s third book.

I can’t figure out how to use the hint productively. Once I know $f$ is a trigonometric polynomial, I see how to finish the problem, but I don’t know how to conclude that $f$ is a trigonometric polynomial.

I tried substituting in the Fourier transform in the formula for Fourier coefficients and switching the order of integration, but I couldn’t get that to work. I can’t think of any more ideas.

Problem: Suppose $f$ is continuous on $\mathbb{R}$. Prove $f$ and $\hat f$ cannot both be compactly supported unless $f=0$.

Hint: Suppose $f$ is supported in $[0, 1/2]$ and expand it in a Fourier series in $[0,1]$. Show $f$ must be a trigonometric polynomial.

This question was asked before, but with different hypotheses and in the context of complex analysis. Please do not close as a duplicate.

Solutions Collecting From Web of "A function and its Fourier transform cannot both be compactly supported"

Further hint: let $c_n$ the $n$-th Fourier coefficient of $f$. We can write $\widehat f(n)=c_n$ and since $\widehat f$ is compactly supported, $c_n$ vanishes for $n$ large enough. It implies that $f$ is a trigonometric polynomial.

The hypothesis of the hint is not restrictive: using a substitution in the integral defining the Fourier transform, we can assume that the support of $f$ is contained in $[0,a]$ for some $a>0$, then define $g(x):=f\left(\frac x{2a}\right)$.