Measurements of the double-differential charged pion production cross-section in the range of momentum 0.5 GeV/c < p < 8.0 GeV/c and angle 0.025 rad < theta <0.25 rad in collisions of protons on beryllium, carbon, nitrogen, oxygen, aluminium, copper, tin, tantalum and lead are presented. The data were taken with the large acceptance HARP detector in the T9 beam line of the CERN PS. Incident particles were identified by an elaborate system of beam detectors. The data were taken with thin targets of 5% of a nuclear interaction length. The tracking and identification of the produced particles was performed using the forward system of the HARP experiment. Results are obtained for the double-differential cross section mainly at four incident proton beam momenta (3 GeV/c, 5 GeV/c, 8 GeV/c and 12 GeV/c). Measurements are compared with the GEANT4 and MARS Monte Carlo generators. A global parametrization is provided as an approximation of all the collected datasets which can serve as a tool for quick yields estimates.