For a real analytic periodic function 𝜙: ℝ→ℝ, an integer 𝑏≥2 and 𝜆∈(1/𝑏,1), we prove the following dichotomy for the Weierstrass-type function 𝑊(𝑥)=∑_{𝑛≥0} 𝜆^𝑛 𝜙(𝑏^𝑛 𝑥): Either W(x) is real analytic, or the Hausdorff dimension of its graph is equal to 2+log𝑏𝜆. Furthermore, given b and 𝜙, the former alternative only happens for finitely many 𝜆 unless 𝜙 is constant.