Several improvements have been introduced for the Fourier modal method in the last fifteen years. Among those, the formulation of the correct factorization rules and adaptive spatial resolution have been crucial steps towards a fast converging scheme, but an application to arbitrary two-dimensional shapes is quite complicated.We present a generalization of the scheme for non-trivial planar geometries using a covariant formulation of Maxwell's equations and a matched coordinate system aligned along the interfaces of the structure that can be easily combined with adaptive spatial resolution. In addition, a symmetric application of Fourier factorization is discussed.