Measurement of the forward-backward asymmetry in $\mathrm{Z} \to \mathrm{b} \bar{\mathrm{b}}$ and $\mathrm{Z} \to \mathrm c \bar{\mathrm c}$ decays with leptons