The Fourier modal method (FMM) is a method for efficiently solving Maxwell equations with periodic boundary conditions. In a recent paper [1] the extension of the FMM to non-periodic structures has been demonstrated for a simple two-dimensional rectangular scatterer illuminated by TE-polarized light with a wavevector normal to the third (invariant) dimension. In this paper we present a generalized version of the aperiodic Fourier modal method in contrast-field formulation (aFMM-CFF) which allows arbitrary profiles of the scatterer as well as arbitrary angles of incidence of light. Keywords: Fourier modal method, FMM, aperiodic, aFMM-CFF, perfectly matched layer, PML