A general solution for the field of a two-dimensional polygonal electromagnet is presented. The solution is applicable to magnetic recording head models of finite size and arbitrary polygonal configuration. It uses a combination of analytic and numerical techniques. Analytic procedures are based on mixed boundary conditions and a succession of conformal mappings starting with the Schwarz-Christoffel (S-C) transformation. A concept of an idealized winding allows to reduce any magnetostatic problem to an electrostatic problem of two equipotential shims on the plane of conformal mapping. The result of analytic solution is a parametric formula for the field vector that can be easily obtained for any model by an inspection of its configuration. This formula, however, contains S-C constants and parameters of unknown values. These difficulties are resolved by numerical procedures. A comprehensive error control technique in numerical procedures facilitates determination of S-C constants and parameters with any desired accuracy. The theory is illustrated by the calculations of the fields and wavelength responses for two head models of complex configurations. The general solution provides features that are not available in previously known semi-infinite head models: estimation of head inductance and efficiency, and quantitative insight on the effect of core/pole shapes on head performance.